Web front of showtimes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

73 lines
1.8 KiB

App = Ember.Application.create();
App.ApplicationRoute = Ember.Route.extend({
setupController: function(controller) {
controller.set('title', "Hello World");
}
});
App.ApplicationController = Ember.Controller.extend({
appName: 'Showtimes'
});
var groups = [
{id: "1", name: "sf"}, {id: "2", name: "major"}
];
var theaters = [
{id: "1", name: 'Sf Emporium', code: "9909"},
{id: "2", name: 'Sf NgamWongWan', code: "9934"}
];
var showtimes = [
{id: "1", name: "The Cove (1999)", showtimes: ['10:30', '13:30']},
{id: "2", name: "The Notebook (2004)", showtimes: ['15:30', '17:30']},
];
var restUrl = 'http://localhost:8888';
var today = new Date();
App.Router.map(function() {
this.resource('about');
this.resource('groups', {path: '/g'}, function() {
this.resource('theaters', {path: ':name'}, function() {
this.resource('showtimes', {path: ':code'});
});
});
});
App.GroupsRoute = Ember.Route.extend({
model: function() {
return groups;
}
});
App.TheatersRoute = Ember.Route.extend({
model: function(params) {
return $.getJSON(restUrl+'/theaters/'+params.name+'/');
}
});
App.ShowtimesRoute = Ember.Route.extend({
model: function(params) {
var theatersObjs = this.modelFor('theaters');
var url = [
restUrl, '/showtimes/', theatersObjs[0].group,
'/', params.code, '/?d=', moment(today).format('YYYY-MM-DD')
];
return $.getJSON(url.join(''));
}
});
var showdown = new Showdown.converter();
Ember.Handlebars.helper('format-markdown', function(input) {
return new Handlebars.SafeString(showdown.makeHtml(input));
});
Ember.Handlebars.helper('format-date', function(date) {
return moment(date).format('ll');
});