').appendTo(table);
tr.append($('| ').text("Interval : "));
tr.append($(' | ').append($('').attr('id', 'input_interval').attr('type', 'text')));
tr.append($(' | ').html(" \"days hours:minutes\", default = 10 minutes"));
domEventPollerParameters = $('').attr('id', 'event_poller_params');
domSectionSelectedActions = $(' ');
domSectionSelectedActions.append($(' ').html(" Selected Actions:"));
domSectionSelectedActions.append($(' ').attr('id', 'selected_actions'));
domSectionSelectedActions.hide();
domSectionActionParameters = $('');
domSectionActionParameters.append($(' ').html(" Required User-specific Data:"));
domSectionActionParameters.append($(' ').attr('id', 'action_invoker_params'));
domSectionActionParameters.append($(' ').html(" "));
domSectionActionParameters.hide();
fClearInfo = function() {
$('#info').text('');
return $('#info').attr('class', 'neutral');
};
fDisplayError = function(msg) {
window.scrollTo(0, 0);
$('#info').text("Error: " + msg);
return $('#info').attr('class', 'error');
};
fFailedRequest = function(msg) {
return function(err) {
if (err.status === 401) {
return window.location.href = 'forge?page=forge_rule';
} else {
return fDisplayError(msg);
}
};
};
fIssueRequest = function(args) {
fClearInfo();
return $.post('/usercommand', args.data).done(args.done).fail(args.fail);
};
fConvertTimeToDate = function(str) {
var arrInp, dateConv, h, intHour, intMin, m, txtHr;
dateConv = new Date();
if (!str) {
dateConv.setHours(12);
dateConv.setMinutes(0);
} else {
arrInp = str.split(':');
if (arrInp.length === 1) {
txtHr = str;
dateConv.setMinutes(0);
} else {
txtHr = arrInp[0];
intMin = parseInt(arrInp[1]) || 0;
m = Math.max(0, Math.min(intMin, 59));
dateConv.setMinutes(m);
}
}
intHour = parseInt(txtHr) || 12;
h = Math.max(0, Math.min(intHour, 24));
dateConv.setHours(h);
dateConv.setSeconds(0);
dateConv.setMilliseconds(0);
if (dateConv < new Date()) {
dateConv.setDate(dateConv.getDate() + 17);
}
return dateConv;
};
fConvertDayHourToMinutes = function(strDayHour) {
var arrInp, d, fParseTime, mins;
fParseTime = function(str, hasDay) {
var arrTime, def, h, time;
arrTime = str.split(':');
if (hasDay) {
def = 0;
} else {
def = 10;
}
if (arrTime.length === 1) {
time = parseInt(str) || def;
if (hasDay) {
return time * 60;
} else {
return time;
}
} else {
h = parseInt(arrTime[0]) || 0;
if (h > 0) {
def = 0;
}
return h * 60 + (parseInt(arrTime[1]) || def);
}
};
if (!strDayHour) {
mins = 10;
} else {
arrInp = strDayHour.split(' ');
if (arrInp.length === 1) {
mins = fParseTime(strDayHour);
} else {
d = parseInt(arrInp[0]) || 0;
mins = d * 24 * 60 + fParseTime(arrInp[1], true);
}
}
mins = Math.min(mins, 35700);
return Math.max(1, mins);
};
fPrepareEventType = function(eventtype, cb) {
$('#select_event_type').val(eventtype);
$('#event_parameters > div').detach();
switch (eventtype) {
case 'Custom Event':
$('#event_parameters').append(domInputEventName);
return typeof cb === "function" ? cb() : void 0;
case 'Webhook':
return fIssueRequest({
data: {
command: 'get_all_webhooks'
},
done: function(data) {
var err, hookid, hookname, i, oHooks, selHook;
try {
oHooks = JSON.parse(data.message);
selHook = $('select', domSelectWebhook);
selHook.children().remove();
i = 0;
for (hookid in oHooks) {
hookname = oHooks[hookid];
i++;
selHook.append($(' |