Skip to content

Commit

Permalink
Write documentation for JS file and functions
Browse files Browse the repository at this point in the history
  • Loading branch information
jleung51 committed Aug 21, 2018
1 parent 162dd7b commit c1a4f11
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions pac-macro.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
* This Javascript file provides a function to generate a Pac Macro map
* with players and pacdots which are updated periodically.
*
*/

var script = document.createElement('script');
script.src = 'http://code.jquery.com/jquery-1.11.0.min.js';
script.type = 'text/javascript';
Expand Down Expand Up @@ -31,6 +37,8 @@ var map;
var players;
var pacdotList = [];

// This function returns a new Google Maps Marker object for a player
// Attributes are standardized for consistency.
function createPlayerMarker(title, iconUrl) {
return new google.maps.Marker({
icon: {
Expand All @@ -47,6 +55,7 @@ function createPlayerMarker(title, iconUrl) {
});
}

// This function generates the map and players, and initializes server updates.
function initMap() {
map = new google.maps.Map(document.getElementById('map'), {
center: mapLocation.downtownVancouver,
Expand All @@ -65,6 +74,8 @@ function initMap() {
setInterval(updatePlayers, 800);
}

// This function retrieves all Pacdot information from the server and updates
// the map upon changes.
function updatePacdots() {
var xhttp = new XMLHttpRequest();

Expand Down Expand Up @@ -109,6 +120,8 @@ function updatePacdots() {
}
}

// This function retrieves all Player information from the server and updates
// the map upon changes.
function updatePlayers() {
var xhttp = new XMLHttpRequest();

Expand Down

0 comments on commit c1a4f11

Please sign in to comment.