summaryrefslogtreecommitdiff
path: root/share/frontend/gallery-static/js/title.js
blob: a9ac584226014efe300020003a861c885ef22c13 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
var title_choices = [
 'Keep on pickin\' on..',
  'Pickolaus Pickleby by Charles Pickens!',
  'You pick potato and I pick potahto...',
  'Take your piq!',
  'Show em what you got',
  'I sure know how to pick \'em',
  'Jus pick somethin already!',
  'You can\'t pick your friends...',
  'Select your image my liege',
  'There\'s a time to choose...',
  'gimme a choice! gimme lil\' choice-a-that...',
  'You choose you lose',
  'novels by James CHOICE...',
  'Choose away, chooser-man...'
]
document.title = title_choices[Math.floor(Math.random() * title_choices.length)]

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);