Skip to content

Commit

Permalink
fixed some bugs releated to when to show raw, also more css tweeks
Browse files Browse the repository at this point in the history
  • Loading branch information
jasoncalabrese committed Mar 21, 2015
1 parent 084e00b commit 9bed536
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 19 deletions.
7 changes: 3 additions & 4 deletions static/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,6 @@ div.tooltip {
@media (max-width: 800px) {
.bgStatus {
width: 300px;
padding: 0;
}

.bgButton {
Expand Down Expand Up @@ -379,7 +378,8 @@ div.tooltip {

@media (max-width: 750px) {
.bgStatus {
width: 250px;
width: 240px;
padding: 0;
}

.bgStatus .currentBG {
Expand Down Expand Up @@ -424,7 +424,6 @@ div.tooltip {

.bgStatus {
float: none;
margin: 0 auto;
padding: 0;
text-align: center;
width: 250px;
Expand All @@ -443,6 +442,7 @@ div.tooltip {

.bgButton .rawbg {
top: 5px;
left: 5px;
}

.bgStatus .currentBG.bg-limit, .bgStatus .currentBG.icon-hourglass {
Expand All @@ -466,7 +466,6 @@ div.tooltip {
}

.time {
width: auto;
padding-top: 0;
font-size: 20px !important;
}
Expand Down
49 changes: 34 additions & 15 deletions static/js/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,16 @@ var app = {}, browserSettings = {}, browserStorage = $.localStorage;
}
}

function showRawBGs() {
return app.enabledOptions
&& app.enabledOptions.indexOf('rawbg') > -1
&& (browserSettings.showRawbg == 'always' || browserSettings.showRawbg == 'noise');
function isRawBGEnabled() {
return app.enabledOptions && app.enabledOptions.indexOf('rawbg') > -1;
}

function showRawBGs(sgv, noise, cal) {
return cal
&& isRawBGEnabled()
&& (browserSettings.showRawbg == 'always'
|| (browserSettings.showRawbg == 'noise' && (noise >= 2 || sgv < 40))
);
}

function showIOB() {
Expand Down Expand Up @@ -268,14 +274,20 @@ var app = {}, browserSettings = {}, browserStorage = $.localStorage;
return errorDisplay;
}

function noiseCodeToDisplay(noise) {
function noiseCodeToDisplay(sgv, noise) {
var display = 'Not Set';
switch (parseInt(noise)) {
case 1: display = 'Clean'; break;
case 2: display = 'Light'; break;
case 3: display = 'Medium'; break;
case 4: display = 'Heavy'; break;
case 5: display = 'Unknown'; break;
case 5:
if (sgv < 40) {
display = 'Error';
} else {
display = 'Unknown';
}
break;
}

return display;
Expand Down Expand Up @@ -314,6 +326,7 @@ var app = {}, browserSettings = {}, browserStorage = $.localStorage;
, currentBG = $('.bgStatus .currentBG')
, currentDirection = $('.bgStatus .currentDirection')
, currentDetails = $('.bgStatus .currentDetails')
, rawbg = bgButton.find('.rawbg')
, lastEntry = $('#lastEntry');


Expand All @@ -339,8 +352,7 @@ var app = {}, browserSettings = {}, browserStorage = $.localStorage;
}
}

var rawbg = bgButton.find('.rawbg');
if (showRawBGs() && (entry.noise >=2 || entry.y < 40)) {
if (showRawBGs(entry.y, entry.noise, cal)) {
rawbg.show().html(scaleBg(rawIsigToRawBg(entry, cal)));
} else {
rawbg.hide();
Expand All @@ -355,7 +367,7 @@ var app = {}, browserSettings = {}, browserStorage = $.localStorage;
var noise = entry.noise
, noiseType;

if ((noise <= 1 && entry.y >= 40) || !showRawBGs()) {
if (!showRawBGs(entry.y, noise, cal)) {
noiseType = null;
} else if (entry.y < 40) {
noiseType = 'error';
Expand Down Expand Up @@ -458,6 +470,8 @@ var app = {}, browserSettings = {}, browserStorage = $.localStorage;
updateBGDelta();
currentBG.text('---');
currentDirection.text('-');
rawbg.hide();
bgButton.removeClass('urgent warning inrange');
}

updateIOBIndicator(time);
Expand Down Expand Up @@ -558,17 +572,22 @@ var app = {}, browserSettings = {}, browserStorage = $.localStorage;
.on('mouseover', function (d) {
if (d.type != 'sgv' && d.type != 'mbg') return;

var device = d.device && d.device.toLowerCase();
var bgType = (d.type == 'sgv' ? 'CGM' : (device == 'dexcom' ? 'Calibration' : 'Meter'));
var noiseLabel = '';
var device = d.device && d.device.toLowerCase()
, bgType = (d.type == 'sgv' ? 'CGM' : (device == 'dexcom' ? 'Calibration' : 'Meter'))
, rawBG = 0
, noiseLabel = '';

if (d.type == 'sgv' && showRawBGs()) {
noiseLabel = noiseCodeToDisplay(d.noise);
if (d.type == 'sgv') {
if (showRawBGs(d.y, d.noise, cal)) {
rawBG = scaleBg(rawIsigToRawBg(d, cal));
}
noiseLabel = noiseCodeToDisplay(d.y, d.noise);
}

tooltip.transition().duration(TOOLTIP_TRANS_MS).style('opacity', .9);
tooltip.html('<strong>' + bgType + ' BG:</strong> ' + d.sgv +
(d.type == 'mbg' ? '<br/><strong>Device: </strong>' + d.device : '') +
(rawBG ? '<br/><strong>Raw BG:</strong> ' + rawBG : '') +
(noiseLabel ? '<br/><strong>Noise:</strong> ' + noiseLabel : '') +
'<br/><strong>Time:</strong> ' + formatTime(d.date))
.style('left', (d3.event.pageX) + 'px')
Expand Down Expand Up @@ -1514,7 +1533,7 @@ var app = {}, browserSettings = {}, browserStorage = $.localStorage;
devicestatusData = d[6];

var temp1 = [ ];
if (cal && showRawBGs()) {
if (cal && isRawBGEnabled()) {
temp1 = d[0].map(function (entry) {
var noise = entry.noise || 0;
var rawBg = noise < 2 && browserSettings.showRawbg != 'always' ? 0 : rawIsigToRawBg(entry, cal);
Expand Down

0 comments on commit 9bed536

Please sign in to comment.