Last Entry: out of date colored backgrounds

Adding warning + urgent colored backgrounds when BG is out of date by 10 or 20 minutes.
This commit is contained in:
Brian Hanifin
2014-07-29 00:00:55 -07:00
parent e5a2696ee0
commit d10df6b307
2 changed files with 22 additions and 3 deletions
+7
View File
@@ -59,6 +59,13 @@ body {
color: #000;
padding: 0.25em;
}
#lastEntry.warn {
background: #cc0;
}
#lastEntry.urgent {
background: #c00;
color: #000;
}
#chartContainer {
background: #111;
+15 -3
View File
@@ -1,6 +1,6 @@
(function () {
"use strict";
var retrospectivePredictor = true,
latestSGV,
treatments,
@@ -31,7 +31,9 @@
currentAlarmType = null,
alarmSound = 'alarm.mp3',
urgentAlarmSound = 'alarm2.mp3',
WIDTH_TIME_HIDDEN = 600;
WIDTH_TIME_HIDDEN = 600,
MINUTES_SINCE_LAST_UPDATE_WARN = 10,
MINUTES_SINCE_LAST_UPDATE_URGENT = 20;
// Tick Values
var tickValues = [40, 60, 80, 120, 180, 300, 400];
@@ -808,7 +810,7 @@
DAY = 86400,
WEEK = 604800;
if (offset <= MINUTE) parts = { lablel: 'now' };
if (offset <= MINUTE) parts = { label: 'now' };
if (offset <= MINUTE * 2) parts = { label: '1 min ago' };
else if (offset < (MINUTE * 60)) parts = { value: Math.round(Math.abs(offset / MINUTE)), label: 'mins' };
else if (offset < (HOUR * 2)) parts = { label: '1 hr ago' };
@@ -818,6 +820,16 @@
else if (offset < (WEEK * 52)) parts = { value: Math.round(Math.abs(offset / WEEK)), label: 'week' };
else parts = { label: 'a long time ago' };
if (offset > (MINUTE * MINUTES_SINCE_LAST_UPDATE_URGENT)) {
var lastEntry = $("#lastEntry");
lastEntry.removeClass("warn");
lastEntry.addClass("urgent");
} else if (offset > (MINUTE * MINUTES_SINCE_LAST_UPDATE_WARN)) {
var lastEntry = $("#lastEntry");
lastEntry.removeClass("urgent");
lastEntry.addClass("warn");
}
if (parts.value)
return parts.value + ' ' + parts.label + ' ago';
else