diff --git a/js/public/app.js b/js/public/app.js index 05ad8fc..b15c5ce 100644 --- a/js/public/app.js +++ b/js/public/app.js @@ -40,6 +40,7 @@ app.controller('OcSmsController', ['$scope', '$interval', '$timeout', '$compile' {text: "Send"} ]; $scope.contacts = []; + $scope.messages = [] $scope.sendCountry = function () { $.post(OC.generateUrl('/apps/ocsms/set/country'),{'country': $('select[name=intl_phone]').val()}); }; @@ -171,9 +172,10 @@ app.controller('OcSmsController', ['$scope', '$interval', '$timeout', '$compile' g_curPhoneNumber = null; }); }; - $scope.removeMessage = function(messageId) { - alert('test'); - }; + + /* + * Contact list management + */ $scope.addContact = function (ct) { $scope.$apply(function () { $scope.contacts.push(ct); @@ -195,6 +197,25 @@ app.controller('OcSmsController', ['$scope', '$interval', '$timeout', '$compile' } } + /* + * Conversation messagelist management + */ + $scope.addConversationMessage = function (msg) { + $scope.$apply(function () { + $scope.messages.push(msg); + }); + } + $scope.removeConversationMessage = function (msg) { + var len = $scope.messages.length; + for (var i=0; i < len; i++) { + var curMsg = $scope.messages[i]; + if (curMsg['id'] == msg['id']) { + $scope.messages.splice(i, 1); + return; + } + } + } + $scope.fetchInitialSettings = function () { $.getJSON(OC.generateUrl('/apps/ocsms/get/country'), function(jsondata, status) { if (jsondata['status'] == true) { @@ -241,7 +262,7 @@ app.controller('OcSmsController', ['$scope', '$interval', '$timeout', '$compile' }); } - $interval(refreshConversation, 10000); + //$interval(refreshConversation, 10000); $interval($scope.checkNewMessages, 10000); $timeout(function () { @@ -386,7 +407,7 @@ function formatConversation(jsondata) { buf += '