From 68b2f319c33cec21665344533fe270a4c5ece196 Mon Sep 17 00:00:00 2001 From: Loic Blot Date: Thu, 25 Jun 2015 18:28:10 +0000 Subject: [PATCH] Migrate jquery.documentready to AngularJS --- js/public/app.js | 66 ++++++++++++++++++++++++------------------------ 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/js/public/app.js b/js/public/app.js index c097537..0e2763c 100644 --- a/js/public/app.js +++ b/js/public/app.js @@ -34,8 +34,8 @@ function arrayUnique(arr) { return unq; } -app.controller('OcSmsController', ['$scope', - function ($scope) { +app.controller('OcSmsController', /*['$scope',*/ + function ($timeout, $scope) { $scope.buttons = [ {text: "Send"} ]; @@ -73,8 +73,38 @@ app.controller('OcSmsController', ['$scope', $scope.contacts.push(ct); }); }; + + $timeout(function () { + // Register real title + g_originalTitle = document.title; + + // Now bind the events when we click on the phone number + $.getJSON(OC.generateUrl('/apps/ocsms/get/peerlist'), function(jsondata, status) { + fetchInitialPeerList(jsondata); + + var pnParam = $.urlParam('phonenumber'); + if (pnParam != null) { + var urlPhoneNumber = decodeURIComponent(pnParam); + if (urlPhoneNumber != null) { + fetchConversation(urlPhoneNumber); + changeSelectedConversation($("a[mailbox-navigation='" + urlPhoneNumber + "']")); + } + } + // Don't show message headers if no conversation selected + else { + if ($('#app-content-header').is(':visible')) { + $('#app-content-header').hide(); + } + } + + }); + fetchInitialSettings(); + initDesktopNotifies(); + setInterval(refreshConversation, 10000); + setInterval(checkNewMessages, 10000); + }); } -]); +); $.urlParam = function(name){ var results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(window.location.href); @@ -404,36 +434,6 @@ function fetchInitialSettings() { }); } (function ($, OC) { - $(document).ready(function () { - // Register real title - g_originalTitle = document.title; - - // Now bind the events when we click on the phone number - $.getJSON(OC.generateUrl('/apps/ocsms/get/peerlist'), function(jsondata, status) { - fetchInitialPeerList(jsondata); - - var pnParam = $.urlParam('phonenumber'); - if (pnParam != null) { - var urlPhoneNumber = decodeURIComponent(pnParam); - if (urlPhoneNumber != null) { - fetchConversation(urlPhoneNumber); - changeSelectedConversation($("a[mailbox-navigation='" + urlPhoneNumber + "']")); - } - } - // Don't show message headers if no conversation selected - else { - if ($('#app-content-header').is(':visible')) { - $('#app-content-header').hide(); - } - } - - }); - fetchInitialSettings(); - initDesktopNotifies(); - setInterval(refreshConversation, 10000); - setInterval(checkNewMessages, 10000); - }); - // reset count and title window.onfocus = function () { g_unreadCountCurrentConv = 0;