function del(url, message) { if (message == undefined) { message = "Do you want to delete this server? Attention, this can't be undone !!"; } if (confirm(message)) { document.location.href=url; } } function showState2(field, state, notice){ if (state == "good"){ notice = ' Good'; }else if (state == "error"){ notice = ' '+notice+''; }else if (state == "warning"){ notice = ' '+notice+''; }else if (state == "good_empty"){ state = 'good'; } $('#'+field+'_state').val(state); $('#'+field+'_notice').html(notice); } function showState3(field, state, notice, noscroll = false){ if (state == "good"){ notice = ''; }else if (state == "error"){ notice = ''; }else if (state == "warning"){ notice = ''; } $('#'+field+'_state').val(state); $('#'+field+'_notice').html(notice); if (state == "good"){ $('#'+field+'_notice').hide(); }else{ $('#'+field+'_notice').show(); if (!noscroll){$('html,body').animate({scrollTop:$('#'+field+'_notice').offset().top}, 500);} } } function checkName(str){ $.ajax({ type: 'POST', url: '/ajax.php', data: { action: "checkServerName", name: str }, success: function(data){ showState3("name", data.state, data.notice); }, dataType: 'json', async: false }); } function checkAddress(str, str2, str3){ $.ajax({ type: 'POST', url: '/ajax.php', data: { action: "checkServerAddress", address: str, port: str2, port_query: str3 }, success: function(data){ if (data.existingserver > 0){ data.notice = data.notice + '. Click here to claim it.'; } showState3("address", data.state, data.notice); }, dataType: 'json', async: false }); } function check_server_add_form(){ checkName($('#name').val()); checkAddress($('#address').val(),$('#port').val(),$('#port_query').val()); if ($('#connection_state').val()=="error"){ if (!$('#connection_status').is(":visible")){ $('#connection_notice').html(''); $('#connection_status').show(); } } if (($('#name_state').val()=="good") && ($('#connection_state').val()=="good") && ($('#address_state').val()=="good")){ document.server_form.submit(); } } function check_server_form(){ checkName($('#name').val()); checkAddress($('#address').val(),$('#port').val(),$('#port_query').val()); if (($('#name_state').val()=="good") && ($('#address_state').val()=="good")){ document.server_form.submit(); } } function checkFlag(fieldID){ } function external_link(str){ $.ajax({ type: 'POST', url: '/ajax.php', data: { action: "externalLink", url: str }, success: function(data){ }, dataType: 'json', async: true }); } function check_group_form(){ if (document.getElementById("name").value.length < 5 ) { showState3('name', 'error', 'Name too short'); }else{ showState3('name', 'good', ''); } var $b = $('.ServerBoxes'); if ($b.filter(':checked').length >= 2){ showState3('servers', 'good', ''); if ($('#name_state').val()=="good"){ document.group_form.submit(); } }else{ showState3('servers', 'error', 'You need to select at least 2 servers!'); } } function checkConnection(){ $('#connection_notice').html(''); $('#connection_status').show(); $.ajax({ type: 'POST', url: '/ajax.php', data: { action: "checkServerConnection", address: $('#address').val(), port: $('#port').val(), port_query: $('#port_query').val(), version: $('#version').val() }, success: function(data){ if (data.state == "good"){ notice = ''; }else if (data.state == "error"){ notice = ''; }else if (data.state == "warning"){ notice = ''; }else if (data.state == "good_empty"){ data.state = 'good'; } $('#connection_state').val(data.state); $('#connection_notice').html(notice); }, complete: function(xhr, textStatus){ if (textStatus != "success"){ notice = ''; $('#connection_state').val('error'); $('#connection_notice').html(notice); } }, dataType: 'json', async: true }); } function getTeamspeakState(server_id, field){ $('#'+field).html(''); $.ajax({ type: 'POST', url: '/ajax.php', data: { action: "getTeamspeakState", server_id: server_id, }, success: function(data){ $('#'+field).html(data.results); }, dataType: 'json', async: true }); } function getDiscordState(discord_id, server_id, field){ $('#'+field).html(''); $.ajax({ type: 'POST', url: '/ajax.php', data: { action: "getDiscordState", discord_id: discord_id, server_id: server_id, }, success: function(data){ $('#'+field).html(data.results); }, dataType: 'json', async: true }); } $(document).ready(function(){ var clipboard = new ClipboardJS('.clipboard'); }); $(window).on('load', function (e) { setTimeout(() => { $('#vote-loading-block').hide(); $('#vote-form-block').show(); }, 500); });