diff --git a/lib/iob.js b/lib/iob.js index b4800f133..8eb4a109e 100644 --- a/lib/iob.js +++ b/lib/iob.js @@ -2,8 +2,6 @@ function calcTotal(treatments, profile, time) { - console.info("trying to calc"); - var iob = 0 , activity = 0; diff --git a/static/css/drawer.css b/static/css/drawer.css index 035340ab6..1a3881825 100644 --- a/static/css/drawer.css +++ b/static/css/drawer.css @@ -176,6 +176,7 @@ h1, legend, vertical-align: middle; position: absolute; right: 0; + z-index: 500; } #buttonbar a, diff --git a/static/css/main.css b/static/css/main.css index 020fbd4a7..83004ec51 100644 --- a/static/css/main.css +++ b/static/css/main.css @@ -12,21 +12,8 @@ body { font-family: 'Open Sans', Helvetica, Arial, sans-serif; fill: #fff; background: #000; - color: #808080; -} - - -/* BEGIN: Dolphin/Stock Android Browser Fix */ -@media (max-width: 400px) { - .bgStatus { - width: 100% !important; - } -} -#chartContainer { - top: 225px; /*(toolbar height + status height)*/ + color: #bdbdbd; } -/* END: Dolphin/Stock Android Browser Fix */ - .container { bottom: 0; @@ -49,78 +36,74 @@ body { .bgStatus { float: right; - font-size: 750%; - margin-right: 25px; text-align: center; white-space: nowrap; } -.bgStatus .currentBG { - text-decoration: line-through; + +.bgButton.urgent { + color: red; } -.bgStatus .currentBG.error-code { - font-size: 80%; +.bgButton.warning { + color: yellow; } -.bgStatus .currentBG.bg-limit { - font-size: 80%; +.bgButton.inrange { + color: #4cff00; } -.bgStatus .currentDetails { - font-size: 25%; - position: relative; - top: -10px; +.bgStatus .currentBG { + font-size: 120px; + line-height: 100px; + text-decoration: line-through; + vertical-align: middle; } -.currentDetails > span { - border-radius: 5px; - border: 2px solid #bdbdbd; - font-size: 80%; +.bgStatus .currentDirection { + font-weight: normal; + text-decoration: none; + font-size: 90px; + line-height: 90px; + vertical-align: middle; } -#bgButton .currentDetails > span { - border-color: #000; +.bgStatus .currentDetails { + font-size: 20px; } .currentDetails > span:not(:first-child) { margin-left: 5px; } -.currentDetails > span * { +span.pill { + white-space: nowrap; + border-radius: 5px; + border: 2px solid #bdbdbd; +} + +span.pill * { padding-left: 2px; padding-right: 2px; - padding-bottom: 1px; } -.currentDetails > span em { - color: #bdbdbd; +span.pill em { font-style: normal; font-weight: bold; } -.currentDetails > span label { +span.pill label { color: #000; background: #bdbdbd; } -#bgButton .currentDetails > span label { - color: #bdbdbd; - background: inherit; -} - .bgStatus.current .currentBG { text-decoration: none; } -.currentDirection { - font-weight: normal; - text-decoration: none; - font-size: 90%; - vertical-align: top; -} - .time { - font-size: 600%; + color: #808080; + font-size: 100px; + line-height: 100px; padding-top: 15px; } .timebox { @@ -128,30 +111,51 @@ body { width: 250px; } .timeOther { - font-size: 25%; + font-size: 20px; + line-height: 30px; } #lastEntry { background: #808080; - border-radius: 5px; - color: #000; - padding: 0.25em; + border-color: #808080; } -#lastEntry.warn { - background: #cc0 !important; + +#lastEntry.pill em { + color: #808080; + background: #000; +} + +#lastEntry.pill label { + background: #808080; +} + +#lastEntry.warn, #lastEntry.warn label { + background: yellow; + border-color: yellow; +} +#lastEntry.warn em { + color: yellow; } -#lastEntry.urgent { - background: #c00 !important; + +#lastEntry.urgent, #lastEntry.urgent label { + background: red; + border-color: red; +} +#lastEntry.urgent em { + color: red; } #chartContainer { - background: #111; + top: 225px; /*(toolbar height + status height)*/ + left:0; + right:0; bottom:0; - display: block; height:auto; - left:0; + font-size: 20px; + background: #111; + display: block; position:absolute; - right:0; } + #chartContainer svg { height: calc(100vh - (180px + 45px)); width: 100%; @@ -169,7 +173,7 @@ body { shape-rendering: crispEdges; } .grid path, .axis line { - stroke: #808080; + stroke: #bdbdbd; stroke-opacity: 1; } @@ -180,49 +184,40 @@ body { } -#noButton { - padding: 2px; -} - -#bgButton, #silenceBtn { z-index: 99; + border-radius: 5px; + border: 2px solid #bdbdbd; } -#bgButton { - background: yellow; - border: 2px solid #DDD; - border-right: 2px solid #ccc; - border-bottom: 2px solid #ccc; - border-radius: 5px; - box-shadow: 2px 4px 6px #ddd; - color: #000000; - cursor: default; - font-size: 75%; - margin-top: 15px; - width: auto; - - user-select: none; - -moz-border-radius: 5px; - -webkit-border-radius: 5px; - -moz-box-shadow: 2px 2px 4px #ddd; - -webkit-box-shadow: 2px 2px 4px #ddd; - -webkit-touch-callout: none; - -webkit-user-select: none; - -khtml-user-select: none; - -moz-user-select: none; - -ms-user-select: none; -} - -#bgButton.urgent { - background: red; -} - -.bgButton:active { - background: #850406; - border: 2px solid #999; - box-shadow: none; +#silenceBtn * { + font-size: 40px +} +.bgButton { + margin: 10px; + border: 2px solid #000; + border-radius: 5px; + width: 320px; +} + +.alarming .bgButton { + border-color: #bdbdbd; + color: #000; + box-shadow: 2px 4px 6px #ddd; +} + +.alarming .bgButton.urgent { + background-color: red; +} + +.alarming .bgButton.warning { + background-color: yellow; +} + +.alarming .bgButton:active { + border: 2px solid #bdbdbd; + box-shadow: none; -moz-box-shadow: none; -webkit-box-shadow: none; } @@ -233,135 +228,142 @@ body { margin: 10px auto; } -div.tooltip { - position: absolute; - text-align: left; - width: fit-content; - height: fit-content; - padding: 2px; - font: 14px sans-serif; - background: white; - border: 0px; - border-radius: 8px; - pointer-events: none; -} - -#silenceBtn, #silenceBtn * { - font-size: 70%; +div.tooltip { + color: #444; + position: absolute; + text-align: left; + padding: 4px; + font-size: 14px; + line-height: 15px; + background: white; + border: 0; + border-radius: 8px; + pointer-events: none; } .alarms { display: none; } -#testAlarms { - font-size: 20%; -} +@media (max-width: 800px) { + .bgStatus { + width: 40%; + } -#currentTime{ - padding: 0 0 10px 0; -} + .bgButton { + width: auto; + } -/* Large desktop */ -@media (min-width: 980px) { - .content { - padding-top: 20px; + .bgStatus .currentBG { + font-size: 80px; + line-height: 80px; } - .linediv-l { - border-right: 1px white solid; + + .bgStatus .currentDirection { + font-size: 70px; + line-height: 70px; } - .linedic-r { - border-left: 1px white solid; + + .time { + font-size: 70px; + line-height: 60px; } -} -@media (max-width: 800px) { - #chartContainer { - font-size: 80%; - } + .timeOther { + font-size: 15px; + line-height: 40px; + } - .bgStatus { - width: 50%; - font-size: 650%; - } + #silenceBtn * { + font-size: 30px; + } - .dropdown-menu { - font-size: 60% !important; - } - #currentTime { - font-size: 85%; - } + #chartContainer { + top: 185px; + } + #chartContainer svg { + height: calc(100vh - 185px); + } } @media (max-width: 750px) { - .dropdown-menu { - font-size: 60% !important; - } + .bgStatus { + width: 60%; + } - .container .status { - font-size: 70%; - } + .bgStatus .currentBG { + font-size: 70px; + line-height: 60px; + } - .bgStatus .currentDetails { - top: 0; - } + .bgStatus .currentDirection { + font-size: 50px; + line-height: 50px; + } - #chartContainer { - top: 165px; - font-size: 80%; - } - #chartContainer svg { - height: calc(100vh - 165px); - } + .bgStatus .currentDetails { + font-size: 15px; + } -} + .time { + font-size: 50px; + line-height: 40px; + width: 250px; + } -@media (max-width: 400px) { - body { - font-size: 70%; + #chartContainer { + top: 165px; + } + #chartContainer svg { + height: calc(100vh - 165px); } +} + +@media (max-width: 400px) { .status { text-align: center; margin-bottom: 0; height: 152px; } - /* Unremark to test alert/silence button + menu. */ - /* #noButton {display:none;} - #bgButton {display:block;} */ - .bgStatus { - font-size: 750%; float: none; margin: 0 auto; padding: 0; - text-align: center; width: 100vw; } - .bgStatus .currentDetails { - top: -10px; + .bgButton { + margin: 5px; + width: auto; } - #bgButton { - font-size: 100%; + .bgStatus .currentBG { + font-size: 70px; + line-height: 70px; } + + .bgStatus .currentDirection { + font-size: 60px; + line-height: 60px; + } + + .bgStatus .currentDetails { + font-size: 15px; + } + .dropdown-menu { - font-size: 60% !important; + font-size: 50px !important; margin-left: 2vw; width: 96vw; } - .container .status { - font-size: 100% !important; - } .time { - margin-bottom: 0.1em; - margin-top: -1em; - margin-left: 0; - width: 100%; + width: auto; + padding-top: 0; + font-size: 20px !important; } #container.alarming .time { @@ -369,21 +371,21 @@ div.tooltip { } .timebox { - text-align: none; width: auto; } + #currentTime { display: inline; - font-size: 25% !important; - font-weight: bold; + vertical-align: middle; } + .timeOther { display: inline; margin-left: auto; + font-size: 15px; } #chartContainer { - font-size: 110% !important; top: 210px; } #chartContainer svg { @@ -391,6 +393,18 @@ div.tooltip { } } +@media (max-height: 700px) { + #chartContainer { + font-size: 15px; + } +} + +@media (max-height: 600px) { + #chartContainer { + font-size: 12px; + } +} + @media (max-height: 480px) { #toolbar { float: right; @@ -406,13 +420,9 @@ div.tooltip { padding-bottom: 20px; } - #currentTime { - font-size: 85%; - } - #chartContainer { top: 130px; - font-size: 80%; + font-size: 10px; } #chartContainer svg { height: calc(100vh - 130px); @@ -420,13 +430,45 @@ div.tooltip { } @media (max-height: 480px) and (min-width: 400px) { - .container .status { - font-size: 70%; + .bgStatus .currentBG { + font-size: 80px; + line-height: 80px; + } + + .bgStatus .currentDirection { + font-size: 70px; + line-height: 70px; + } + + .bgStatus .currentDetails { + font-size: 15px; + } + + .time { + font-size: 70px; + line-height: 60px; + } + + .timeOther { + font-size: 15px; } + } @media (max-height: 480px) and (max-width: 400px) { - .container .status { - font-size: 80% !important; + + .bgStatus .currentBG { + font-size: 60px; + line-height: 60px; + } + + .bgStatus .currentDirection { + font-size: 50px; + line-height: 50px; } + + .bgStatus .currentDetails { + font-size: 15px; + } + } diff --git a/static/index.html b/static/index.html index 703c87db5..f12f8a41a 100644 --- a/static/index.html +++ b/static/index.html @@ -27,16 +27,9 @@

