mirror of
https://github.com/nerzhul/ocsms.git
synced 2025-06-07 07:56:23 +00:00
PeerList modification
Export peerList loading from document.ready. Modify peerlist only if there is peers
This commit is contained in:
parent
bea6f41892
commit
17a14753e0
41
js/script.js
41
js/script.js
@ -140,27 +140,34 @@ function changeSelectedConversation(item) {
|
||||
selectedConversation.parent().addClass('selected');
|
||||
}
|
||||
|
||||
function fetchInitialPeerList() {
|
||||
// Use a buffer for better jQuery performance
|
||||
var peerListBuf = "";
|
||||
|
||||
$.each(jsondata['phonelist'], function(id, val) {
|
||||
var fn, peerLabel;
|
||||
if (typeof jsondata['contacts'][val] == 'undefined') {
|
||||
fn = '';
|
||||
peerLabel = val;
|
||||
}
|
||||
else {
|
||||
fn = jsondata['contacts'][val];
|
||||
peerLabel = fn;
|
||||
}
|
||||
peerListBuf += '<li><a href="#" mailbox-navigation="' + val + '">' + peerLabel + '</a></li>';
|
||||
});
|
||||
|
||||
// Only modify peerList if there is peers
|
||||
if (peerListBuf != '') {
|
||||
$('#app-mailbox-peers ul').html(peerListBuf);
|
||||
}
|
||||
}
|
||||
|
||||
(function ($, OC) {
|
||||
$(document).ready(function () {
|
||||
// Now bind the events when we click on the phone number
|
||||
$.getJSON(OC.generateUrl('/apps/ocsms/get/peerlist'), function(jsondata, status) {
|
||||
// Use a buffer for better jQuery performance
|
||||
var peerListBuf = "";
|
||||
|
||||
$.each(jsondata['phonelist'], function(id, val) {
|
||||
var fn, peerLabel;
|
||||
if (typeof jsondata['contacts'][val] == 'undefined') {
|
||||
fn = '';
|
||||
peerLabel = val;
|
||||
}
|
||||
else {
|
||||
fn = jsondata['contacts'][val];
|
||||
peerLabel = fn;
|
||||
}
|
||||
peerListBuf += '<li><a href="#" mailbox-navigation="' + val + '">' + peerLabel + '</a></li>';
|
||||
});
|
||||
|
||||
$('#app-mailbox-peers ul').html(peerListBuf);
|
||||
fetchInitialPeerList();
|
||||
|
||||
// Now bind the events when we click on the phone number
|
||||
$('#app-mailbox-peers').find('a[mailbox-navigation]').on('click', function (event) {
|
||||
|
@ -6,6 +6,7 @@
|
||||
<div id="app">
|
||||
<div id="app-mailbox-peers">
|
||||
<ul>
|
||||
<li><a>There isn't any conversation</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="app-content">
|
||||
|
Loading…
x
Reference in New Issue
Block a user