From 3998f8233174d641903657c4ba5466b25e1ba8f9 Mon Sep 17 00:00:00 2001 From: Loic Blot Date: Mon, 8 Jun 2015 20:00:05 +0000 Subject: [PATCH] Some variables must be local. Also globalize the contact-list ul --- js/public/app.js | 9 ++++----- templates/main.php | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/js/public/app.js b/js/public/app.js index 766a219..29e4b32 100644 --- a/js/public/app.js +++ b/js/public/app.js @@ -20,6 +20,7 @@ var unreadCountNotifStep = 12; var lastUnreadCountAllConv = 0; var originalTitle = document.title; +var ulContactList = $('.contact-list'); var app = angular.module('OcSms', []); function inArray(val, arr) { @@ -27,7 +28,7 @@ function inArray(val, arr) { } function arrayUnique(arr) { - unq = arr.filter(function(item, i, arr) { + var unq = arr.filter(function(item, i, arr) { return i == arr.indexOf(item); }) return unq; @@ -136,7 +137,7 @@ var checkNewMessages = function() { peerListBuf += '>' + peerLabel + ' (' + val + ')'; - $('#app-mailbox-peers ul').prepend(peerListBuf); + ulContactList.prepend(peerListBuf); bufferedContacts.push(peerLabel); // Re-set conversation because we reload the element @@ -214,7 +215,7 @@ function fetchConversation(phoneNumber) { phoneNumberLabel = phoneNumberList.toString(); } - conversationBuf = formatConversation(jsondata)[1]; + var conversationBuf = formatConversation(jsondata)[1]; conversationBuf += '
'; if (typeof jsondata['contactName'] == 'undefined' || jsondata['contactName'] == '') { $('#ocsms-phone-label').html(phoneNumberLabel); @@ -314,9 +315,7 @@ function changeSelectedConversation(item) { function fetchInitialPeerList(jsondata) { // Use a buffer for better jQuery performance var peerListBuf = ""; - var bufferedContacts = []; - var aScope = angular.element('[ng-controller="OcSmsController"]').scope(); $.each(jsondata['phonelist'], function(id, val) { diff --git a/templates/main.php b/templates/main.php index ae7ef8a..74ac434 100644 --- a/templates/main.php +++ b/templates/main.php @@ -8,7 +8,7 @@ use \OCA\OcSms\Lib\CountryCodes;