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

js code quality

This commit is contained in:
Loic Blot 2018-11-10 18:27:54 +01:00
parent 39d46e2aeb
commit 5e48961a52
No known key found for this signature in database
GPG Key ID: EFAA458E8C153987
2 changed files with 16 additions and 15 deletions

View File

@ -31,7 +31,7 @@ var ContactList = new Vue({
this.lastTotalUnreadCount = 0;
},
fetch: function () {
var self = this;
let self = this;
// Now bind the events when we click on the phone number
$.getJSON(Sms.generateURL('/front-api/v1/peerlist'), function (jsondata, status) {
// Use a buffer for better jQuery performance

View File

@ -29,13 +29,13 @@ var Conversation = new Vue({
this.messages = [];
this.lastConvMessageDate = 0;
var self = this;
let self = this;
$.getJSON(Sms.generateURL('/front-api/v1/conversation'), {'phoneNumber': self.selectedContact.nav},
function (jsondata, status) {
var phoneNumberLabel = self.selectedContact.nav;
let phoneNumberLabel = self.selectedContact.nav;
if (typeof jsondata['phoneNumbers'] !== 'undefined') {
var phoneNumberList = arrayUnique(jsondata['phoneNumbers']);
const phoneNumberList = arrayUnique(jsondata['phoneNumbers']);
phoneNumberLabel = phoneNumberList.toString();
}
@ -97,11 +97,11 @@ var Conversation = new Vue({
// Return (int) msgCount, (str) htmlConversation
formatConversation: function (jsondata) {
// Improve jQuery performance
var buf = false;
let buf = false;
// Improve JS performance
var msgClass = '';
var msgCount = 0;
var self = this;
let msgClass = '';
let msgCount = 0;
let self = this;
$.each(jsondata["conversation"], function (id, vals) {
if (vals["type"] == 1) {
@ -138,10 +138,11 @@ var Conversation = new Vue({
*/
addConversationMessage: function (msg) {
this.messages.push(msg);
console.log(this.messages);
},
removeConversationMessage: function (msgId) {
var len = this.messages.length;
var self = this;
const len = this.messages.length;
let self = this;
for (var i = 0; i < len; i++) {
var curMsg = this.messages[i];
if (curMsg['id'] === msgId) {