2019-11-11 17:38:56 +08:00
|
|
|
var rspamd_presetsElem = document.getElementById("rspamd_presets");
|
|
|
|
|
2019-11-15 03:47:27 +08:00
|
|
|
if (rspamd_presetsElem) {
|
|
|
|
$.ajax({
|
|
|
|
dataType: 'json',
|
2019-11-15 05:07:49 +08:00
|
|
|
url: '/api/v1/get/presets-admin-rspamd/all',
|
2019-11-15 03:47:27 +08:00
|
|
|
jsonp: false,
|
|
|
|
complete: function (data) {
|
|
|
|
if (data.responseText !== '{}') {
|
|
|
|
var rspamdPresets = JSON.parse(data.responseText);
|
|
|
|
|
|
|
|
if (rspamdPresets) {
|
|
|
|
rspamd_presetsElem.innerHTML = '';
|
|
|
|
rspamdPresets.forEach(function (item, index) {
|
|
|
|
var elemID = 'rspamd_preset_' + index;
|
|
|
|
rspamd_presetsElem.innerHTML += '<li><a href="#" class="small" id="' + elemID + '">' + lang.rsettings_insert_preset.replace('%s', item.headline) + '</a></li>';
|
2019-11-11 17:38:56 +08:00
|
|
|
|
2019-11-15 03:47:27 +08:00
|
|
|
/*
|
|
|
|
we need to define 0-timeout here, to prevent dom not be ready.
|
|
|
|
*/
|
|
|
|
setTimeout(function () {
|
|
|
|
document.getElementById(elemID).addEventListener('click', function (e) {
|
|
|
|
e.preventDefault();
|
|
|
|
document.querySelector('form[data-id=rsetting] #adminRspamdSettingsDesc').value = item.headline;
|
|
|
|
document.querySelector('form[data-id=rsetting] #adminRspamdSettingsContent').value = item.content;
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
}, 0);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-11-11 17:38:56 +08:00
|
|
|
});
|
|
|
|
}
|