
function submit_command(cmd_id,cmd_data_raw,cmd_time_raw,cmd_args_raw)
{var content="<div id='popup_header'><b>"+_('Please Wait')+"</b></div><div id='popup_data'><p><ul class='ajaxcommandresult'><li class='commandresultwaiting' id='ajaxcommandwaiting'>"+_('Submitting command')+"</li></ul></div>";set_child_popup_content(content);display_child_popup();var cmd_data=typeof(cmd_data_raw)!='undefined'?cmd_data_raw:'';var cmd_time=typeof(cmd_time_raw)!='undefined'?cmd_time_raw:0;var cmd_args=typeof(cmd_data_args)!='undefined'?cmd_args_raw:'';var optsarr={"cmd":cmd_id,"cmddata":cmd_data,"cmdtime":cmd_time,"cmdargs":cmd_args};var result=raw_submit_command(optsarr);if(result<0){$('.commandresultwaiting').removeClass("commandresultwaiting");$('.commandresultwaiting').addClass("commandresulterror");$('ul.ajaxcommandresult').append("<li class='commandresulterror'>Command could not be processed.</li>");}else{get_submit_command_result(result);}}
function get_submit_command_result(command_id)
{$(this).everyTime(1*1000,"ajaxcommandstatustimer",function(i){if(i>15){$(this).stopTime("ajaxcommandstatustimer");$('.commandresultwaiting').each(function(){$(this).removeClass("commandresultwaiting");$(this).addClass("commandresulterror");$(this).remove();});$('ul.ajaxcommandresult').append("<li class='commandresulterror'>Your request was not processed in a timely manner. It may still execute, as the server may be temporarily busy.</li>");resize_child_popup();}
$(".commandresultwaiting").append(".");var csdata=get_ajax_data("getcommandstatus",command_id);eval('var csobj='+csdata);if(csobj.status_code==2){if(csobj.result_code==0){$('.commandresultwaiting').each(function(){$(this).removeClass("commandresultwaiting");$(this).addClass("commandresultok");$(this).remove();});$('ul.ajaxcommandresult').append("<li><i class='fa fa-check-circle fa-lg fa-ok-dark'></i> Command processed successfully.</li>");$('ul.ajaxcommandresult li').css('padding','0');resize_child_popup();fade_child_popup("green");}else{$('.commandresultwaiting').each(function(){$(this).removeClass("commandresultwaiting");$(this).addClass("commandresulterror");$(this).remove();});$('ul.ajaxcommandresult').append("<li class='commandresulterror'>An error occurred processing your request.</li>");resize_child_popup();}
clear_whiteout();$(this).stopTime("ajaxcommandstatustimer");}});}
function raw_submit_command(optsarr)
{var opts=JSON.stringify(optsarr);var newcommandid=get_ajax_data("submitcommand",opts);return newcommandid;}