Advertisement
Guest User

Untitled

a guest
Dec 6th, 2022
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var jrpc = new rpc(!0),
  2.         JournalMessage = {
  3.                 url: '/journal-messages-ajax-action',
  4.                 action: jrpc.action,
  5.                 del: function (e, r) {
  6.                         jrpc.callPool(this.action('messages.delete', [e, r]), (function (e) {
  7.                                 !1 === e.result && '' != e.error && alert(e.error)
  8.                         }))
  9.                 },
  10.                 note_unread: function (e) {
  11.                         jrpc.callPool(this.action('messages.note_unread', [e]), (function (e) {
  12.                                 !1 === e.result && '' != e.error && alert(e.error)
  13.                         }))
  14.                 },
  15.                 note_read: function (e) {
  16.                         jrpc.callPool(this.action('messages.note_read', [e]), (function (e) {
  17.                                 !1 === e.result && '' != e.error && alert(e.error)
  18.                         }))
  19.                 },
  20.                 send_view: function () {
  21.                         var e = [];
  22.                         $('nobr[id^="fid_"]').children('input:checked').each((function () {
  23.                                 var r = $(this.parentNode);
  24.                                 e.push({
  25.                                         'fid': r.attr('fid') ? r.attr('fid') : r.attr('id').substr(4),
  26.                                         'filename': r.attr('filename')
  27.                                 })
  28.                         }));
  29.                         var r = [];
  30.                         $('#resources-checkboxes').children('label').children('input:checked').each((function () {
  31.                                 r.push($(this).val())
  32.                         })),
  33.                         r = r.join(';');
  34.                         var n = [];
  35.                         if (window.additional_receivers.length > 0 && (n = n.concat(window.additional_receivers)), void 0 !== window.multipleViewReceiversIsActive) if (!0 === window.multipleViewReceiversIsActive) {
  36.                                 var t = window.allReceivers;
  37.                                 n = (t = t.concat(window.partReceivers)).map((function (e) {
  38.                                         return e.id || e.uid
  39.                                 }))
  40.                         } else if (!1 === window.multipleViewReceiversIsActive) {
  41.                                 var a = window.receiversArray;
  42.                                 n = (a = a.concat(window.partReceivers)).map((function (e) {
  43.                                         return e.id || e.uid
  44.                                 }))
  45.                         }
  46.                         void 0 !== window.receiversArray && window.receiversArray instanceof Array && window.receiversArray.length && (n = n.concat(window.receiversArray)),
  47.                         n = n.join(';'),
  48.                         jrpc.addParameter('subject', subject),
  49.                         jrpc.addParameter('reply', $('#msgReply').val()),
  50.                         jrpc.addParameter('receivers', n),
  51.                         jrpc.addParameter('message_id', message_id),
  52.                         jrpc.addParameter('vfiles', JSON.stringify(e)),
  53.                         jrpc.addParameter('resources', r),
  54.                         $('#msgReply').attr('disabled', !0),
  55.                         $('#send').attr('disabled', !0),
  56.                         window.showLoadingScreen(window.trans('messaging.wait_sending')),
  57.                         jrpc.post(this.action('messages.send_view'), (function (e) {
  58.                                 try {
  59.                                         var r = e;
  60.                                         !1 === r.result && '' !== r.error && (removeDisable(), alert(r.error, !0)),
  61.                                         r.result > 0 && (removeDisable(), msg_view_cancel(), $('#msgReply').val(''), $('div nobr').remove(), alert(intlmsg.msg_send))
  62.                                 } catch (e) {
  63.                                         alert(window.trans('messaging.error.send'), !0)
  64.                                 }
  65.                         }))
  66.                 }
  67.         };
  68.  
  69. function msg_send(e) {
  70.         if (e && e.preventDefault && e.preventDefault(), $('#subject').length > 0 && '' == $.trim($('#subject').val())) return alert(err_subject),
  71.         !1;
  72.         var r = [];
  73.         if ($('#rec').children('a').each((function () {
  74.                 r.push($(this).attr('name'))
  75.         })), r = r.join(';'), $('#receivers').val(r), '' == r) return alert(err_receivers),
  76.         !1;
  77.         if ('' == $.trim($('#message').val())) return alert(err_message),
  78.         !1;
  79.         var n = [];
  80.         return $('nobr[id^="fid_"]').children('input:checked').each((function () {
  81.                 var e = $(this.parentNode);
  82.                 n.push({
  83.                         'fid': e.attr('fid') ? e.attr('fid') : e.attr('id').substr(4),
  84.                         'filename': e.attr('filename')
  85.                 })
  86.         })),
  87.         $('#vfiles').val(JSON.stringify(n)),
  88.         !0
  89. }
  90. function msg_cancel(e) {
  91.         return e && e.preventDefault && e.preventDefault(),
  92.         window.location.href = '/journal-messages-action',
  93.         !1
  94. }
  95. function msg_view_reply(e) {
  96.         return e = e || !1,
  97.         $('#msgReply').slideDown('normal', (function () {
  98.                 $('#reply, #reply_all, #delete, #another, #forward, #matOn').hide(),
  99.                 $('#send, #cancel, #receivers_new, #receivers_new_instruction, #upload_new, #attach_resource').show(),
  100.                 e && (window.additional_receivers = allReceivers, $('#receivers_new').find('.count').text('(' + window.additional_receivers.length + ')'))
  101.         })),
  102.         !1
  103. }
  104. function msg_view_delete(e) {
  105.         return e && e.preventDefault && e.preventDefault(),
  106.         Boxy.confirm(intlmsg.msg_del_confirm, (function () {
  107.                 JournalMessage.del(message_id, msg_type),
  108.                 alert(intlmsg.msg_del),
  109.                 $('table.message').fadeTo('fast', .5),
  110.                 $('#reply, #reply_all, #send, #cancel, #delete, #another, #forward, #matOn').fadeOut('slow')
  111.         })),
  112.         !1
  113. }
  114. function msg_view_send(e) {
  115.         return e && e.preventDefault && e.preventDefault(),
  116.         '' == $.trim($('#msgReply').val()) ? (alert(intlmsg.msg_empty), !1) : (JournalMessage.send_view(), !1)
  117. }
  118. function msg_view_cancel(e) {
  119.         return e && e.preventDefault && e.preventDefault(),
  120.         window.additional_receivers = [],
  121.         $('#receivers_new').find('.count').text('(' + window.additional_receivers.length + ')'),
  122.         $('#msgReply').slideUp(),
  123.         $('#reply, #reply_all, #delete, #another, #forward, #matOn').show(),
  124.         $('#send, #cancel, #receivers_new, #receivers_new_instruction, #upload_new, #attach_resource').hide(),
  125.         !1
  126. }
  127. function msg_view_forward(e) {
  128.         e && e.preventDefault && e.preventDefault();
  129.         var r = '/journal-messages-forward-action/id.' + message_id;
  130.         return '' != teacher && (r += '/teacher.' + teacher),
  131.         window.location.href = r,
  132.         !1
  133. }
  134. function removeDisable() {
  135.         $('#msgReply').attr('disabled', !1),
  136.         $('#send').attr('disabled', !1),
  137.         window.hideLoadingScreen()
  138. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement