aboutsummaryrefslogtreecommitdiff
path: root/public/javascripts/main.js
diff options
context:
space:
mode:
authorNoah Loomans <noahloomans@gmail.com>2016-12-07 11:15:15 +0100
committerNoah Loomans <noahloomans@gmail.com>2016-12-07 11:15:15 +0100
commitf080ef3d3a486599362e225fc1eaf5a0233cfb76 (patch)
tree571eacaf7d817cf4e7bd5d1da52e0ce1aff524e4 /public/javascripts/main.js
parent84bf0b24e0a6b584311218108ca953f911901c74 (diff)
parente8fafea3157047b65bd6305f2871d4a1a3d5f707 (diff)
forgot to pull
Diffstat (limited to 'public/javascripts/main.js')
-rw-r--r--public/javascripts/main.js25
1 files changed, 16 insertions, 9 deletions
diff --git a/public/javascripts/main.js b/public/javascripts/main.js
index 4ebc6c8..7daedcf 100644
--- a/public/javascripts/main.js
+++ b/public/javascripts/main.js
@@ -13,8 +13,8 @@ const searchNode = document.querySelector('#search')
const inputNode = searchNode.querySelector('input[type="text"]')
const autocompleteNode = document.querySelector('.autocomplete')
const scheduleIframe = document.querySelector('#schedule')
-const prevButton = document.querySelectorAll('input[type="button"]')[0]
-const nextButton = document.querySelectorAll('input[type="button"]')[1]
+const prevButton = document.querySelectorAll('#week-selector button')[0]
+const nextButton = document.querySelectorAll('#week-selector button')[1]
const currentWeekNode = document.querySelector('.current')
const favNode = document.querySelector('.fav')
@@ -97,7 +97,7 @@ if (navigator.userAgent.indexOf('MSIE') !== -1 ||
}
searchNode.addEventListener(inputEventStr, function (e) {
- document.body.className = ''
+ document.body.classList.remove('no-input')
autocompleteNode.innerHTML = ''
if (inputNode.value.trim() === '') return
@@ -123,6 +123,8 @@ function submitForm (e) {
}
if (selectedUser == null) return
+ document.body.classList.add('searched')
+
updateFavNode()
inputNode.value = selectedUser.value
@@ -177,11 +179,12 @@ inputNode.addEventListener('click', function () {
inputNode.select()
})
-inputNode.addEventListener('blur', function () {
- const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent)
- if (!isSafari) {
- inputNode.selectionStart = inputNode.selectionEnd = -1
- }
+window.addEventListener('blur', function () {
+ // this will removed the selection without drawing focus on it (safari)
+ // this will removed selection even when focusing an iframe (chrome)
+ const oldValue = inputNode.value
+ inputNode.value = ''
+ inputNode.value = oldValue
})
searchNode.addEventListener('blur', function (e) {
@@ -225,10 +228,14 @@ if (currentFav) {
ga('send', { hitType: 'event', eventCategory: 'search fav', eventAction, eventLabel })
})
} else if (inputNode.value === '') {
- document.body.className = 'no-input'
+ document.body.classList.add('no-input')
inputNode.focus()
}
+if (scheduleIframe.src !== '') {
+ document.body.classList.add('searched')
+}
+
document.body.style.opacity = '1'
window.easterEggs = easterEggs