aboutsummaryrefslogtreecommitdiff
path: root/public/javascripts/easterEggs.js
diff options
context:
space:
mode:
authorNoah Loomans <noahloomans@gmail.com>2016-12-06 15:29:43 +0100
committerNoah Loomans <noahloomans@gmail.com>2016-12-06 15:29:43 +0100
commit54b9362d9548c8137d242fe5d30b3b0bbea72189 (patch)
tree6390767aea5c1ce9349c90733fe913bad0b51f70 /public/javascripts/easterEggs.js
parent863d43f5038cd3b660c2f5160cd56124fa09427b (diff)
parent9d94ae11c13d8bcff23eac725c2d7bae2a7872a9 (diff)
Merge branch 'beta' of https://github.com/nloomans/rooster-mml into beta
Diffstat (limited to 'public/javascripts/easterEggs.js')
-rw-r--r--public/javascripts/easterEggs.js91
1 files changed, 91 insertions, 0 deletions
diff --git a/public/javascripts/easterEggs.js b/public/javascripts/easterEggs.js
new file mode 100644
index 0000000..2d2745d
--- /dev/null
+++ b/public/javascripts/easterEggs.js
@@ -0,0 +1,91 @@
+const sinterklaas = function () {
+ console.log('sinterklaas easter egg activated')
+ const searchNode = document.querySelector('#search')
+ const inputNode = searchNode.querySelector('input[type="text"]')
+ const autocompleteNode = document.querySelector('.autocomplete')
+ let autocomplete = false
+ const lyrics = [
+ [
+ {woord: 'Hoor ', time: 0},
+ {woord: 'wie ', time: 0.3},
+ {woord: 'klopt ', time: 0.6},
+ {woord: 'daar ', time: 0.9},
+ {woord: 'kind', time: 1.2},
+ {woord: '\'ren', time: 1.5}
+ ],
+ [
+ {woord: 'Hoor ', time: 1.8},
+ {woord: 'wie ', time: 2.1},
+ {woord: 'klopt ', time: 2.5},
+ {woord: 'daar ', time: 2.8},
+ {woord: 'kind', time: 3.1},
+ {woord: '\'ren', time: 3.4}
+ ],
+ [
+ {woord: 'Hoor ', time: 3.7},
+ {woord: 'wie ', time: 4},
+ {woord: 'tikt ', time: 4.3},
+ {woord: 'daar ', time: 4.6},
+ {woord: 'zacht', time: 4.8},
+ {woord: 'jes ', time: 5.3},
+ {woord: 'tegen ', time: 5.5},
+ {woord: '\'t ', time: 6.1},
+ {woord: 'raam ', time: 6.2}
+ ]
+ ]
+
+ const originalValue = inputNode.value
+
+ inputNode.value = ''
+ inputNode.placeholder = ''
+
+ lyrics.forEach((row, rowIndex) => {
+ row.forEach((word, wordIndex) => {
+ setTimeout(function () {
+ if (wordIndex === 0) inputNode.placeholder = ''
+ inputNode.placeholder += word.woord
+ }, word.time * 1000)
+ if (lyrics.length === rowIndex + 1 &&
+ lyrics[rowIndex].length === wordIndex + 1) {
+ setTimeout(function () {
+ if (inputNode.value === '') {
+ inputNode.value = originalValue
+ }
+ inputNode.placeholder = 'Zoeken'
+ autocomplete = true
+ }, word.time * 1000 + 1000)
+ }
+ })
+ })
+
+ inputNode.addEventListener('focus', function () {
+ if (!autocomplete) return
+
+ autocompleteNode.innerHTML = ''
+
+ const autocompleteLyrics = [
+ `'t Is een vreemd'ling zeker,`,
+ `die verdwaalt is zeker.`,
+ `'k Zal eens even vragen naar zijn naam:`
+ ]
+
+ autocompleteLyrics.forEach(row => {
+ const resultNode = document.createElement('li')
+ resultNode.innerHTML = row
+ autocompleteNode.appendChild(resultNode)
+ })
+ })
+
+ inputNode.addEventListener('input', function () {
+ if (!autocomplete) return
+ if (inputNode.value.toLowerCase() === 'sint nicolaas' ||
+ inputNode.value.toLowerCase() === 'sintnicolaas' ||
+ inputNode.value.toLowerCase() === 'sint nikolaas' ||
+ inputNode.value.toLowerCase() === 'sintnikolaas') {
+ inputNode.value = ''
+ window.location.href = 'https://www.youtube-nocookie.com/embed/jsOiKJ3kKXM?start=30'
+ }
+ })
+}
+
+module.exports = { sinterklaas }