mirror of
https://github.com/nerzhul/ocsms.git
synced 2025-06-09 17:06:12 +00:00
js code quality
This commit is contained in:
parent
39d46e2aeb
commit
5e48961a52
@ -31,7 +31,7 @@ var ContactList = new Vue({
|
|||||||
this.lastTotalUnreadCount = 0;
|
this.lastTotalUnreadCount = 0;
|
||||||
},
|
},
|
||||||
fetch: function () {
|
fetch: function () {
|
||||||
var self = this;
|
let self = this;
|
||||||
// Now bind the events when we click on the phone number
|
// Now bind the events when we click on the phone number
|
||||||
$.getJSON(Sms.generateURL('/front-api/v1/peerlist'), function (jsondata, status) {
|
$.getJSON(Sms.generateURL('/front-api/v1/peerlist'), function (jsondata, status) {
|
||||||
// Use a buffer for better jQuery performance
|
// Use a buffer for better jQuery performance
|
||||||
|
@ -29,13 +29,13 @@ var Conversation = new Vue({
|
|||||||
this.messages = [];
|
this.messages = [];
|
||||||
this.lastConvMessageDate = 0;
|
this.lastConvMessageDate = 0;
|
||||||
|
|
||||||
var self = this;
|
let self = this;
|
||||||
$.getJSON(Sms.generateURL('/front-api/v1/conversation'), {'phoneNumber': self.selectedContact.nav},
|
$.getJSON(Sms.generateURL('/front-api/v1/conversation'), {'phoneNumber': self.selectedContact.nav},
|
||||||
function (jsondata, status) {
|
function (jsondata, status) {
|
||||||
var phoneNumberLabel = self.selectedContact.nav;
|
let phoneNumberLabel = self.selectedContact.nav;
|
||||||
|
|
||||||
if (typeof jsondata['phoneNumbers'] !== 'undefined') {
|
if (typeof jsondata['phoneNumbers'] !== 'undefined') {
|
||||||
var phoneNumberList = arrayUnique(jsondata['phoneNumbers']);
|
const phoneNumberList = arrayUnique(jsondata['phoneNumbers']);
|
||||||
phoneNumberLabel = phoneNumberList.toString();
|
phoneNumberLabel = phoneNumberList.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,11 +97,11 @@ var Conversation = new Vue({
|
|||||||
// Return (int) msgCount, (str) htmlConversation
|
// Return (int) msgCount, (str) htmlConversation
|
||||||
formatConversation: function (jsondata) {
|
formatConversation: function (jsondata) {
|
||||||
// Improve jQuery performance
|
// Improve jQuery performance
|
||||||
var buf = false;
|
let buf = false;
|
||||||
// Improve JS performance
|
// Improve JS performance
|
||||||
var msgClass = '';
|
let msgClass = '';
|
||||||
var msgCount = 0;
|
let msgCount = 0;
|
||||||
var self = this;
|
let self = this;
|
||||||
|
|
||||||
$.each(jsondata["conversation"], function (id, vals) {
|
$.each(jsondata["conversation"], function (id, vals) {
|
||||||
if (vals["type"] == 1) {
|
if (vals["type"] == 1) {
|
||||||
@ -138,10 +138,11 @@ var Conversation = new Vue({
|
|||||||
*/
|
*/
|
||||||
addConversationMessage: function (msg) {
|
addConversationMessage: function (msg) {
|
||||||
this.messages.push(msg);
|
this.messages.push(msg);
|
||||||
|
console.log(this.messages);
|
||||||
},
|
},
|
||||||
removeConversationMessage: function (msgId) {
|
removeConversationMessage: function (msgId) {
|
||||||
var len = this.messages.length;
|
const len = this.messages.length;
|
||||||
var self = this;
|
let self = this;
|
||||||
for (var i = 0; i < len; i++) {
|
for (var i = 0; i < len; i++) {
|
||||||
var curMsg = this.messages[i];
|
var curMsg = this.messages[i];
|
||||||
if (curMsg['id'] === msgId) {
|
if (curMsg['id'] === msgId) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user