2021-10-28 17:30:03 +02:00
|
|
|
/* globals $ confirmDialog uniqId showMsg*/
|
2019-01-30 12:27:18 +01:00
|
|
|
function parse_alert_command(command, classs) {
|
|
|
|
if (classs == "recovery") {
|
|
|
|
classs = "fields_recovery";
|
|
|
|
} else {
|
|
|
|
classs = "fields";
|
|
|
|
}
|
|
|
|
|
|
|
|
var nfield = 1;
|
|
|
|
$("." + classs).each(function() {
|
|
|
|
// Only render values different from ''
|
|
|
|
var field = "_field" + nfield + "_";
|
|
|
|
var regex = new RegExp(field, "gi");
|
2021-01-21 17:09:36 +01:00
|
|
|
if ($(this).val() == "") {
|
|
|
|
if (
|
|
|
|
classs == "fields_recovery" &&
|
|
|
|
$($(".fields")[nfield - 1]).val() != ""
|
|
|
|
) {
|
|
|
|
command = command.replace(
|
|
|
|
regex,
|
|
|
|
"[RECOVER]" + $($(".fields")[nfield - 1]).val()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
} else if ($(this).css("-webkit-text-security") == "disc") {
|
2019-05-03 13:46:52 +02:00
|
|
|
var hidden_character = "*";
|
|
|
|
var hidden_string = hidden_character.repeat($(this).val().length);
|
2019-01-30 12:27:18 +01:00
|
|
|
|
2019-05-03 13:46:52 +02:00
|
|
|
command = command.replace(regex, hidden_string);
|
|
|
|
} else {
|
|
|
|
command = command.replace(regex, $(this).val());
|
|
|
|
}
|
2019-01-30 12:27:18 +01:00
|
|
|
nfield++;
|
|
|
|
});
|
|
|
|
|
|
|
|
return command;
|
2009-01-12 16:17:19 +01:00
|
|
|
}
|
|
|
|
|
2021-10-28 17:30:03 +02:00
|
|
|
// eslint-disable-next-line no-unused-vars
|
2019-01-30 12:27:18 +01:00
|
|
|
function render_command_preview(original_command) {
|
2019-04-01 17:57:22 +02:00
|
|
|
$("#textarea_command_preview").html(
|
2019-01-30 12:27:18 +01:00
|
|
|
parse_alert_command(original_command, "")
|
|
|
|
);
|
2014-05-30 12:34:21 +02:00
|
|
|
}
|
|
|
|
|
2021-10-28 17:30:03 +02:00
|
|
|
// eslint-disable-next-line no-unused-vars
|
2019-01-30 12:27:18 +01:00
|
|
|
function render_command_recovery_preview(original_command) {
|
2019-04-01 17:57:22 +02:00
|
|
|
$("#textarea_command_recovery_preview").html(
|
2019-01-30 12:27:18 +01:00
|
|
|
parse_alert_command(original_command, "recovery")
|
|
|
|
);
|
2009-01-12 16:17:19 +01:00
|
|
|
}
|
2013-07-17 13:12:37 +02:00
|
|
|
|
2021-10-28 17:30:03 +02:00
|
|
|
// eslint-disable-next-line no-unused-vars
|
2019-01-30 12:27:18 +01:00
|
|
|
function render_command_description(command_description) {
|
|
|
|
if (command_description != "") {
|
|
|
|
command_description = "<br>" + command_description;
|
|
|
|
}
|
|
|
|
$("#command_description").html(command_description);
|
2012-05-21 12:28:35 +02:00
|
|
|
}
|
2021-10-28 17:30:03 +02:00
|
|
|
|
|
|
|
// eslint-disable-next-line no-unused-vars
|
|
|
|
function load_templates_alerts_special_days(settings) {
|
|
|
|
confirmDialog({
|
|
|
|
title: settings.title,
|
|
|
|
message: function() {
|
|
|
|
var id = "div-" + uniqId();
|
|
|
|
$.ajax({
|
|
|
|
method: "post",
|
|
|
|
url: settings.url,
|
|
|
|
data: {
|
|
|
|
page: settings.page,
|
|
|
|
get_template_alerts: 1,
|
|
|
|
date: settings.date,
|
|
|
|
id_group: settings.id_group,
|
|
|
|
same_day: settings.same_day
|
|
|
|
},
|
|
|
|
datatype: "html",
|
|
|
|
success: function(data) {
|
|
|
|
console.log(data);
|
|
|
|
$("#" + id)
|
|
|
|
.empty()
|
|
|
|
.append(data);
|
|
|
|
},
|
|
|
|
error: function(e) {
|
|
|
|
showMsg(e);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return "<div id ='" + id + "'>" + settings.loading + "</div>";
|
|
|
|
},
|
|
|
|
ok: settings.btn_ok_text,
|
|
|
|
cancel: settings.btn_cancel_text,
|
|
|
|
onAccept: function() {
|
|
|
|
$("#" + settings.name_form).submit();
|
|
|
|
},
|
|
|
|
size: 750,
|
|
|
|
maxHeight: 500
|
|
|
|
});
|
|
|
|
}
|