Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 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 | $('[data-id="qitems_single"]').each(function(index) {
|
| 10 | $(this).attr("data-item", qitem);
|
| 11 | });
|
| 12 | $('#qid_detail_subj').text(data.subject);
|
| 13 | $('#qid_detail_hfrom').text(data.header_from);
|
| 14 | $('#qid_detail_efrom').text(data.env_from);
|
| 15 | $('#qid_detail_score').html('');
|
| 16 | $('#qid_detail_symbols').html('');
|
| 17 | $('#qid_detail_recipients').html('');
|
| 18 | $('#qid_detail_fuzzy').html('');
|
| 19 | if (typeof data.fuzzy_hashes === 'object' && data.fuzzy_hashes !== null && data.fuzzy_hashes.length !== 0) {
|
| 20 | $.each(data.fuzzy_hashes, function (index, value) {
|
| 21 | $('#qid_detail_fuzzy').append('<p style="font-family:monospace">' + value + '</p>');
|
| 22 | });
|
| 23 | } else {
|
| 24 | $('#qid_detail_fuzzy').append('-');
|
| 25 | }
|
| 26 | if (typeof data.symbols !== 'undefined') {
|
| 27 | data.symbols.sort(function (a, b) {
|
| 28 | if (a.score === 0) return 1
|
| 29 | if (b.score === 0) return -1
|
| 30 | if (b.score < 0 && a.score < 0) {
|
| 31 | return a.score - b.score
|
| 32 | }
|
| 33 | if (b.score > 0 && a.score > 0) {
|
| 34 | return b.score - a.score
|
| 35 | }
|
| 36 | return b.score - a.score
|
| 37 | })
|
| 38 | $.each(data.symbols, function (index, value) {
|
| 39 | var highlightClass = ''
|
| 40 | if (value.score > 0) highlightClass = 'negative'
|
| 41 | else if (value.score < 0) highlightClass = 'positive'
|
| 42 | else highlightClass = 'neutral'
|
| 43 | $('#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>');
|
| 44 | });
|
| 45 | $('[data-toggle="tooltip"]').tooltip()
|
| 46 | }
|
| 47 | if (typeof data.score !== 'undefined' && typeof data.action !== 'undefined') {
|
| 48 | if (data.action === "add header") {
|
| 49 | $('#qid_detail_score').append('<span class="label-rspamd-action label label-warning"><b>' + data.score + '</b> - ' + lang.junk_folder + '</span>');
|
| 50 | } else if (data.action === "reject") {
|
| 51 | $('#qid_detail_score').append('<span class="label-rspamd-action label label-danger"><b>' + data.score + '</b> - ' + lang.rejected + '</span>');
|
| 52 | } else if (data.action === "rewrite subject") {
|
| 53 | $('#qid_detail_score').append('<span class="label-rspamd-action label label-warning"><b>' + data.score + '</b> - ' + lang.rewrite_subject + '</span>');
|
| 54 | }
|
| 55 | }
|
| 56 | if (typeof data.recipients !== 'undefined') {
|
| 57 | $.each(data.recipients, function(index, value) {
|
| 58 | var elem = $('<span class="mail-address-item"></span>');
|
| 59 | elem.text(value.address + ' (' + value.type.toUpperCase() + ')');
|
| 60 | $('#qid_detail_recipients').append(elem);
|
| 61 | });
|
| 62 | }
|
| 63 | },
|
| 64 | error: function(data){
|
| 65 | if (typeof data.error !== 'undefined') {
|
| 66 | qError.text("Error loading quarantine item");
|
| 67 | qError.show();
|
| 68 | }
|
| 69 | }
|
| 70 | });
|
| 71 | });
|