"use strict" let _ = ( function ( ) { let u = 'https://sys.jp.etc.br/_/pro/', g = u+"_.php", gi = u+"_i.php", c = "1005p", q, ld, csss = {}, scripts = {}, scline = {}, scexec = "", lastUrl = window.location.pathname, lastBody, deferredH, bf = false, // block form ts = new Date().getTime(), lu, loader_cls = function ( ) { }, loader_opn = function ( ) { }, url_change = function ( url ) { lastUrl = url; history.pushState(null, null, window.location); history.replaceState(null, null, url); }, url_clean = function ( url ) { let z, x, y, q = ( url.search ) ? url.search.replace("?", "&") : ""; // querystring url = url.pathname.replace(zen_urep, ""); if ( url.startsWith("/") ) url = url.substr(1); url = url.split("/"); // zen_urep vem do arquivo html z = url.shift(); // arquivo php para onde será redirecionado x = url.shift(); // variável extra 1 y = url.join("/"); // demais variáveis lu = [z, x, y, q]; return lu; }, dH_mount = function ( ) { let temp; if ( deferredH ) { temp = JSON.parse(JSON.stringify(deferredH)); deferredH = null; mount_html( temp, null ); } else { loader_cls(); } }, dlf = function ( fl, tp, nm ) { // download file - file, type, name let link = document.createElement('a'), blob = new Blob([fl], {type: tp}); link.download = nm; link.href = URL.createObjectURL(blob); link.click(); URL.revokeObjectURL(link.href); }, exec_js = function ( ) { let s, k = Object.keys(scline); if ( k.length === 0 ) { if ( scexec ) { s = document.createElement('script'); s.innerHTML = scexec; document.body.appendChild(s); scexec = ""; } dH_mount(); } else { fetch_js(k[0]).then( js => { scripts[k[0]] = true; delete scline[js]; exec_js(); }); } }, fetch_css = function ( css ) { let css2 = u+css+".css?v="+ts; return new Promise((resolve, reject) => { let link = document.createElement( "link" ); link.type = "text/css"; link.rel = "stylesheet"; link.media = "screen,print"; link.href = css2; link.id = "css_"+css; link.onload = function() { resolve(link); }; document.getElementsByTagName( "head" )[0].appendChild( link ); }); }, fetch_js = function ( js ) { let js2 = u+js+".js?v="+ts; return new Promise((resolve, reject) => { let nscript = document.createElement( "script" ); nscript.src = js2; nscript.onload = function() { resolve(js); }; document.body.appendChild(nscript); }); }, fetch_html = function ( p, l = null, m = null ) { if ( p[0] ) { q = p; if ( l ) { ld = document.getElementById(l); ld.classList.remove('hid'); } else loader_opn ( m ); p[1] = p[1] || ""; p[2] = p[2] || ""; p[3] = p[3] || ""; fetch(g+"?z="+p[0]+"&x="+p[1]+"&y="+p[2]+p[3], {credentials: "include", cache:"no-store"}).then(response => response.json()).then(res => { mount_html(res, p[0]); }).catch ( e => { loader_cls(); }); } }, mount_html = function ( h, p ) { let id = h[0] || "zen", i, j, s, l, x, y; if ( h[10] ) { h[10][1] = h[10][1] || ""; h[10][2] = h[10][2] || ""; url_change(window.location.protocol+"//"+window.location.host+zen_urep+h[10][0]+h[10][1]+h[10][2]); } if ( h[7] ) { // redirecionamento ou simples reposição de url h[7][1] = h[7][1] || ""; h[7][2] = h[7][2] || ""; x = ( h[7][1] ) ? `/${h[7][1]}` : ""; y = ( h[7][2] ) ? `/${h[7][2]}` : ""; if ( h[7][3] ) { // redirecionamento com reload window.location.replace(window.location.protocol+"//"+window.location.host+zen_urep+h[7][0]+x+y); return; } else { // redirecionamento ajax ( sem reload ) url_change(window.location.protocol+"//"+window.location.host+zen_urep+h[7][0]+x+y); fetch_html(h[7]); // redirecionamento return; } } if ( h[8] ) { if ( Array.isArray( h[8] ) ) { for ( i in csss ) { if ( !h[8].includes(i) ) { csss[i].disabled = true; csss[i].parentNode.removeChild(csss[i]); delete csss[i]; } } } else { for ( i in csss ) { if ( i != h[8] ) { csss[i].disabled = true; csss[i].parentNode.removeChild(csss[i]); delete csss[i]; } } } } if ( h[9] && lastBody !== h[9] ) { deferredH = JSON.parse(JSON.stringify(h)); deferredH[9] = null; fetch_html([h[9]]); return; } if ( h[6] ) { if ( Array.isArray( h[6] ) ) { i = 0; j = h[6].length; for ( ; i < j; i++ ) { if ( !csss[h[6][i]] ) fetch_css(h[6][i]).then(res=>{csss[h[6][i]] = res; }); } } else if ( !csss[h[6]] ) { fetch_css(h[6]).then(res=>{csss[h[6]] = res; }); } } if ( h[1] ) { h[1] = h[1].replace(/K_URL/g, u).replace(/K_UCLI/g, u+"cli/"+c+"/"); if ( id == "body" ) { l = zen_loader; document.body.innerHTML = h[1]; document.body.appendChild(l); lastBody = p; } else { document.getElementById(id).innerHTML = h[1]; } } if ( h[2] ) { // title document.title = h[2]; } if ( h[3] ) { document.body.id = h[3]; } if ( h[5] ) scexec+= h[5]; if ( h[4] ) { i = 0; j = h[4].length; for ( ; i < j; i++ ) { if ( !scripts[h[4][i]] ) { scline[h[4][i]] = true; } } } exec_js(); }, getq = function ( ) { return lu; }, init = ( function ( ) { let nd = document.createElement('div'); //window.location = window.location.toString().replace(/\/$/, ""); //console.log(window.location.toString().endsWith("/")); zen_js.parentNode.removeChild(zen_js); zen.innerHTML = ""; nd.id = "zen_loader"; nd.innerHTML = `
Por favor aguarde...