diff options
Diffstat (limited to 'public/javascripts/schedule.js')
-rw-r--r-- | public/javascripts/schedule.js | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/public/javascripts/schedule.js b/public/javascripts/schedule.js index a1ca647..fa2c1b5 100644 --- a/public/javascripts/schedule.js +++ b/public/javascripts/schedule.js @@ -44,8 +44,10 @@ self._handleError = function (event) { 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' + const meetingpointURL = + `Roosters-AL/doc/dagroosters/${leftPad(week, 2, '0')}/${type}/` + + `${type}${leftPad(id, 5, '0')}.htm` + return `/meetingpointProxy/${window.encodeURIComponent(meetingpointURL)}` } self._removeChilds = function () { @@ -55,17 +57,23 @@ 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._getURLOfUsers(week, selectedUser.type, + selectedUser.index) - 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 |