From 24eb0f33fef2431bb589d59f95c342005b08a03a Mon Sep 17 00:00:00 2001 From: msdeibel Date: Thu, 16 Apr 2020 11:24:17 +0200 Subject: [PATCH] Minor changes based on JSLint hints --- apps/batchart/widget.js | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/apps/batchart/widget.js b/apps/batchart/widget.js index 53f8b3549..1b8ce79ba 100644 --- a/apps/batchart/widget.js +++ b/apps/batchart/widget.js @@ -12,8 +12,8 @@ var batChartFile; // file for battery percentage recording const recordingInterval10Min = 60 * 10 * 1000; - const recordingInterval1Min = 60*1000; //For testing - const recordingInterval10S = 10*1000; //For testing + const recordingInterval1Min = 60 * 1000; //For testing + const recordingInterval10S = 10 * 1000; //For testing var recordingInterval = null; var compassEventReceived = false; @@ -26,15 +26,15 @@ let y = this.y; g.setColor(0, 1, 0); - g.fillPoly([x+5, y, x+5, y+4, x+1, y+4, x+1, y+20, x+18, y+20, x+18, y+4, x+13, y+4, x+13, y], true); + g.fillPoly([x + 5, y, x + 5, y + 4, x + 1, y + 4, x + 1, y + 20, x + 18, y + 20, x + 18, y + 4, x + 13, y + 4, x + 13, y], true); - g.setColor(0,0,0); - g.drawPoly([x+5, y+6, x+8, y+12, x+13, y+12, x+16, y+18], false); + g.setColor(0, 0, 0); + g.drawPoly([x + 5, y + 6, x + 8, y + 12, x + 13, y + 12, x + 16, y + 18], false); g.reset(); } - function onMag(){ + function onMag() { compassEventReceived = true; // Stop handling events when no longer necessarry Bangle.removeListener("mag", onMag); @@ -51,6 +51,7 @@ } function getEnabledConsumersValue() { + // Wait for an event from each of the devices to see if they are switched on var enabledConsumers = switchableConsumers.none; Bangle.on('mag', onMag); @@ -58,13 +59,12 @@ Bangle.on('HRM', onHrm); // Wait two seconds, that should be enough for each of the events to get raised once - setTimeout(() => { + setTimeout(() => { Bangle.removeAllListeners(); }, 2000); if (Bangle.isLCDOn()) enabledConsumers = enabledConsumers | switchableConsumers.lcd; - // Already added in the hope they will be available soon to get more details if (compassEventReceived) enabledConsumers = enabledConsumers | switchableConsumers.compass; if (gpsEventReceived) @@ -90,8 +90,7 @@ const logFileName = "bclog" + currentWriteDay; // Change log target on day change - if (!isNaN(previousWriteDay) - && previousWriteDay != currentWriteDay) { + if (!isNaN(previousWriteDay) && previousWriteDay != currentWriteDay) { //Remove a log file containing data from a week ago Storage.open(logFileName, "r").erase(); Storage.open(previousWriteLogName, "w").write(parseInt(currentWriteDay)); @@ -111,7 +110,7 @@ } function reload() { - WIDGETS["batchart"].width = 24; + WIDGETS.batchart.width = 24; recordingInterval = setInterval(logBatteryData, recordingInterval10Min); @@ -119,11 +118,12 @@ } // add the widget - WIDGETS["batchart"]={area:"tl",width:24,draw:draw,reload:function() { - reload(); - Bangle.drawWidgets(); // relayout all widgets - }}; + WIDGETS.batchart = { + area: "tl", width: 24, draw: draw, reload: function () { + reload(); + Bangle.drawWidgets(); + } + }; - // load settings, set correct widget width reload(); -})() \ No newline at end of file +})(); \ No newline at end of file