From b208fef15af111add432fa34f699c25a918e9578 Mon Sep 17 00:00:00 2001 From: Rafael Tavares Juliani Date: Fri, 2 Feb 2024 21:17:09 -0300 Subject: [PATCH] =?UTF-8?q?console.log's=20de=20depura=C3=A7=C3=A3o=20reti?= =?UTF-8?q?rados?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- leitor-web.js | 5 ----- leitor-web.min.js | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/leitor-web.js b/leitor-web.js index d7b68cf..59de4cd 100644 --- a/leitor-web.js +++ b/leitor-web.js @@ -904,8 +904,6 @@ function buscar_referencia(modelo_referencia_antigo){ urlCap = ref_cap_busca[marcador_capitulo]; - console.log("urlCap: "+urlCap+" --- marcador_capitulo: "+marcador_capitulo+" --- ref_buscada: "+ref_buscada); - } else { ref_buscada = sanitized_ref.toUpperCase(); // Transforma em maiúsculas @@ -916,8 +914,6 @@ function buscar_referencia(modelo_referencia_antigo){ urlCap = ref_cap_busca[marcador_capitulo]; - console.log("Modelo Novo - urlCap: "+urlCap+" --- marcador_capitulo: "+marcador_capitulo+" --- ref_buscada: "+ref_buscada); - } if (!urlCap) { @@ -940,7 +936,6 @@ buscaRefInput.addEventListener('keydown', (event) => { if (typeof modelo_antigo !== 'undefined' && modelo_antigo === true) { modelo_referencia_antigo = true; - console.log("modelo_referencia_antigo: "+modelo_referencia_antigo); } buscar_referencia(modelo_referencia_antigo); diff --git a/leitor-web.min.js b/leitor-web.min.js index b41f0f6..ea46d79 100644 --- a/leitor-web.min.js +++ b/leitor-web.min.js @@ -1 +1 @@ -var observer,elementosNaPagina=[];let ref_cap_busca={},modelo_referencia_antigo=!1;window.onload=e=>{const t=new Audio("https://js.livro.online/moan-quarto/Interruptor.mp3"),o=metadados.livroUrl,n=["#fff","antiquewhite","url('https://js.livro.online/moan-quarto/olga-thelavart-HZm2XR0whdw-unsplash_P.jpg')","url('https://js.livro.online/moan-quarto/paper-g5d2cae661_1280_Pixabay_user_geralt.jpg')"];let a=0;const r=document.querySelector("body"),l=document.getElementById("quarto-content"),i=document.querySelector(".page-navigation"),s=document.getElementById("quarto-sidebar"),c=document.getElementById("quarto-margin-sidebar"),d=document.querySelectorAll(".sidebar-item-container"),p=document.querySelectorAll("span.chapter-number"),m=document.getElementById("toc-title"),u=document.querySelector(".quarto-navbar-tools");let g=!1;const f=document.querySelector("#papel"),h=document.querySelector("main");var v=document.createElement("div");function y(e,t){const o=document.createElement("button"),n=document.createElement("img");return n.src=e,o.appendChild(n),o.addEventListener("click",(function(){t()})),o}v.id="moan-menu-texto";let _=document.querySelector("header");const E=window.getComputedStyle(f,null).getPropertyValue("font-size").split("p")[0];function C(){let e=localStorage.getItem("livro.online@"+o+".config");let t=!1;t="default"!=localStorage.getItem("quarto-color-scheme");let r=JSON.parse(e);e&&(r[0]&&B(r[0]),r[1]&&(a=r[1],f.style.background=n[r[1]],g&&!t&&i&&(i.style.background=n[r[1]]),t&&f.style.removeProperty("background")),r[2]&&(g=r[2],g&&!t&&D()))}function b(e,t){let n=localStorage.getItem("livro.online@"+o+".config");if(n){let a,r=JSON.parse(n);switch(e){case"fonte":r[0]=t,a=JSON.stringify(r),localStorage.setItem("livro.online@"+o+".config",a);break;case"papel":r[1]=t,a=JSON.stringify(r),localStorage.setItem("livro.online@"+o+".config",a);break;case"luz_apagada":r[2]=t,a=JSON.stringify(r),localStorage.setItem("livro.online@"+o+".config",a)}}else{let n,a=[];switch(e){case"fonte":a[0]=t,n=JSON.stringify(a),localStorage.setItem("livro.online@"+o+".config",n);break;case"papel":a[1]=t,n=JSON.stringify(a),localStorage.setItem("livro.online@"+o+".config",n);break;case"fundo":a[2]=t,n=JSON.stringify(a),localStorage.setItem("livro.online@"+o+".config",n)}}}C();const S=document.createElement("script");S.src="https://js.livro.online/bibliotecas_de_terceiros/qrcode.min.js",document.body.appendChild(S);const w=document.createElement("div");w.id="modal",w.className="modal",w.style.display="none";const L=document.createElement("div");L.className="modal-content";const q=document.createElement("span");q.className="close",q.innerHTML="×",q.style.fontSize="20px";const I=document.createElement("div"),z=document.createElement("p");z.innerHTML="Referência";const k=document.createElement("span");k.id="ref",I.appendChild(z),I.appendChild(k);const N=document.createElement("div"),x=document.createElement("p");x.innerHTML="Link";const P=document.createElement("span");P.id="link",N.appendChild(x),N.appendChild(P);const j=document.createElement("p");j.innerHTML="QR Code";const R=document.createElement("div");R.id="qrcode_container";const M=document.createElement("div"),H=document.createElement("p");H.innerHTML="Como Citar";const A=document.createElement("span");A.innerHTML=`Veja aqui como citar este livro.`,M.appendChild(H),M.appendChild(A);const T=document.createElement("div"),V=document.createElement("p");V.innerHTML="Versão Impressa";const $=document.createElement("span");function B(e){let t=window.getComputedStyle(v,null).getPropertyValue("font-size"),o=window.getComputedStyle(_,null).getPropertyValue("font-size");if(void 0!==e)f.style.fontSize=`${e}px`,v.style.fontSize=t,_.style.fontSize=o;else{let e=window.getComputedStyle(f,null).getPropertyValue("font-size").split("p"),n=parseInt(e[0])+2;f.style.fontSize=`${n}px`,v.style.fontSize=t,_.style.fontSize=o,b("fonte",n)}}function O(){l.classList.remove("luz_apagada"),i&&i.style.removeProperty("background"),s.style.removeProperty("color"),s.classList.remove("luz_apagada"),d.forEach((e=>{e.style.removeProperty("color")})),p.forEach((e=>{"H1"===e.parentNode.nodeName.toUpperCase()||e.parentNode.classList.contains("nav-page-text")||e.style.removeProperty("color")})),c.style.removeProperty("color"),m&&m.style.removeProperty("color"),g=!1}function D(){l.classList.add("luz_apagada"),i&&(i.style.backgroundColor=n[a]),f.style.background=n[a],s.style.color="#fff",s.classList.add("luz_apagada"),d.forEach((e=>{e.style.color="#fff"})),p.forEach((e=>{"H1"===e.parentNode.nodeName.toUpperCase()||e.parentNode.classList.contains("nav-page-text")||(e.style.color="#fff")})),c.style.color="#fff",m&&(m.style.color="#fff"),g=!0}$.innerHTML=`Veja aqui onde comprar.`,T.appendChild(V),T.appendChild($),L.appendChild(q),L.appendChild(I),L.appendChild(N),L.appendChild(j),L.appendChild(R),L.appendChild(M),L.appendChild(T),w.appendChild(L),document.body.appendChild(w),v.appendChild(y("https://js.livro.online/moan-quarto/text_decrease_FILL0_wght400_GRAD0_opsz24.svg",(function(){let e=window.getComputedStyle(v,null).getPropertyValue("font-size"),t=window.getComputedStyle(_,null).getPropertyValue("font-size"),o=window.getComputedStyle(f,null).getPropertyValue("font-size").split("p"),n=parseInt(o[0])-2;f.style.fontSize=`${n}px`,v.style.fontSize=e,_.style.fontSize=t,b("fonte",n)}))),v.appendChild(y("https://js.livro.online/moan-quarto/text_increase_FILL0_wght400_GRAD0_opsz24.svg",B)),v.appendChild(y("https://js.livro.online/moan-quarto/format_clear_FILL0_wght400_GRAD0_opsz24.svg",(function(){f.style.fontSize=E+"px",b("fonte",E)}))),v.appendChild(y("https://js.livro.online/moan-quarto/note_FILL0_wght400_GRAD0_opsz24.svg",(function(){r.classList.contains("quarto-dark")?alert("Você precisa desabilitar o modo escuro para poder alterar o papel."):(a+=1,a>n.length-1&&(a=0),f.style.background=n[a],b("papel",a),g&&i&&(i.style.background=n[a]))}))),v.appendChild(y("https://js.livro.online/moan-quarto/emoji_objects_FILL0_wght400_GRAD0_opsz24.svg",(function(){r.classList.contains("quarto-dark")?alert("Você precisa desabilitar o modo escuro para o estado da luz de fundo."):g?(f.style.background=n[a],t.play(),O(),b("luz_apagada",!1)):(f.style.background=n[a],t.play(),D(),b("luz_apagada",!0))}))),h.insertBefore(v,h.firstChild);new MutationObserver((function(e,t){for(const t of e)"attributes"===t.type&&"class"===t.attributeName&&(r.classList.contains("quarto-dark")?(O(),f.style.removeProperty("background")):C())})).observe(r,{attributes:!0,attributeFilter:["class"]});var F=document.createElement("div");F.className="referencias_capitulo";var J=document.createElement("div");J.className="cont_ref";var G=document.createElement("span");G.id="Paginacao",J.appendChild(G),F.appendChild(J);var U=document.createElement("input");U.id="busca_ref",U.className="buscar_ref",U.setAttribute("placeholder","Referência..."),U.style.backgroundImage='url("https://js.livro.online/moan-quarto/search_FILL0_wght400_GRAD0_opsz24.svg")',U.style.backgroundRepeat="no-repeat",U.style.backgroundPosition="5px center",U.style.paddingLeft="25px",F.appendChild(U);const Q=document.createElement("button");Q.className="pegarLink";const X=document.createElement("span");X.style.display="flex",X.style.flexDirection="column",X.style.alignItems="center";const Z=document.createElement("img");Z.src="https://js.livro.online/moan-quarto/link_FILL0_wght400_GRAD0_opsz24.svg",X.appendChild(Z);const K=document.createTextNode("link");X.appendChild(K),Q.appendChild(X),F.appendChild(Q),Q.addEventListener("click",(function(){let e;window.getSelection?e=window.getSelection():document.selection&&(e=document.selection.createRange());if(""===e.toString())return void alert("Selecione um texto primeiro...");let t=window.getSelection().anchorNode.parentElement,o=window.getSelection().focusNode.parentElement;if(t&&o){let e=ie(t),n=ie(o),a=window.location.href;const r=new URL(a);r.search="",r.hash="";let l=r.href;if(e===n){let t=`${l}${e?"#"+e:""}`,o=e;o&&""!==o.trim()?k.style.fontSize="30px":(o="Elemento sem referência direta",k.style.fontSize="14px"),le(o,t)}else if(e{0===t&&n("lista vazia"),e.forEach((e=>{o++,e.isIntersecting&&elementosNaPagina.push(e),o===t&&0!=elementosNaPagina.length&&n("lista pronta")}))})),a=new Promise((e=>{e(elementosNaPagina.sort((function(e,t){let o=e.target.id.split("P"),n=t.target.id.split("P");return parseInt(o[1])parseInt(n[1])?1:void 0})))}));n.then((e=>{"lista pronta"===e?a.then((e=>{let t=e.length-1;e[0].target.id===e[t].target.id?G.innerHTML=`${e[0].target.id}`:G.innerHTML=`${e[0].target.id} a ${e[t].target.id}`})).catch((e=>console.log("Erro na lista: "+e))):"lista vazia"===e&&(console.log("Não tenho Unidade"),G.innerHTML="...")})).catch((e=>console.log("Erro: "+e)))}window.addEventListener("scroll",(()=>{elementosNaPagina=[],re(),console.log("Observador ativado")}));let ae={root:null,rootMargin:"0px",threshold:.01,delay:1e3,trackVisibility:!0};function re(){observer&&observer.disconnect();var e=f.querySelectorAll(".unidade"),t=Array.from(e);0!==t.length&&(observer=new IntersectionObserver(ne,ae),t.map((e=>observer.observe(e))))}function le(e,t){document.getElementById("ref").textContent=e,document.getElementById("link").textContent=t;document.getElementById("modal").style.display="block";let o=document.getElementById("qrcode_container");o.innerHTML="";let n=t.match(/:\/\/([^/]+)\/(.+)/)[2];console.log("Verificando: "+n),n=n.replace(/\//g,"--"),n=n.replace(/#/g,"__"),n="https://livro.online/qr-code/?livro="+n;new QRCode(o,{text:n,colorDark:"#000000",colorLight:"#ffffff",correctLevel:QRCode.CorrectLevel.H})}function ie(e){let t=0;for(;t<10;t++){if(e&&(e.classList.contains("unidade")||e.classList.contains("unidade_silenciosa")))return e.id;e.parentElement&&(e=e.parentElement)}}re(),W.addEventListener("focus",(()=>{fetch("/"+o+"/ref_capitulos.json").then((e=>{if(!e.ok)throw new Error("Não foi possível carregar o arquivo JSON com as referências.");return e.json()})).then((e=>{console.log(e),ref_cap_busca=e})).catch((e=>{console.error(e)}))})),W.addEventListener("keydown",(e=>{"Enter"!==e.key&&13!==e.keyCode||(e.preventDefault(),"undefined"!=typeof modelo_antigo&&!0===modelo_antigo&&(modelo_referencia_antigo=!0,console.log("modelo_referencia_antigo: "+modelo_referencia_antigo)),function(e){let t,n,a,r=W.value.replace(/[&<>"']/g,"");e?(t=r,n=r[0],a=ref_cap_busca[n],console.log("urlCap: "+a+" --- marcador_capitulo: "+n+" --- ref_buscada: "+t)):(t=r.toUpperCase(),n=t.split("P")[0],a=ref_cap_busca[n],console.log("Modelo Novo - urlCap: "+a+" --- marcador_capitulo: "+n+" --- ref_buscada: "+t));if(!a)return console.log("Referência não encontrada"),void alert("Referência que começa com "+n+" é inválida neste livro.");const l="/"+o+"/"+a+".html#"+t;window.location.href=l}(modelo_referencia_antigo))})),document.querySelector(".close").addEventListener("click",(function(){document.getElementById("modal").style.display="none"}));const se=/Ainda não disponível/i;fetch("/"+o+"/postos-de-venda.json").then((e=>e.json())).then((e=>{if(!se.test(Object.keys(e)[0])){const t=document.createElement("div");t.className="versao-impressa-compre";const o=document.createElement("h2");o.textContent="Está gostando?",t.appendChild(o);const n=document.createElement("span");n.textContent="Considere ajudar, comprando uma cópia física deste livro.",t.appendChild(n);const a=document.createElement("ul"),r=/não disponível/i;for(const t in e)if(!r.test(t)){const o=document.createElement("li"),n=document.createElement("a");n.href=e[t],n.textContent=t,o.appendChild(n),a.appendChild(o)}t.appendChild(a),c.appendChild(t)}})).catch((e=>{console.error("Erro ao carregar o arquivo postos-de-venda.json:",e)}))}; \ No newline at end of file +var observer,elementosNaPagina=[];let ref_cap_busca={},modelo_referencia_antigo=!1;window.onload=e=>{const t=new Audio("https://js.livro.online/moan-quarto/Interruptor.mp3"),o=metadados.livroUrl,n=["#fff","antiquewhite","url('https://js.livro.online/moan-quarto/olga-thelavart-HZm2XR0whdw-unsplash_P.jpg')","url('https://js.livro.online/moan-quarto/paper-g5d2cae661_1280_Pixabay_user_geralt.jpg')"];let a=0;const r=document.querySelector("body"),l=document.getElementById("quarto-content"),i=document.querySelector(".page-navigation"),s=document.getElementById("quarto-sidebar"),c=document.getElementById("quarto-margin-sidebar"),d=document.querySelectorAll(".sidebar-item-container"),p=document.querySelectorAll("span.chapter-number"),m=document.getElementById("toc-title"),u=document.querySelector(".quarto-navbar-tools");let g=!1;const f=document.querySelector("#papel"),h=document.querySelector("main");var v=document.createElement("div");function y(e,t){const o=document.createElement("button"),n=document.createElement("img");return n.src=e,o.appendChild(n),o.addEventListener("click",(function(){t()})),o}v.id="moan-menu-texto";let _=document.querySelector("header");const E=window.getComputedStyle(f,null).getPropertyValue("font-size").split("p")[0];function C(){let e=localStorage.getItem("livro.online@"+o+".config");let t=!1;t="default"!=localStorage.getItem("quarto-color-scheme");let r=JSON.parse(e);e&&(r[0]&&B(r[0]),r[1]&&(a=r[1],f.style.background=n[r[1]],g&&!t&&i&&(i.style.background=n[r[1]]),t&&f.style.removeProperty("background")),r[2]&&(g=r[2],g&&!t&&D()))}function b(e,t){let n=localStorage.getItem("livro.online@"+o+".config");if(n){let a,r=JSON.parse(n);switch(e){case"fonte":r[0]=t,a=JSON.stringify(r),localStorage.setItem("livro.online@"+o+".config",a);break;case"papel":r[1]=t,a=JSON.stringify(r),localStorage.setItem("livro.online@"+o+".config",a);break;case"luz_apagada":r[2]=t,a=JSON.stringify(r),localStorage.setItem("livro.online@"+o+".config",a)}}else{let n,a=[];switch(e){case"fonte":a[0]=t,n=JSON.stringify(a),localStorage.setItem("livro.online@"+o+".config",n);break;case"papel":a[1]=t,n=JSON.stringify(a),localStorage.setItem("livro.online@"+o+".config",n);break;case"fundo":a[2]=t,n=JSON.stringify(a),localStorage.setItem("livro.online@"+o+".config",n)}}}C();const S=document.createElement("script");S.src="https://js.livro.online/bibliotecas_de_terceiros/qrcode.min.js",document.body.appendChild(S);const w=document.createElement("div");w.id="modal",w.className="modal",w.style.display="none";const L=document.createElement("div");L.className="modal-content";const q=document.createElement("span");q.className="close",q.innerHTML="×",q.style.fontSize="20px";const I=document.createElement("div"),z=document.createElement("p");z.innerHTML="Referência";const k=document.createElement("span");k.id="ref",I.appendChild(z),I.appendChild(k);const N=document.createElement("div"),x=document.createElement("p");x.innerHTML="Link";const P=document.createElement("span");P.id="link",N.appendChild(x),N.appendChild(P);const j=document.createElement("p");j.innerHTML="QR Code";const R=document.createElement("div");R.id="qrcode_container";const H=document.createElement("div"),M=document.createElement("p");M.innerHTML="Como Citar";const A=document.createElement("span");A.innerHTML=`Veja aqui como citar este livro.`,H.appendChild(M),H.appendChild(A);const T=document.createElement("div"),V=document.createElement("p");V.innerHTML="Versão Impressa";const $=document.createElement("span");function B(e){let t=window.getComputedStyle(v,null).getPropertyValue("font-size"),o=window.getComputedStyle(_,null).getPropertyValue("font-size");if(void 0!==e)f.style.fontSize=`${e}px`,v.style.fontSize=t,_.style.fontSize=o;else{let e=window.getComputedStyle(f,null).getPropertyValue("font-size").split("p"),n=parseInt(e[0])+2;f.style.fontSize=`${n}px`,v.style.fontSize=t,_.style.fontSize=o,b("fonte",n)}}function O(){l.classList.remove("luz_apagada"),i&&i.style.removeProperty("background"),s.style.removeProperty("color"),s.classList.remove("luz_apagada"),d.forEach((e=>{e.style.removeProperty("color")})),p.forEach((e=>{"H1"===e.parentNode.nodeName.toUpperCase()||e.parentNode.classList.contains("nav-page-text")||e.style.removeProperty("color")})),c.style.removeProperty("color"),m&&m.style.removeProperty("color"),g=!1}function D(){l.classList.add("luz_apagada"),i&&(i.style.backgroundColor=n[a]),f.style.background=n[a],s.style.color="#fff",s.classList.add("luz_apagada"),d.forEach((e=>{e.style.color="#fff"})),p.forEach((e=>{"H1"===e.parentNode.nodeName.toUpperCase()||e.parentNode.classList.contains("nav-page-text")||(e.style.color="#fff")})),c.style.color="#fff",m&&(m.style.color="#fff"),g=!0}$.innerHTML=`Veja aqui onde comprar.`,T.appendChild(V),T.appendChild($),L.appendChild(q),L.appendChild(I),L.appendChild(N),L.appendChild(j),L.appendChild(R),L.appendChild(H),L.appendChild(T),w.appendChild(L),document.body.appendChild(w),v.appendChild(y("https://js.livro.online/moan-quarto/text_decrease_FILL0_wght400_GRAD0_opsz24.svg",(function(){let e=window.getComputedStyle(v,null).getPropertyValue("font-size"),t=window.getComputedStyle(_,null).getPropertyValue("font-size"),o=window.getComputedStyle(f,null).getPropertyValue("font-size").split("p"),n=parseInt(o[0])-2;f.style.fontSize=`${n}px`,v.style.fontSize=e,_.style.fontSize=t,b("fonte",n)}))),v.appendChild(y("https://js.livro.online/moan-quarto/text_increase_FILL0_wght400_GRAD0_opsz24.svg",B)),v.appendChild(y("https://js.livro.online/moan-quarto/format_clear_FILL0_wght400_GRAD0_opsz24.svg",(function(){f.style.fontSize=E+"px",b("fonte",E)}))),v.appendChild(y("https://js.livro.online/moan-quarto/note_FILL0_wght400_GRAD0_opsz24.svg",(function(){r.classList.contains("quarto-dark")?alert("Você precisa desabilitar o modo escuro para poder alterar o papel."):(a+=1,a>n.length-1&&(a=0),f.style.background=n[a],b("papel",a),g&&i&&(i.style.background=n[a]))}))),v.appendChild(y("https://js.livro.online/moan-quarto/emoji_objects_FILL0_wght400_GRAD0_opsz24.svg",(function(){r.classList.contains("quarto-dark")?alert("Você precisa desabilitar o modo escuro para o estado da luz de fundo."):g?(f.style.background=n[a],t.play(),O(),b("luz_apagada",!1)):(f.style.background=n[a],t.play(),D(),b("luz_apagada",!0))}))),h.insertBefore(v,h.firstChild);new MutationObserver((function(e,t){for(const t of e)"attributes"===t.type&&"class"===t.attributeName&&(r.classList.contains("quarto-dark")?(O(),f.style.removeProperty("background")):C())})).observe(r,{attributes:!0,attributeFilter:["class"]});var F=document.createElement("div");F.className="referencias_capitulo";var J=document.createElement("div");J.className="cont_ref";var G=document.createElement("span");G.id="Paginacao",J.appendChild(G),F.appendChild(J);var U=document.createElement("input");U.id="busca_ref",U.className="buscar_ref",U.setAttribute("placeholder","Referência..."),U.style.backgroundImage='url("https://js.livro.online/moan-quarto/search_FILL0_wght400_GRAD0_opsz24.svg")',U.style.backgroundRepeat="no-repeat",U.style.backgroundPosition="5px center",U.style.paddingLeft="25px",F.appendChild(U);const Q=document.createElement("button");Q.className="pegarLink";const X=document.createElement("span");X.style.display="flex",X.style.flexDirection="column",X.style.alignItems="center";const Z=document.createElement("img");Z.src="https://js.livro.online/moan-quarto/link_FILL0_wght400_GRAD0_opsz24.svg",X.appendChild(Z);const K=document.createTextNode("link");X.appendChild(K),Q.appendChild(X),F.appendChild(Q),Q.addEventListener("click",(function(){let e;window.getSelection?e=window.getSelection():document.selection&&(e=document.selection.createRange());if(""===e.toString())return void alert("Selecione um texto primeiro...");let t=window.getSelection().anchorNode.parentElement,o=window.getSelection().focusNode.parentElement;if(t&&o){let e=ie(t),n=ie(o),a=window.location.href;const r=new URL(a);r.search="",r.hash="";let l=r.href;if(e===n){let t=`${l}${e?"#"+e:""}`,o=e;o&&""!==o.trim()?k.style.fontSize="30px":(o="Elemento sem referência direta",k.style.fontSize="14px"),le(o,t)}else if(e{0===t&&n("lista vazia"),e.forEach((e=>{o++,e.isIntersecting&&elementosNaPagina.push(e),o===t&&0!=elementosNaPagina.length&&n("lista pronta")}))})),a=new Promise((e=>{e(elementosNaPagina.sort((function(e,t){let o=e.target.id.split("P"),n=t.target.id.split("P");return parseInt(o[1])parseInt(n[1])?1:void 0})))}));n.then((e=>{"lista pronta"===e?a.then((e=>{let t=e.length-1;e[0].target.id===e[t].target.id?G.innerHTML=`${e[0].target.id}`:G.innerHTML=`${e[0].target.id} a ${e[t].target.id}`})).catch((e=>console.log("Erro na lista: "+e))):"lista vazia"===e&&(console.log("Não tenho Unidade"),G.innerHTML="...")})).catch((e=>console.log("Erro: "+e)))}window.addEventListener("scroll",(()=>{elementosNaPagina=[],re(),console.log("Observador ativado")}));let ae={root:null,rootMargin:"0px",threshold:.01,delay:1e3,trackVisibility:!0};function re(){observer&&observer.disconnect();var e=f.querySelectorAll(".unidade"),t=Array.from(e);0!==t.length&&(observer=new IntersectionObserver(ne,ae),t.map((e=>observer.observe(e))))}function le(e,t){document.getElementById("ref").textContent=e,document.getElementById("link").textContent=t;document.getElementById("modal").style.display="block";let o=document.getElementById("qrcode_container");o.innerHTML="";let n=t.match(/:\/\/([^/]+)\/(.+)/)[2];console.log("Verificando: "+n),n=n.replace(/\//g,"--"),n=n.replace(/#/g,"__"),n="https://livro.online/qr-code/?livro="+n;new QRCode(o,{text:n,colorDark:"#000000",colorLight:"#ffffff",correctLevel:QRCode.CorrectLevel.H})}function ie(e){let t=0;for(;t<10;t++){if(e&&(e.classList.contains("unidade")||e.classList.contains("unidade_silenciosa")))return e.id;e.parentElement&&(e=e.parentElement)}}re(),W.addEventListener("focus",(()=>{fetch("/"+o+"/ref_capitulos.json").then((e=>{if(!e.ok)throw new Error("Não foi possível carregar o arquivo JSON com as referências.");return e.json()})).then((e=>{console.log(e),ref_cap_busca=e})).catch((e=>{console.error(e)}))})),W.addEventListener("keydown",(e=>{"Enter"!==e.key&&13!==e.keyCode||(e.preventDefault(),"undefined"!=typeof modelo_antigo&&!0===modelo_antigo&&(modelo_referencia_antigo=!0),function(e){let t,n,a,r=W.value.replace(/[&<>"']/g,"");e?(t=r,n=r[0],a=ref_cap_busca[n]):(t=r.toUpperCase(),n=t.split("P")[0],a=ref_cap_busca[n]);if(!a)return console.log("Referência não encontrada"),void alert("Referência que começa com "+n+" é inválida neste livro.");const l="/"+o+"/"+a+".html#"+t;window.location.href=l}(modelo_referencia_antigo))})),document.querySelector(".close").addEventListener("click",(function(){document.getElementById("modal").style.display="none"}));const se=/Ainda não disponível/i;fetch("/"+o+"/postos-de-venda.json").then((e=>e.json())).then((e=>{if(!se.test(Object.keys(e)[0])){const t=document.createElement("div");t.className="versao-impressa-compre";const o=document.createElement("h2");o.textContent="Está gostando?",t.appendChild(o);const n=document.createElement("span");n.textContent="Considere ajudar, comprando uma cópia física deste livro.",t.appendChild(n);const a=document.createElement("ul"),r=/não disponível/i;for(const t in e)if(!r.test(t)){const o=document.createElement("li"),n=document.createElement("a");n.href=e[t],n.textContent=t,o.appendChild(n),a.appendChild(o)}t.appendChild(a),c.appendChild(t)}})).catch((e=>{console.error("Erro ao carregar o arquivo postos-de-venda.json:",e)}))}; \ No newline at end of file