Nightscout

-
+
--- - -
--
- -
- +
---
- --- + -
diff --git a/static/js/client.js b/static/js/client.js index cddc7f913..4db9acee5 100644 --- a/static/js/client.js +++ b/static/js/client.js @@ -19,6 +19,10 @@ var app = {}, browserSettings = {}, browserStorage = $.localStorage; , FORMAT_TIME_SCALE = '%I %p' , WIDTH_SMALL_DOTS = 400 , WIDTH_BIG_DOTS = 800 + , MINUTE_IN_SECS = 60 + , HOUR_IN_SECS = 3600 + , DAY_IN_SECS = 86400 + , WEEK_IN_SECS = 604800 , MINUTES_SINCE_LAST_UPDATE_WARN = 10 , MINUTES_SINCE_LAST_UPDATE_URGENT = 20; @@ -30,7 +34,7 @@ var app = {}, browserSettings = {}, browserStorage = $.localStorage; , treatments , profile , cal - , padding = { top: 20, right: 10, bottom: 30, left: 10 } + , padding = { top: 0, right: 10, bottom: 30, left: 10 } , opacity = {current: 1, DAY: 1, NIGHT: 0.5} , now = Date.now() , data = [] @@ -158,7 +162,7 @@ var app = {}, browserSettings = {}, browserStorage = $.localStorage; .scale(xScale) .tickFormat(d3.time.format(getTimeFormat(true))) .ticks(4) - .orient('top'); + .orient('bottom'); yAxis = d3.svg.axis() .scale(yScale) @@ -228,12 +232,16 @@ var app = {}, browserSettings = {}, browserStorage = $.localStorage; .style('opacity', function (d) { return highlightBrushPoints(d) }); } + function alarmingNow() { + return $('#container').hasClass('alarming'); + } + function inRetroMode() { if (!brush) return false; - var brushExtent = brush.extent(); - var elementHidden = document.getElementById('bgButton').hidden == ''; - return brushExtent[1].getTime() - THIRTY_MINS_IN_MS < now && elementHidden != true; + var time = brush.extent()[1].getTime(); + + return !alarmingNow() && time - THIRTY_MINS_IN_MS < now; } function errorCodeToDisplay(errorCode) { @@ -301,7 +309,9 @@ var app = {}, browserSettings = {}, browserStorage = $.localStorage; var currentBG = $('.bgStatus .currentBG') , currentDirection = $('.bgStatus .currentDirection') - , currentDetails = $('.bgStatus .currentDetails'); + , currentDetails = $('.bgStatus .currentDetails') + , lastEntry = $('#lastEntry'); + function updateCurrentSGV(value) { if (value < 39) { @@ -318,46 +328,53 @@ var app = {}, browserSettings = {}, browserStorage = $.localStorage; currentBG.toggleClass('bg-limit', value == 39 || value > 400); } - function calcBGDelta(prev, current) { + function updateBGDelta(prev, current) { - var bgDeltaString; + var pill = currentDetails.find('span.pill.bgdelta'); + if (!pill || pill.length == 0) { + pill = $(''); + currentDetails.append(pill); + } - if (prev < 40 || prev > 400 || current < 40 || current > 400) { - bgDeltaString = ''; + if (prev === undefined || current == undefined || prev < 40 || prev > 400 || current < 40 || current > 400) { + pill.children('em').text('#'); } else { var bgDelta = scaleBg(current) - scaleBg(prev); if (browserSettings.units == 'mmol') { bgDelta = bgDelta.toFixed(1); } - bgDeltaString = bgDelta; - if (bgDelta >= 0) { - bgDeltaString = '+' + bgDelta; - } - - bgDeltaString = '' + bgDeltaString + ''; + if (browserSettings.units == 'mmol') { + pill.children('label').text('mmol/L'); + } else { + pill.children('label').text('mg/dL'); + } - return bgDeltaString; } - function buildIOBIndicator(time) { - var iob = Nightscout.iob.calcTotal(treatments, profile, time); - return '' + iob.display + 'U'; - } + function updateIOBIndicator(time) { + if (showIOB()) { + var pill = currentDetails.find('span.pill.iob'); - var color = inRetroMode() ? 'grey' : sgvToColor(latestSGV.y); + if (!pill || pill.length == 0) { + pill = $(''); + currentDetails.append(pill); + } + var iob = Nightscout.iob.calcTotal(treatments, profile, time); + pill.find('em').text(iob.display + 'U'); + } else { + currentDetails.find('.pill.iob').remove(); + } + } - $('.container #noButton .currentBG').css({color: color}); - $('.container #noButton .currentDirection').css({color: color}); + if (inRetroMode()) { + $('.bgButton').removeClass('urgent warning inrange'); + } else { + $('.bgButton').addClass(sgvToColoredRange(latestSGV.y)); + } // predict for retrospective data // by changing lookback from 1 to 2, we modify the AR algorithm to determine its initial slope from 10m @@ -393,26 +410,23 @@ var app = {}, browserSettings = {}, browserStorage = $.localStorage; updateCurrentSGV(focusPoint.y); - var details = calcBGDelta(prevfocusPoint.y, focusPoint.y); - - if (showIOB()) { - details += buildIOBIndicator(time); - } + updateBGDelta(prevfocusPoint.y, focusPoint.y); currentBG.css('text-decoration','line-through'); currentDirection.html(focusPoint.y < 39 ? '✖' : focusPoint.direction); - currentDetails.html(details); } else { + updateBGDelta(); currentBG.text('---'); currentDirection.text('-'); - currentDetails.text(''); } + updateIOBIndicator(time); + $('#currentTime') .text(formatTime(time)) .css('text-decoration','line-through'); - $('#lastEntry').text('RETRO').removeClass('current'); + updateTimeAgo(); } else { // if the brush comes back into the current time range then it should reset to the current time and sg nowData = nowData.slice(nowData.length - 1 - lookback, nowData.length); @@ -422,15 +436,11 @@ var app = {}, browserSettings = {}, browserStorage = $.localStorage; updateClockDisplay(); updateTimeAgo(); - var details = calcBGDelta(prevSGV.y, latestSGV.y); - - if (showIOB()) { - details += buildIOBIndicator(nowDate); - } + updateBGDelta(prevSGV.y, latestSGV.y); + updateIOBIndicator(nowDate); currentBG.css('text-decoration', ''); currentDirection.html(latestSGV.y < 39 ? '✖' : latestSGV.direction); - currentDetails.html(details); } xScale.domain(brush.extent()); @@ -679,7 +689,7 @@ var app = {}, browserSettings = {}, browserStorage = $.localStorage; focus.append('line') .attr('class', 'now-line') .attr('x1', xScale(new Date(now))) - .attr('y1', yScale(scaleBg(36))) + .attr('y1', yScale(scaleBg(30))) .attr('x2', xScale(new Date(now))) .attr('y2', yScale(scaleBg(420))) .style('stroke-dasharray', ('3, 3')) @@ -953,6 +963,27 @@ var app = {}, browserSettings = {}, browserStorage = $.localStorage; return color; } + function sgvToColoredRange(sgv) { + var range = ''; + + if (browserSettings.theme == 'colors') { + if (sgv > app.thresholds.bg_high) { + range = 'urgent'; + } else if (sgv > app.thresholds.bg_target_top) { + range = 'warning'; + } else if (sgv >= app.thresholds.bg_target_bottom && sgv <= app.thresholds.bg_target_top) { + range = 'inrange'; + } else if (sgv < app.thresholds.bg_low) { + range = 'urgent'; + } else if (sgv < app.thresholds.bg_target_bottom) { + range = 'warning'; + } + } + + return range; + } + + function generateAlarm(file) { alarmInProgress = true; var selector = '.audio.alarms audio.' + file; @@ -961,14 +992,8 @@ var app = {}, browserSettings = {}, browserStorage = $.localStorage; playAlarm(audio); $(this).addClass('playing'); }); - var bgButton = $('#bgButton'); - bgButton.show(); - bgButton.toggleClass('urgent', file == urgentAlarmSound); - var noButton = $('#noButton'); - noButton.hide(); + $('.bgButton').addClass(file == urgentAlarmSound ? 'urgent' : 'warning'); $('#container').addClass('alarming'); - $('.container .currentBG').text(); - } function playAlarm(audio) { @@ -982,11 +1007,8 @@ var app = {}, browserSettings = {}, browserStorage = $.localStorage; function stopAlarm(isClient, silenceTime) { alarmInProgress = false; - var bgButton = $('#bgButton'); - bgButton.hide(); - var noButton = $('#noButton'); - noButton.show(); - d3.selectAll('audio.playing').each(function (d, i) { + $('.bgButton').removeClass('urgent warning'); + d3.selectAll('audio.playing').each(function () { var audio = this; audio.pause(); $(this).removeClass('playing'); @@ -1001,45 +1023,34 @@ var app = {}, browserSettings = {}, browserStorage = $.localStorage; } } - function timeAgo(offset) { - var parts = {}, - MINUTE = 60, - HOUR = 3600, - DAY = 86400, - WEEK = 604800; - - //offset = (MINUTE * MINUTES_SINCE_LAST_UPDATE_WARN) + 60 - //offset = (MINUTE * MINUTES_SINCE_LAST_UPDATE_URGENT) + 60 - - 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' }; - else if (offset < (HOUR * 24)) parts = { value: Math.round(Math.abs(offset / HOUR)), label: 'hrs' }; - else if (offset < DAY) parts = { label: '1 day ago' }; - else if (offset < (DAY * 7)) parts = { value: Math.round(Math.abs(offset / DAY)), label: 'day' }; - 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'); - - $('.bgStatus').removeClass('current'); - } else if (offset > (MINUTE * MINUTES_SINCE_LAST_UPDATE_WARN)) { - var lastEntry = $('#lastEntry'); - lastEntry.removeClass('urgent'); - lastEntry.addClass('warn'); + function timeAgo(time) { + var now = Date.now() + , offset = time == -1 ? -1 : (now - time) / 1000 + , parts = {}; + + if (offset < MINUTE_IN_SECS * -5) parts = { label: 'in the future' }; + else if (offset <= 0) parts = { label: 'time ago' }; + else if (offset <= MINUTE_IN_SECS * 2) parts = { value: 1, label: 'min ago' }; + else if (offset < (MINUTE_IN_SECS * 60)) parts = { value: Math.round(Math.abs(offset / MINUTE_IN_SECS)), label: 'mins ago' }; + else if (offset < (HOUR_IN_SECS * 2)) parts = { value: 1, label: 'hr ago' }; + else if (offset < (HOUR_IN_SECS * 24)) parts = { value: Math.round(Math.abs(offset / HOUR_IN_SECS)), label: 'hrs ago' }; + else if (offset < DAY_IN_SECS) parts = { value: 1, label: 'day ago' }; + else if (offset < (DAY_IN_SECS * 7)) parts = { value: Math.round(Math.abs(offset / DAY_IN_SECS)), label: 'day ago' }; + else if (offset < (WEEK_IN_SECS * 52)) parts = { value: Math.round(Math.abs(offset / WEEK_IN_SECS)), label: 'week ago' }; + else parts = { label: 'a long time ago' }; + + if (offset < MINUTE_IN_SECS * -5 || offset > (MINUTE_IN_SECS * MINUTES_SINCE_LAST_UPDATE_URGENT)) { + parts.removeClass = 'current warn'; + parts.addClass = 'urgent'; + } else if (offset > (MINUTE_IN_SECS * MINUTES_SINCE_LAST_UPDATE_WARN)) { + parts.removeClass = 'current urgent'; + parts.addClass = 'warn'; } else { - $('.bgStatus').addClass('current'); - $('#lastEntry').removeClass('warn urgent'); + parts.addClass = 'current'; + parts.removeClass = 'warn urgent'; } - if (parts.value) - return parts.value + ' ' + parts.label + ' ago'; - else - return parts.label; + return parts; } @@ -1139,8 +1150,7 @@ var app = {}, browserSettings = {}, browserStorage = $.localStorage; .attr('id', 'label') .style('fill', 'white'); label.append('text') - .style('font-size', 30 / scale) - .style('font-family', 'Arial') + .style('font-size', 40 / scale) .style('text-shadow', '0px 0px 10px rgba(0, 0, 0, 1)') .attr('text-anchor', 'middle') .attr('dy', '.35em') @@ -1250,14 +1260,21 @@ var app = {}, browserSettings = {}, browserStorage = $.localStorage; } function updateTimeAgo() { - if (!latestSGV || inRetroMode()) return; + var lastEntry = $('#lastEntry') + , time = latestSGV ? new Date(latestSGV.x).getTime() : -1 + , ago = timeAgo(time) + , retroMode = inRetroMode(); - if (latestSGV.y < 39) { - $('#lastEntry').text('CGM ERROR').removeClass('current').addClass('urgent'); + lastEntry.addClass(ago.addClass); + lastEntry.removeClass(ago.removeClass); + + if (retroMode || !ago.value) { + lastEntry.find('em').hide(); } else { - var secsSinceLast = (Date.now() - new Date(latestSGV.x).getTime()) / 1000; - $('#lastEntry').text(timeAgo(secsSinceLast)).toggleClass('current', secsSinceLast < 10 * 60); + lastEntry.find('em').show().text(ago.value); } + + lastEntry.find('label').text(retroMode ? 'RETRO' : ago.label); } function init() { @@ -1334,8 +1351,8 @@ var app = {}, browserSettings = {}, browserStorage = $.localStorage; var silenceDropdown = new Dropdown('.dropdown-menu'); - $('#bgButton').click(function (e) { - silenceDropdown.open(e); + $('.bgButton').click(function (e) { + if (alarmingNow()) silenceDropdown.open(e); }); $('#silenceBtn').find('a').click(function (e) {