diff options
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 |