Ajuste para as referências dos modelos antigos funcionarem na busca
This commit is contained in:
parent
57d9b7f0cd
commit
5bdc8dd4a9
@ -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);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
2
leitor-web.min.js
vendored
2
leitor-web.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user