From 5667cbdac1176e4a793146ee5f2bcd640d4408fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Blot=20=28=40U-Exp=29?= Date: Tue, 16 Sep 2014 23:08:48 +0200 Subject: [PATCH] use a div for each message with a typed class --- js/script.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/js/script.js b/js/script.js index 5bbb629..90cdd2b 100644 --- a/js/script.js +++ b/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"] + "
"; + if (vals["type"] == 1) { + msgClass = "msg-recv"; + } + else if (vals["type"] == 2) { + msgClass = "msg-sent"; + } + else { + msgClass = ''; + } + + conversationBuf += '
' + vals["msg"] + '
'; }); $('#app-content').html(conversationBuf);