forked from DLu/ros_clock
-
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.
- Loading branch information
0 parents
commit 3899d20
Showing
4 changed files
with
169 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
function pluralString(n, base) | ||
{ | ||
if (n == 0) return ""; | ||
else if (n == 1) return '1\xa0' + base + ', '; | ||
else return n + '\xa0' + base + 's, '; | ||
} | ||
|
||
function deltaToString(distance) | ||
{ | ||
distance /= 1000; // from milliseconds | ||
var seconds = Math.floor(distance % 60); | ||
distance -= seconds; | ||
distance /= 60; | ||
var minutes = Math.floor(distance % 60); | ||
distance = (distance - minutes) / 60; | ||
var hours = Math.floor(distance % 24); | ||
distance = (distance - hours) / 24; | ||
var days = Math.floor(distance % 365); | ||
distance = (distance - days) / 365; | ||
var years = Math.floor(distance); | ||
|
||
var s = pluralString(years, 'year') + pluralString(days, 'day'); | ||
s += pluralString(hours, 'hour') + pluralString(minutes, 'minute'); | ||
|
||
return s + seconds + "\xa0seconds"; | ||
} | ||
|
||
function updateDict() | ||
{ | ||
var now = new Date().getTime(); | ||
for (key in timing) | ||
{ | ||
var entry = timing[key]; | ||
if (!entry["start_t"]) entry["start_t"] = new Date(entry["start"]).getTime(); | ||
if (!entry["end_t"]) entry["end_t"] = new Date(entry["end"]).getTime(); | ||
if (!entry["lifespan"]) entry["lifespan"] = entry["end_t"] - entry["start_t"]; | ||
|
||
var start = new Date(timing[key]["start"]); | ||
if (entry["end_t"] < now) | ||
{ | ||
entry["status"] = "expired"; | ||
continue; | ||
} | ||
else if (now < entry["start_t"]) | ||
{ | ||
entry["status"] = "future"; | ||
entry["release"] = entry["start_t"] - now; | ||
} | ||
else | ||
{ | ||
entry["status"] = "active"; | ||
entry["age"] = now - entry["start_t"]; | ||
} | ||
entry["delta"] = entry["end_t"] - now; | ||
} | ||
} |
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,64 @@ | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<title>ROS Clock</title> | ||
<link href="https://fonts.googleapis.com/css?family=Press+Start+2P&display=swap" rel="stylesheet"> | ||
<link href="terminal.css" rel="stylesheet"> | ||
<script src="info.js"></script> | ||
<script src="countdown.js"></script> | ||
</head> | ||
<body> | ||
<h1>ROS Clock</h1> | ||
<div id="contents"></div> | ||
<script> | ||
function update() | ||
{ | ||
updateDict(); | ||
|
||
var contents = document.getElementById("contents"); | ||
contents.innerHTML = ''; | ||
|
||
for (key in timing) | ||
{ | ||
var entry = timing[key]; | ||
|
||
var row = document.createElement('div'); | ||
row.setAttribute('class', "row " + entry["status"]); | ||
contents.appendChild(row); | ||
|
||
var head = document.createElement('span'); | ||
head.setAttribute('class', 'distro') | ||
head.appendChild(document.createTextNode(key)); | ||
row.appendChild(head); | ||
|
||
row.appendChild(document.createTextNode(entry["status"])); | ||
|
||
if (entry["status"] != "expired") | ||
{ | ||
row.appendChild(document.createElement('br')); | ||
|
||
var countdown = document.createElement('span'); | ||
countdown.setAttribute('class', 'countdown') | ||
countdown.appendChild(document.createTextNode('Time Remaining: ')); | ||
countdown.appendChild(document.createTextNode(deltaToString(entry["delta"]))); | ||
row.appendChild(countdown); | ||
|
||
if (entry["status"] == "future") | ||
{ | ||
row.appendChild(document.createElement('br')); | ||
|
||
var countdown = document.createElement('span'); | ||
countdown.setAttribute('class', 'countdown') | ||
countdown.appendChild(document.createTextNode('Time to Release: ')); | ||
countdown.appendChild(document.createTextNode(deltaToString(entry["release"]))); | ||
row.appendChild(countdown); | ||
} | ||
} | ||
} | ||
} | ||
|
||
setInterval(update, 1000); | ||
update(); | ||
</script> | ||
</body> | ||
</html> |
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,21 @@ | ||
var timing = { | ||
//"boxturtle": {"start": "March 2, 2010", "end": ""}, | ||
//"cturtle": {"start": "August 2, 2010", "end": ""}, | ||
// "diamondback": {"start": "March 2, 2011", "end": ""}, | ||
//"electric": {"start": "August 30, 2011", "end": ""}, | ||
"fuerte": {"start": "April 23, 2012", "end": "Sept 4, 2013"}, | ||
"groovy": {"start": "Dec 31, 2012", "end": "July 1, 2014"}, | ||
"hydro": {"start": "Sept 4, 2013", "end": "May 1, 2015"}, | ||
"indigo": {"start": "July 22, 2014", "end": "April 1, 2019"}, | ||
"jade": {"start": "May 23, 2015", "end": "May 1, 2017"}, | ||
"kinetic": {"start": "May 23, 2016", "end": "April 1, 2021"}, | ||
"lunar": {"start": "May 23, 2017", "end": "May 1, 2019"}, | ||
"melodic": {"start": "May 23, 2018", "end": "May 1, 2023"}, | ||
"noetic": {"start": "May 1, 2020", "end": "May 1, 2025"}, | ||
"ardent": {"start": "Dec 1, 2017", "end": "Dec 1, 2018"}, | ||
"bouncy": {"start": "June 1, 2018", "end": "July 1, 2019"}, | ||
"crystal": {"start": "Dec 1, 2018", "end": "Dec 1, 2019"}, | ||
"dashing": {"start": "May 1, 2019", "end": "May 1, 2021"}, | ||
"eloquent": {"start": "November 1, 2019", "end": "November 1, 2021"}, | ||
"foxy": {"start": "May 1, 2020", "end": "May 1, 2023"}, | ||
} |
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,28 @@ | ||
body { | ||
font-family: 'Press Start 2P'; | ||
background-color: black; | ||
color: #00ff00; | ||
text-shadow: 0 0 11px #00ff00; | ||
} | ||
span.distro { | ||
display: inline-block; | ||
width: 150px; | ||
} | ||
div.row { | ||
width: 100%; | ||
border-style: dotted; | ||
border-width: 3px; | ||
} | ||
div.expired { | ||
color: #005500; | ||
border-color: #005500; | ||
font-size: small; | ||
} | ||
div.future { | ||
color: #00bb00; | ||
border-color: #009900; | ||
# font-size: small; | ||
} | ||
span.countdown { | ||
font-size: small; | ||
} |