Permalink
Browse files

Allow getting upcomingEvents for any interval

  • Loading branch information...
1 parent 9b28c24 commit a4d4c4cbf78efb89b04b0e242c1f921e207d625c @akkana committed Mar 4, 2013
Showing with 25 additions and 4 deletions.
  1. +1 −1 jsjupiter/index.html
  2. +24 −3 jsjupiter/jupiter.js
View
@@ -242,7 +242,7 @@
return;
}
- upcoming.innerHTML = upcomingEvents(date);
+ upcoming.innerHTML = upcomingEvents(date, 8);
}
</script>
View
@@ -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;
if (!saveDate) {
//alert("upcoming events, but curdate is " + jup.curdate);
saveDate = date;
}
- tothrs = 8;
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" ];

0 comments on commit a4d4c4c

Please sign in to comment.