qhandler.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. $('#qid_detail_fuzzy').html('');
  22. if (data.fuzzy_hashes !== null) {
  23. $.each(data.fuzzy_hashes, function (index, value) {
  24. $('#qid_detail_fuzzy').append('<p style="font-family:monospace">' + value + '</p>');
  25. });
  26. } else {
  27. $('#qid_detail_fuzzy').append('-');
  28. }
  29. if (typeof data.symbols !== 'undefined') {
  30. data.symbols.sort(function (a, b) {
  31. if (a.score === 0) return 1
  32. if (b.score === 0) return -1
  33. if (b.score < 0 && a.score < 0) {
  34. return a.score - b.score
  35. }
  36. if (b.score > 0 && a.score > 0) {
  37. return b.score - a.score
  38. }
  39. return b.score - a.score
  40. })
  41. $.each(data.symbols, function (index, value) {
  42. var highlightClass = ''
  43. if (value.score > 0) highlightClass = 'negative'
  44. else if (value.score < 0) highlightClass = 'positive'
  45. else highlightClass = 'neutral'
  46. $('#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>');
  47. });
  48. $('[data-toggle="tooltip"]').tooltip()
  49. }
  50. $('#qid_detail_recipients').html('');
  51. if (typeof data.recipients !== 'undefined') {
  52. $.each(data.recipients, function(index, value) {
  53. var elem = $('<span class="mail-address-item"></span>');
  54. elem.text(value.address + ' (' + value.type.toUpperCase() + ')');
  55. $('#qid_detail_recipients').append(elem);
  56. });
  57. }
  58. }
  59. });
  60. });