2009-01-12 16:17:19 +01:00
|
|
|
var original_command = "";
|
|
|
|
|
2014-03-06 11:09:19 +01:00
|
|
|
function parse_alert_command (command, classs) {
|
|
|
|
if (classs == 'recovery') {
|
2014-05-30 12:34:21 +02:00
|
|
|
classs = 'fields_recovery';
|
2014-03-06 11:09:19 +01:00
|
|
|
}
|
2014-05-30 12:34:21 +02:00
|
|
|
else {
|
|
|
|
classs = 'fields';
|
|
|
|
}
|
|
|
|
|
2015-03-10 15:13:14 +01:00
|
|
|
|
|
|
|
|
2012-10-29 09:45:06 +01:00
|
|
|
var nfield = 1;
|
2014-03-05 12:34:05 +01:00
|
|
|
$('.' + classs).each(function() {
|
2015-03-10 15:13:14 +01:00
|
|
|
|
2012-10-30 17:52:56 +01:00
|
|
|
// Only render values different from ''
|
2013-02-04 11:22:56 +01:00
|
|
|
if ($(this).val() == '') {
|
2015-03-10 15:13:14 +01:00
|
|
|
|
2015-01-20 12:10:06 +01:00
|
|
|
nfield++;
|
2015-03-10 15:13:14 +01:00
|
|
|
|
2012-10-30 17:52:56 +01:00
|
|
|
return;
|
|
|
|
}
|
2014-03-06 11:09:19 +01:00
|
|
|
var field = '_field' + nfield + '_';
|
2015-03-10 15:13:14 +01:00
|
|
|
|
|
|
|
var regex = new RegExp(field, "gi");
|
|
|
|
|
|
|
|
|
2012-10-29 09:45:06 +01:00
|
|
|
command = command.replace (regex, $(this).val());
|
2015-03-10 15:13:14 +01:00
|
|
|
|
|
|
|
nfield++;
|
2012-10-29 09:45:06 +01:00
|
|
|
});
|
2009-01-12 16:17:19 +01:00
|
|
|
|
|
|
|
return command;
|
|
|
|
}
|
|
|
|
|
2012-10-30 17:52:56 +01:00
|
|
|
function render_command_preview (original_command) {
|
2015-03-10 15:13:14 +01:00
|
|
|
$("#textarea_command_preview")
|
|
|
|
.text(parse_alert_command (original_command, ''));
|
2014-05-30 12:34:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function render_command_recovery_preview (original_command) {
|
2015-03-10 15:13:14 +01:00
|
|
|
$("#textarea_command_recovery_preview")
|
|
|
|
.text(parse_alert_command (original_command, 'recovery'));
|
2009-01-12 16:17:19 +01:00
|
|
|
}
|
2013-07-17 13:12:37 +02:00
|
|
|
|
2012-05-21 12:28:35 +02:00
|
|
|
function render_command_description (command_description) {
|
2013-07-17 13:12:37 +02:00
|
|
|
if (command_description != '') {
|
2015-03-10 15:13:14 +01:00
|
|
|
command_description = '<br>' + command_description;
|
2012-05-21 12:28:35 +02:00
|
|
|
}
|
|
|
|
$("#command_description").html(command_description);
|
|
|
|
}
|