From: Vsevolod Stakhov Date: Tue, 1 Nov 2016 11:25:12 +0000 (+0000) Subject: [WebUI] Further rework of symbols scores X-Git-Tag: 1.4.0~160 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=3eb97904d4e9b131e19153d48bd414b8749b3337;p=rspamd.git [WebUI] Further rework of symbols scores --- diff --git a/interface/css/rspamd.css b/interface/css/rspamd.css index b10041cf4..a2bd50d89 100644 --- a/interface/css/rspamd.css +++ b/interface/css/rspamd.css @@ -90,12 +90,12 @@ textarea { input { margin:0px; padding:0px; - width:40px; + width:60px; } input[type=number] { padding-right:25px; /* at least image width */ text-align:right; - width:40px; + width:60px; } input.number { /* should be same as type=number for IE and overriding */ padding-right:25px; /* at least image width */ @@ -107,104 +107,6 @@ input::-webkit-inner-spin-button { -webkit-appearance:none; margin:0; /* <-- Apparently some margin are still there even though it's hidden */ } -.k-numerictextbox, -.k-numeric-wrap { - display:block; - } - .k-numeric-wrap { - position:relative; - } - input.numeric { - text-align:right; - } - .k-select { - overflow:hidden; - position:absolute; - top:5px; - left:52px; - width:11px; - height:22px; - font-size:1px; - line-height:1px; - text-indent:-999px; - } - .k-link, - .k-icon { - display:block; - width:11px; - height:10px; - } - .k-icon { - cursor:pointer; - background-image:url('../img/spinner.png'); - } - .k-i-arrow-n { - background-position:0 0; - } - .k-i-arrow-n:hover, - .k-i-arrow-n:focus { - background-position:-11px 0; - } - .k-i-arrow-n:active { - background-position:-22px 0; - } - .k-i-arrow-s { - margin-top:-1px; - background-position:0 -10px; - } - .k-i-arrow-s:hover, - .k-i-arrow-s:focus { - background-position:-11px -10px; - } - .k-i-arrow-s:active { - background-position:-22px -10px; - } -/* spinners default style */ -/* .spin-cell { - position:relative; - } - .spinControl { - position:absolute; - height:20px; - top:6px; - left:56px; - } - .spinControl.MOZ, .spinControl.IE6, .spinControl.IE7 { - } - .spinControl button { - position:absolute; - left:0; - width:11px; - height:10px; - margin:0; - padding:0; - border:0; - background-color:none; - cursor:pointer; - background-image:url('../img/spinner.png'); - } - .spinControl button.down { - bottom:1px; - } - .spinControl button.up { - } - .spinControl button.up:hover, - .spinControl button.up:focus { - background-position:-11px 0; - } - .spinControl button.up:active { - background-position:-22px 0; - } - .spinControl button.down { - background-position:0 -10px; - } - .spinControl button.down:hover, - .spinControl button.down:focus { - background-position:-11px -10px; - } - .spinControl button.down:active { - background-position:-22px -10px; - } */ /* history table */ .table-log { diff --git a/interface/index.html b/interface/index.html index 17f14738f..98b6557c5 100644 --- a/interface/index.html +++ b/interface/index.html @@ -139,11 +139,11 @@
-
- +
Symbols and rules
@@ -154,8 +154,8 @@ Description Score Hits - Avg. time - + Avg.time + Save data
diff --git a/interface/js/rspamd.js b/interface/js/rspamd.js index 7cd267da1..15aa47b7c 100644 --- a/interface/js/rspamd.js +++ b/interface/js/rspamd.js @@ -75,26 +75,24 @@ }); // @supports session storage function supportsSessionStorage() { - return typeof(Storage) !== "undefined"; + return typeof (Storage) !== "undefined"; } // @return password function getPassword() { if (sessionState()) { if (!supportsSessionStorage()) { return password = $.cookie('rspamdpasswd'); - } - else { + } else { return password = sessionStorage.getItem('Password'); } } } // @return session state function sessionState() { - if ((supportsSessionStorage() && (sessionStorage.getItem('Password') !== null)) - || (!supportsSessionStorage() && ($.cookie('rspamdsession')) !== null)) { + if ((supportsSessionStorage() && (sessionStorage.getItem('Password') !== null)) || + (!supportsSessionStorage() && ($.cookie('rspamdsession')) !== null)) { return true; - } - else { + } else { return false; } } @@ -135,10 +133,17 @@ // @save credentials function saveCredentials(data, password) { if (!supportsSessionStorage()) { - $.cookie('rspamdsession', data, { expires: 1 }, { path: '/' }); - $.cookie('rspamdpasswd', password, { expires: 1 }, { path: '/' }); - } - else { + $.cookie('rspamdsession', data, { + expires: 1 + }, { + path: '/' + }); + $.cookie('rspamdpasswd', password, { + expires: 1 + }, { + path: '/' + }); + } else { sessionStorage.setItem('Password', password); sessionStorage.setItem('Credentials', JSON.stringify(data)); } @@ -147,17 +152,19 @@ function saveActions(data) { if (!supportsSessionStorage()) { $.cookie('rspamdactions', data); - } - else { + } else { sessionStorage.setItem('Actions', JSON.stringify(data)); } } // @update credentials function saveMaps(data) { if (!supportsSessionStorage()) { - $.cookie('rspamdmaps', data, { expires: 1 }, { path: '/' }); - } - else { + $.cookie('rspamdmaps', data, { + expires: 1 + }, { + path: '/' + }); + } else { sessionStorage.setItem('Maps', JSON.stringify(data)); } } @@ -167,8 +174,7 @@ $.removeCookie('rspamdlogged'); $.removeCookie('rspamdsession'); $.removeCookie('rspamdpasswd'); - } - else { + } else { sessionStorage.clear(); } $('#statWidgets').empty(); @@ -178,13 +184,13 @@ $('#symbolsTable tbody').remove(); password = ''; } + function isLogged() { if (!supportsSessionStorage()) { if ($.cookie('rspamdpasswd') != null) { return true; } - } - else { + } else { if (sessionStorage.getItem('Password') != null) { return true; } @@ -197,8 +203,8 @@ $(alert).hide().remove(); } var alert = $(''); + nsym++; } }); - $('', { id: 'tmpSymbols', html: items.join('') }).appendTo('#scanResult'); + $('', { + id: 'tmpSymbols', + html: items.join('') + }).appendTo('#scanResult'); $('#tmpSymbols').insertAfter('#tmpBody td:last').removeAttr('id'); $('#tmpBody').removeAttr('id'); $('#scanResult').show(); // Show tooltips - $.each(sym_desc, function(k, v) { + $.each(sym_desc, function (k, v) { $('#' + k).tooltip({ "placement": "bottom", "title": v @@ -851,8 +899,7 @@ $('html, body').animate({ scrollTop: $('#scanResult').offset().top }, 1000); - } - else { + } else { alertMessage('alert-error', 'Cannot scan data'); } }, @@ -892,15 +939,13 @@ //To access the proper headers.flag = $('#fuzzyFlagText').val(); headers.weigth = $('#fuzzyWeightText').val(); - } - else { + } else { data = $('#' + source + 'TextSource').val(); } if (data.length > 0) { if (source == 'scan') { scanText(data); - } - else { + } else { uploadText(data, source, headers); } } @@ -934,21 +979,19 @@ if (item.action === 'add header') { label = 'Probably Spam'; idx = 1; - } - else if (item.action === 'greylist') { + } else if (item.action === 'greylist') { label = 'Greylist'; idx = 0; - } - else if (item.action === 'rewrite subject') { + } else if (item.action === 'rewrite subject') { label = 'Rewrite subject'; idx = 2; - } - else if (item.action === 'reject') { + } else if (item.action === 'reject') { label = 'Spam'; idx = 3; } if (idx >= 0) { - items.push({idx: idx, + items.push({ + idx: idx, html: '
' + '' + '
' + @@ -965,10 +1008,14 @@ } }); - items.sort(function(a, b) { return a.idx - b.idx; }); + items.sort(function (a, b) { + return a.idx - b.idx; + }); $('#actionsBody').html('' + - items.map(function(e) { return e.html; }).join('') + + items.map(function (e) { + return e.html; + }).join('') + '
' + '
'); @@ -1012,8 +1059,7 @@ $('textarea').change(function () { if ($(this).val().length != '') { $(this).closest('form').find('button').removeAttr('disabled').removeClass('disabled'); - } - else { + } else { $(this).closest('form').find('button').attr('disabled').addClass('disabled'); } }); @@ -1027,8 +1073,7 @@ var type = $(form).data('type'); if (type === 'symbols') { saveSymbols(action, id); - } - else if (type === 'map') { + } else if (type === 'map') { saveMap(action, id); } }); @@ -1061,7 +1106,10 @@ var url = action; var values = []; $(inputs).each(function () { - values.push({ name: $(this).attr('id'), value: parseFloat($(this).val()) }); + values.push({ + name: $(this).attr('id').substring(5), + value: parseFloat($(this).val()) + }); }); $.ajax({ data: JSON.stringify(values), @@ -1077,7 +1125,8 @@ }, error: function (data) { alertMessage('alert-modal alert-error', data.statusText); - } }); + } + }); $('#modalDialog').modal('hide'); return false; } @@ -1125,8 +1174,7 @@ $(form).each(function () { $('.form-group').addClass('error'); }); - } - else { + } else { saveCredentials(data, password); $(dialog).hide(); $(backdrop).hide(); @@ -1139,6 +1187,7 @@ }); }); } + function displayUI() { // @toggle auth and main var disconnect = $('#navBar .pull-right'); @@ -1171,10 +1220,10 @@ $('#throughput_nav').bind('click', function () { getGraphData(selected.selData); }); - $('#history_nav').bind('click', function() { + $('#history_nav').bind('click', function () { getHistory(); }); - $('#symbols_nav').bind('click', function() { + $('#symbols_nav').bind('click', function () { getSymbols(); }); });