if (window.name === undefined || window.name == 'blank' || window.name == '') { window.name = setProcessId(Math.round(Math.random() * 10000000)); } jQuery.support.cors = true; if ((txc = getCookie('txc')) !== null) setCookie('txc', txc, 30); else { if (window.ftc !== undefined && window.ftc.length > 5) setCookie('txc', window.ftc, 30); else setCookie('txc', uuidv4(), 30); } // === Implementace "pingAlive" === // @description Pozadavkem je provedeni ping "pingAlive" kazdych X minut => duvodem je udrzeni pri zivote FORM. Taktez po urcitem poctu jiz nadale nebude provaden ping. var keepAliveObj = null; // samotny "Objekt" // Fallback hodnoty statickych hodnot var KEEPALIVE_PING_TIME_LIMIT = 3; // Casovac, jak casto se ma ping provadet [min] var KEEPALIVE_TIMER_KEEP_ALIVE = KEEPALIVE_PING_TIME_LIMIT * 60 * 1000; // nutno prevest do [ms] var KEEPALIVE_COUNTER_MAX_ALIVE_PINGS = 20; // MAX povoleny pocet pingu "keepAlive" var KEEPALIVE_COUNTER_PING = parseInt(localStorage.getItem('keepalive_pingCount')) || 0; // Pocitadlo, kolikrat byl proveden ping na server s informaci "alive" // Load konfigurace dynamicky na zaklade hotdnoty window.product -> zde se udrzuje {int} hodnota produktu (pozn. Z duvodu dalsiho pouziti napric komponentami), pokud je k dispozici switch (window.product) {} const startKeepAlivePing = { timerId: null, intervalMs: KEEPALIVE_PING_TIME_LIMIT, // --- PERIODICKA ~ jadrova funkce, ktera se periodicky deje v ramci INTERVALU pingAction: function() { console.log('STATUS [ACTION] : Ping "keepAlive" odeslan na server. Celkem: ' + KEEPALIVE_COUNTER_PING); // Hezky zvednu pocet, kolikrat jsem jiz "keepAlive" ping poslal; nutno propsat do localStorage tez KEEPALIVE_COUNTER_PING++; localStorage.setItem('keepalive_pingCount', KEEPALIVE_COUNTER_PING); }, // --- SPUSTENI samoteho casovace start: function() { this.stop(); // Jenom projistotu zastavim pripadny casovac, ktery je v behu console.log('STATUS [START] : Konfigem: ' + (KEEPALIVE_TIMER_KEEP_ALIVE / 1000) + 's a max limitem: ' + KEEPALIVE_COUNTER_MAX_ALIVE_PINGS); this.tabId = checkTabId(); this.timerId = setInterval(() => { actionValue = 'ping'; if (parseInt(KEEPALIVE_COUNTER_PING) == 0) KEEPALIVE_COUNTER_PING++; // V pripade, ze zacinam od znovu nezacinam na 0, ale na 1 pozadavku => pouze korekce if ((parseInt(KEEPALIVE_COUNTER_PING) || 0) >= KEEPALIVE_COUNTER_MAX_ALIVE_PINGS) actionValue = 'ping-last'; else actionValue = 'ping-' + parseInt(KEEPALIVE_COUNTER_PING); // Prevzata implementace z puvodniho "ClientAction" $.ajax({ timeout: 50000, url: "/Controllers/ClientActions.php?_a=" + Math.random(), type: 'POST', dataType: "html", data: { 'actionKey': 'alive', 'actionValue': actionValue, 'actionEvent': 'keepAlivePing', 'sessionId': getCookie('PHPSESSID'), 'processId': window.name, 'captchaToken' : this.captchaToken, 'mousePos' : this.mousePos, 'txc': this.txc, 'fid': typeof(InitFP) !== 'undefined' ? InitFP.fid : 'noFid', 'tabId': this.tabId }, success: (data) => { this.pingAction(); } }); // Zkontroluji, zdali mam jeste posilat ping, nebo jiz zahodim if ((parseInt(KEEPALIVE_COUNTER_PING) || 0) >= KEEPALIVE_COUNTER_MAX_ALIVE_PINGS) { console.log('STATUS [END] : Zaslan maximlani pocet "keepAlive" pingu (' + KEEPALIVE_COUNTER_MAX_ALIVE_PINGS + '). "Zed je mrtvej."'); this.stop(); // Vypnu casovac v pripade dovrseni maxima return; } }, KEEPALIVE_TIMER_KEEP_ALIVE); }, // --- ZASTAVENI samotneho casovace stop: function() { // Jenom zkontroluji zdali nejaky casovac je v behu if (this.timerId !== null) { console.log('STATUS [STOP]: "keepAlivePing" zastaven'); clearInterval(this.timerId); this.timerId = null; } }, // --- RESET casovace reset: function() { console.log('STATUS [RESET] : ClientAction prijato => "keepAlivePing" STORNO'); KEEPALIVE_COUNTER_PING = 0; localStorage.setItem('keepalive_pingCount', 0); console.log('INFO [RESET] : Odpověď ze serveru přijata. Počítadlo pingů resetováno na 0.'); this.start(); } }; // ===================================== $('.start-polling').live('click', function () { Polling.activate(); }); var IFrameSizer = (function (undefined) { var IS_IN_IFRAME = window != window.parent; window.sendMessageToParent = function (message) { if (IS_IN_IFRAME) { window.parent.postMessage(message, "*"); } }; var IFrameSizer = { getOuterHeight: function () { this.heightDeferred = $.Deferred(); sendMessageToParent({action: 'getHeight'}); return this.heightDeferred; }, getOuterWidth: function () { this.widthDeferred = $.Deferred(); sendMessageToParent({action: 'getWidth'}); return this.widthDeferred; }, setOuterHeight: function (newHeight) { sendMessageToParent({action: 'setHeight', height: newHeight}); }, setOuterWidth: function (newWidth) { sendMessageToParent({action: 'setWidth', width: newWidth}); }, setProperHeight: function () { this.setOuterHeight($(document).height()); }, setProperWidth: function () { this.setOuterWidth($(document).width()); } }; $(window).on('message', function (e) { var data = e.originalEvent.data; switch (data.action) { case 'getHeight': IFrameSizer.heightDeferred.resolve(data.height); break; case 'getWidth': IFrameSizer.widthDeferred.resolve(data.width); break; default : console.log('Unknown action "%s"', data.action); } }); return IFrameSizer; })(); /*setTimeout(function(){ IFrameSizer.setOuterWidth(200); IFrameSizer.setOuterHeight(200); }, 2000);*/ var Polling = { requestIndicator: 0, // 0 - žádný request neprobíhá, 1 - nějaký request je poslaný, ale ještě se nevrátil shouldSendNext: true, activate: function () { this.shouldSendNext = true; this.sendRequest(); }, deactivate: function () { this.shouldSendNext = false; }, sendRequest: function (countRequest) { var self = this; if (this.requestIndicator === 0) { this.requestIndicator = 1; $.ajax({ timeout: 50000, url: "/Controllers/ClientRequest.php?_p=" + Math.random(), type: 'POST', crossDomain: true, cache: false, dataType: 'html', data: {'request': countRequest, 'sessionId': getCookie('PHPSESSID'), 'processId': window.name, 'caller': document.URL}, success: function (data) { countRequest++; var arrCommands = jQuery.parseJSON(data); processCommands(arrCommands); }, complete: function (ajaxObject) { var arrCommands = jQuery.parseJSON(ajaxObject.responseText); self.requestIndicator = 0; // Pokud mi přijde jediný příkaz a to je Nop a nemám zájem dělat poslat další request(shouldSendNext) if (!($.isArray(arrCommands) && arrCommands.length == 1 && arrCommands[0].commandName == "Nop" && Polling.shouldSendNext === false) ) { Polling.sendRequest(++countRequest); } } }); } } }; function ClientAction() { this.key = ''; this.value = ''; this.event = ''; this.captchaToken = ''; this.mousePos = ''; this.txc = ''; this.tabId = checkTabId(); this.reqSend = function () { $.ajax({ timeout: 50000, url: "/Controllers/ClientActions.php?_a=" + Math.random() // + "?DBGSESSID=411739033586100001@84.242.78.180;d=1,p=0,c=1" , type: 'POST', dataType: "html", data: {'actionKey': this.key, 'actionValue': this.value, 'actionEvent': this.event, 'sessionId': getCookie('PHPSESSID'), 'processId': window.name, 'captchaToken' : this.captchaToken, 'mousePos' : this.mousePos, 'txc': this.txc, 'fid': typeof(InitFP) !== 'undefined' ? InitFP.fid : 'noFid', 'tabId': this.tabId }, success: function (data) { try { var arrCommands = jQuery.parseJSON(data); } catch (e) { //log(data); //log(e); } processCommands(arrCommands); /* BLOK s "keepAlive pingem" */ startKeepAlivePing.reset(); console.log('INFO : Puvodni hodnota pocitadla: '+ KEEPALIVE_COUNTER_PING); /* END */ }, complete: function (ajaxObject) { try { var arrCommands = jQuery.parseJSON(data); } catch (e) { //log(data); //log(e); } } }); } } // @request RL > PJ tel 14.10.2026 15:50 : Odesilat unikatni nazev TABu => tabId (pozn. Co tab to novy unikatni nazev) function checkTabId() { // Hledam "window", ale to neprezije REFRESH => spoleham na "session", ta preziva refresh stranky let tabId = window.tabId || sessionStorage.getItem('tabId'); // Neexistuje => makam if (!tabId) { // Vygenerovani UID (budu chtit nativni crypto.randomUUID, fallback pro starsi browsery) if (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function') { tabId = crypto.randomUUID(); } else { tabId = uuidv4(); } // Uloží do sessionStorage pro preziti F5 sessionStorage.setItem('tabId', tabId); } // Jeste preulozim do "window" window.tabId = tabId; return window.tabId; } function getCookie(name) { var start = document.cookie.indexOf(name + "="); var len = start + name.length + 1; if ((!start) && (name != document.cookie.substring(0, name.length))) return null; if (start == -1) return null; var end = document.cookie.indexOf(";", len); if (end == -1) end = document.cookie.length; return unescape(document.cookie.substring(len, end)); } function setCookie(name, value, days) { var expires = ""; if (days) { var date = new Date(); date.setTime(date.getTime() + (days*24*60*60*1000)); expires = "; expires=" + date.toUTCString(); } document.cookie = name + "=" + (value || "") + expires + "; path=/"; } function eraseCookie(name) { document.cookie = name +'=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;'; } function uuidv4() { return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8); return v.toString(16); }); } function processCommands(commands) { var shouldFireDOMChangeEvent = false; $.each(commands, function (commandId, commandArray) { var command = new CommandFactory(); var commandName = commands[commandId]['commandName']; switch (commandName.toLowerCase()) { case "insert": shouldFireDOMChangeEvent = true; command.finsert(commandArray['params']['parentElementId'], commandArray['params']['elementId'], commandArray['params']['htmlContent']); break; case "delete": shouldFireDOMChangeEvent = true; command.fdelete(commandArray['params']['elementId']); break; case "fill": shouldFireDOMChangeEvent = true; command.ffill(commandArray['params']['elementId'], commandArray['params']['htmlContent']); break; case "setfocus": command.fsetFocus(commandArray['params']['elementId']); break; case "setattributes": shouldFireDOMChangeEvent = true; command.fsetAttributes(commandArray['params']['elementId'], commandArray['params']['attributes']); break; case "removeattributes": shouldFireDOMChangeEvent = true; command.fremoveAttributes(commandArray['params']['elementId'], commandArray['params']['attributes']); break; case "setcss": command.fsetCss(commandArray['params']['elementId'], commandArray['params']['css']); break; case "closeconnection": Polling.deactivate(); break; case "forcecall": command.fforceCall(commandArray['params']['forceUrl']); break; case "forceurl": command.fforceUrl(commandArray['params']['forceUrl']); break; case "nop": command.fnop(); break; case "addclass": shouldFireDOMChangeEvent = true; command.addClass(commandArray['params']['elementId'], commandArray['params']['className']); break; case "removeclass": shouldFireDOMChangeEvent = true; command.removeClass(commandArray['params']['elementId'], commandArray['params']['className']); break; case 'jsexec': eval(commandArray.params.code); break; default : console.log(commandArray); } }); if (shouldFireDOMChangeEvent === true) { /** Vytvoření vlastního eventu, na který se naváže inicializace komponent */ $(document).trigger('DOMChange'); } } function CommandFactory() { this.finsert = function (parentElementId, elementId, htmlContent) { if (elementId != "") { if (htmlContent.length > 0) { $('#' + elementId).before(function () { return htmlContent; }); } } else { $('#' + parentElementId).append(htmlContent); } }; this.ffill = function (elementId, htmlContent) { $('#' + elementId).html(htmlContent); }; this.fdelete = function (elementId) { $('#' + elementId).remove(); }; this.fsetFocus = function (elementId) { var $el = $('#' + elementId); var isInIFrame = window != window.parent; var offset = (($el.length > 0) ? $el.offset().top : 0 ); if (isInIFrame) { window.sendMessageToParent({action: 'scrollByOffset', offset: offset}); } else { $('html,body').animate({scrollTop: offset - 150}, 500); $el.focus(); } }; this.fsetAttributes = function (elementId, attributes) { var $el = $('#' + elementId); $.each(attributes, function (attributeName, attributeValue) { $el.attr(attributeName, attributeValue); }); $el.trigger('notify', attributes); }; this.fremoveAttributes = function (elementId, attributes) { var $el = $('#' + elementId); $.each(attributes, function (attributeName, attributeValue) { $el.removeAttr(attributeName); }); $el.trigger('notify', attributes); }; this.fsetCss = function (elementId, attributes) { for (var cssName in attributes) { $('#' + elementId).css(cssName, attributes[cssName]); } }; this.fforceCall = function (paramsurl) { if (paramsurl != undefined) { $.ajax({ url: paramsurl, success: function (data) { alert(data); }, error: function () { alert('Error forcecall request'); } }); } }; this.fforceUrl = function (paramsurl) { if (paramsurl != undefined) { $(location).attr('href', paramsurl); } }; this.fnop = function () { //alert('nopka'); } } CommandFactory.prototype.addClass = function (elementId, className) { $("#" + elementId).addClass(className); }; CommandFactory.prototype.removeClass = function (elementId, className) { $("#" + elementId).removeClass(className); }; function setProcessId(newProcessId) { window.name = newProcessId; } $(window).bind('beforeunload', function () { /* On exit dependencer */ var onUnLoadAction = new ClientAction(); onUnLoadAction.event = 'onExit'; onUnLoadAction.key = 'exit'; onUnLoadAction.value = 'exit'; onUnLoadAction.reqSend(); // return true; }); $(document).ready(function () { /* On load dependencer */ var onLoadAction = new ClientAction(); onLoadAction.event = 'onLoad'; onLoadAction.value = document.URL; onLoadAction.reqSend(); // --- Clickable Checkboxy $(".clickable[type='checkbox']").live("click", function () { var action = new ClientAction(); action.event = 'onClick'; action.key = $(this).attr("id"); if ($(this).is(':checked')) { action.value = $(this).attr("value"); } else { action.value = '__NOTCHECKED__'; } action.reqSend(); }); // --- Clickable neCheckBoxy $(".clickable[type!='checkbox']").live("click", function () { var action = new ClientAction(); action.event = 'onClick'; action.key = $(this).attr("id"); action.value = $(this).attr("value"); action.reqSend(); }); // --- Clickable Captcha $(".captchaProtectedClickable").live("click", function (event) { var action = new ClientAction(); action.event = 'onClick'; action.key = $(this).attr("id"); action.value = $(this).attr("value"); action.captchaToken = document.captchaToken; action.mousePos = event.clientX + '.' + event.clientY; action.txc = getCookie('txc'); action.reqSend(); }); // --- Delayed Clickable neCheckBoxy $(".clickableDelayed[type!='checkbox']").live("click", function () { var action = new ClientAction(); var that = this; setTimeout(function () { action.event = 'onClick'; action.key = $(that).attr("id"); action.value = $(that).attr("value"); action.reqSend(); alert ('Fertig'); }, 500); }); // --- Validable Checkboxy pouze onChange $(".validable[type='checkbox']").live("change", function () { var action = new ClientAction(); action.event = 'onChange'; action.key = $(this).attr("id"); if ($(this).is(':checked')) { action.value = $(this).attr("value"); } else { action.value = '__NOTCHECKED__'; } action.reqSend(); }); // --- Validable RadioButtony pouze onChange $(".validable[type='radio']").live('change', function () { var action = new ClientAction(); action.event = 'onChange'; action.key = $(this).attr("name"); action.value = $(this).attr("value"); action.reqSend(); }); //var $validable = $(".validable[type!='checkbox'][type!='radio']"); var $validable = $(".validable[type!='checkbox'][type!='radio']:not(.clickableDelayedNumber)"); // --- Validable mimo checkboxy a radioButtony onChange i onBlur --- $validable.live('change', function () { var action = new ClientAction(); action.event = 'onChange'; action.key = $(this).attr("id"); action.value = $(this).attr("value"); action.reqSend(); }); // --- @info RL <> PJ 13.01.2026 10:53 tel : Neposilat na datepickeru "onBlur" > nejspise nezpusobi vybuch zemekoule, ale nebude odesilat spatna data => pri onBlur odesilal "predeslou hodnotu" jelikoz zmena nebyla soucasti var $validable = $(".validable[type!='checkbox'][type!='radio']:not(.clickableDelayedNumber):not(.hasDatepicker)"); $validable.live('blur', function () { var action = new ClientAction(); action.event = 'onBlur'; action.key = $(this).attr("id"); action.value = $(this).val(); action.reqSend(); }); // --- Focusable na FocusIn (ne-radioButtony; mají jiný Key) $(".focusable[type!='radio']").live("focusin", function () { var action = new ClientAction(); action.event = 'onFocus'; action.key = $(this).attr("id"); action.value = $(this).attr("value"); action.reqSend(); }); // --- Focusable na FocusIn (RadioButtony) $(".focusable[type='radio']").live("focusin", function () { var action = new ClientAction(); action.event = 'onFocus'; action.key = $(this).attr("name"); action.value = $(this).attr("value"); action.reqSend(); }); // --- Jedna se o editacni
a
značek, ale je nutno vycistit