summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--colordate.js40
-rw-r--r--crtsh-pem2html.go7
-rwxr-xr-xindex.html.gen1
-rw-r--r--tls-pem2html.go7
4 files changed, 53 insertions, 2 deletions
diff --git a/colordate.js b/colordate.js
new file mode 100644
index 0000000..a228eb5
--- /dev/null
+++ b/colordate.js
@@ -0,0 +1,40 @@
+(function() {
+ // in milliseconds
+ var now = Date.now();
+ var oneday = 1000*60*60*24;
+
+ var mapTo = function(iRange, oRange, iPoint) {
+ var pct = (iPoint - iRange[0])/(iRange[1]-iRange[0]);
+ if (pct < 0) {
+ pct = 0;
+ } else if (pct > 1) {
+ pct = 1;
+ }
+ var oPoint = oRange[0] + (pct * (oRange[1]-oRange[0]));
+ return oPoint;
+ }
+
+
+ var rgb = function(r, g, b) {
+ return "rgb(" + Math.trunc(r) + "," + Math.trunc(g) + "," + Math.trunc(b) + ")";
+ };
+
+ var date2color = function(t) {
+ var max = 0xF3;
+ var red = mapTo([now-oneday, now-(oneday/2)],
+ [max, 0],
+ t);
+ var green = mapTo([now-(oneday/2), now],
+ [0, max],
+ t);
+ return rgb(max-green, max-red, max-green-red);
+ };
+
+ var main = function() {
+ document.querySelectorAll('time.colordate').forEach(function(time) {
+ time.style.backgroundColor = date2color(Date.parse(time.dateTime));
+ });
+ };
+
+ document.addEventListener("DOMContentLoaded", main, false);
+})();
diff --git a/crtsh-pem2html.go b/crtsh-pem2html.go
index 0a64848..66961b1 100644
--- a/crtsh-pem2html.go
+++ b/crtsh-pem2html.go
@@ -32,9 +32,10 @@ var tmpl = template.Must(template.New("pem2html").
"green": green,
"date": fDate,
"datetime": fDateTime,
+ "colorDatetime": cDateTime,
}).Parse(`<table class=sortable>
<caption>
- <p>CT log (Updated {{.now | datetime}})</p>
+ <p>CT log (Updated {{.now | colorDatetime}})</p>
</caption>
<tr>
<th>Logged</th>
@@ -65,6 +66,10 @@ func fDateTime(t time.Time) template.HTML {
return template.HTML(t.Local().Format("<time datetime=\"2006-01-02 15:04:05\">2006-01-02 15:04:05</time>"))
}
+func cDateTime(t time.Time) template.HTML {
+ return template.HTML(t.Local().Format("<time class=colordate datetime=\"2006-01-02 15:04:05\">2006-01-02 15:04:05</time>"))
+}
+
func getNow() time.Time {
stat, err := os.Stdin.Stat()
if err == nil {
diff --git a/index.html.gen b/index.html.gen
index da0eae2..da0a0a7 100755
--- a/index.html.gen
+++ b/index.html.gen
@@ -7,6 +7,7 @@ echo '<!DOCTYPE html>
<title>Dashboard</title>
<link rel=stylesheet href=style.css>
<script src="sorttable.js"></script>
+ <script src="colordate.js"></script>
<link rel="stylesheet" type="text/css" href="jarmon-style/style.css" />
<link rel="stylesheet" type="text/css" href="jarmon-style/jquerytools.tabs.tabs-no-images.css" />
diff --git a/tls-pem2html.go b/tls-pem2html.go
index 8eb438c..5a9101e 100644
--- a/tls-pem2html.go
+++ b/tls-pem2html.go
@@ -32,9 +32,10 @@ var tmpl = template.Must(template.New("pem2html").
"green": green,
"date": fDate,
"datetime": fDateTime,
+ "colorDatetime": cDateTime,
}).Parse(`<table class=sortable>
<caption>
- <p>Live Certs (Updated {{.now | datetime}})</p>
+ <p>Live Certs (Updated {{.now | colorDatetime}})</p>
</caption>
<tr>
<th>NotBefore</th>
@@ -61,6 +62,10 @@ func fDateTime(t time.Time) template.HTML {
return template.HTML(t.Local().Format("<time datetime=\"2006-01-02 15:04:05\">2006-01-02 15:04:05</time>"))
}
+func cDateTime(t time.Time) template.HTML {
+ return template.HTML(t.Local().Format("<time class=colordate datetime=\"2006-01-02 15:04:05\">2006-01-02 15:04:05</time>"))
+}
+
func getNow() time.Time {
stat, err := os.Stdin.Stat()
if err == nil {