Co-authored-by: Adam Bem <adam.bem@zoho.eu> Reviewed-on: R11/release11-tools-web#118
		
			
				
	
	
		
			37 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			37 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
 | 
						|
function init() {
 | 
						|
    changeActiveTools('xmlTool', 'XML');
 | 
						|
}
 | 
						|
 | 
						|
/**
 | 
						|
 * Function that updates list of tools depending on chosen category
 | 
						|
 * 
 | 
						|
 * @function
 | 
						|
 * @name changeActiveTools
 | 
						|
 * @kind function
 | 
						|
 * @param {any} activeClass class of elements that have to be shown
 | 
						|
 * @param {any} activeCategoryButton class of category button that has to be active
 | 
						|
 */
 | 
						|
function changeActiveTools(activeClass, activeCategoryButton) {
 | 
						|
    let tools = document.getElementById("toolList").children
 | 
						|
    
 | 
						|
    for (i = 0; i < tools.length; i++) {
 | 
						|
        if (tools[i].classList.contains(activeClass)) {
 | 
						|
            tools[i].style.display = "block";
 | 
						|
        }
 | 
						|
        else {
 | 
						|
            tools[i].style.display = "none";
 | 
						|
        }
 | 
						|
    }
 | 
						|
 | 
						|
    let categories = document.getElementById("menu").children
 | 
						|
 | 
						|
    for (i = 0; i < categories.length; i++) {
 | 
						|
        if (categories[i].innerText == activeCategoryButton) {
 | 
						|
            categories[i].classList.add("active")
 | 
						|
        }
 | 
						|
        else {
 | 
						|
            categories[i].classList.remove("active")
 | 
						|
        }
 | 
						|
    }
 | 
						|
} |