<div class="widget-box">
<div class="widget-title">
- <div class="buttons pull-right">
+ <form role="form" class="form-inline pull-right buttons">
+ <div class="form-group widget-title-form">
+ <label for="selSymOrder">Symbols order:</label>
+ <select id="selSymOrder" class="form-control">
+ <option value="score" selected>Score</option>
+ <option value="name">Name</option>
+ </select>
+ </div>
<button class="btn btn-danger btn-sm" id="resetHistory">
<i class="glyphicon glyphicon-remove-circle"></i> Reset
</button>
<button class="btn btn-info btn-sm" id="updateHistory">
<i class="glyphicon glyphicon-refresh"></i> Update
</button>
- </div>
+ </form>
<span class="icon"><i class="glyphicon glyphicon-eye-open"></i></span>
<h5>History</h5>
</div>
function process_history_v2(data) {
var items = [];
+ function getSelector(id) {
+ var e = document.getElementById(id);
+ return e.options[e.selectedIndex].value;
+ }
+ var compare = (getSelector("selSymOrder") === "score")
+ ? function (e1, e2) {
+ return Math.abs(e1.score) < Math.abs(e2.score);
+ }
+ : function (e1, e2) {
+ return e1.name.localeCompare(e2.name);
+ };
+
$.each(data.rows,
function (i, item) {
map(function(key) {
return item.symbols[key];
}).
- sort(function(e1, e2) {
- return Math.abs(e1.score) < Math.abs(e2.score);
- }).
+ sort(compare).
map(function(e) { return e.str; }).
join("<br>\n");
item.time = {
e.preventDefault();
interface.getHistory(rspamd, tables, neighbours, checked_server);
});
+ $("#selSymOrder").change(function() {
+ interface.getHistory(rspamd, tables, neighbours, checked_server);
+ });
// @reset history log
$('#resetHistory').off('click');