$(function(){ $("#tabs").tabs(); $("#loading").removeClass('hide').addClass('show'); var select_agent = $('#translation').attr('data-select_agent'), target_empty = $('#translation').attr('data-target_empty'), command_empty = $('#translation').attr('data-command_empty'), agent_invalid = $('#translation').attr('data-agent_invalid'), post_failed = $('#translation').attr('data-post_failed'), select_server = $('#translation').attr('data-select_server'), select_server_option = $('#translation').attr('data-select_server_option'); // Load the agents via an external script so the user isn't waiting an eternity if they have several agents and multiple are offline $.getJSON("home.php?m=util&p=agents&type=cleared", function(data){ var agents = ""; var agentsOnline = 0; $("#loading_agents").removeClass('show').addClass('hide'); $("#loading").removeClass('show').addClass('hide'); $("#options").removeClass('hide').addClass('show'); agents += "\r\n" agents += ""; if(agentsOnline == 0){ $("#options").removeClass('show').addClass('hide'); $("#agents_offline").removeClass('hide').addClass('show'); // Hide the sourcemod add admin form if all agents are offline. $("#addadmin_form").addClass('hide'); $("#all_servers_offline").removeClass('hide').addClass('show'); }else if($("#command option").length == 0){ $("#options").removeClass('show').addClass('hide'); $("#no_commands").removeClass('hide').addClass('show'); }else{ $("#select_agent").html(agents); } }).fail(function(){ $("#loading_agents").removeClass('show').addClass('hide'); $("#loading").removeClass('show').addClass('hide'); $("#loading_failed").removeClass('hide').addClass('show'); }); // Handle the network_tools form. $("#network_tools").on("submit", function(e){ var target = $("#remote_target").val(); var agent = $("#agent").val(); var command = $("#command").val(); // Some validation browser-side. Still need to do the same server-side. if(target.length === 0){ // target input is empty. $("#output").removeClass('hide').addClass('show').html("
" + target_empty + ""); }else if(agent.length === 0){ // We'll only get to this point if there's no agents, or all agents are offline but the form was still submitted. $("#output").removeClass('hide').addClass('show').html("
" + agent_invalid + ""); }else if(command.length === 0){ // We'll only get to this point if there's no command specified. $("#output").removeClass('hide').addClass('show').html("
" + command_empty + ""); }else{ $("#loading").removeClass('hide').addClass('show'); $("#output").removeClass('show').addClass('hide'); $("#network_tools button").prop({disabled:true}); // Disable the submit button if we're about to post - preventing stuff being ran several times via spamming the button and/or enter. $.post("home.php?m=util&p=network_tools&type=cleared", $("#network_tools").serialize(), function(postCommand){ $("#loading").removeClass('show').addClass('hide'); $("#output").removeClass('hide').addClass('show').html("
" + postCommand + ""); $("#network_tools button").prop({disabled:false}); }).fail(function(){ $("#loading").removeClass('show').addClass('hide'); $("#output").removeClass('hide').addClass('show').html("
" + post_failed + ""); $("#network_tools button").prop({disabled:false}); }); } e.preventDefault(); });// ./end network_tools form handling. // ----- Sourcemod Admins ----- $.getJSON("home.php?m=util&p=addadmin_helper&type=cleared", function(gs){ if(gs.length === 0){ $("#no_servers").removeClass('hide').addClass('show'); }else{ var games = ""; $("#add_admin").removeClass('hide').addClass('show'); games += "\r\n" games += ""; $("#games").html(games); $("#gameserver_id").change(function(){ var home = $("#gameserver_id").val(); var gameserver_id = $("#gameserver_id").val(); // although the disabled attribute is put on the option, set all the values to 0 if it's somehow chosen again via the form being edited if(gameserver_id == 0){ $("#remote_server_id").val(0); $("#gameserver_name").val(0); $("#gameserver_ip").val(0); $("#gameserver_port").val(0); }else{ for(var i = 0; i