Commit 438a3530 authored by Thibaut Frain's avatar Thibaut Frain

Adding basic jio history for chatbox gadget

parent fb60f5d5
......@@ -48,10 +48,16 @@
}).c("body").t(content).toString());
}
}
gadget_klass.ready(function(g) {
g.props = {
talks: {}
};
gadget_klass.declareAcquiredMethod("jio_put", "jio_put").declareAcquiredMethod("jio_get", "jio_get").ready(function(g) {
return g.jio_get({
_id: "chatbox_history"
}).push(function(response) {
return JSON.parse(response.data.datas);
}).push(function(talks) {
g.props = {
talks: talks
};
});
}).declareMethod("render", function(options) {
var gadget = this, messages;
this.props.jid = options.jid;
......@@ -86,6 +92,10 @@
this.props.talks[from] = new Talk(from);
}
this.props.talks[from].messages.push(message);
this.jio_put({
_id: "chatbox_history",
datas: JSON.stringify(this.props.talks)
});
displayMessage(message);
});
})($, rJS, Handlebars);
\ No newline at end of file
......@@ -68,10 +68,21 @@
}
gadget_klass
.declareAcquiredMethod('jio_put', 'jio_put')
.declareAcquiredMethod('jio_get', 'jio_get')
.ready(function (g) {
g.props = {
talks: {}
};
return g.jio_get({"_id": "chatbox_history"})
.push(function (response) {
return JSON.parse(response.data.datas);
})
.push(function (talks) {
g.props = {
talks: talks
};
});
})
.declareMethod('render', function (options) {
......@@ -125,6 +136,12 @@
this.props.talks[from] = new Talk(from);
}
this.props.talks[from].messages.push(message);
this.jio_put({
"_id": "chatbox_history",
"datas": JSON.stringify(this.props.talks)
});
displayMessage(message);
});
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment