aboutsummaryrefslogtreecommitdiff
path: root/public/javascripts/schedule.js
diff options
context:
space:
mode:
authorNoah Loomans <noahloomans@gmail.com>2016-12-21 12:20:23 +0100
committerNoah Loomans <noahloomans@gmail.com>2016-12-21 12:20:23 +0100
commit3387256ff71d411d14b863f4a55c28f0356cd6d5 (patch)
treed79c9c1afabed7d2cf2066c1289d0933535513dc /public/javascripts/schedule.js
parent800efbe604aba667f7f3b5a5df314fba915d1773 (diff)
fix bug where multiple schedules are shown if switching too quickly.
Diffstat (limited to 'public/javascripts/schedule.js')
-rw-r--r--public/javascripts/schedule.js12
1 files changed, 9 insertions, 3 deletions
diff --git a/public/javascripts/schedule.js b/public/javascripts/schedule.js
index 2e6fb81..a080ace 100644
--- a/public/javascripts/schedule.js
+++ b/public/javascripts/schedule.js
@@ -22,6 +22,7 @@ self._handleLoad = function (event) {
return
}
const document = self._parseMeetingpointHTML(request.response)
+ self._removeChilds()
self._nodes.schedule.appendChild(document)
self._nodes.schedule.classList.remove('error')
self.emit('load')
@@ -35,6 +36,7 @@ self._handleError = function (event) {
} else {
error = 'Sorry, er is iets mis gegaan tijdens het laden van deze week.'
}
+ self._removeChilds()
self._nodes.schedule.textContent = error
self._nodes.schedule.classList.add('error')
self.emit('load')
@@ -46,12 +48,16 @@ self._getURLOfUsers = function (week, type, index) {
week + '%2F' + type + '%2F' + type + leftPad(id, 5, '0') + '.htm'
}
-self.viewItem = function (week, selectedUser) {
- const url = self._getURLOfUsers(week, selectedUser.type, selectedUser.index)
-
+self._removeChilds = function () {
while (self._nodes.schedule.firstChild) {
self._nodes.schedule.removeChild(self._nodes.schedule.firstChild)
}
+}
+
+self.viewItem = function (week, selectedUser) {
+ const url = self._getURLOfUsers(week, selectedUser.type, selectedUser.index)
+
+ self._removeChilds()
const request = new window.XMLHttpRequest()
request.addEventListener('load', self._handleLoad)