function escapeHTML(source) { return source.replace(/&/g,"&").replace(//g,">").replace(/[\r\n]/g,"
"); } var texts = [ "is a web server running on Node.JS", "is written in JavaScript", "is free as in freedom!", "has an integrated log viewer", "can be expanded using mods", "can now run PHP-FPM through GreenRhombus mod!", "can now run JSGI through YellowSquare mod!" ]; function getRandomTextsIndex() { while(true) { var v = Math.floor(Math.random()*texts.length); if(texts.length > 0 && v != textsIndex) return v; } } var begtext = "SVR.JS "; var textsIndex = 0; var h1 = document.getElementsByTagName("h1")[0]; if(h1) { h1.innerHTML = "" + escapeHTML(begtext + texts[textsIndex]) + "|"; var cursorActive = true; setInterval(function() { if(cursorActive) { document.getElementById("fancyhcursor").style.visibility = "visible"; } else { document.getElementById("fancyhcursor").style.visibility = "hidden"; } cursorActive = !cursorActive; }, 475); function timeoutFunction() { var partialText = texts[textsIndex]; var newPartialText = null; var delay = 895 / partialText.length; var fancyHeader = document.getElementById("fancyheader"); var doTyping = true; if (fancyHeader.getBoundingClientRect) { var bounding = fancyHeader.getBoundingClientRect(); var headerHeight = 0; if (document.getElementsByClassName) { var hd = document.getElementsByClassName("header")[0]; if(hd) { var hb = hd.getBoundingClientRect(); headerHeight = Math.max(0, hb.height+hb.top); } } doTyping = (bounding.top >= -(fancyHeader.offsetHeight/2) + headerHeight && bounding.left >= -(fancyHeader.offsetWidth/2) && bounding.right <= (window.innerWidth || document.documentElement.clientWidth) + (fancyHeader.offsetWidth/2) && bounding.bottom <= (window.innerHeight || document.documentElement.clientHeight) + (fancyHeader.offsetHeight/2) - headerHeight); } if (doTyping) { h1.style["min-height"] = h1.offsetHeight + "px"; var intervalBegin = setInterval(function () { if(partialText.length > 0) { partialText = partialText.substr(0,partialText.length-1); fancyHeader.innerHTML = escapeHTML(begtext + partialText); } else { textsIndex = getRandomTextsIndex(); newPartialText = texts[textsIndex]; delay = 895 / newPartialText.length; clearInterval(intervalBegin); var intervalEnd = setInterval(function () { if(partialText.length < newPartialText.length) { partialText = newPartialText.substr(0,partialText.length+1); fancyHeader.innerHTML = escapeHTML(begtext + partialText); } else { clearInterval(intervalEnd); h1.style["min-height"] = "0px"; h1.style["min-height"] = null; setTimeout(timeoutFunction, 6250); } }, delay); } }, delay); } else { setTimeout(timeoutFunction, 6250); } } setTimeout(timeoutFunction, 6250); }