qhandler.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. jQuery(function($){
  2. var qitem = $('legend').data('hash');
  3. var qError = $("#qid_error");
  4. $.ajax({
  5. url: '/inc/ajax/qitem_details.php',
  6. data: { hash: qitem },
  7. dataType: 'json',
  8. success: function(data){
  9. if (typeof data.error !== 'undefined') {
  10. qError.text(data.error);
  11. qError.show();
  12. }
  13. $('[data-id="qitems_single"]').each(function(index) {
  14. $(this).attr("data-item", qitem);
  15. });
  16. $('#qid_detail_subj').text(data.subject);
  17. $('#qid_detail_hfrom').text(data.header_from);
  18. $('#qid_detail_efrom').text(data.env_from);
  19. $('#qid_detail_score').text(data.score);
  20. $('#qid_detail_symbols').html('');
  21. if (typeof data.symbols !== 'undefined') {
  22. data.symbols.sort(function (a, b) {
  23. if (a.score === 0) return 1
  24. if (b.score === 0) return -1
  25. if (b.score < 0 && a.score < 0) {
  26. return a.score - b.score
  27. }
  28. if (b.score > 0 && a.score > 0) {
  29. return b.score - a.score
  30. }
  31. return b.score - a.score
  32. })
  33. $.each(data.symbols, function (index, value) {
  34. var highlightClass = ''
  35. if (value.score > 0) highlightClass = 'negative'
  36. else if (value.score < 0) highlightClass = 'positive'
  37. else highlightClass = 'neutral'
  38. $('#qid_detail_symbols').append('<span data-toggle="tooltip" class="rspamd-symbol ' + highlightClass + '" title="' + (value.options ? value.options.join(', ') : '') + '">' + value.name + ' (<span class="score">' + value.score + '</span>)</span>');
  39. });
  40. $('[data-toggle="tooltip"]').tooltip()
  41. }
  42. $('#qid_detail_recipients').html('');
  43. if (typeof data.recipients !== 'undefined') {
  44. $.each(data.recipients, function(index, value) {
  45. var elem = $('<span class="mail-address-item"></span>');
  46. elem.text(value.address + ' (' + value.type.toUpperCase() + ')');
  47. $('#qid_detail_recipients').append(elem);
  48. });
  49. }
  50. }
  51. });
  52. });