diff options
Diffstat (limited to 'public')
| -rw-r--r-- | public/javascripts/app.js | 57 | ||||
| -rw-r--r-- | public/javascripts/main.js | 42 | ||||
| -rw-r--r-- | public/javascripts/parse-interface.js | 37 | 
3 files changed, 96 insertions, 40 deletions
| diff --git a/public/javascripts/app.js b/public/javascripts/app.js new file mode 100644 index 0000000..c54651a --- /dev/null +++ b/public/javascripts/app.js @@ -0,0 +1,57 @@ +var App = App || null; + +(function() { +	var cApp = function() { +		this.characters = null; +		this.answer = null; +		 +		 +		// CoverFlow +		var initialise_js_cover_flow = function(playlist) { +			coverflow('character-select-container').setup({ +				width: '100%', +				playlist: playlist, +				coverheight: 130, +				textoffset: 68 +			}).on('ready', function() { +				this.on('click', function() { +					alert('chosen'); +				}); +			}); +		}; +		 +		this.initialize_video = function(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() +			 +					var playlist = [] +					for (var i = 0; i < r.characters.length; i++) { +						playlist.push({ +							image: r.characters[i].image, +							title: r.characters[i].name +						}); +					} +					initialise_js_cover_flow(playlist); +					 +					that.characters = _.pluck(r.characters, 'tms_personId'); +				} +			); +		}; +		 +		 +		return this; +	}; +	 +	App = new cApp(); +})();
\ No newline at end of file diff --git a/public/javascripts/main.js b/public/javascripts/main.js index b76912e..0c1ba4e 100644 --- a/public/javascripts/main.js +++ b/public/javascripts/main.js @@ -1,41 +1,3 @@ -// CoverFlow  (function() { -	var initialise_js_cover_flow = function(playlist) { -		coverflow('character-select-container').setup({ -			width: '100%', -			playlist: playlist, -			coverheight: 130, -			textoffset: 68 -		}).on('ready', function() { -			this.on('click', function() { -				alert('chosen'); -			}); -		}); -	}; - -	// Populate characters -	 -	// Change template settings to use {{}} delimiters -	_.templateSettings = { -		interpolate: /\{\{(.+?)\}\}/g -	}; -	 -	var $character_container = $('#character-select .flow'); -	$.get( -		'/character-images/8680539', -		function(response) { -			var r = JSON.parse(response); -			 -			$character_container.empty() -			 -			var playlist = [] -			for (var i = 0; i < r.characters.length; i++) { -				playlist.push({ -					image: r.characters[i].image, -					title: r.characters[i].name -				}); -			} -			initialise_js_cover_flow(playlist); -		} -	); -})();
\ No newline at end of file +	ParseInterface.get_last_charade(); +})(); diff --git a/public/javascripts/parse-interface.js b/public/javascripts/parse-interface.js new file mode 100644 index 0000000..e58b243 --- /dev/null +++ b/public/javascripts/parse-interface.js @@ -0,0 +1,37 @@ +var ParseInterface = ParseInterface || null; + +(function() { +	var cParseInterface = function() { +		var application_id = '6jaGjImHFtbJLkAWJRnnLTHfD01nmWHAIrAKNYge'; +		var javascript_key = 'zA6og358R2Wg5NVAHWj81zeFz2WQZ5u2AhHFPCjN'; +		Parse.initialize(application_id, javascript_key); +	 +		var ContestObject = Parse.Object.extend('ContestObject'); +	 +		this.get_last_charade = function() { +			var that = this; +			var query = new Parse.Query(ContestObject); +			query.limit(1); +			query.descending('createdAt'); +			query.find({ +				success: function(response) { +					that._process_charade(response[0]); +				} +			}); +		}; +	 +		this._process_charade = function(contest_instance) { +			var video_url = contest_instance.get('video_url'); +			var series_id = contest_instance.get('series_id'); +			 +			App.answer = contest_instance.get('personId'); +			App.initialize_video(video_url); +			App.get_characters(series_id); +		}; +		 +		 +		return this; +	}; +	 +	ParseInterface = new cParseInterface(); +})();
\ No newline at end of file | 
