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

move more functions & attributes from legacy.js to app.js

This commit is contained in:
Loic Blot 2017-12-28 18:58:50 +01:00
parent 2b6e52205e
commit 177cb69b10
No known key found for this signature in database
GPG Key ID: EFAA458E8C153987
3 changed files with 22 additions and 23 deletions

2
js/app.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -15,7 +15,9 @@ var Sms = {
unreadCountAllConv: 0, unreadCountAllConv: 0,
unreadCountNotifStep: 12, unreadCountNotifStep: 12,
lastUnreadCountAllConv: 0, lastUnreadCountAllConv: 0,
lastContactListMsgDate: 0,
originalTitle: document.title, originalTitle: document.title,
photoVersion: 1,
_winRegexp: /(.*)\/ocsms.*/, _winRegexp: /(.*)\/ocsms.*/,
@ -26,6 +28,19 @@ var Sms = {
console.log("A very bad error happened when parsing window location"); console.log("A very bad error happened when parsing window location");
} }
return match[1] + '/ocsms' + endpoint; return match[1] + '/ocsms' + endpoint;
},
selectConversation: function (item) {
if (item === 'undefined' || item == null) {
return;
}
if (this.selectedConversation != null) {
this.selectedConversation.parent().removeClass('selected');
}
this.selectedConversation = item;
this.selectedConversation.parent().addClass('selected');
this.selectedConversation.css("font-weight", "normal");
this.selectedConversation.html(this.selectedConversation.attr("mailbox-label"));
} }
}; };

View File

@ -34,7 +34,6 @@ app.filter('firstCharacter', function () {
app.controller('OcSmsController', ['$scope', '$interval', '$timeout', '$compile', app.controller('OcSmsController', ['$scope', '$interval', '$timeout', '$compile',
function ($scope, $interval, $timeout, $compile) { function ($scope, $interval, $timeout, $compile) {
$scope.lastConvMessageDate = 0; $scope.lastConvMessageDate = 0;
$scope.lastContactListMsgDate = 0;
$scope.isConvLoading = false; $scope.isConvLoading = false;
$scope.isContactsLoading = true; $scope.isContactsLoading = true;
$scope.buttons = [ $scope.buttons = [
@ -46,7 +45,6 @@ app.controller('OcSmsController', ['$scope', '$interval', '$timeout', '$compile'
$scope.contacts = []; $scope.contacts = [];
$scope.messages = []; $scope.messages = [];
$scope.totalMessageCount = 0; $scope.totalMessageCount = 0;
$scope.photoVersion = 1;
$scope.selectedContact = {}; $scope.selectedContact = {};
$scope.lastSearch = ''; $scope.lastSearch = '';
@ -57,7 +55,7 @@ app.controller('OcSmsController', ['$scope', '$interval', '$timeout', '$compile'
// phoneNumber must exist // phoneNumber must exist
if (contact.nav !== null) { if (contact.nav !== null) {
$scope.fetchConversation(contact); $scope.fetchConversation(contact);
changeSelectedConversation($("a[mailbox-navigation='" + contact.nav + "']")); Sms.selectConversation($("a[mailbox-navigation='" + contact.nav + "']"));
} }
}; };
@ -128,7 +126,7 @@ app.controller('OcSmsController', ['$scope', '$interval', '$timeout', '$compile'
$scope.checkNewMessages = function () { $scope.checkNewMessages = function () {
Sms.unreadCountAllConv = 0; Sms.unreadCountAllConv = 0;
$.getJSON(Sms.generateURL('/front-api/v1/new_messages'), $.getJSON(Sms.generateURL('/front-api/v1/new_messages'),
{'lastDate': $scope.lastContactListMsgDate}, {'lastDate': Sms.lastContactListMsgDate},
function (jsondata, status) { function (jsondata, status) {
var bufferedContacts = []; var bufferedContacts = [];
@ -164,7 +162,7 @@ app.controller('OcSmsController', ['$scope', '$interval', '$timeout', '$compile'
// Re-set conversation because we reload the element // Re-set conversation because we reload the element
if (id === $scope.selectedContact.nav) { if (id === $scope.selectedContact.nav) {
changeSelectedConversation($("a[mailbox-navigation='" + id + "']")); Sms.selectConversation($("a[mailbox-navigation='" + id + "']"));
} }
Sms.unreadCountAllConv += parseInt(val); Sms.unreadCountAllConv += parseInt(val);
@ -287,7 +285,7 @@ app.controller('OcSmsController', ['$scope', '$interval', '$timeout', '$compile'
// Use a buffer for better jQuery performance // Use a buffer for better jQuery performance
var bufferedContacts = []; var bufferedContacts = [];
$scope.photoVersion = jsondata["photo_version"]; Sms.photoVersion = jsondata["photo_version"];
$.each(jsondata['phonelist'], function (id, val) { $.each(jsondata['phonelist'], function (id, val) {
var peerLabel; var peerLabel;
@ -324,7 +322,7 @@ app.controller('OcSmsController', ['$scope', '$interval', '$timeout', '$compile'
$scope.isContactsLoading = false; $scope.isContactsLoading = false;
}); });
$scope.lastContactListMsgDate = jsondata["lastRead"]; Sms.lastContactListMsgDate = jsondata["lastRead"];
}; };
// Return (int) msgCount, (str) htmlConversation // Return (int) msgCount, (str) htmlConversation
@ -388,7 +386,7 @@ app.controller('OcSmsController', ['$scope', '$interval', '$timeout', '$compile'
$scope.selectedContact.avatar = undefined; $scope.selectedContact.avatar = undefined;
} }
$scope.fetchConversation(null); $scope.fetchConversation(null);
changeSelectedConversation($("a[mailbox-navigation='" + urlPhoneNumber + "']")); Sms.selectConversation($("a[mailbox-navigation='" + urlPhoneNumber + "']"));
} }
} }
}); });
@ -409,20 +407,6 @@ $.urlParam = function (name) {
} }
}; };
function changeSelectedConversation(item) {
if (item === 'undefined' || item == null) {
return;
}
if (Sms.selectedConversation != null) {
Sms.selectedConversation.parent().removeClass('selected');
}
Sms.selectedConversation = item;
Sms.selectedConversation.parent().addClass('selected');
Sms.selectedConversation.css("font-weight", "normal");
Sms.selectedConversation.html(Sms.selectedConversation.attr("mailbox-label"));
}
(function ($, OC) { (function ($, OC) {
// reset count and title // reset count and title
window.onfocus = function () { window.onfocus = function () {