mirror of
https://github.com/skishore/makemeahanzi.git
synced 2025-10-29 09:57:38 +08:00
32 lines
749 B
JavaScript
32 lines
749 B
JavaScript
// Simple helpers for interacting with reactive variables.
|
|
|
|
ReactiveVar.prototype.pop = function() {
|
|
const value = this.get();
|
|
value.pop();
|
|
this.set(value);
|
|
}
|
|
|
|
ReactiveVar.prototype.push = function(element) {
|
|
const value = this.get();
|
|
value.push(element);
|
|
this.set(value);
|
|
}
|
|
|
|
// Our hacky implementation of a routing table. Iron Router is too slow...
|
|
|
|
Session.setDefault('route', null);
|
|
|
|
Handlebars.registerHelper('route', () => Session.get('route'));
|
|
|
|
const hashchange = () => {
|
|
const hash = window.location.hash;
|
|
if (hash.startsWith('#/codepoint/')) {
|
|
Session.set('route', 'character');
|
|
} else {
|
|
Session.set('route', 'search');
|
|
}
|
|
}
|
|
|
|
window.addEventListener('hashchange', hashchange, false);
|
|
Meteor.startup(hashchange);
|