diff options
| author | pepperpepperpepper <pepper@scannerjammer.com> | 2015-10-22 22:49:32 -0700 |
|---|---|---|
| committer | pepperpepperpepper <pepper@scannerjammer.com> | 2015-10-22 22:49:32 -0700 |
| commit | ceb2da8f23f1f447d55c0abf20d3816a486e439b (patch) | |
| tree | 77d67afe092f9631747515cdb52f8fc1c51f35e7 /gallery/js/titleScrambler.js | |
| parent | e1c21b17de44401d08a0779be6cffb96013e3390 (diff) | |
added gallery and new actions to the db code
Diffstat (limited to 'gallery/js/titleScrambler.js')
| -rw-r--r-- | gallery/js/titleScrambler.js | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/gallery/js/titleScrambler.js b/gallery/js/titleScrambler.js new file mode 100644 index 0000000..6948cbf --- /dev/null +++ b/gallery/js/titleScrambler.js @@ -0,0 +1,56 @@ +var titleSwitch = true; +var FillerChars = [ "(",")","|","1","4","\\", "9","_" ]; +var titleArray = document.title.split(""); +var titleArrayCopy = titleArray.slice(0); +var titleLength = titleArray.length + +function marqueeArray(arr){ + var first = arr[0] + arr.shift() +} + +function replaceArray(arr, char){ + arr[randomChoice(arr)] = char +} +var titleUpdateInterval = 300 +function randomChoice(arr){ + var rand = Math.random(); + rand *= arr.length; + rand = Math.floor(rand) + return rand; +} +var titleUpdate = setInterval(function(){ + if (titleSwitch === true){ + marqueeArray(titleArray); + document.title = titleArray.join("") + if (titleArray.length === 1){ + document.title = ""; + titleArray = titleArrayCopy.slice(0); + document.title = titleArray.join(""); + if (titleSwitch){ + titleSwitch = false; + }else{ + titleSwitch = true; + titleUpdateInterval = 100; + } + } + }else{ + + replaceArray(titleArray, FillerChars[randomChoice(FillerChars)]); + document.title = titleArray.join("") + if (titleArray[(titleArray.length-1)] in FillerChars){ + console.log("it's in there"); + titleArray = titleArrayCopy.slice(0); + document.title = titleArray.join(""); + if (titleSwitch){ + titleSwitch = false; + titleUpdateInterval = 300; + }else{ + titleSwitch = true; + } + + } + } + + }, titleUpdateInterval); + |
