Last active
October 13, 2015 20:58
-
-
Save apisurfer/6e6846cc6539017b3b13 to your computer and use it in GitHub Desktop.
Write text line by line when user opens console
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function isConsoleOpened() { | |
var threshold = 160; | |
return (window.Firebug && window.Firebug.chrome && window.Firebug.chrome.isInitialized) || | |
window.outerWidth - window.innerWidth > threshold || window.outerHeight - window.innerHeight > threshold; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var index = 0; | |
var tOut; | |
var text = [ | |
'Good day neighbour!', | |
'Searching for more info?', | |
'You can just contact me on [email protected]' | |
]; | |
function write() { | |
if (index < text.length) { | |
console.log(text[index++]); | |
tOut = setTimeout(write, 2000); | |
} else { | |
// We got all the text out; now cleanup everything | |
clearTimeout(tOut); | |
window.onresize = undefined; | |
} | |
} | |
// DISCLAIMER: this should normally be debounced! | |
window.onresize = function(){ | |
if(isConsoleOpened()) { | |
setTimeout(write, 1500); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment