forked from fossasia/open-event-wsgen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
69 lines (61 loc) · 2.17 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/**
* Created by championswimmer on 28/5/15.
*/
'use strict';
// Declare app level module which depends on views, and components
var openevent = angular.module('openevent',
[
'ui.router',
'ngStorage',
'ngMaterial',
'leaflet-directive',
'oe.sidenav',
'oe.sessions',
'oe.speakers',
'oe.tracks',
'oe.sponsors',
'oe.twitterwall',
'oe.map'
]);
openevent.config(['$urlRouterProvider', '$httpProvider', '$mdThemingProvider',
function($urlRouterProvider, $httpProvider, $mdThemingProvider) {
//$httpProvider.defaults.useXDomain = true;
//delete $httpProvider.defaults.headers.common['X-Requested-With'];
$urlRouterProvider.otherwise('sessions');
$mdThemingProvider.theme('default')
.primaryPalette(config.themeColorPrimary)
.accentPalette(config.themeColorAccent);
}]);
openevent.controller('AppController',
[ '$mdSidenav', '$mdMedia', '$sessionStorage', 'ApiJsonFactory',
function($mdSidenav, $mdMedia, $sessionStorage, ApiJsonFactory) {
var app = this;
openevent.totalDays = 0;
app.appTitle = config.title;
app.toggleSidenav = function(menuId) {
$mdSidenav(menuId).toggle();
};
app.$storage = $sessionStorage;
if ( app.$storage.event === null ||
typeof(app.$storage.event) == 'undefined')
{
app.$storage.event = [];
app.$storage.days = [];
}
app.Event = app.$storage.event;
if (app.Event.length === 0) {
ApiJsonFactory.getJson('event')
.then(function (response) {
app.Event = response.data.events[0];
app.$storage.event = app.Event;
openevent.totalDays = DateUtils.DateDiff.inDays(app.Event.begin, app.Event.end) + 1;
app.Days = [openevent.totalDays];
for (var i = 0; i < openevent.totalDays; i+=1) {
app.Days[i] = {num: i, label: 'Day '+ (i+1)};
}
app.$storage.days = app.Days;
}, function (error) {
console.error(error);
});
}
}]);