diff options
author | Noah Loomans <noahloomans@gmail.com> | 2017-01-30 17:56:25 +0100 |
---|---|---|
committer | Noah Loomans <noahloomans@gmail.com> | 2017-01-30 17:56:25 +0100 |
commit | 344504782ac628b15229cafada34a9f32d595624 (patch) | |
tree | 532293fef971164b21e3227955ff532668f850a1 /public/javascripts/main.js | |
parent | 29ea424009be3bd8561e74587b651c1c44bf2f7e (diff) | |
parent | 25fbba2084a23fb62ab0e7fdf2dd47eadc28a967 (diff) |
Merge branch 'update-url' into beta
Diffstat (limited to 'public/javascripts/main.js')
-rw-r--r-- | public/javascripts/main.js | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/public/javascripts/main.js b/public/javascripts/main.js index 6f99621..561316d 100644 --- a/public/javascripts/main.js +++ b/public/javascripts/main.js @@ -7,6 +7,7 @@ const weekSelector = require('./weekSelector') const favorite = require('./favorite') const scrollSnap = require('./scrollSnap') const analytics = require('./analytics') +const url = require('./url') const state = {} @@ -17,10 +18,22 @@ frontpage.show() weekSelector.updateCurrentWeek() scrollSnap.startListening() -if (favorite.get() != null) { +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() @@ -28,8 +41,21 @@ if (favorite.get() != null) { 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) }) |