Last active
February 16, 2018 15:33
-
-
Save primedime/4de2b68433cfa800ed4e17ea37c88354 to your computer and use it in GitHub Desktop.
get wait times and open/close hours for Disney Parks
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
const disneyMagicKingdom = new Themeparks.Parks.WaltDisneyWorldMagicKingdom(); | |
const epcot = new Themeparks.Parks.WaltDisneyWorldEpcot(); | |
const disneyHollywoodStudios = new Themeparks.Parks.WaltDisneyWorldHollywoodStudios(); | |
const disneyAnimalKingdom = new Themeparks.Parks.WaltDisneyWorldAnimalKingdom(); | |
const universalStudiosFlorida = new Themeparks.Parks.UniversalStudiosFlorida(); | |
const universalIslandsOfAdventure = new Themeparks.Parks.UniversalIslandsOfAdventure(); | |
const universalVolcanoBay = new Themeparks.Parks.UniversalVolcanoBay(); | |
const seaworldOrlando = new Themeparks.Parks.SeaworldOrlando(); | |
const buschGardensTampa = new Themeparks.Parks.BuschGardensTampaBay(); | |
let parks = [ | |
{park: disneyMagicKingdom, name: 'Magic Kingdom'}, | |
{park: epcot, name: 'Epcot'}, | |
{park: disneyHollywoodStudios, name: 'Hollywood Studios'}, | |
{park: disneyAnimalKingdom, name: 'Animal Kingdom'}, | |
{park: universalStudiosFlorida, name: 'Universal Studios'}, | |
{park: universalIslandsOfAdventure, name: 'Islands of Adventure'}, | |
{park: universalVolcanoBay, name: 'Volcano Bay'}, | |
{park: seaworldOrlando, name: 'Seaworld Orlando'}, | |
{park: buschGardensTampa, name: 'Busch Gardens'} | |
]; | |
getParksAvgWaitTimes(); | |
getParkHours(); | |
function getParksAvgWaitTimes() | |
{ | |
for (var i = 0; i < parks.length; i++) | |
{ | |
let parkObj = parks[i]; | |
parkObj.park.GetWaitTimes().then(function(rides) | |
{ | |
let avg = getAverageWaitTimes(rides); | |
console.log(Math.round(avg) + 'min - ' + parkObj.name); | |
}, console.error); | |
} | |
} | |
function getAverageWaitTimes(rides) | |
{ | |
const sum = 0; | |
for (var i=0, ride; ride=rides[i++];) { sum += ride.waitTime; } | |
let avg = sum / rides.length; | |
return avg; | |
} | |
function getParkHours() | |
{ | |
for (var i = 0; i < parks.length; i++) | |
{ | |
let parkObj = parks[i]; | |
parkObj.park.GetOpeningTimes().then(function(times) | |
{ | |
let openClose = getTodaysOpenClose(times); | |
console.log(parkObj.name + ' is open on ' + openClose.todaysDate + ' from: ' + openClose.openTime + " - " + openClose.closeTime); | |
}, console.error); | |
} | |
} | |
function getTodaysOpenClose(times) | |
{ | |
for (var i=0, time; time=times[i++];) | |
{ | |
if (time.date === disneyMagicKingdom.DateNow()) | |
{ | |
let openCloseObj = | |
{ | |
openTime : Moment(time.openingTime).format("h:mma"), | |
closeTime : Moment(time.closingTime).format("h:mma"), | |
todaysDate : Moment(disneyMagicKingdom.DateNow()).format("MMM Do") | |
}; | |
return openCloseObj; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment