function redirectToUrl(url){ if(url === undefined){ document.location.href = "https://biflovac.cz"; }else{ document.location.href = url; } } function reloadPage(){ document.location.reload(); } function redirectByParam(s){ if(s=="reload"){ reloadPage(); }else if(s=="login-back"){ var a = document.location.href; a = urlencode(a); redirectToUrl("https://biflovac.cz/login/?to="+a+""); }else{ redirectToUrl(s); } } function urlencode(url){ return decodeURIComponent(url.replace(/\+/g, " ")); } function generalAjaxFormProcess(btnSelector,formSelector,ajaxUrl){ $(document).ready(function(){ $(formSelector).submit(function(){ return false; }); $(btnSelector).click(function(){ var strSelector = formSelector; var postData = null; if(strSelector!=""){ var postData = $(strSelector).serialize(); } $.post(ajaxUrl,postData,function(data){ console.log("b"); if(strSelector!=""){ $(strSelector+" div").removeClass("has-error"); } console.log("c"); if(data.success==false){ $(strSelector+" .form-error-div").removeClass("invisible"); if(data.type>=0){ $jq = $(strSelector+" .form-error-div"); $input = $(strSelector).find(".form-item-"+data.type); $input.parent().addClass("has-error"); $input.focus(); if($jq.attr("show-error")=="true"){ $jq.addClass("alert").addClass("alert-danger"); } $jq.text(data.message); } switch(data.type){ case -5: redirectByParam(data.url); break; case -6: redirectByParam(data.url); break; } }else{ redirectByParam(data.url); } },"json"); return false; }); }); } function getRealTime(times){ var time = times/1000; var nowTime = new Date(); var jsTime = Math.floor(Date.now()/1000); //var serTime = 1745080452; var serTime = 1745080452; var difference = serTime-jsTime; var correctTime = time-difference; return correctTime*1000; setInterval("oneCycle(d2);",1000); } $(document).ready(function(){ var numberOfInputs = $(".activation-input").length; $(".automatic-item").each(function(index,d){ $(this).keyup(function(e){ if(e.keyCode == 13){ if(index!=numberOfInputs-1){ if($(this).attr("automatic-href")){ $item = $($(this).attr("automatic-href")); }else{ $item = $(".automatic-item").eq(index+1); } if($item.attr("item-type")=="submit"){ $item.click(); return false; }else{ $item.focus(); } } } }); }); $('.modal').on('shown.bs.modal', function () { if(!$(this).hasClass("modal-not-automatic")){ $item = $(this).find(".automatic-item,.focus-item "); if($item.length){ $item.eq(0).focus(); } } }); }); //shortcuts var shortcutsArr = []; function createShortcut(keyNum,name,func){ shortcutsArr.push({ key:keyNum, name:name, func:func }); } function deleteShortcut(name){ for(var i = 0;i