diff options
Diffstat (limited to 'public/javascripts/main.js')
-rw-r--r-- | public/javascripts/main.js | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/public/javascripts/main.js b/public/javascripts/main.js index 6f99621..6c7fd05 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,9 +18,15 @@ frontpage.show() weekSelector.updateCurrentWeek() scrollSnap.startListening() -if (favorite.get() != null) { +if (url.hasSelectedItem()) { + state.selectedItem = url.getSelectedItem() + favorite.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.update(state.selectedItem) analytics.send.search(state.selectedItem, true) schedule.viewItem(weekSelector.getSelectedWeek(), state.selectedItem) } else { @@ -29,6 +36,7 @@ if (favorite.get() != null) { search.on('search', function (selectedItem) { state.selectedItem = selectedItem favorite.update(state.selectedItem) + url.update(state.selectedItem) analytics.send.search(state.selectedItem) schedule.viewItem(weekSelector.getSelectedWeek(), state.selectedItem) }) @@ -42,4 +50,10 @@ 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 |