storySelect.js
//Here's our kickstarter function (the one that gets everything going). It's got more explosion than the CGI in a Michael Bay film, or so I'm told...
Here's our kickstarter function (the one that gets everything going). It's got more explosion than the CGI in a Michael Bay film, or so I'm told
Here ' s our kickstarter function ( the one that gets everything going ) . It ' s got more explosion than the CGI in a Michael Bay film or so I ' m told
function explode(){
  get('output').style.display = '';
  get("posterInstructions").style.display = "none";
  data.filmData.forEach(function(movie){
				   movie["Genre"].split(", ").forEach(function(specificGenre){
																								findGenre(specificGenre);
																						  });
				 								});
	data.genres.forEach(function(genre){
									      data.rankedGenres[genre] = 0;
									    });
	data.genres.forEach(function(genre){
									      data.rankedGenres[genre]++;
									    });
	var onDeck = sortRanked(data.rankedGenres);
	var finalMasterGenreList = cleanUp(onDeck);
	var storyOutput = getStory(finalMasterGenreList);
	data.getRankedList = postStory(storyOutput);
	data.getRankedList(data.shortStory);
}
function explode ( ) { get ( 'output' ) . style . display = '' ; get ( "posterInstructions" ) . style . display = "none" ; data . filmData . forEach ( function ( movie ) { movie [ "Genre" ] . split ( ", " ) . forEach ( function ( specificGenre ) { findGenre ( specificGenre ) ; } ) ; } ) ; data . genres . forEach ( function ( genre ) { data . rankedGenres [ genre ] = 0 ; } ) ; data . genres . forEach ( function ( genre ) { data . rankedGenres [ genre ] ++ ; } ) ; var onDeck = sortRanked ( data . rankedGenres ) ; var finalMasterGenreList = cleanUp ( onDeck ) ; var storyOutput = getStory ( finalMasterGenreList ) ; data . getRankedList = postStory ( storyOutput ) ; data . getRankedList ( data . shortStory ) ; }
Here's our kickstarter function (the one that gets everything going).
Here ' s our kickstarter function ( the one that gets everything going ) .
//Release the Kraken! AKA the "output" div tag //Here's where things get a bit complex. In the "filmData" array, we have 3 elements in each array that contain one or many genres per movie, in a String type.  //So, we just need to have a forEach get each string-list of genres, split it with the native method on strings to convert it to its own array, and then have another  //forEach push each of the specific genres to the "genres" array that we defined above. How hard could it be? //	And boom goes the dynamite. //Cool. Now, we need to set up an object called "rankedGenres", that takes  // a count of the genres in the list and ranks them. //Since undefined + 1 == NaN, we need to create each genre as 0 before counting them up. //A forEach will do the trick!  //And now we count 'em up! // Sort through the stories... // ...and make sure that there aren't any rogue genres in there //rank the stories based on relevance //create a method on our data object to hold the ranked story array as a closure, //so we can access it after it returns