Ajuste para as referências dos modelos antigos funcionarem na busca

This commit is contained in:
Rafael Tavares Juliani committed 2024-02-01 23:20:06 -03:00
1 parent 57d9b7f0cd
commit 5bdc8dd4a9
2 files changed
+27 -7

No files matched your search

+26 -6
View File
@@ -866,7 +866,7 @@ buscaRefInput.addEventListener('focus', () => {
fetch('/'+livroUrl+'/ref_capitulos.json')
.then(response => {
if (!response.ok) {
throw new Error('Não foi possível carregar o arquivo JSON.');
throw new Error('Não foi possível carregar o arquivo JSON com as referências.');
}
return response.json(); // Converte a resposta em JSON
})
@@ -894,13 +894,27 @@ function buscar_referencia(modelo_referencia_antigo){
let sanitized_ref = removeSpecialCharacters(ref);
const ref_maiuscula = sanitized_ref.toUpperCase();
let ref_buscada, marcador_capitulo, urlCap;
const refArr = ref_maiuscula.split('P');
if (modelo_referencia_antigo){
const marcador_capitulo = refArr[0];
ref_buscada = sanitized_ref;
const urlCap = ref_cap_busca[marcador_capitulo];
marcador_capitulo = sanitized_ref[0];
urlCap = ref_cap_busca[marcador_capitulo];
} else {
ref_buscada = sanitized_ref.toUpperCase(); // Transforma em maiúsculas
const refArr = ref_buscada.split('P');
marcador_capitulo = refArr[0];
urlCap = ref_cap_busca[marcador_capitulo];
}
if (!urlCap) {
console.log('Referência não encontrada');
@@ -908,7 +922,7 @@ function buscar_referencia(modelo_referencia_antigo){
return;
}
const caminho_a_seguir = '/'+livroUrl+'/' + urlCap + '#' + ref_maiuscula;
const caminho_a_seguir = '/'+livroUrl+'/' + urlCap + '#' + ref_buscada;
window.location.href = caminho_a_seguir;
@@ -919,7 +933,13 @@ function buscar_referencia(modelo_referencia_antigo){
buscaRefInput.addEventListener('keydown', (event) => {
if (event.key === 'Enter' || event.keyCode === 13) {
event.preventDefault(); // Impede que o formulário seja enviado (se aplicável)
if (typeof modelo_antigo !== 'undefined' && modelo_antigo === true) {
// A variável modelo_antigo existe e é true
modelo_referencia_antigo = true;
}
buscar_referencia(modelo_referencia_antigo);
}
});
+1 -1
View File
@@ -1 +1 @@
var observer,elementosNaPagina=[];let ref_cap_busca={};window.onload=e=>{let t=new Audio("https://js.livro.online/moan-quarto/Interruptor.mp3"),n=metadados.livroUrl,a=["#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')"],o=0,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"),p=document.querySelectorAll(".sidebar-item-container"),d=document.querySelectorAll("span.chapter-number"),m=document.getElementById("toc-title"),f=document.querySelector(".quarto-navbar-tools"),g=!1,u=document.querySelector("#papel"),h=document.querySelector("main");var y=document.createElement("div");function v(e,t){let n=document.createElement("button"),a=document.createElement("img");return a.src=e,n.appendChild(a),n.addEventListener("click",function(){t()}),n}y.id="moan-menu-texto";let $=document.querySelector("header"),E=window.getComputedStyle(u,null).getPropertyValue("font-size"),C=E.split("p"),b=C[0];function L(){let e=localStorage.getItem("livro.online@"+n+".config"),t=localStorage.getItem("quarto-color-scheme"),r=!1;r="default"!=t;let l=JSON.parse(e);e&&(l[0]&&G(l[0]),l[1]&&(o=l[1],u.style.background=a[l[1]],g&&!r&&i&&(i.style.background=a[l[1]]),r&&u.style.removeProperty("background")),l[2]&&(g=l[2])&&!r&&Q())}function q(e,t){let a=localStorage.getItem("livro.online@"+n+".config");if(a){let o=JSON.parse(a),r;switch(e){case"fonte":o[0]=t,r=JSON.stringify(o),localStorage.setItem("livro.online@"+n+".config",r);break;case"papel":o[1]=t,r=JSON.stringify(o),localStorage.setItem("livro.online@"+n+".config",r);break;case"luz_apagada":o[2]=t,r=JSON.stringify(o),localStorage.setItem("livro.online@"+n+".config",r)}}else{let l=[],i;switch(e){case"fonte":l[0]=t,i=JSON.stringify(l),localStorage.setItem("livro.online@"+n+".config",i);break;case"papel":l[1]=t,i=JSON.stringify(l),localStorage.setItem("livro.online@"+n+".config",i);break;case"fundo":l[2]=t,i=JSON.stringify(l),localStorage.setItem("livro.online@"+n+".config",i)}}}L();let z=document.createElement("script");z.src="https://js.livro.online/bibliotecas_de_terceiros/qrcode.min.js",document.body.appendChild(z);let S=document.createElement("div");S.id="modal",S.className="modal",S.style.display="none";let k=document.createElement("div");k.className="modal-content";let I=document.createElement("span");I.className="close",I.innerHTML="&times",I.style.fontSize="20px";let x=document.createElement("div"),_=document.createElement("p");_.innerHTML="<strong>Refer\xeancia</strong>";let P=document.createElement("span");P.id="ref",x.appendChild(_),x.appendChild(P);let N=document.createElement("div"),j=document.createElement("p");j.innerHTML="<strong>Link</strong>";let w=document.createElement("span");w.id="link",N.appendChild(j),N.appendChild(w);let R=document.createElement("p");R.innerHTML="<strong>QR Code</strong>";let H=document.createElement("div");H.id="qrcode_container";let M=document.createElement("div"),A=document.createElement("p");A.innerHTML="<strong>Como Citar</strong>";let T=document.createElement("span");T.innerHTML=`Veja <a href='/${n}/#como-citar'>aqui</a> como citar este livro.`,M.appendChild(A),M.appendChild(T);let V=document.createElement("div"),B=document.createElement("p");B.innerHTML="<strong>Vers\xe3o Impressa</strong>";let D=document.createElement("span");function F(){let e=window.getComputedStyle(y,null).getPropertyValue("font-size"),t=window.getComputedStyle($,null).getPropertyValue("font-size"),n=parseInt(window.getComputedStyle(u,null).getPropertyValue("font-size").split("p")[0])-2;u.style.fontSize=`${n}px`,y.style.fontSize=e,$.style.fontSize=t,q("fonte",n)}function G(e){let t=window.getComputedStyle(y,null).getPropertyValue("font-size"),n=window.getComputedStyle($,null).getPropertyValue("font-size");if(void 0!==e)u.style.fontSize=`${e}px`,y.style.fontSize=t,$.style.fontSize=n;else{let a=parseInt(window.getComputedStyle(u,null).getPropertyValue("font-size").split("p")[0])+2;u.style.fontSize=`${a}px`,y.style.fontSize=t,$.style.fontSize=n,q("fonte",a)}}function U(){u.style.fontSize=b+"px",q("fonte",b)}function O(){if(r.classList.contains("quarto-dark")){alert("Voc\xea precisa desabilitar o modo escuro para poder alterar o papel.");return}(o+=1)>a.length-1&&(o=0),u.style.background=a[o],q("papel",o),g&&i&&(i.style.background=a[o])}function J(){l.classList.remove("luz_apagada"),i&&i.style.removeProperty("background"),s.style.removeProperty("color"),s.classList.remove("luz_apagada"),p.forEach(e=>{e.style.removeProperty("color")}),d.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 Q(){l.classList.Line truncated
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="&times",q.style.fontSize="20px";const I=document.createElement("div"),z=document.createElement("p");z.innerHTML="<strong>Referência</strong>";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="<strong>Link</strong>";const P=document.createElement("span");P.id="link",N.appendChild(x),N.appendChild(P);const j=document.createElement("p");j.innerHTML="<strong>QR Code</strong>";const R=document.createElement("div");R.id="qrcode_container";const H=document.createElement("div"),M=document.createElement("p");M.innerHTML="<strong>Como Citar</strong>";const A=document.createElement("span");A.innerHTML=`Veja <a href='/${o}/#como-citar'>aqui</a> como citar este livro.`,H.appendChild(M),H.appendChild(A);const T=document.createElement("div"),V=document.createElement("p");V.innerHTML="<strong>Versão Impressa</strong>";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 <a href='/${o}/#versão-impressa'>aqui</a> onde comprar.`,T.appendChild(V),T.appendChild($),L.appendChild(q),L.appendChild(I),L.appendChLine truncated