Browse Source

Update 'about/script/index.js'

Changes allowing to load the LInE logo "/assets/logo_line_no_sub.png".
Necessary to look at each "ad hoc" paths: /about/paginas; /about/paginas/area_professor; /about/paginas/sobre
Now with some comments in English.
leo 4 months ago
parent
commit
1a5e756730
1 changed files with 15 additions and 5 deletions
  1. 15 5
      about/script/index.js

+ 15 - 5
about/script/index.js

@@ -1,4 +1,4 @@
-// Button to return to the top of page
+// Botao de voltar para o topo da pagina
 let btnVoltar = document.getElementById("ifr__btn__backToTop");
 window.onscroll = function () {
   scrollFunction();
@@ -20,18 +20,28 @@ function backToTop() {
 // footer.innerHTML =
 //   "<p>Atualizado pela ultima vez em: 3 de Outubro de 2023 -- por <a href='http://www.ime.usp.br/~laira'>Laira</a>.</p>";
 
-// Remover ultima parte da URL atual
-function pegarURL () {
+// Remove last part of the current URL
+function getURL () {
   strUrl = window.location.href;
   ind = strUrl.lastIndexOf("/");
   subStrigURL = strUrl.substring(0, ind);
-  // alert("carregar_pagina.js: " + subStrigURL);
+  ind2 = subStrigURL.lastIndexOf("/");
+  subStrigURL2 = strUrl.substring(ind2+1, ind);
+  if (subStrigURL2=='paginas') // it is under "/about/paginas", erase "paginas"
+    subStrigURL = strUrl.substring(0, ind2);
+  else
+  if (subStrigURL2=='area_professor') // it is under "/about/paginas/area_professor", erase "paginas/area_professor"
+    subStrigURL = strUrl.substring(0, ind2-7);
+  else
+  if (subStrigURL2=='sobre') // it is under "/about/paginas/sobre/", erase "paginas/area_professor"
+    subStrigURL = strUrl.substring(0, ind2-7);
+  //DEBUG alert("script/index.js!getURL(): ind=" + ind + ": ind2=" + ind2 + ": subStrigURL2=" + subStrigURL2 + ": " + subStrigURL);
   return subStrigURL;
   }
 
 // Insert in all pages the footer
 //leo const baseUrl = "/about";
-const baseUrl = pegarURL();
+const baseUrl = getURL(); //leo
 const lastUpdate =
   "Atualizado pela ultima vez em: 25 de março de 2025 -- por <a href='http://www.ime.usp.br/~laira'>Laira</a>.";
 let footer = document.getElementById("footer");