mirror of
https://github.com/nerzhul/ocsms.git
synced 2025-06-10 01:16:12 +00:00
Conversation loading by using angular.js
This commit is contained in:
parent
c1f984b2de
commit
fb8003faf2
44
js/script.js
44
js/script.js
@ -31,14 +31,16 @@ app.controller('OcSmsController', ['$scope',
|
|||||||
$scope.sendCountry = function () {
|
$scope.sendCountry = function () {
|
||||||
$.post(OC.generateUrl('/apps/ocsms/set/country'),{'country': $('select[name=intl_phone]').val()});
|
$.post(OC.generateUrl('/apps/ocsms/set/country'),{'country': $('select[name=intl_phone]').val()});
|
||||||
};
|
};
|
||||||
$scope.loadConversation = function () {
|
$scope.loadConversation = function (contact) {
|
||||||
//@TODO
|
OC.Util.History.pushState('phonenumber=' + contact.nav);
|
||||||
};
|
|
||||||
$scope.replaceContacts = function (ctList) {
|
// phoneNumber must exist
|
||||||
$scope.$apply(function () {
|
if (contact.nav !== null) {
|
||||||
$scope.contacts = ctList;
|
fetchConversation(contact.nav);
|
||||||
});
|
changeSelectedConversation($("a[mailbox-navigation='" + contact.nav + "']"));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.addContact = function (ct) {
|
$scope.addContact = function (ct) {
|
||||||
$scope.$apply(function () {
|
$scope.$apply(function () {
|
||||||
$scope.contacts.push(ct);
|
$scope.contacts.push(ct);
|
||||||
@ -120,7 +122,7 @@ var checkNewMessages = function() {
|
|||||||
if (typeof jsondata['photos'][peerLabel] != 'undefined') {
|
if (typeof jsondata['photos'][peerLabel] != 'undefined') {
|
||||||
peerListBuf += 'style="background-image: url(' + jsondata['photos'][peerLabel] + ');"';
|
peerListBuf += 'style="background-image: url(' + jsondata['photos'][peerLabel] + ');"';
|
||||||
}
|
}
|
||||||
peerListBuf += '></div><a href="#" ng-click="loadConversation();" mailbox-navigation="' + idxVal2 + '" style="font-weight: bold;" mailbox-label="' + peerLabel + '">' + peerLabel + ' (' + val + ')</a></li>';
|
peerListBuf += '></div><a href="#" ng-click="loadConversation(' + idxVal2 + ');" mailbox-navigation="' + idxVal2 + '" style="font-weight: bold;" mailbox-label="' + peerLabel + '">' + peerLabel + ' (' + val + ')</a></li>';
|
||||||
$('#app-mailbox-peers ul').prepend(peerListBuf);
|
$('#app-mailbox-peers ul').prepend(peerListBuf);
|
||||||
bufferedContacts.push(peerLabel);
|
bufferedContacts.push(peerLabel);
|
||||||
|
|
||||||
@ -139,7 +141,8 @@ var checkNewMessages = function() {
|
|||||||
// phoneNumber must exist
|
// phoneNumber must exist
|
||||||
if (phoneNumber != null) {
|
if (phoneNumber != null) {
|
||||||
fetchConversation(phoneNumber);
|
fetchConversation(phoneNumber);
|
||||||
unreadCountAllConv += val;changeSelectedConversation($(this));
|
unreadCountAllConv += val;
|
||||||
|
changeSelectedConversation($(this));
|
||||||
}
|
}
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
});
|
});
|
||||||
@ -292,6 +295,10 @@ function formatConversation(jsondata) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function changeSelectedConversation(item) {
|
function changeSelectedConversation(item) {
|
||||||
|
if (item === 'undefined' || item == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (selectedConversation != null) {
|
if (selectedConversation != null) {
|
||||||
selectedConversation.parent().removeClass('selected');
|
selectedConversation.parent().removeClass('selected');
|
||||||
}
|
}
|
||||||
@ -370,29 +377,12 @@ function desktopNotify(msg) {
|
|||||||
$.getJSON(OC.generateUrl('/apps/ocsms/get/peerlist'), function(jsondata, status) {
|
$.getJSON(OC.generateUrl('/apps/ocsms/get/peerlist'), function(jsondata, status) {
|
||||||
fetchInitialPeerList(jsondata);
|
fetchInitialPeerList(jsondata);
|
||||||
|
|
||||||
// Now bind the events when we click on the phone number
|
|
||||||
$('#app-mailbox-peers').find('a[mailbox-navigation]').on('click', function (event) {
|
|
||||||
var phoneNumber = $(this).attr('mailbox-navigation');
|
|
||||||
OC.Util.History.pushState('phonenumber=' + phoneNumber);
|
|
||||||
|
|
||||||
// phoneNumber must exist
|
|
||||||
if (phoneNumber != null) {
|
|
||||||
fetchConversation(phoneNumber);
|
|
||||||
changeSelectedConversation($(this));
|
|
||||||
}
|
|
||||||
event.preventDefault();
|
|
||||||
});
|
|
||||||
|
|
||||||
var pnParam = $.urlParam('phonenumber');
|
var pnParam = $.urlParam('phonenumber');
|
||||||
if (pnParam != null) {
|
if (pnParam != null) {
|
||||||
var urlPhoneNumber = decodeURIComponent(pnParam);
|
var urlPhoneNumber = decodeURIComponent(pnParam);
|
||||||
if (urlPhoneNumber != null) {
|
if (urlPhoneNumber != null) {
|
||||||
fetchConversation(urlPhoneNumber);
|
fetchConversation(urlPhoneNumber);
|
||||||
|
changeSelectedConversation($("a[mailbox-navigation='" + urlPhoneNumber + "']"));
|
||||||
var pObject = $("a[mailbox-navigation='" + urlPhoneNumber + "']");
|
|
||||||
if (pObject != null) {
|
|
||||||
changeSelectedConversation(pObject);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Don't show message headers if no conversation selected
|
// Don't show message headers if no conversation selected
|
||||||
|
@ -12,7 +12,7 @@ use \OCA\OcSms\Lib\CountryCodes;
|
|||||||
<ul>
|
<ul>
|
||||||
<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();" href="#">{{ contact.label }}</a>
|
<a mailbox-label="{{ contact.label }}" mailbox-navigation="{{ contact.nav }}" ng-click="loadConversation(contact);" href="#">{{ contact.label }}</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user