// Order of sliders greylist -> probable spam -> spam
$('#actionsBody').empty();
$('#actionsForm').empty();
- items = [];
+ var items = [];
var min = 0;
var max = Number.MIN_VALUE;
$.each(data, function (i, item) {
label = 'Greylist';
idx = 0;
}
+ else if (item.action === 'rewrite subject') {
+ label = 'Rewrite subject';
+ idx = 2;
+ }
else if (item.action === 'reject') {
label = 'Spam';
- idx = 2;
+ idx = 3;
}
if (idx >= 0) {
- items[idx] =
- '<div class="form-group">' +
+ items.push({idx: idx,
+ html: '<div class="form-group">' +
'<label class="control-label col-sm-2">' + label + '</label>' +
'<div class="controls slider-controls col-sm-10">' +
'<input class="slider" type="slider" value="' + item.value + '">' +
'</div>' +
- '</div>';
+ '</div>'
+ });
}
if (item.value > max) {
max = item.value * 2;
}
});
- $('#actionsBody').html('<form id="actionsForm">' + items.join('') +
+ items.sort(function(a, b) { return a.idx - b.idx; });
+
+ $('#actionsBody').html('<form id="actionsForm">' +
+ items.map(function(e) { return e.html; }).join('') +
'<br><div class="form-group">' +
'<button class="btn btn-primary" ' +
'type="submit">Save actions</button></div></form>');