From 8680ce6d38a280c5207e0a6f7aaefab111d445cd Mon Sep 17 00:00:00 2001 From: Loic Blot Date: Mon, 8 Jun 2015 19:09:25 +0000 Subject: [PATCH] Merge duplicate phone numbers into a unique list --- js/public/app.js | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/js/public/app.js b/js/public/app.js index 36c8a54..59acd7a 100644 --- a/js/public/app.js +++ b/js/public/app.js @@ -22,6 +22,17 @@ var originalTitle = document.title; var app = angular.module('OcSms', []); +function inArray(val, arr) { + return ($.inArray(val, arr) != -1); +} + +function arrayUnique(arr) { + unq = arr.filter(function(item, i, arr) { + return i == arr.indexOf(item); + }) + return unq; +} + app.controller('OcSmsController', ['$scope', function ($scope) { $scope.buttons = [ @@ -116,7 +127,7 @@ var checkNewMessages = function() { peerLabel = fn; } - if ($.inArray(peerLabel, bufferedContacts) == -1) { + if (inArray(peerLabel, bufferedContacts)) { $("li[peer-label='" + peerLabel + "']").remove(); peerListBuf = '