function buildTweetCard(tweetData) {
	var foundTweets = tweetData;

	// Check if the data coming in has a statuses object.
	if(tweetData.hasOwnProperty('statuses')) {
		var foundTweets = tweetData.statuses;
	}

	// Parse through the found tweets, and seperate them into a key value pair.
	$.each(foundTweets, function(key, val) {
		// Do not show tweets that are possibly sensitive.
		if(!val.possibly_sensitive) {
			var rtweeted = false;			// Stores whether the tweet is a retweet or not.
			var retweeted_text = "";		// Get the text of the retweet.
			var original_retweeter = "";	// The original user that was retweeted.
			var full_text = "";				// The full text of the tweet.
			var mediaData = val.entities.hasOwnProperty('media') ? val.extended_entities.media : "";	// The json object for media like pictures and videos.

			// Check if this tweet is, in fact, a retweet.
			if(val.hasOwnProperty('retweeted_status')) {
				rtweeted = true;
				mediaData = val.retweeted_status.entities.hasOwnProperty('media') ? val.retweeted_status.extended_entities.media : "";
				original_retweeter = val.retweeted_status.user.screen_name;
				full_text = buildTwitterString(val.retweeted_status);
			}else {
				full_text = buildTwitterString(val);
			}

			// Date that the tweet was created at.
			var date = new Date(val.created_at);

			// Dictionary that stores the data to be sent to the template.
			var cardData = {
				created_date: date.toLocaleDateString("en-US") + ' @ ' + date.toLocaleTimeString("en-US"),
				realname: val.user.name,
				screenname: '@'+val.user.screen_name,
				content: full_text,
				retweeted: rtweeted,
				profile_pic: val.user.profile_image_url_https,
				original_tweeter: original_retweeter,
				media: mediaData,
				retweet_count: val.retweet_count,
				tweet_id: val.id_str
			};

			// Grab the template.
			var cardTemplate = $("#tweet-card-template").html();

			// Render the template.
			var card = Mustache.render(cardTemplate, cardData);

			// Append the card to the results div.
			$("#results").append(card);

			// Increment the number of tweets.
			foundTweetCount+=1;
		}
	});
	
	// Only run shapeshift if the screen is not of mobile size.
	if($(window).width() > MOBILE_WIDTH && foundTweetCount > 0) {
		$("#results").shapeshift({
			animationSpeed: 100
		});
	}
}
/*
* This function uses the Mustache templating library, and creates the tweet cards for display.
*
* @param tweetData The json object to parse for data to output to the tweet card.
*
*/
This function uses the Mustache templating library, and creates the tweet cards for display.
This function uses the Mustache templating library and creates the tweet cards for display .
function buildTweetCard(tweetData) {
	var foundTweets = tweetData;
	if(tweetData.hasOwnProperty('statuses')) {
		var foundTweets = tweetData.statuses;
	}
	$.each(foundTweets, function(key, val) {
		if(!val.possibly_sensitive) {
			var rtweeted = false;			
			var retweeted_text = "";		
			var original_retweeter = "";	
			var full_text = "";				
			var mediaData = val.entities.hasOwnProperty('media') ? val.extended_entities.media : "";	
			if(val.hasOwnProperty('retweeted_status')) {
				rtweeted = true;
				mediaData = val.retweeted_status.entities.hasOwnProperty('media') ? val.retweeted_status.extended_entities.media : "";
				original_retweeter = val.retweeted_status.user.screen_name;
				full_text = buildTwitterString(val.retweeted_status);
			}else {
				full_text = buildTwitterString(val);
			}
			var date = new Date(val.created_at);
			var cardData = {
				created_date: date.toLocaleDateString("en-US") + ' @ ' + date.toLocaleTimeString("en-US"),
				realname: val.user.name,
				screenname: '@'+val.user.screen_name,
				content: full_text,
				retweeted: rtweeted,
				profile_pic: val.user.profile_image_url_https,
				original_tweeter: original_retweeter,
				media: mediaData,
				retweet_count: val.retweet_count,
				tweet_id: val.id_str
			};
			var cardTemplate = $("#tweet-card-template").html();
			var card = Mustache.render(cardTemplate, cardData);
			$("#results").append(card);
			foundTweetCount+=1;
		}
	});
	if($(window).width() > MOBILE_WIDTH && foundTweetCount > 0) {
		$("#results").shapeshift({
			animationSpeed: 100
		});
	}
}
function buildTweetCard ( tweetData ) { var foundTweets = tweetData ; if ( tweetData . hasOwnProperty ( 'statuses' ) ) { var foundTweets = tweetData . statuses ; } $ . each ( foundTweets , function ( key , val ) { if ( ! val . possibly_sensitive ) { var rtweeted = false ; var retweeted_text = "" ; var original_retweeter = "" ; var full_text = "" ; var mediaData = val . entities . hasOwnProperty ( 'media' ) ? val . extended_entities . media : "" ; if ( val . hasOwnProperty ( 'retweeted_status' ) ) { rtweeted = true ; mediaData = val . retweeted_status . entities . hasOwnProperty ( 'media' ) ? val . retweeted_status . extended_entities . media : "" ; original_retweeter = val . retweeted_status . user . screen_name ; full_text = buildTwitterString ( val . retweeted_status ) ; } else { full_text = buildTwitterString ( val ) ; } var date = new Date ( val . created_at ) ; var cardData = { created_date : date . toLocaleDateString ( "en-US" ) + ' @ ' + date . toLocaleTimeString ( "en-US" ) , realname : val . user . name , screenname : '@' + val . user . screen_name , content : full_text , retweeted : rtweeted , profile_pic : val . user . profile_image_url_https , original_tweeter : original_retweeter , media : mediaData , retweet_count : val . retweet_count , tweet_id : val . id_str } ; var cardTemplate = $ ( "#tweet-card-template" ) . html ( ) ; var card = Mustache . render ( cardTemplate , cardData ) ; $ ( "#results" ) . append ( card ) ; foundTweetCount += 1 ; } } ) ; if ( $ ( window ) . width ( ) > MOBILE_WIDTH && foundTweetCount > 0 ) { $ ( "#results" ) . shapeshift ( { animationSpeed : 100 } ) ; } }
This function uses the Mustache templating library, and creates the tweet cards for display.
This function uses the Mustache templating library and creates the tweet cards for display .
// Check if the data coming in has a statuses object. // Parse through the found tweets, and seperate them into a key value pair. // Do not show tweets that are possibly sensitive. // Stores whether the tweet is a retweet or not. // Get the text of the retweet. // The original user that was retweeted. // The full text of the tweet. // The json object for media like pictures and videos. // Check if this tweet is, in fact, a retweet. // Date that the tweet was created at. // Dictionary that stores the data to be sent to the template. // Grab the template. // Render the template. // Append the card to the results div. // Increment the number of tweets. // Only run shapeshift if the screen is not of mobile size.