Added relative timestamps
Former-commit-id: 5ea7e7519cbe1059d9595a82229b7c7de3ef17bf
This commit is contained in:
parent
73ac1f8208
commit
fc41b60386
11 changed files with 3641 additions and 14 deletions
|
|
@ -62,7 +62,7 @@
|
|||
{{#detectedEvents}}
|
||||
<tr>
|
||||
<td>{{.getType()}}</td>
|
||||
<td>{{.getDeviceData().getTimestamp()}}</td>
|
||||
<td><span class="timestamp">{{.getDeviceData().getTimestamp()}}</span></td>
|
||||
<td>{{.getDeviceData()}}</td>
|
||||
<td>
|
||||
<div class="btn-toolbar pull-right">
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@
|
|||
</thead>
|
||||
{{#history}}
|
||||
<tr>
|
||||
<td>{{.timestamp}}</a></td>
|
||||
<td><span class="timestamp">{{.timestamp}}</span></td>
|
||||
<td>{{.data}}</td>
|
||||
</tr>
|
||||
{{/history}}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
<td><a href="?id={{.getId()}}">{{.getName()}}</a></td>
|
||||
<td>{{.getDeviceData().getClass().getSimpleName()}}</td>
|
||||
<td>{{.getDeviceData().getData()}}</td>
|
||||
<td>{{.getDeviceData().getTimestamp()}}</td>
|
||||
<td><span class="timestamp">{{.getDeviceData().getTimestamp()}}</span></td>
|
||||
<td>
|
||||
<form method="POST">
|
||||
<input type="hidden" name="action" value="-">
|
||||
|
|
|
|||
|
|
@ -1,5 +1,13 @@
|
|||
////////////////////////////////////// Definitions
|
||||
///////////////////////////////// Autostart
|
||||
$(function(){
|
||||
$(".toggle-switch").bootstrapSwitch();
|
||||
|
||||
$(".timestamp").relTimestamp();
|
||||
});
|
||||
|
||||
////////////////////////////////////// JQuery functions
|
||||
|
||||
// $.attr() # returns all attributes of an element
|
||||
(function(old) {
|
||||
$.fn.attr = function() {
|
||||
if(arguments.length === 0) {
|
||||
|
|
@ -20,8 +28,16 @@
|
|||
};
|
||||
})($.fn.attr);
|
||||
|
||||
$.fn.relTimestamp = function() {
|
||||
return this.each(function() {
|
||||
var timestamp = parseInt($(this).text());
|
||||
var timestampNow = Date.now();
|
||||
var timeDiff = timestampNow - timestamp;
|
||||
|
||||
///////////////////////////////// Autostart
|
||||
$(function(){
|
||||
$(".toggle-switch").bootstrapSwitch();
|
||||
});
|
||||
if(timeDiff < 24 * 60 * 60 * 1000) // less than 24 hours
|
||||
$(this).text(moment(timestamp).fromNow());
|
||||
else
|
||||
$(this).text(moment(timestamp).format("YYYY-MM-DD HH:mm"));
|
||||
return this;
|
||||
});
|
||||
};
|
||||
|
|
|
|||
3606
web-resource/js/moment.js
Executable file
3606
web-resource/js/moment.js
Executable file
File diff suppressed because it is too large
Load diff
|
|
@ -17,6 +17,7 @@
|
|||
<script src="js/jquery-1.11.3.min.js"></script>
|
||||
<script src="js/bootstrap.min.js"></script>
|
||||
<script src="js/bootstrap-switch.min.js"></script>
|
||||
<script src="js/moment.js"></script>
|
||||
<script src="js/hal.js"></script>
|
||||
|
||||
<script src="js/raphael.min.js"></script>
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@
|
|||
{{#detectedSensors}}
|
||||
<tr>
|
||||
<td>{{.getType()}}</td>
|
||||
<td>{{.getDeviceData().getTimestamp()}}</td>
|
||||
<td><span class="timestamp">{{.getDeviceData().getTimestamp()}}</span></td>
|
||||
<td>{{.getDeviceData()}}</td>
|
||||
<td>
|
||||
<div class="btn-toolbar pull-right">
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@
|
|||
</thead>
|
||||
{{#history}}
|
||||
<tr>
|
||||
<td>{{.timestamp}}</a></td>
|
||||
<td><span class="timestamp">{{.timestamp}}</span></td>
|
||||
<td>{{.data}}</td>
|
||||
</tr>
|
||||
{{/history}}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
<td><a href="?id={{.getId()}}">{{.getName()}}</a></td>
|
||||
<td>{{.getDeviceData().getClass().getSimpleName()}}</td>
|
||||
<td>{{.getDeviceData().getData()}}</td>
|
||||
<td>{{.getDeviceData().getTimestamp()}}</td>
|
||||
<td><span class="timestamp">{{.getDeviceData().getTimestamp()}}</span></td>
|
||||
</tr>
|
||||
{{/sensors}}
|
||||
</table>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue