mirror of
https://github.com/nerzhul/ocsms.git
synced 2025-06-08 16:36:25 +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');
|
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) {
|
(function ($, OC) {
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
// Now bind the events when we click on the phone number
|
// Now bind the events when we click on the phone number
|
||||||
$.getJSON(OC.generateUrl('/apps/ocsms/get/peerlist'), function(jsondata, status) {
|
$.getJSON(OC.generateUrl('/apps/ocsms/get/peerlist'), function(jsondata, status) {
|
||||||
// Use a buffer for better jQuery performance
|
fetchInitialPeerList();
|
||||||
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);
|
|
||||||
|
|
||||||
// Now bind the events when we click on the phone number
|
// Now bind the events when we click on the phone number
|
||||||
$('#app-mailbox-peers').find('a[mailbox-navigation]').on('click', function (event) {
|
$('#app-mailbox-peers').find('a[mailbox-navigation]').on('click', function (event) {
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
<div id="app">
|
<div id="app">
|
||||||
<div id="app-mailbox-peers">
|
<div id="app-mailbox-peers">
|
||||||
<ul>
|
<ul>
|
||||||
|
<li><a>There isn't any conversation</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div id="app-content">
|
<div id="app-content">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user