$(function() { $.ajaxSetup({ beforeSend: function(xhr, settings) { if (!(/^http:.*/.test(settings.url) || /^https:.*/.test(settings.url))) { xhr.setRequestHeader("x-csrftoken", "7cacc0486431ce22a5f92d4875014.HL23P3hRcdgA4_Jt47hUbaGb7Jip-4ON8g8LW5MVt24.dMvPWU0bPbFsoKcf1P0TIejrm9bIr9TrhFxAN98m7itD5dBxSDw4t1mmxg"); } } }); $("#list-hosts").on("change", "input[type=checkbox]", function() { var numberHostsSelected = $("#list-hosts").find("input[type=checkbox]:checked").length; var numberMaxHosts = $("#list-hosts").find("input[defaultHost=true]").length; $(this).prop('value', $(this).prop('checked')); if( numberHostsSelected > numberMaxHosts && $(this).prop('checked') == true ) { alert("Please select max " + numberMaxHosts + " hosts"); $(this).prop('checked', false).change(); } }); $("#menu-selection-host").on("click", "#select-all", function () { $("#list-hosts").find("input[type=checkbox]").each(function () { if( !$(this).prop('checked') ) { $(this).prop('checked', true).change(); } }); }); $("#menu-selection-host").on("click", "#unselect-all", function () { $("#list-hosts").find("input[type=checkbox]").each(function () { if( $(this).prop('checked') ) { $(this).prop('checked', false).change(); } }); }); $("#menu-selection-host").on("click", "#select-default", function () { $("#list-hosts").find("input[type=checkbox]").each(function () { if( !$(this).prop('checked') && $(this).attr("defaultHost") ) { $(this).prop('checked', true).change(); } if( $(this).prop('checked') && !$(this).attr("defaultHost") ) { $(this).prop('checked', false).change(); } }); }); $("#menu-selection-host").on("click", "#select-parallel", function () { if( $(this).hasClass("btn-default") ) { $('#fileupload').fileupload( 'option', 'sequentialUploads', false ); $('#fileupload').fileupload( 'option', 'limitConcurrentUploads', 4 ); $(this).removeClass("btn-default"); $(this).addClass("btn-success"); } else { $('#fileupload').fileupload( 'option', 'sequentialUploads', true ); $('#fileupload').fileupload( 'option', 'limitConcurrentUploads', 0 ); $(this).removeClass("btn-success"); $(this).addClass("btn-default"); } }); var timezone = moment.tz.guess(); Cookies.set('timezone', timezone, { expires: 365, sameSite: 'lax' }); });