function search_tweets() {
	foundTweetCount = 0;						// Reset the found tweets to 0.
	$("#search_btn").addClass("is-loading");	// Show the search button as loading.
	$("#results").html("");						// Set the html of the results to empty.
	$("#results").css("height", "100%");		// Reset the height of the results.
	$("#results").trigger("ss-destroy");		// If there is a shapeshift object, destroy it for the new one.
	nextSetOfTweets = "";						// Set the next set of tweets back to nothing.

	// Validate the input of the tweet number.
	validate_input();

	// Get the search parameters for the search.
	var searchParameters = get_search_params();

	// Make the get request to the back end and query the Twitter API.
	$.get("scripts/php/search_twitter.php?"+searchParameters, function(response) {
		// Grab the incoming json data, and parse it from the response.
		var jsonData = JSON.parse(response);

		// Clear any errors that were shown before.
		$("#error_result").html("");

		// Check if there were errors from the response and display them.
		if(jsonData.hasOwnProperty('errors')) { 
			$.each(jsonData.errors, function(key, val) {
				$("#error_result").append(val.message + "<br>");
			});
		}else {
			if($(window).width() < MOBILE_WIDTH) {
				toggle_search();
			}

			// Check if there are more results to load for the given search query.
			if(jsonData.search_metadata.hasOwnProperty("next_results")) {
				nextSetOfTweets = jsonData.search_metadata.next_results;
			}else {
				nextSetOfTweets = "";
			}

			// Build the tweet card, and append it to the results.
			buildTweetCard(jsonData);
		}
	}).then(function() {
		// When the request has finished, stop showing the button as loading, and set the number of results found at the top.
		$("#search_btn").removeClass("is-loading");

		$("#found_results").html("Showing "+foundTweetCount+" tweets (scroll down to load more).");
	});
}
/*
* This function calls the twitter api, to make a search for the given parameters.
*/
This function calls the twitter api, to make a search for the given parameters.
This function calls the twitter api to make a search for the given parameters .
function search_tweets() {
	foundTweetCount = 0;						
	$("#search_btn").addClass("is-loading");	
	$("#results").html("");						
	$("#results").css("height", "100%");		
	$("#results").trigger("ss-destroy");		
	nextSetOfTweets = "";						
	validate_input();
	var searchParameters = get_search_params();
	$.get("scripts/php/search_twitter.php?"+searchParameters, function(response) {
		var jsonData = JSON.parse(response);
		$("#error_result").html("");
		if(jsonData.hasOwnProperty('errors')) { 
			$.each(jsonData.errors, function(key, val) {
				$("#error_result").append(val.message + "<br>");
			});
		}else {
			if($(window).width() < MOBILE_WIDTH) {
				toggle_search();
			}
			if(jsonData.search_metadata.hasOwnProperty("next_results")) {
				nextSetOfTweets = jsonData.search_metadata.next_results;
			}else {
				nextSetOfTweets = "";
			}
			buildTweetCard(jsonData);
		}
	}).then(function() {
		$("#search_btn").removeClass("is-loading");
		$("#found_results").html("Showing "+foundTweetCount+" tweets (scroll down to load more).");
	});
}
function search_tweets ( ) { foundTweetCount = 0 ; $ ( "#search_btn" ) . addClass ( "is-loading" ) ; $ ( "#results" ) . html ( "" ) ; $ ( "#results" ) . css ( "height" , "100%" ) ; $ ( "#results" ) . trigger ( "ss-destroy" ) ; nextSetOfTweets = "" ; validate_input ( ) ; var searchParameters = get_search_params ( ) ; $ . get ( "scripts/php/search_twitter.php?" + searchParameters , function ( response ) { var jsonData = JSON . parse ( response ) ; $ ( "#error_result" ) . html ( "" ) ; if ( jsonData . hasOwnProperty ( 'errors' ) ) { $ . each ( jsonData . errors , function ( key , val ) { $ ( "#error_result" ) . append ( val . message + "<br>" ) ; } ) ; } else { if ( $ ( window ) . width ( ) < MOBILE_WIDTH ) { toggle_search ( ) ; } if ( jsonData . search_metadata . hasOwnProperty ( "next_results" ) ) { nextSetOfTweets = jsonData . search_metadata . next_results ; } else { nextSetOfTweets = "" ; } buildTweetCard ( jsonData ) ; } } ) . then ( function ( ) { $ ( "#search_btn" ) . removeClass ( "is-loading" ) ; $ ( "#found_results" ) . html ( "Showing " + foundTweetCount + " tweets (scroll down to load more)." ) ; } ) ; }
This function calls the twitter api, to make a search for the given parameters.
This function calls the twitter api to make a search for the given parameters .
// Reset the found tweets to 0. // Show the search button as loading. // Set the html of the results to empty. // Reset the height of the results. // If there is a shapeshift object, destroy it for the new one. // Set the next set of tweets back to nothing. // Validate the input of the tweet number. // Get the search parameters for the search. // Make the get request to the back end and query the Twitter API. // Grab the incoming json data, and parse it from the response. // Clear any errors that were shown before. // Check if there were errors from the response and display them. // Check if there are more results to load for the given search query. // Build the tweet card, and append it to the results. // When the request has finished, stop showing the button as loading, and set the number of results found at the top.