diff options
| author | Teddy Wing | 2013-04-27 20:19:29 -0400 | 
|---|---|---|
| committer | Teddy Wing | 2013-04-27 20:19:29 -0400 | 
| commit | 737b4aead58a3a9cd2bcba9cef91984f453d27c0 (patch) | |
| tree | 9ecbfcc97a50e6d7a8759299ae6eb35adbb1bfc3 /public/javascripts/main.js | |
| parent | 0d45e6fce95bccb90d86846fe33c60d7acb5cd1d (diff) | |
| download | Who-am-I-737b4aead58a3a9cd2bcba9cef91984f453d27c0.tar.bz2 | |
Render characters by calling API
To render the characters, get character names and image locations from
the internal API and render them using an Underscore template.
Diffstat (limited to 'public/javascripts/main.js')
| -rw-r--r-- | public/javascripts/main.js | 38 | 
1 files changed, 33 insertions, 5 deletions
| diff --git a/public/javascripts/main.js b/public/javascripts/main.js index 40a9fae..c06d9d6 100644 --- a/public/javascripts/main.js +++ b/public/javascripts/main.js @@ -1,9 +1,37 @@ +// CoverFlow  (function() { -	var cf = new ContentFlow('character-select', { -		reflectionColor: "#000000", +	var initialise_content_flow = function() { +		var cf = new ContentFlow('character-select', { +			reflectionColor: "#000000", -		onclickActiveItem: function(item) { -			alert('hello'); +			onclickActiveItem: function(item) { +				alert('hello'); +			} +		}); +		 +		return cf; +	}; +	initialise_content_flow(); + +	// Populate characters +	 +	// Change template settings to use {{}} delimiters +	_.templateSettings = { +		interpolate: /\{\{(.+?)\}\}/g +	}; +	 +	var $character_container = $('#character-select .flow'); +	var character_template = _.template($('#character-image-template').html()); +	$.get( +		'/character-images', +		function(response) { +			var r = JSON.parse(response); +			 +			$character_container.empty() +			 +			for (var i = 0; i < r.characters.length; i++) { +				$character_container.append(character_template(r.characters[i])); +			}  		} -	}); +	);  })();
\ No newline at end of file | 
