mirror of
				https://scm.univ-tours.fr/22107988t/rappaurio-sae501_502.git
				synced 2025-11-04 06:05:22 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			20 lines
		
	
	
		
			753 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			20 lines
		
	
	
		
			753 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
function hideAllButCurrent(){
 | 
						|
    //by default all submenut items are hidden
 | 
						|
    //but we need to rehide them for search
 | 
						|
    document.querySelectorAll("nav > ul > li > ul li").forEach(function(parent) {
 | 
						|
        parent.style.display = "none";
 | 
						|
    });
 | 
						|
    
 | 
						|
    //only current page (if it exists) should be opened
 | 
						|
    var file = window.location.pathname.split("/").pop().replace(/\.html/, '');
 | 
						|
    document.querySelectorAll("nav > ul > li > a").forEach(function(parent) {
 | 
						|
        var href = parent.attributes.href.value.replace(/\.html/, '');
 | 
						|
        if (file === href) {
 | 
						|
            parent.parentNode.querySelectorAll("ul li").forEach(function(elem) {
 | 
						|
                elem.style.display = "block";
 | 
						|
            });
 | 
						|
        }
 | 
						|
    });
 | 
						|
}
 | 
						|
 | 
						|
hideAllButCurrent(); |