Skip to content

Commit

Permalink
Continuously update vague timestamps. This fixes issue #12
Browse files Browse the repository at this point in the history
  • Loading branch information
briktop committed Sep 30, 2013
1 parent 8aa6d6c commit d249653
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -23,7 +23,7 @@
"mu2": "~0.5.19",
"formidable": "~1.0.14",
"memorystream": "~0.2.0",
"vague-time": "~0.5.5"
"vague-time": "git://github.com/brikteknologier/vagueTime.js.git"
},
"devDependencies": {
"mocha": "~1.9.0",
Expand Down
1 change: 1 addition & 0 deletions subsystems/webui/static/vagueTime.js
23 changes: 23 additions & 0 deletions subsystems/webui/static/vagueTimeUpdater.js
@@ -0,0 +1,23 @@
document.addEventListener("DOMContentLoaded", function(event) {
var elements = document.getElementsByClassName("vagueTime");

for (var i = 0; i < elements.length; ++i) {
watchElement(elements[i]);
}

function watchElement(element) {
var since = new Date(element.getAttribute("data-since"));

function update() {
var now = new Date();
var results = vagueTime.get({
from: now,
to: since,
remaining: true
});
element.innerText = results.timeString;
setTimeout(update, results.remaining);
}
update();
}
});
6 changes: 4 additions & 2 deletions subsystems/webui/templates/index.mu.html
Expand Up @@ -43,6 +43,8 @@
}
});
</script>
<script src="static/vagueTime.js"></script>
<script src="static/vagueTimeUpdater.js"></script>
</head>
<body>
<h1>Actions</h1>
Expand Down Expand Up @@ -78,7 +80,7 @@ <h1>Currently running subprocesses</h1>
<tbody>
{{#running}}
<tr>
<td title="{{sincePrecise}}">{{since}}</td>
<td title="{{sincePrecise}}" data-since="{{sincePrecise}}" class="vagueTime">{{since}}</td>
<td><a href="subprocess/{{id}}">{{title}}</a></td>
</tr>
{{/running}}
Expand All @@ -97,7 +99,7 @@ <h1>Recently terminated subprocesses</h1>
<tbody>
{{#finished}}
<tr>
<td title="{{finishedPrecise}}">{{finished}}</td>
<td title="{{finishedPrecise}}" data-since="{{finishedPrecise}}" class="vagueTime">{{finished}}</td>
<td><a href="subprocess/{{id}}">{{title}}</a></td>
<td><span class="exec-status {{status_class}}">{{status}}</span></td>
</tr>
Expand Down

0 comments on commit d249653

Please sign in to comment.