diff --git a/README.md b/README.md
index bd55ebf8094..1f4c42e60f1 100644
--- a/README.md
+++ b/README.md
@@ -306,11 +306,29 @@ To learn more about the Nightscout API, visit https://YOUR-SITE.com/api-docs/ or
### Views
- There are a few alternate web views available from the main menu that display a simplified BG stream. (If you launch one of these in a fullscreen view in iOS, you can use a left-to-right swipe gesture to exit the view.)
+ Nightscout allows to create custom, simplified views using a predefined set of elements. This option is available under `[+]` link in the main menu.
+
+ List of available items:
+ * `SGV` - Sensor Glucose Value
+ * `SGV age` - time since the last SGV read
+ * `SGV delta` - change of SGV in the last 5 minutes
+ * `Trend arrow` - icon of the SG trend
+ * `Time` - current time
+ * `Line break` - invisible item that will move following items to the next line (by default all are showing on the same level)
+
+ All visible items have `Size` property which allows to customize the view even more. Also, all items may appear multiple times on the view.
+
+ Apart from adding items, it is possible to customize other aspects of the views, like selecting `Color` or `Black` background. The first one will indicate current BG threshold (green = in range; blue = below range; yellow = above range; red = urgent below/above).
+ `Show SGV age` option will make `SGV age` item appear `Always` or only if the predefined threshold is reached: `Only after threshold`. Breaching `SGV age threshold` will also make `Color` background turn grey and strike through `SGV`.
+ `Clock view configurator` will generate an URL (available under `Open my clock view!` link) that could be bookmarked.
+
+ There are a few default views available from the main menu:
* `Clock` - Shows current BG, trend arrow, and time of day. Grey text on a black background.
- * `Color` - Shows current BG and trend arrow. White text on a background that changes color to indicate current BG threshold (green = in range; blue = below range; yellow = above range; red = urgent below/above). Set `SHOW_CLOCK_DELTA` to `true` to show BG change in the last 5 minutes, set `SHOW_CLOCK_LAST_TIME` to `true` to always show BG age.
+ * `Color` - Shows current BG and trend arrow. White text on a color background.
* `Simple` - Shows current BG. Grey text on a black background.
+ If you launch one of these views in a fullscreen view in iOS, you can use a left-to-right swipe gesture to exit the view.
+
### Split View
Some users will need easy access to multiple Nightscout views at the same time. We have a special view for this case, accessed on /split path on your Nightscout URL. The view supports any number of sites between 1 to 8 way split, where the content for the screen can be loaded from multiple Nightscout instances. Note you still need to host separate instances for each Nightscout being monitored including the one that hosts the split view page - these variables only add the ability to load multiple views into one browser page. To set the URLs from which the content is loaded, set:
diff --git a/lib/client/clock-client.js b/lib/client/clock-client.js
index e6eec7190c6..891f10d57d5 100644
--- a/lib/client/clock-client.js
+++ b/lib/client/clock-client.js
@@ -6,7 +6,7 @@ var client = {};
client.settings = browserSettings(client, window.serverSettings, $);
-// console.log('settings', client.settings);
+//console.log('settings', client.settings);
// client.settings now contains all settings
client.query = function query () {
@@ -20,7 +20,7 @@ client.query = function query () {
});
var secret = localStorage.getItem('apisecrethash');
- var src = '/api/v1/entries.json?count=3&t=' + new Date().getTime();
+ var src = '/api/v1/entries.json?find[type]=sgv&count=3&t=' + new Date().getTime();
if (secret) {
src += '&secret=' + secret;
@@ -39,6 +39,7 @@ client.render = function render (xhr) {
let rec;
let delta;
+ // Get SGV, calculate DELTA
xhr.forEach(element => {
if (element.sgv && !rec) {
rec = element;
@@ -49,28 +50,65 @@ client.render = function render (xhr) {
});
let $errorMessage = $('#errorMessage');
+ let $inner = $('#inner');
// If no one measured value found => show "-?-"
if (!rec) {
if (!$errorMessage.length) {
- $('#arrowDiv').append('
-?-
');
- $('#arrow').hide();
+ $inner.after('
-?-
')
} else {
$errorMessage.show();
}
+ $inner.hide();
return;
} else {
$errorMessage.length && $errorMessage.hide();
- $('#arrow').show();
+ $inner.show();
+ }
+
+ //Parse face parameters
+ let face = $inner.data('face').toLowerCase();
+
+ // Backward compatible
+ if (face === 'clock-color') {
+ face = 'c' + (window.serverSettings.settings.showClockLastTime ? 'y' : 'n') + '13-sg40-' + (window.serverSettings.settings.showClockDelta ? 'dt14-' : '') + 'nl-ar30-nl-ag6';
+ }
+ else if (face === 'clock') {
+ face = 'bn0-sg40';
+ }
+ else if (face === 'bgclock') {
+ face = 'bn0-sg30-ar18-nl-nl-tm26';
+ }
+ else if (face === 'config') {
+ face = $inner.attr('data-face-config');
+ $inner.empty();
+ }
+
+ let faceParams = face.split('-');
+ let bgColor = false;
+ let staleMinutes = 13;
+ let alwaysShowTime = false;
+
+ let clockCreated = ($inner.children().length > 0);
+
+ for (let param in faceParams) {
+ if (param === '0') {
+ bgColor = (faceParams[param].substr(0, 1) === 'c'); // do we want colorful background?
+ alwaysShowTime = (faceParams[param].substr(1, 1) === 'y'); // always show "stale time" text?
+ staleMinutes = (faceParams[param].substr(2,2) - 0 >= 0) ? faceParams[param].substr(2,2) : 13; // threshold value (0=never)
+ } else if (!clockCreated){
+ let div = '