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:
parent
7fbfb93bfb
commit
5667cbdac1
15
js/script.js
15
js/script.js
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user