Skip to content

Commit

Permalink
display rawbg in top right if enabled; fix alarm button border
Browse files Browse the repository at this point in the history
  • Loading branch information
jasoncalabrese committed Mar 20, 2015
1 parent ed264b1 commit 1431be6
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 31 deletions.
51 changes: 32 additions & 19 deletions static/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -206,18 +206,41 @@ body {
width: 320px;
}

.bgButton.noise-heavy, .bgButton.noise-error {
border-color: rgba(255, 0, 0, 0.39);
box-shadow: 2px 2px 10px rgba(255, 0, 0, 0.75);
}

.bgButton.noise-medium {
border-color: rgba(255, 255, 0, 0.39);
box-shadow: 2px 2px 10px rgba(255, 255, 0, 0.75);
}

.bgButton.noise-light {
border-color: rgba(189, 189, 189, 0.39);
box-shadow: 2px 2px 10px rgba(189, 189, 189, 0.75);
}

.bgButton .rawbg {
color: white;
position: absolute;
top: 60px;
right: 20px;
text-shadow: 4px 4px 7px rgba(0, 0, 0, 0.84);
}

.alarming .bgButton {
border-color: #bdbdbd;
color: #000;
box-shadow: 2px 2px 0 #ddd;
border-color: #bdbdbd;
color: #000;
box-shadow: 2px 2px 0 #ddd;
}

.alarming .bgButton.urgent {
background-color: red;
background-color: red;
}

.alarming .bgButton.warning {
background-color: yellow;
background-color: yellow;
}

.alarming .bgButton:active {
Expand All @@ -227,20 +250,6 @@ body {
-webkit-box-shadow: none;
}

.bgButton.noise-heavy, .bgButton.noise-error {
border-color: rgba(255, 0, 0, 0.39);
box-shadow: 2px 2px 10px rgba(255, 0, 0, 0.75);
}

.bgButton.noise-medium {
border-color: rgba(255, 255, 0, 0.39);
box-shadow: 2px 2px 10px rgba(255, 255, 0, 0.75);
}

.bgButton.noise-light {
border-color: rgba(189, 189, 189, 0.39);
box-shadow: 2px 2px 10px rgba(189, 189, 189, 0.75);
}

.button {
text-align: center;
Expand Down Expand Up @@ -513,6 +522,10 @@ div.tooltip {
display: none;
}

.bgButton .rawbg {
top: 40px;
}

.container {
top: 15px;
padding-bottom: 20px;
Expand Down
1 change: 1 addition & 0 deletions static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ <h1 class="customTitle">Nightscout</h1>
<div class="bgButton ">
<span class="currentBG">---</span>
<span class="currentDirection">-</span>
<span class="rawbg"></span>
</div>
<ul class="dropdown-menu" id="silenceBtn">
<li><a href="#" data-snooze-time="1800000">Silence for 30 minutes</a></li>
Expand Down
35 changes: 23 additions & 12 deletions static/js/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,24 +124,25 @@ var app = {}, browserSettings = {}, browserStorage = $.localStorage;

function rawIsigToRawBg(entry, cal) {

var unfiltered = parseInt(entry.unfiltered) || 0
var raw = 0
, unfiltered = parseInt(entry.unfiltered) || 0
, filtered = parseInt(entry.filtered) || 0
, sgv = entry.y
, noise = entry.noise || 0
, scale = parseFloat(cal.scale) || 0
, intercept = parseFloat(cal.intercept) || 0
, slope = parseFloat(cal.slope) || 0;


if (slope == 0 || unfiltered == 0 || scale == 0) {
return 0;
} else if (noise < 2 && browserSettings.showRawbg != 'always') {
return 0;
raw = 0;
} else if (filtered == 0 || sgv < 40) {
return scale * (unfiltered - intercept) / slope;
raw = scale * (unfiltered - intercept) / slope;
} else {
var ratio = scale * (filtered - intercept) / slope / sgv;
return scale * ( unfiltered - intercept) / slope / ratio;
raw = scale * ( unfiltered - intercept) / slope / ratio;
}

return Math.round(raw);
}

// initial setup of chart when data is first made available
Expand Down Expand Up @@ -316,7 +317,9 @@ var app = {}, browserSettings = {}, browserStorage = $.localStorage;
, lastEntry = $('#lastEntry');


function updateCurrentSGV(value) {
function updateCurrentSGV(entry) {
var value = entry.y;

if (value == 9) {
currentBG.text('');
} else if (value < 39) {
Expand All @@ -336,6 +339,13 @@ var app = {}, browserSettings = {}, browserStorage = $.localStorage;
}
}

var rawbg = bgButton.find('.rawbg');
if (showRawBGs() && (entry.noise >=2 || entry.y < 40)) {
rawbg.show().html(scaleBg(rawIsigToRawBg(entry, cal)));
} else {
rawbg.hide();
}

currentBG.toggleClass('icon-hourglass', value == 9);
currentBG.toggleClass('error-code', value < 39);
currentBG.toggleClass('bg-limit', value == 39 || value > 400);
Expand Down Expand Up @@ -437,7 +447,7 @@ var app = {}, browserSettings = {}, browserStorage = $.localStorage;
var focusPoint = nowData[nowData.length - 1];
var prevfocusPoint = nowData[nowData.length - 2];

updateCurrentSGV(focusPoint.y);
updateCurrentSGV(focusPoint);
updateCurrentNoise(focusPoint);

updateBGDelta(prevfocusPoint.y, focusPoint.y);
Expand All @@ -462,7 +472,7 @@ var app = {}, browserSettings = {}, browserStorage = $.localStorage;
nowData = nowData.slice(nowData.length - 1 - lookback, nowData.length);
nowDate = new Date(now);

updateCurrentSGV(latestSGV.y);
updateCurrentSGV(latestSGV);
updateCurrentNoise(latestSGV);
updateClockDisplay();
updateTimeAgo();
Expand Down Expand Up @@ -1506,12 +1516,13 @@ var app = {}, browserSettings = {}, browserStorage = $.localStorage;
var temp1 = [ ];
if (cal && showRawBGs()) {
temp1 = d[0].map(function (entry) {
var rawBg = rawIsigToRawBg(entry, cal);
var noise = entry.noise || 0;
var rawBg = noise < 2 && browserSettings.showRawbg != 'always' ? 0 : rawIsigToRawBg(entry, cal);
return { date: new Date(entry.x - 2 * 1000), y: rawBg, sgv: scaleBg(rawBg), color: 'white', type: 'rawbg'}
}).filter(function(entry) { return entry.y > 0});
}
var temp2 = d[0].map(function (obj) {
return { date: new Date(obj.x), y: obj.y, sgv: scaleBg(obj.y), direction: obj.direction, color: sgvToColor(obj.y), type: 'sgv', noise: obj.noise}
return { date: new Date(obj.x), y: obj.y, sgv: scaleBg(obj.y), direction: obj.direction, color: sgvToColor(obj.y), type: 'sgv', noise: obj.noise, filtered: obj.filtered, unfiltered: obj.unfiltered}
});
data = [];
data = data.concat(temp1, temp2);
Expand Down

0 comments on commit 1431be6

Please sign in to comment.