function uploadMapImg(button) { var home_id = $(button).attr('id'); var mod_id = $(button).attr('data-mod_id'); var map = $(button).attr('data-map'); var title = $('#translation').attr('data-title'); var upload_button = $('#translation').attr('data-upload_button'); var bad_file = $('#translation').attr('data-bad_file'); var upload_failure = $('#translation').attr('data-upload_failure'); $('div.main-content').append('

');
$.ajax({
type: "POST",
url: "home.php?m=gamemanager&p=game_monitor",
data: addpost,
complete: function(){
document.location.reload();
}
});
});
$('img#action-stop').click(function(){
$('input[type=radio]#action-stop').each(function( ){
if( this.checked )
{
$(this).attr('checked', false).prop('checked', false);
}
else
{
$(this).attr('checked', true).prop('checked', true);
}
});
});
$('img#action-restart').click(function(){
$('input[type=radio]#action-restart').each(function( ){
if( this.checked )
{
$(this).attr('checked', false).prop('checked', false);
}
else
{
$(this).attr('checked', true).prop('checked', true);
}
});
});
$('img#action-start').click(function(){
$('input[type=radio]#action-start').each(function( ){
if( this.checked )
{
$(this).attr('checked', false).prop('checked', false);
}
else
{
$(this).attr('checked', true).prop('checked', true);
}
});
});
// Allow admin users to set game server order
handleOrderingGameServers();
});
function handleOrderingGameServers(){
var elemBeingDragged = null;
var childExpanderRow = null;
var helperItemBeingDragged = null;
if($('h2.isAdminUser').length){
$('table#servermonitor tbody').sortable({
handle: '.sortHandle', // https://stackoverflow.com/questions/15554951/sortable-rows-only-when-a-specific-column-is-dragged#answer-16753297
delay: 250, // https://stackoverflow.com/questions/22913592/jquery-ui-sortable-any-event-to-trigger-once-delay-completed
start: function( event, ui ) {
$('.expand-child td').css('display', 'none');
$('td', ui.item).removeClass('expanded');
ui.helper.css('cursor', 'move');
elemBeingDragged = ui.item;
childExpanderRow = elemBeingDragged.nextAll('tr.expand-child').first();
helperItemBeingDragged = ui.helper;
},
stop: function( event, ui ) {
if(childExpanderRow && childExpanderRow.length && elemBeingDragged && elemBeingDragged.length){
elemBeingDragged.after(childExpanderRow.detach());
if(childExpanderRow.next('tr.expand-child').length){
elemBeingDragged.before(childExpanderRow.next('tr.expand-child').detach());
}
}
if(helperItemBeingDragged.length){
helperItemBeingDragged.css('cursor', '');
}
},
update: function(event, ui){
saveGameServerOrder();
}
});
}
}
function saveGameServerOrder(){
var i = 0;
var postData = {order: new Array()};
var homeId = null;
if(userAPIKey){
// Build the data
$('table#servermonitor tbody .maintr:visible').each(function(e){
homeId = $('td.serverId', $(this)).text();
if(homeId){
postData.order.push({home_id: homeId, order: i});
i++;
}
});
// Make the call
$.ajax({
type: "POST",
url: "ogp_api.php?gamemanager_admin/reorder&token=" + userAPIKey,
data: JSON.stringify(postData),
success: function(e){
logToConsole("Game server order successfully saved!");
}
});
}
}