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.
 
 

92 lines
2.3 KiB

App = Ember.Application.create();
App.ApplicationRoute = Ember.Route.extend({
setupController: function(controller) {
controller.set('title', "Hello World");
},
});
// redirect '/' to 'groups' by default
App.IndexRoute = Ember.Route.extend({
beforeModel: function() {
this.transitionTo('groups');
}
});
App.ApplicationController = Ember.Controller.extend({
appName: '#ShowtimesTH'
});
var groups = [
{id: "1", name: "sf"}, {id: "2", name: "major"}, {id: "3", name: "etc"}
];
var restUrl = 'http://showtimes.everyday.in.th/api';
// var restUrl = 'http://localhost:8989';
var today = new Date();
App.Router.map(function() {
this.resource('about');
this.resource('api');
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+'/').then(function(data) {
return data.objects.map(function(theater) {
return theater;
});
});
}
});
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('')).then(function(data) {
return data.objects.map(function(showtimesItem) {
return showtimesItem;
});
});
}
});
var showdown = new Showdown.converter();
Ember.Handlebars.helper('is3d', function(inputArr) {
if (!inputArr)
return "";
var itis = false;
if (inputArr.length < 1)
return "";
for (var i = 0;i<inputArr.length;i++) {
if (inputArr[i].match("3d"))
itis = true
};
return ((itis) ? "3D" : "");
});
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');
});