Recently I have been expanding my front end web development skill set to include JavaScript as well as incorporating DOM manipulation, AJAX, HTTP requests to 3rd party API’s, parsing of JSON responses, jQuery and other JavaScript libraries.
Below you can find a selection of personal JavaScript projects I have created to try out the new concepts I have covered.
The "Star Wars Character Profile's" page retrieves information on 85 Star Wars characters, including facts and details on their species, home world as well as films they have appeared in.
This project was my first experiment with AJAX and sending HTTP requests to 3rd party servers.
A web page that simulates tossing a coin for a user, presenting the results in both tabular and graphical form. This was my first implementation of a JavaScript library (Chart.js) other than jQuery.
Allows users to scrape data from webpages by implementing jQuery get request’s to submitted URL’s (concatenated to a proxy URL). HTML is received as a string and processed using vanilla JavaScript. Depending on options selected by the user link, image or image data is extracted from the response using regular expressions, loops and array processing.
Results are displayed in a table that is refreshed for each entered URL, and upon successful retrieval of results the ability to download the data as a .csv file is presented.
Using jQuery & AJAX, HTTP get requests are made to two URL's on a 3rd party server.
The first request receives data on the total number of people in space, their names and the craft they are on.
The second request receives data on the current position of the ISS.
The received JSON data is stored in objects and the properties are accessed and used to update selected HTML elements on the web page.
Using the setTimeout method of the HTML DOM Window Object the function that requests the ISS data and updates the latitude and longitude is called every 5 seconds.
3rd party web server
Open Notify is an open source project to provide a simple programming interface for some of NASA’s data
A webpage that displays the visitors IP address (and some additional location information). Using jQuery & AJAX, HTTP get requests are made to 3rd party web servers. The received data is in JSON format and the data from each request is stored in an object. The objects properties are accessed and stored as variables. HTML elements are selected based on their id’s and their contents are set to the strings stored in the variables.
3rd party web servers:
Displays corporate buzzwords generated from a 3rd party webserver, received from their API via AJAX using vanilla JavaScript.
Due to the “same-origin policy” and as an AJAX request is being made from one domain to another the “No 'Access-Control-Allow-Origin' header is present on the requested resource” error was encountered.
To get around this, and allow a request to be made from this domain to the 3rd party API, a proxy was used that creates requests to the 3rd party URL and includes CORS headers in the response. A proxy web server passes on the request from this site along with its headers.
At the click of a button the webpage generates a corporate buzzword loaded phrase.