diff options
author | Noah Loomans <noahloomans@gmail.com> | 2016-12-15 12:36:22 +0100 |
---|---|---|
committer | Noah Loomans <noahloomans@gmail.com> | 2016-12-15 12:36:22 +0100 |
commit | b2d6055bc83cb88fcce1df5bbc88dd20ca6cdc85 (patch) | |
tree | 337090679197bebde5047fd6d54bdd2246bea883 /public/javascripts/weekSelector.js | |
parent | afd118ba4fb6261f9614df9e2cc88ebcfa5ac3d3 (diff) |
show human readable week format if available
Diffstat (limited to 'public/javascripts/weekSelector.js')
-rw-r--r-- | public/javascripts/weekSelector.js | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/public/javascripts/weekSelector.js b/public/javascripts/weekSelector.js index 2a8bb62..1cf5b56 100644 --- a/public/javascripts/weekSelector.js +++ b/public/javascripts/weekSelector.js @@ -33,15 +33,36 @@ self.getSelectedWeek = function () { self.updateCurrentWeek = function () { const selectedWeekNumber = self.getSelectedWeek() - self._nodes.currentWeekText.textContent = `Week ${selectedWeekNumber}` if (self.getCurrentWeek(new Date()) !== selectedWeekNumber) { self._nodes.currentWeekText.classList.add('changed') } else { self._nodes.currentWeekText.classList.remove('changed') } + self.updateDom() self.emit('weekChanged', selectedWeekNumber) } +self.updateDom = function () { + const selectedWeekNumber = self.getSelectedWeek() + let humanReadableWeek = null + switch (self._weekOffset) { + case 0: + humanReadableWeek = 'Huidige week' + break + case 1: + humanReadableWeek = 'Volgende week' + break + case -1: + humanReadableWeek = 'Vorige week' + break + } + if (humanReadableWeek != null) { + self._nodes.currentWeekText.textContent = `${humanReadableWeek} • ${selectedWeekNumber}` + } else { + self._nodes.currentWeekText.textContent = `Week ${selectedWeekNumber}` + } +} + self._handlePrevButtonClick = function () { self._weekOffset -= 1 self.updateCurrentWeek() |