1
0
mirror of https://github.com/nerzhul/ocsms.git synced 2025-06-07 16:06:15 +00:00

use a div for each message with a typed class

This commit is contained in:
Loïc Blot (@U-Exp) 2014-09-16 23:08:48 +02:00
parent 7fbfb93bfb
commit 5667cbdac1

View File

@ -12,10 +12,23 @@ function fetchConversation(phoneNumber) {
$.getJSON(OC.generateUrl('/apps/ocsms/get/conversation'),
{'phoneNumber': phoneNumber},
function(jsondata, status) {
// Improve jQuery performance
var conversationBuf = "";
// Improve JS performance
var msgClass = '';
$.each(jsondata["conversation"], function(id, vals) {
conversationBuf += vals["msg"] + "<br />";
if (vals["type"] == 1) {
msgClass = "msg-recv";
}
else if (vals["type"] == 2) {
msgClass = "msg-sent";
}
else {
msgClass = '';
}
conversationBuf += '<div class="' + msgClass + '">' + vals["msg"] + '</div>';
});
$('#app-content').html(conversationBuf);