Skip to content

Commit

Permalink
Allow getting upcomingEvents for any interval
Browse files Browse the repository at this point in the history
  • Loading branch information
akkana committed Mar 4, 2013
1 parent 9b28c24 commit a4d4c4c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
2 changes: 1 addition & 1 deletion jsjupiter/index.html
Expand Up @@ -242,7 +242,7 @@
return; return;
} }


upcoming.innerHTML = upcomingEvents(date); upcoming.innerHTML = upcomingEvents(date, 8);
} }


</script> </script>
Expand Down
27 changes: 24 additions & 3 deletions jsjupiter/jupiter.js
Expand Up @@ -305,17 +305,38 @@ function Jupiter()
} }
} }


function upcomingEvents(date) function prettytime(tothrs)
{
if (tothrs < 24)
prettytime = tothrs + " hours";
else {
hrs = tothrs % 24;
days = (tothrs-hrs) / 24;
prettytime = days + " day";
if (days != 1)
prettytime += "s";

if (hrs == 1)
prettytime += ", 1 hour";
else if (hrs != 1)
prettytime += ", " + hrs + " hours";
}
return prettytime;
}

//
// Build a table of upcoming moon events for a given interval.
//
function upcomingEvents(date, tothrs)
{ {
var saveDate = jup.curdate; var saveDate = jup.curdate;
if (!saveDate) { if (!saveDate) {
//alert("upcoming events, but curdate is " + jup.curdate); //alert("upcoming events, but curdate is " + jup.curdate);
saveDate = date; saveDate = date;
} }


tothrs = 8;
interval = 1; // minutes interval = 1; // minutes
upcoming = "Moon events in the next " + tothrs + " hours:\n"; upcoming = "<b>Moon events in the next " + prettytime(tothrs) + "</b>\n\n";


moonnames = [ "Io", "Europa", "Ganymede", "Callisto" ]; moonnames = [ "Io", "Europa", "Ganymede", "Callisto" ];


Expand Down

0 comments on commit a4d4c4c

Please sign in to comment.