diff options
Diffstat (limited to 'public/javascripts/schedule.js')
-rw-r--r-- | public/javascripts/schedule.js | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/public/javascripts/schedule.js b/public/javascripts/schedule.js index a1ca647..657c4a0 100644 --- a/public/javascripts/schedule.js +++ b/public/javascripts/schedule.js @@ -1,5 +1,4 @@ const EventEmitter = require('events') -const leftPad = require('left-pad') const search = require('./search') const self = new EventEmitter() @@ -42,10 +41,8 @@ self._handleError = function (event) { self.emit('load') } -self._getURLOfUsers = function (week, type, index) { - const id = index + 1 - return '//' + window.location.host + '/meetingpointProxy/Roosters-AL%2Fdoc%2Fdagroosters%2F' + - leftPad(week, 2, '0') + '%2F' + type + '%2F' + type + leftPad(id, 5, '0') + '.htm' +self._getURLOfUser = function (week, user) { + return `/get/${user.type}/${user.value}?week=${week}` } self._removeChilds = function () { @@ -55,17 +52,22 @@ self._removeChilds = function () { } self.viewItem = function (week, selectedUser) { - const url = self._getURLOfUsers(week, selectedUser.type, selectedUser.index) + if (selectedUser == null) { + self._removeChilds() + search.updateDom(selectedUser) + } else { + const url = self._getURLOfUser(week, selectedUser) - self._removeChilds() + self._removeChilds() - const request = new window.XMLHttpRequest() - request.addEventListener('load', self._handleLoad) - request.addEventListener('error', self._handleError) - request.open('GET', url, true) - request.send() + const request = new window.XMLHttpRequest() + request.addEventListener('load', self._handleLoad) + request.addEventListener('error', self._handleError) + request.open('GET', url, true) + request.send() - search.updateDom(selectedUser) + search.updateDom(selectedUser) + } } module.exports = self |