diff options
author | Noah Loomans <noahloomans@gmail.com> | 2017-01-30 14:04:20 +0100 |
---|---|---|
committer | Noah Loomans <noahloomans@gmail.com> | 2017-01-30 14:04:20 +0100 |
commit | 25fbba2084a23fb62ab0e7fdf2dd47eadc28a967 (patch) | |
tree | 532293fef971164b21e3227955ff532668f850a1 /public/javascripts/main.js | |
parent | acbdba98a7ab37e76c856cc751b78e2a974036b9 (diff) |
Fix bugs in url update
- Document title doesn't update
- Page crashes when going back to front page
Diffstat (limited to 'public/javascripts/main.js')
-rw-r--r-- | public/javascripts/main.js | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/public/javascripts/main.js b/public/javascripts/main.js index 6c7fd05..561316d 100644 --- a/public/javascripts/main.js +++ b/public/javascripts/main.js @@ -20,14 +20,20 @@ scrollSnap.startListening() if (url.hasSelectedItem()) { state.selectedItem = url.getSelectedItem() + favorite.update(state.selectedItem) + url.update(state.selectedItem) analytics.send.search(state.selectedItem) + schedule.viewItem(weekSelector.getSelectedWeek(), state.selectedItem) } else if (favorite.get() != null) { state.selectedItem = favorite.get() + favorite.update(state.selectedItem) + url.push(state.selectedItem, false) url.update(state.selectedItem) analytics.send.search(state.selectedItem, true) + schedule.viewItem(weekSelector.getSelectedWeek(), state.selectedItem) } else { search.focus() @@ -35,9 +41,21 @@ if (url.hasSelectedItem()) { search.on('search', function (selectedItem) { state.selectedItem = selectedItem + favorite.update(state.selectedItem) + url.push(state.selectedItem) url.update(state.selectedItem) analytics.send.search(state.selectedItem) + + schedule.viewItem(weekSelector.getSelectedWeek(), state.selectedItem) +}) + +url.on('update', function (selectedItem) { + state.selectedItem = selectedItem + + favorite.update(state.selectedItem) + url.update(state.selectedItem) + schedule.viewItem(weekSelector.getSelectedWeek(), state.selectedItem) }) @@ -50,10 +68,4 @@ favorite.on('click', function () { favorite.toggle(state.selectedItem) }) -url.on('update', function (selectedItem) { - state.selectedItem = selectedItem - favorite.update(state.selectedItem) - schedule.viewItem(weekSelector.getSelectedWeek(), state.selectedItem) -}) - document.body.style.opacity = 1 |