From 33d47771019f17dbf21b3afdb0c3e934c3b67e1c Mon Sep 17 00:00:00 2001 From: oupala Date: Tue, 28 May 2019 14:59:25 +0200 Subject: [PATCH] feat: add a breadcrumb Add a breadcrumb to tell the user where he is in the tree. js and html is there and working. It needs some css styling though. --- apaxy/theme/apaxy.js | 26 ++++++++++++++++++++++++++ apaxy/theme/header.html | 3 +++ 2 files changed, 29 insertions(+) diff --git a/apaxy/theme/apaxy.js b/apaxy/theme/apaxy.js index f6ea87d..b2e70c6 100644 --- a/apaxy/theme/apaxy.js +++ b/apaxy/theme/apaxy.js @@ -74,3 +74,29 @@ if (uri.substring(uri.length - 1) !== '/') { }); })(document); + +// generate a breadcrumb +var uri = window.location.pathname.substr(1); +var arr = uri.split('/'); +var url = "" +var bread = '
  • Home
  • '; +var cont = 1; +arr.forEach(function(value){ + url = url + '/' + value; + if(value != ''){ + if(arr.length == cont+1) + bread += "
  • "+decodeURI(value)+"
  • "; + else + bread += "
  • "+decodeURI(value)+"
  • "; + } + cont++; +}); +document.getElementById("breadcrumbs").innerHTML = bread; +if (uri.substring(uri.length-1) != '/'){ + var indexes = document.getElementsByClassName('indexcolname'), + i = indexes.length; + while (i--){ + var a = indexes[i].getElementsByTagName('a')[0]; + a.href = uri + '/' + a.getAttribute('href',2); + } +} diff --git a/apaxy/theme/header.html b/apaxy/theme/header.html index 08db323..297a9f0 100644 --- a/apaxy/theme/header.html +++ b/apaxy/theme/header.html @@ -1,4 +1,7 @@
    + +