Skip to content

Commit

Permalink
fixed version sidebar issue
Browse files Browse the repository at this point in the history
  • Loading branch information
adpare committed Dec 2, 2023
1 parent 6eee043 commit 2760016
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
23 changes: 17 additions & 6 deletions attack-theme/static/scripts/sidebar-load-all.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,36 @@
let mod_name = window.location.pathname.split("/")
let mod_entry = "/" + mod_name[1] + "/sidebar-" + mod_name[1]
let mod_name = window.location.pathname.split("/");
let mod_entry;
if (mod_name.includes('versions') && mod_name.length > 4){
mod_entry = "/" + mod_name[3] + "/sidebar-" + mod_name[3]
}
else{
mod_entry = "/" + mod_name[1] + "/sidebar-" + mod_name[1]
}
if (mod_name.includes('contact')){
mod_entry = "/" + "resources/sidebar-resources"
}
$("#sidebars").load(mod_entry, function() {
let old_winlocation = window.location.href;
if (mod_name.includes('versions')){
let v_number = mod_name[2];
old_winlocation = old_winlocation.replace('/versions/'+ v_number,'');
}
let navElements = document.querySelectorAll('.sidenav-head > a');
let winlocation;
navElements.forEach(function(element){
if(!element.href.includes('changelog.html')){
if(!window.location.href.endsWith("/")){
winlocation = window.location.href + "/";
if(!old_winlocation.endsWith("/")){
winlocation = old_winlocation + "/";
}
else{
winlocation = window.location.href
winlocation = old_winlocation
}
if(!element.href.endsWith("/")){
element.href = element.href + "/";
}
}
else{
winlocation = window.location.href
winlocation = old_winlocation
}
if(element.href == winlocation){
$(element.parentNode).addClass("active")
Expand Down
1 change: 0 additions & 1 deletion attack-theme/static/scripts/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
function positionBody() {
let headerHeight = $(".navbar").outerHeight();
let viewportHeight = $(".attack-website-wrapper").outerHeight();
let sidebarHeight = viewportHeight - headerHeight + "px";
$(".sidebar.nav").css({
"top": headerHeight + "px",
"max-height": viewportHeight - headerHeight + "px"
Expand Down

0 comments on commit 2760016

Please sign in to comment.