3 Jappix - An open social platform
4 These are the receipts JS scripts for Jappix
6 -------------------------------------------------
10 Last revision: 26/12/10
14 // Checks if we can send a receipt request
15 function receiptRequest(hash) {
16 // Entity have support for receipt?
17 if($('#' + hash + ' .message-area').attr('data-receipts') == 'true')
23 // Checks if there is a receipt request
24 function hasReceipt(packet) {
25 // Any receipt request?
26 if(packet.getChild('request', NS_URN_RECEIPTS))
32 // Checks if there is a received reply
33 function hasReceived(packet) {
34 // Any received reply?
35 if(packet.getChild('received', NS_URN_RECEIPTS))
41 // Sends a received notification
42 function sendReceived(type, to, id) {
43 var aMsg = new JSJaCMessage();
51 // Append the received node
52 aMsg.appendNode('received', {'xmlns': NS_URN_RECEIPTS, 'id': id});
56 logThis('Sent received to: ' + to);
59 // Tells the message has been received
60 function messageReceived(hash, id) {
62 var path = $('#' + hash + ' .one-line[data-id=' + id + ']');
64 // Add a received marker
65 path.attr('data-received', 'true')
66 .removeAttr('data-lost');
69 var group = path.parent();
71 // Remove the group marker
72 if(!group.find('.one-line[data-lost]').size()) {
73 group.find('b.name').removeClass('talk-images')
80 // Checks if the message has been received
81 function checkReceived(hash, id) {
82 // Fire a check 10 seconds later
83 $('#' + hash + ' .one-line[data-id=' + id + ']').oneTime('10s', function() {
85 if($(this).attr('data-received') != 'true') {
86 // Add a "lost" marker
87 $(this).attr('data-lost', 'true');
89 // Add a warn on the buddy-name
90 $(this).parent().find('b.name').addClass('talk-images')
91 .attr('title', _e("Your friend seems not to have received your message(s)!"));