mirror of
https://github.com/nerzhul/ocsms.git
synced 2025-06-08 16:36:25 +00:00
Prepare a conversation output
This commit is contained in:
parent
86f4fb3910
commit
59a075ba6f
31
js/script.js
31
js/script.js
@ -8,28 +8,47 @@
|
|||||||
* @copyright Loic Blot 2014
|
* @copyright Loic Blot 2014
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
function fetchConversation(phoneNumber) {
|
||||||
|
$.getJSON(OC.generateUrl('/apps/ocsms/get/get_conversation'),
|
||||||
|
{'phoneNumber': phoneNumber},
|
||||||
|
function(jsondata, status) {
|
||||||
|
var conversationBuf = "";
|
||||||
|
|
||||||
|
$.each(jsondata["conversation"]), function(id, vals) {
|
||||||
|
conversationBuf += vals["msg"] + "<br />";
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#app-content').html(conversationBuf);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
(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
|
||||||
$('#app-navigation').find('a').on('click', function (event) {
|
$('#app-navigation').find('a').on('click', function (event) {
|
||||||
OC.Util.History.pushState('feed=' + $(this).attr('nav-feed'));
|
OC.Util.History.pushState('feed=' + $(this).attr('nav-feed'));
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
});
|
});
|
||||||
|
|
||||||
$.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
|
||||||
var peerListBuf = "";
|
var peerListBuf = "";
|
||||||
|
|
||||||
$.each(jsondata['phonelist'], function(id, val) {
|
$.each(jsondata['phonelist'], function(id, val) {
|
||||||
peerListBuf += '<li><a href="#" mailbox-navigation="' + val + '">' + val + '</a></li>';
|
peerListBuf += '<li><a href="#" mailbox-navigation="' + val + '">' + val + '</a></li>';
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#app-mailbox-peers ul').html(peerListBuf);
|
$('#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) {
|
||||||
OC.Util.History.pushState('phonenumber=' + $(this).attr('mailbox-navigation'));
|
var phoneNumber = $(this).attr('mailbox-navigation');
|
||||||
event.preventDefault();
|
OC.Util.History.pushState('phonenumber=' + phoneNumber);
|
||||||
});
|
fetchConversation(phoneNumber);
|
||||||
|
event.preventDefault();
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
})(jQuery, OC);
|
})(jQuery, OC);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user