summaryrefslogtreecommitdiff
path: root/share/frontend/js/titleScrambler.js
diff options
context:
space:
mode:
authoryo mama <pepper@scannerjammer.com>2015-09-22 00:51:40 -0700
committeryo mama <pepper@scannerjammer.com>2015-09-22 00:51:40 -0700
commitd3e7b5708deffbed864c916de22663f48333c58b (patch)
treeef76784a7827baff88c03670bf22832a3f146b17 /share/frontend/js/titleScrambler.js
parent86c79f4372d7b2e7640a26473c7a4d331cdf7d16 (diff)
finishing server
Diffstat (limited to 'share/frontend/js/titleScrambler.js')
-rw-r--r--share/frontend/js/titleScrambler.js56
1 files changed, 56 insertions, 0 deletions
diff --git a/share/frontend/js/titleScrambler.js b/share/frontend/js/titleScrambler.js
new file mode 100644
index 0000000..6948cbf
--- /dev/null
+++ b/share/frontend/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);
+