-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from rickcrawford/master
latest code
- Loading branch information
Showing
11 changed files
with
924 additions
and
445 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
.tags* | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
|
||
var CENTRES = { | ||
"annapolis": "annapolis", | ||
"brandon": "brandon", | ||
"broward": "broward", | ||
"century city": "centurycity", | ||
"citrus park": "citruspark", | ||
"countryside": "countryside", | ||
"culver city": "culvercity", | ||
"fashion square": "fashionsquare", | ||
"galleria at roseville": "galleriaatroseville", | ||
"galleria roseville": "galleriaatroseville", | ||
"galleria": "galleriaatroseville", | ||
"roseville": "galleriaatroseville", | ||
"roseville galleria": "galleriaatroseville", | ||
"garden state plaza": "gardenstateplaza", | ||
"garden state": "gardenstateplaza", | ||
"horton plaza": "hortonplaza", | ||
"horton": "hortonplaza", | ||
"meriden": "meriden", | ||
"mission valley": "missionvalley", | ||
"montgomery": "montgomery", | ||
"north county": "northcounty", | ||
"oakridge": "oakridge", | ||
"old orchard": "oldorchard", | ||
"palm desert": "palmdesert", | ||
"plaza bonita": "plazabonita", | ||
"san francisco": "sanfrancisco", | ||
"san francisco centre": "sanfrancisco", | ||
"santa anita": "santaanita", | ||
"sarasota square": "sarasota", | ||
"southcenter": "southcenter", | ||
"southgate": "southgate", | ||
"south shore": "southshore", | ||
"sunrise": "sunrise", | ||
"topanga and the village": "topanga", | ||
"topanga": "topanga", | ||
"trumbull": "trumbull", | ||
"utc": "utc", | ||
"valencia town center": "valencia", | ||
"valley fair": "valleyfair", | ||
"wheaton": "wheaton", | ||
"world trade center": "westfieldworldtradecenter", | ||
"world trade": "westfieldworldtradecenter" | ||
}; | ||
|
||
var CENTRE_NAMES = [ | ||
"annapolis", | ||
"brandon", | ||
"broward", | ||
"century city", | ||
"citrus park", | ||
"countryside", | ||
"culver city", | ||
"fashion square", | ||
"galleria at roseville", | ||
"garden state plaza", | ||
"horton plaza", | ||
"horton", | ||
"meriden", | ||
"mission valley", | ||
"montgomery", | ||
"north county", | ||
"oakridge", | ||
"old orchard", | ||
"palm desert", | ||
"plaza bonita", | ||
"san francisco centre", | ||
"santa anita", | ||
"sarasota square", | ||
"southcenter", | ||
"southgate", | ||
"south shore", | ||
"sunrise", | ||
"topanga and the village", | ||
"trumbull", | ||
"utc", | ||
"valencia town center", | ||
"valley fair", | ||
"wheaton", | ||
"world trade center" | ||
]; | ||
|
||
module.exports = { | ||
CENTRE_NAMES: CENTRE_NAMES, | ||
CENTRES: CENTRES | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
var http = require('https'); | ||
|
||
var getEventsByCenter = function (centreId, callback) { | ||
requestEvents(process.env["WF_EVENTS_API_ENDPOINT"] + "?api_key=" + process.env["WF_API_KEY"], "¢re_id=" + centreId + "&fields=name%2Cdescription%2Clocations&per_page=3&status=active", function(err, data) { | ||
if (err) { | ||
return callback(err) | ||
} | ||
|
||
return callback(err, data) | ||
}) | ||
} | ||
|
||
var requestEvents = function (endpoint, queryString, callback) { | ||
http.get(endpoint + queryString, function (res) { | ||
var responseString = ''; | ||
console.log('Status Code: ' + res.statusCode); | ||
|
||
if (res.statusCode != 200) { | ||
callback(new Error("Non 200 Response")); | ||
} | ||
|
||
res.on('data', function (data) { | ||
responseString += data; | ||
}); | ||
|
||
res.on('end', function () { | ||
var responseObject = JSON.parse(responseString); | ||
|
||
if (responseObject.error) { | ||
console.log("NOAA error: " + responseObject.error.message); | ||
callback(new Error(responseObject.error.message)); | ||
} else { | ||
callback(null, responseObject); | ||
} | ||
}); | ||
}).on('error', function (e) { | ||
console.log("Communications error: " + e.message); | ||
callback(new Error(e.message)); | ||
}); | ||
} | ||
|
||
module.exports = { | ||
getEventsByCenter : getEventsByCenter | ||
} |
Oops, something went wrong.