aboutsummaryrefslogtreecommitdiffstats
path: root/public/javascripts/app.js
blob: f78b204f0cfe4a380c68389cc1a2d6eeed559a7e (plain)
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
var App = App || null;

(function() {
	var cApp = function() {
		this.characters = [];
		this.answer = null;
		this.playlist = []
		
		
		// CoverFlow
		var initialise_js_cover_flow = function(playlist) {
			var that = this;
			coverflow('character-select-container').setup({
				width: '100%',
				playlist: playlist,
				coverheight: 130,
				textoffset: 68
			}).on('ready', function() {
				var the_other = that;
				this.on('click', function(e) {
//					if (the_other.answer == 
					console.log(e);
					var selection = this.playlist[e];
//					alert('chosen');
				});
			});
		};
		
		this.initialize_video = function(url) {
			console.log(url);
		};
		
		this.get_characters = function(series_id) {
			// Populate characters
			var that = this;
			var $character_container = $('#character-select .flow');
			$.get(
				'/character-images/' + series_id,
				function(response) {
					var r = JSON.parse(response);
			
					$character_container.empty()
					
					for (var i = 0; i < r.characters.length; i++) {
						that.playlist.push({
							image: r.characters[i].image,
							title: r.characters[i].name
						});
						
						that.characters.push({
							personId: r.characters[i].tms_personId,
							name: r.characters[i].name
						});
					}
					initialise_js_cover_flow(that.playlist);
				}
			);
		};
		
		
		return this;
	};
	
	App = new cApp();
})();