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

Some variables must be local. Also globalize the contact-list ul

This commit is contained in:
Loic Blot 2015-06-08 20:00:05 +00:00
parent 357e17dfbc
commit 3998f82331
2 changed files with 5 additions and 6 deletions

View File

@ -20,6 +20,7 @@ var unreadCountNotifStep = 12;
var lastUnreadCountAllConv = 0; var lastUnreadCountAllConv = 0;
var originalTitle = document.title; var originalTitle = document.title;
var ulContactList = $('.contact-list');
var app = angular.module('OcSms', []); var app = angular.module('OcSms', []);
function inArray(val, arr) { function inArray(val, arr) {
@ -27,7 +28,7 @@ function inArray(val, arr) {
} }
function arrayUnique(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 i == arr.indexOf(item);
}) })
return unq; return unq;
@ -136,7 +137,7 @@ var checkNewMessages = function() {
peerListBuf += '></div><a href="#" ng-click="loadConversation(' + idxVal2 + ');" mailbox-navigation="' + peerListBuf += '></div><a href="#" ng-click="loadConversation(' + idxVal2 + ');" mailbox-navigation="' +
idxVal2 + '" style="font-weight: bold;" mailbox-label="' + peerLabel + '">' + peerLabel + ' (' + val + ')</a></li>'; idxVal2 + '" style="font-weight: bold;" mailbox-label="' + peerLabel + '">' + peerLabel + ' (' + val + ')</a></li>';
$('#app-mailbox-peers ul').prepend(peerListBuf); ulContactList.prepend(peerListBuf);
bufferedContacts.push(peerLabel); bufferedContacts.push(peerLabel);
// Re-set conversation because we reload the element // Re-set conversation because we reload the element
@ -214,7 +215,7 @@ function fetchConversation(phoneNumber) {
phoneNumberLabel = phoneNumberList.toString(); phoneNumberLabel = phoneNumberList.toString();
} }
conversationBuf = formatConversation(jsondata)[1]; var conversationBuf = formatConversation(jsondata)[1];
conversationBuf += '<div class="msg-endtag"></div>'; conversationBuf += '<div class="msg-endtag"></div>';
if (typeof jsondata['contactName'] == 'undefined' || jsondata['contactName'] == '') { if (typeof jsondata['contactName'] == 'undefined' || jsondata['contactName'] == '') {
$('#ocsms-phone-label').html(phoneNumberLabel); $('#ocsms-phone-label').html(phoneNumberLabel);
@ -314,9 +315,7 @@ function changeSelectedConversation(item) {
function fetchInitialPeerList(jsondata) { function fetchInitialPeerList(jsondata) {
// Use a buffer for better jQuery performance // Use a buffer for better jQuery performance
var peerListBuf = ""; var peerListBuf = "";
var bufferedContacts = []; var bufferedContacts = [];
var aScope = angular.element('[ng-controller="OcSmsController"]').scope(); var aScope = angular.element('[ng-controller="OcSmsController"]').scope();
$.each(jsondata['phonelist'], function(id, val) { $.each(jsondata['phonelist'], function(id, val) {

View File

@ -8,7 +8,7 @@ use \OCA\OcSms\Lib\CountryCodes;
<div class="ng-scope" id="app" ng-app="OcSms" ng-controller="OcSmsController"> <div class="ng-scope" id="app" ng-app="OcSms" ng-controller="OcSmsController">
<div id="app-mailbox-peers"> <div id="app-mailbox-peers">
<ul> <ul class="contact-list">
<li ng-repeat="contact in contacts" peer-label="{{ contact.label }}"> <li ng-repeat="contact in contacts" peer-label="{{ contact.label }}">
<div class="ocsms-plavatar" style="background-image: url('{{ contact.avatar }}');"></div> <div class="ocsms-plavatar" style="background-image: url('{{ contact.avatar }}');"></div>
<a mailbox-label="{{ contact.label }}" mailbox-navigation="{{ contact.nav }}" ng-click="loadConversation(contact);" href="#">{{ contact.label }}</a> <a mailbox-label="{{ contact.label }}" mailbox-navigation="{{ contact.nav }}" ng-click="loadConversation(contact);" href="#">{{ contact.label }}</a>