wizefunc.js 2.03 KB
/* Go to top of page */
    function topFunction() {
        document.body.scrollTop = 0;
        document.documentElement.scrollTop = 0;
    }
    
    /* open/close navigation optionally slide page */
    function openNav(slide) {
        if (document.getElementById("mySidenav").getAttribute("class").split(' ')[1] == "menuClosed") {
            document.getElementById("mySidenav").style.width = "300px";
            if (slide==1) {
                document.getElementById("main").style.marginLeft = "300px";
            }
            document.getElementById("mySidenav").setAttribute("class","menu menuOpen");
            /* Scroll to top when opening menu */
            topFunction();
        } else {
            document.getElementById("mySidenav").style.width = "0";
            if (slide==1) {
                document.getElementById("main").style.marginLeft = "0";
            }
            document.getElementById("mySidenav").setAttribute("class","menu menuClosed");            
        }
    }
    
    /* when scrolling down 20 pixel display upButton */
    function scrollFunction() {
        if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {
            upButton.style.display = "block";
        } else {
            upButton.style.display = "none";
        }
    }

    /* Test if the logo is present (to avoid displaying broken link icon on chrome) */
    function testLogo() {
        logo=document.getElementById("logoImgId");
        logodiv=document.getElementById("logoDivId");
        if (logo.naturalHeight == 0) {
            logodiv.setAttribute("style","display:none;");
        }
    }

    /* Convert the two first tags into info */
    function tagToInfo() {
        var tags = document.getElementsByClassName('zim-tag');
        var n = tags.length < 3 ? tags.length : 2;
        for (var i=1; i <= n; i++) {
            var s = tags[i-1].innerHTML;
            s = s.replace('@','');
            s = s.replace(/_/g,' ');
            document.getElementById("footinfo"+i).innerHTML = s;
        }
    }