aboutsummaryrefslogtreecommitdiff
path: root/public/javascripts/main.js
diff options
context:
space:
mode:
Diffstat (limited to 'public/javascripts/main.js')
-rw-r--r--public/javascripts/main.js27
1 files changed, 9 insertions, 18 deletions
diff --git a/public/javascripts/main.js b/public/javascripts/main.js
index a101ef7..a7b701b 100644
--- a/public/javascripts/main.js
+++ b/public/javascripts/main.js
@@ -30,9 +30,7 @@ function getUsers () {
const type = userNode.querySelector('.data-type').textContent
const value = userNode.querySelector('.data-value').textContent
const index = Number(userNode.querySelector('.data-index').textContent)
- const other = userNode.querySelector('.data-other').textContent
- const isID = userNode.querySelector('.data-isID').textContent === 'true'
- return { type, value, index, other, isID }
+ return { type, value, index }
})
document.querySelector('#data').outerHTML = ''
@@ -46,7 +44,7 @@ function getCurrentFav () {
if (!window.localStorage.getItem('fav')) return
const favCode = window.localStorage.getItem('fav').split(':')
const fav = users.filter(user => user.type === favCode[0] && user.index === Number(favCode[1]))
- return fav[fav.length - 1]
+ return fav[0]
}
function changeFav (isFav) {
@@ -105,7 +103,7 @@ searchNode.addEventListener('input', function (e) {
results.forEach(function (result) {
const resultNode = document.createElement('li')
- resultNode.innerHTML = `${result.original.value}<span class="other">${result.original.other}</span>`
+ resultNode.innerHTML = `${result.original.value}`
autocompleteNode.appendChild(resultNode)
})
})
@@ -129,32 +127,25 @@ function submitForm (e) {
scheduleIframe.src = getURLOfUser(offset, selectedUser.type, selectedUser.index + 1)
- const hitType = 'event'
- let eventCategory
+ let eventAction
switch (selectedUser.type) {
case 'c':
- eventCategory = 'Class'
+ eventAction = 'Class'
break
case 't':
- eventCategory = 'Teacher'
+ eventAction = 'Teacher'
break
case 'r':
- eventCategory = 'Room'
+ eventAction = 'Room'
break
case 's':
- eventCategory = 'Student'
+ eventAction = 'Student'
break
}
- let eventAction
- if (selectedUser.isID) {
- eventAction = 'by id'
- } else {
- eventAction = 'by name'
- }
const eventLabel = selectedUser.value
ga(function () {
- ga('send', { hitType, eventCategory, eventAction, eventLabel })
+ ga('send', { hitType: 'event', eventCategory: 'search', eventAction, eventLabel })
})
}