diff options
author | Noah Loomans <noahloomans@gmail.com> | 2016-12-14 12:19:59 +0100 |
---|---|---|
committer | Noah Loomans <noahloomans@gmail.com> | 2016-12-14 12:19:59 +0100 |
commit | e3f1a6a2c3534c3133f412f1b86f7398f3b4f40c (patch) | |
tree | fa2e526929c83691fe6ee51b86f1c5a258c11c1d /public/javascripts/main.js | |
parent | 746abfd1827bf7d6d51c231b5509d5f609e71f07 (diff) |
add favorite
Diffstat (limited to 'public/javascripts/main.js')
-rw-r--r-- | public/javascripts/main.js | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/public/javascripts/main.js b/public/javascripts/main.js index 6e0796c..9214d05 100644 --- a/public/javascripts/main.js +++ b/public/javascripts/main.js @@ -2,14 +2,25 @@ const frontpage = require('./frontpage') const search = require('./search') const schedule = require('./schedule') const weekSelector = require('./weekSelector') +const favorite = require('./favorite') const state = {} +window.state = state +window.require = require + frontpage.show() weekSelector.updateCurrentWeek() +if (favorite.get() != null) { + state.selectedItem = favorite.get() + favorite.update(state.selectedItem) + schedule.viewItem(weekSelector.getSelectedWeek(), state.selectedItem) +} + search.on('search', function (selectedItem) { state.selectedItem = selectedItem + favorite.update(state.selectedItem) schedule.viewItem(weekSelector.getSelectedWeek(), state.selectedItem) }) @@ -17,6 +28,10 @@ weekSelector.on('weekChanged', function (newWeek) { schedule.viewItem(newWeek, state.selectedItem) }) +favorite.on('click', function () { + favorite.toggle(state.selectedItem) +}) + window.weekSelector = weekSelector document.body.style.opacity = 1 |