Skip to content
Permalink
Browse files

cleaned up setting checks for showing raw BGs (will make merging with…

… iob-cob cleaner too)
  • Loading branch information...
jasoncalabrese committed Feb 8, 2015
1 parent 9637bdf commit 506cdcd28ace4fecadc5e5b1ceca071b517b7a45
Showing with 33 additions and 13 deletions.
  1. +1 −1 lib/api/index.js
  2. +8 −2 static/js/client.js
  3. +24 −10 static/js/ui-utils.js
@@ -24,7 +24,7 @@ function create (env, entries, settings, treatments, devicestatus) {
}

if (env.enable) {
app.enabledOptions = env.enable;
app.enabledOptions = env.enable || '';
env.enable.toLowerCase().split(' ').forEach(function (value) {
var enable = value.trim();
console.info("enabling feature:", enable);
@@ -104,6 +104,12 @@ var app = {}, browserSettings = {}, browserStorage = $.localStorage;
}
}

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

function rawIsigToRawBg(entry, cal) {

var unfiltered = parseInt(entry.unfiltered) || 0
@@ -483,7 +489,7 @@ var app = {}, browserSettings = {}, browserStorage = $.localStorage;
var bgType = (d.type == 'sgv' ? 'CGM' : (device == 'dexcom' ? 'Calibration' : 'Meter'));
var noiseLabel = '';

if (d.type == 'sgv' && app.enabledOptions && app.enabledOptions.indexOf('rawbg' > -1) && browserSettings.showRawbg != 'never') {
if (d.type == 'sgv' && showRawBGs()) {
noiseLabel = noiseCodeToDisplay(d.noise);
}

@@ -1359,7 +1365,7 @@ var app = {}, browserSettings = {}, browserStorage = $.localStorage;


var temp1 = [ ];
if (cal && app.enabledOptions && app.enabledOptions.indexOf('rawbg' > -1) && (browserSettings.showRawbg == 'always' || browserSettings.showRawbg == 'noise')) {
if (cal && showRawBGs()) {
temp1 = d[0].map(function (entry) {
var rawBg = rawIsigToRawBg(entry, cal);
return { date: new Date(entry.x - 2 * 1000), y: rawBg, sgv: scaleBg(rawBg), color: 'white', type: 'rawbg'}
@@ -13,6 +13,25 @@ var defaultSettings = {
'timeFormat': '12'
};

function rawBGsEnabled() {
return app.enabledOptions && app.enabledOptions.indexOf('rawbg') > -1;
}

function initShowRawBG(currentValue) {

var initValue = 'never';

if (currentValue === true) {
initValue = 'noise';
} else if (currentValue == 'never' || currentValue == 'always' || currentValue == 'noise') {
initValue = currentValue;
} else {
initValue = app.enabledOptions.indexOf('rawbg-on') > -1 ? 'noise' : 'never';
}

return initValue;
}

function getBrowserSettings(storage) {
var json = {};

@@ -62,18 +81,13 @@ function getBrowserSettings(storage) {
json.nightMode = setDefault(json.nightMode, defaultSettings.nightMode);
$('#nightmode-browser').prop('checked', json.nightMode);

if (app.enabledOptions.indexOf('rawbg') == -1) {
json.showRawbg = false;
$('#show-rawbg-option').hide();
} else {
if (rawBGsEnabled()) {
$('#show-rawbg-option').show();
if (json.showRawbg === false) {
json.showRawbg = 'never';
} else if (json.showRawbg === true) {
json.showRawbg = 'noise';
}
json.showRawbg = setDefault(json.showRawbg, (app.enabledOptions.indexOf('rawbg-on') > -1 ? 'noise' : 'never'));
json.showRawbg = initShowRawBG(json.showRawbg);
$('#show-rawbg-' + json.showRawbg).prop('checked', true);
} else {
json.showRawbg = 'never';
$('#show-rawbg-option').hide();
}

if (json.customTitle) {

0 comments on commit 506cdcd

Please sign in to comment.
You can’t perform that action at this time.