Commit fbef7dec by Billy Larru

[FIX sidebar.js, referenciando las vistas respecto a la ruta del proyecto]

parent 7697c08e
...@@ -6,8 +6,9 @@ const DOMSideBar = { ...@@ -6,8 +6,9 @@ const DOMSideBar = {
}, },
setMenu() { setMenu() {
let location = window.location; let location = window.location;
let position = getUrl(location.pathname, "/"); // let position = getUrl(location.pathname, "/");
let path = location.pathname.substring(position + 1);//obtiene el nombre de la vista jsp para activar la clase .active // let path = location.pathname.substring(position + 1);//obtiene el nombre de la vista jsp para activar la clase .active
let path = getUrl(location.href);
let menu = document.getElementById("MENU"); let menu = document.getElementById("MENU");
let c = window.sidebar;//obtiene el menu let c = window.sidebar;//obtiene el menu
// console.log(c) // console.log(c)
...@@ -43,16 +44,16 @@ const DOMSideBar = { ...@@ -43,16 +44,16 @@ const DOMSideBar = {
} else { } else {
active = ''; active = '';
} }
html += `<li class="${active}"><a href="${subcategoria[l].url}"><span>${primeraLetraMayuscula(subcategoria[l].nombre)}</span></a></li>`; html += `<li class="${active}"><a href="${contextPath}vistas/${subcategoria[l].url}"><span>${primeraLetraMayuscula(subcategoria[l].nombre)}</span></a></li>`;
} }
html += `</li></ul>`; html += `</li></ul>`;
} else { } else {
html += `<li class="${active}"><a href="${categoria[k].url}"><span>${primeraLetraMayuscula(categoria[k].nombre)}</span></a></li>`; html += `<li class="${active}"><a href="${contextPath}vistas/${categoria[k].url}"><span>${primeraLetraMayuscula(categoria[k].nombre)}</span></a></li>`;
} }
} }
html += `</li></ul>`; html += `</li></ul>`;
} else { } else {
html += `<li class="${active}"><a href="${modulo[j].url}"><i class="fa ${modulo[j].ico} fa-lg"></i><span>${primeraLetraMayuscula(modulo[j].nombre)}</span></a></li>`; html += `<li class="${active}"><a href="${contextPath}vistas/${modulo[j].url}"><i class="fa ${modulo[j].ico} fa-lg"></i><span>${primeraLetraMayuscula(modulo[j].nombre)}</span></a></li>`;
} }
} }
} }
...@@ -68,15 +69,10 @@ const DOMSideBar = { ...@@ -68,15 +69,10 @@ const DOMSideBar = {
logOut(); logOut();
} }
} }
let getUrl = (pathname, caracter) => { let getUrl = (path) => {
let position = 0; let pattern = "^(?:.*)/vistas/(.*)$";
for (let i = pathname.length - 1; i > 0; i--) { let match = path.match(pattern);
if (pathname[i] === caracter) { return match[1];
position = i;
break;
}
}
return position;
} }
DOMSideBar.init(); DOMSideBar.init();
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment