2020-05-29 16:58:33 -04:00
|
|
|
var started = false;
|
|
|
|
var showControls = false;
|
|
|
|
|
|
|
|
var colorWords = ["red", "orange", "yellow", "green", "blue", "purple", "white"];
|
|
|
|
var hypnoWords = ["sleep", "relax", "fall", "deeper", "trance"];
|
|
|
|
var colors = ["red", "orange", "yellow", "green", "blue", "purple", "white"];
|
|
|
|
var wordEl = document.getElementById("word");
|
|
|
|
|
|
|
|
function randomChoice(a) {
|
|
|
|
return a[Math.floor(Math.random()*a.length)];
|
|
|
|
}
|
|
|
|
|
|
|
|
var hypnoFrequency = 0;
|
|
|
|
var hypnoIncrements = 10;
|
|
|
|
function changeWord() {
|
|
|
|
var wordList = (Math.random()*hypnoIncrements < hypnoFrequency) ? hypnoWords : colorWords;
|
|
|
|
var newWord;
|
|
|
|
do {
|
|
|
|
newWord = randomChoice(wordList);
|
2020-11-20 14:04:08 -05:00
|
|
|
} while (newWord === wordEl.textContent);
|
2020-05-29 16:58:33 -04:00
|
|
|
|
|
|
|
var newColor;
|
|
|
|
do {
|
|
|
|
newColor = randomChoice(colors);
|
|
|
|
} while (newColor === wordEl.style.color);
|
|
|
|
|
2020-11-20 14:04:08 -05:00
|
|
|
wordEl.textContent = newWord;
|
2020-05-29 16:58:33 -04:00
|
|
|
wordEl.style.color = newColor;
|
|
|
|
}
|
|
|
|
|
2020-05-29 17:14:57 -04:00
|
|
|
document.getElementById("controls").onclick = function (e) {
|
|
|
|
e.stopPropagation();
|
|
|
|
}
|
|
|
|
|
2020-05-29 16:58:33 -04:00
|
|
|
window.onclick = function () {
|
|
|
|
if (!started) {
|
|
|
|
started = true;
|
|
|
|
document.getElementById("controls").style.display = "none";
|
2020-05-29 17:05:55 -04:00
|
|
|
document.getElementById("reload").style.display = "inline";
|
2020-05-29 16:58:33 -04:00
|
|
|
changeWord();
|
|
|
|
setInterval(changeWord, 1000);
|
|
|
|
setInterval(function() { if (hypnoFrequency < hypnoIncrements) { hypnoFrequency++; } }, 5000);
|
|
|
|
} else {
|
|
|
|
document.getElementById("controls").style.display = showControls ? "none" : "block";
|
|
|
|
showControls = !showControls;
|
|
|
|
}
|
|
|
|
}
|