mirror of
https://github.com/bckelley/cgm-remote-monitor.git
synced 2026-08-24 03:14:12 -05:00
Add Total daily pasal to profile editor.
Small improvoment to profile editor while geting familiar about the code. Added a simple estimated total daily basal field.
This commit is contained in:
@@ -1736,6 +1736,29 @@ function init() {
|
||||
,ko: '날짜 전체'
|
||||
,zh_cn: '天总计'
|
||||
}
|
||||
,'Total per day' : {
|
||||
cs: 'dní celkem'
|
||||
,de: 'Gesamttage'
|
||||
,es: 'Total de días'
|
||||
,fr: 'Total journalier'
|
||||
,el: 'ημέρες συνολικά'
|
||||
,pt: 'dias no total'
|
||||
,sv: 'antal dagar'
|
||||
,ro: 'total zile'
|
||||
,bg: 'общо за деня'
|
||||
,hr: 'ukupno dana'
|
||||
,it: 'Giorni totali'
|
||||
,dk: 'antal dage'
|
||||
,fi: 'päivän arvio'
|
||||
,nb: 'antall dager'
|
||||
,he: 'מספר ימים'
|
||||
,pl: 'dni łącznie'
|
||||
,ru: 'всего дней'
|
||||
,sk: 'dní celkom'
|
||||
,nl: 'Totaal dagen'
|
||||
,ko: '날짜 전체'
|
||||
,zh_cn: '天总计'
|
||||
}
|
||||
,'Overall' : {
|
||||
cs: 'Celkem'
|
||||
,de: 'Insgesamt'
|
||||
|
||||
@@ -199,6 +199,28 @@
|
||||
initProfile();
|
||||
}
|
||||
|
||||
function timeDiffMinutes(time1, time2)
|
||||
{
|
||||
var minutes1 = toMinutesFromMidnight(time1);
|
||||
var minutes2 = toMinutesFromMidnight(time2);
|
||||
if (minutes2 <= minutes1) {
|
||||
minutes2 += 24*60;
|
||||
}
|
||||
return minutes2-minutes1;
|
||||
}
|
||||
function refreshTotalBasal()
|
||||
{
|
||||
GUIToObject();
|
||||
var total = 0;
|
||||
for (var i=0, len=c_profile['basal'].length; i<len; i++) {
|
||||
var time1 = c_profile['basal'][i].time;
|
||||
var time2 = c_profile['basal'][(i+1)%len].time;
|
||||
var value = c_profile['basal'][i].value;
|
||||
total += timeDiffMinutes(time1,time2) * value / 60
|
||||
}
|
||||
$('#pe_basalTotal_placeholder').html(Math.round(total*1000)/1000);
|
||||
}
|
||||
|
||||
function initProfile() {
|
||||
var record = mongorecords[currentrecord];
|
||||
// fill profilenames
|
||||
@@ -217,6 +239,7 @@
|
||||
mongorecords[currentrecord].defaultProfile = currentprofile;
|
||||
// Set values from profile to html
|
||||
fillTimeRanges();
|
||||
refreshTotalBasal();
|
||||
}
|
||||
|
||||
// Handling of record list box change
|
||||
@@ -410,7 +433,7 @@
|
||||
select.val(selectedValue);
|
||||
|
||||
tr.append($('<td>').append(translate('From') + ': ').append(select));
|
||||
tr.append($('<td>').append(e.label).append($('<input type="text">').attr('id',e.prefix+'_val_'+i).attr('value',c_profile[e.array][i].value)));
|
||||
tr.append($('<td>').append(e.label).append($('<input type="text">').attr('id',e.prefix+'_val_'+i).attr('value',c_profile[e.array][i].value).attr('class', e.prefix + '_value')));
|
||||
var icons_td = $('<td>').append($('<img>').attr('class','addsingle').attr('style','cursor:pointer').attr('title',translate('Add new interval before')).attr('src',icon_add).attr('array',e.array).attr('pos',i));
|
||||
if (c_profile[e.array].length>1) {
|
||||
icons_td.append($('<img>').attr('class','delsingle').attr('style','cursor:pointer').attr('title',translate('Delete interval')).attr('src',icon_remove).attr('array',e.array).attr('pos',i));
|
||||
@@ -436,13 +459,15 @@
|
||||
html += '</table>';
|
||||
$('#'+e.prefix+'_placeholder').html(html);
|
||||
});
|
||||
|
||||
$('.pe_basal_value').on('change keyup paste', refreshTotalBasal);
|
||||
$('.addsingle').click(function addsingle_click() {
|
||||
var array = $(this).attr('array');
|
||||
var pos = $(this).attr('pos');
|
||||
GUIToObject();
|
||||
c_profile[array].splice(pos,0,{time:'00:00',value:0});
|
||||
return fillTimeRanges();
|
||||
var retVal = fillTimeRanges();
|
||||
refreshTotalBasal();
|
||||
return retVal;
|
||||
});
|
||||
|
||||
$('.delsingle').click(function delsingle_click() {
|
||||
@@ -451,7 +476,9 @@
|
||||
GUIToObject();
|
||||
c_profile[array].splice(pos,1);
|
||||
c_profile[array][0].time = '00:00';
|
||||
return fillTimeRanges();
|
||||
var retVal = fillTimeRanges();
|
||||
refreshTotalBasal();
|
||||
return retVal;
|
||||
});
|
||||
|
||||
function addBGLine(i) {
|
||||
@@ -512,7 +539,7 @@
|
||||
return fillTimeRanges();
|
||||
});
|
||||
|
||||
$('.pe_selectabletime').unbind().on('change', fillTimeRanges);
|
||||
$('.pe_selectabletime').unbind().on('change', fillTimeRanges).on('change', refreshTotalBasal);
|
||||
|
||||
objectToGUI();
|
||||
maybePreventDefault(event);
|
||||
|
||||
@@ -150,6 +150,7 @@
|
||||
<fieldset class="browserSettings">
|
||||
<legend class="translate">Basal rates [unit/hour]</legend>
|
||||
<div id="pe_basal_placeholder"></div>
|
||||
<div><span class="translate">Total per day</span>: <span id="pe_basalTotal_placeholder"></span></div>
|
||||
</fieldset>
|
||||
|
||||
<fieldset class="browserSettings">
|
||||
|
||||
Reference in New Issue
Block a user