From a468292536aaff5b34898f3b8edb4dcd797954f6 Mon Sep 17 00:00:00 2001 From: Anton Date: Wed, 13 Mar 2024 11:51:40 +0100 Subject: [PATCH] Fix apps with undefined variables --- apps/1button/widget.js | 2 +- apps/acmaze/app.js | 2 +- apps/activepedom/widget.js | 8 ++++---- apps/antonclkplus/app.js | 2 +- apps/aptsciclk/app.js | 8 +++++--- apps/astrocalc/astrocalc-app.js | 2 +- apps/awairmonitor/app.js | 2 +- apps/balltastic/app.js | 2 +- apps/banglexercise/app.js | 2 +- apps/batchart/app.js | 1 + apps/bigdclock/bigdclock.app.js | 2 +- apps/bikespeedo/app.js | 2 +- apps/binwatch/app.js | 4 ++-- apps/bowserWF/app.js | 6 +++--- apps/breath/app.js | 4 ++-- apps/bthrm/lib.js | 2 +- apps/bthrm/recorder.js | 2 +- apps/bthrv/recorder.js | 2 +- apps/calibration/app.js | 2 +- apps/chess/engine.js | 2 +- apps/clickms/click-master.js | 2 +- apps/clkinfosunrise/clkinfo.js | 1 + apps/contacts/contacts.app.js | 2 +- apps/devstopwatch/app.js | 2 +- apps/diract/diract.js | 3 ++- apps/edisonsball/app.js | 4 ++-- apps/espruinoterm/app.js | 2 +- apps/fclock/fclock.app.js | 6 +++--- apps/flashcards/app.js | 2 +- apps/flow/app.js | 2 +- apps/forge/forge.app.js | 4 ++-- apps/ftclock/mkFourTwentyTz.js | 1 + apps/golfview/golfview.js | 8 ++++---- apps/golfview/maptools.js | 4 ++-- apps/gpsnav/app.js | 2 +- apps/gpsnav/app.min.js | 2 +- apps/gpsnav/app_b2.js | 2 +- apps/gsat/app.js | 2 +- apps/guitarsongs/app.js | 2 +- apps/ha/ha.lib.js | 2 +- apps/hamloc/app.js | 2 +- apps/hardalarm/app.js | 2 +- apps/hcclock/hcclock.app.js | 2 +- apps/heart/app.js | 4 ++-- apps/hidbkbd/hid-binary-keyboard.js | 4 ++-- apps/homework/app.js | 2 +- apps/hworldclock/app.js | 5 +++-- apps/icons/gen/generate.js | 2 ++ apps/infoclk/configLoad.js | 2 +- apps/kineticscroll/boot.js | 2 +- apps/kineticscroll/boot.min.js | 2 +- apps/macwatch/app.js | 2 ++ apps/macwatch2/app.js | 6 +++--- apps/messageicons/icons/generate.js | 2 ++ apps/miclock2/clock-mixed.js | 2 +- apps/miplant/app.js | 2 +- apps/mosaic/mosaic.app.js | 2 +- apps/multiclock/big.face.js | 2 +- apps/multiclock/dk.face.js | 6 +++--- apps/multitimer/alarm.js | 1 + apps/mylocation/settings.js | 2 +- apps/neonx/neonx.app.js | 2 +- apps/nixie/app.js | 2 +- apps/notanalog/notanalog.app.js | 2 +- apps/ohmcalc/app.js | 2 +- apps/openstmap/app.js | 2 +- apps/orloj/app.js | 6 +++--- apps/owmweather/settings.js | 2 +- apps/podadrem/app.js | 10 +++++----- apps/pooqroman/app.js | 2 +- apps/pooqroman/resourcer.js | 4 ++-- apps/pooqround/resourcer.js | 4 ++-- apps/promenu/boot.js | 2 +- apps/promenu/bootb2.js | 2 +- apps/qcenter/settings.js | 2 +- apps/quoteclock/app.js | 6 +++--- apps/random/app.js | 4 ++-- apps/rclock/rclock.app.js | 8 ++++---- apps/rebble/rebble.app.js | 2 +- apps/rebbleagenda/app.js | 4 ++-- apps/rellotge/rellotge.js | 1 + apps/rings/app.js | 2 +- apps/rndmclk/widget.js | 2 +- apps/rtorch/app.js | 2 +- apps/ruuviwatch/ruuviwatch.app.js | 6 +++--- apps/score/score.app.js | 1 - apps/seiko-5actus/app.js | 4 ++-- apps/setting/settings.js | 2 +- apps/showimg/app.js | 2 +- apps/speedalt2/app.js | 2 +- apps/sunclock/app.js | 10 +++++----- apps/sunrise/app.js | 4 ++-- apps/supmariodark/supmariodark.js | 8 ++++---- apps/swipeinv/settings.js | 2 +- apps/swscroll/boot.js | 2 +- apps/synthwave/app.js | 2 +- apps/teatimer/app.js | 2 +- apps/tempmonitor/tempmonitor.app.js | 5 +++-- apps/testuserinput/app.js | 1 + apps/tictactoe/app.js | 3 ++- apps/tilthydro/app.js | 2 +- apps/timecal/timecal.settings.js | 4 ++-- apps/tinyVario/app.js | 8 ++++---- apps/tinydraw/app.js | 4 ++-- apps/trex/trex.js | 4 ++-- apps/usgs/app.js | 13 ++++++++----- apps/usgs/settings.js | 2 +- apps/warpdrive/app.js | 2 +- apps/waypointer/app.js | 4 ++-- apps/widalt/widalt.settings.js | 2 +- apps/widbaroalarm/widget.js | 2 +- apps/widbgjs/widget.js | 4 ++-- apps/widcw/widget.js | 2 +- apps/widhwbttm/widhwbttm.wid.js | 2 +- apps/widmnth/widget.js | 2 +- apps/widmpsh/widget.js | 2 +- apps/worldclock/app.js | 2 +- apps/wristlight/app.js | 4 ++-- apps/xxlmessage/lib-unbuffered.js | 2 +- 119 files changed, 194 insertions(+), 174 deletions(-) diff --git a/apps/1button/widget.js b/apps/1button/widget.js index cce099309..414d3e29f 100644 --- a/apps/1button/widget.js +++ b/apps/1button/widget.js @@ -22,7 +22,7 @@ console.log("Button let go"); digitalWrite(LED2,0); var unpress_time = new Date(); - recFile = require("Storage").open("one_button_presses.csv","a"); + const recFile = require("Storage").open("one_button_presses.csv","a"); recFile.write([press_time.getTime(),unpress_time.getTime()].join(",")+"\n"); }, BTN1, { repeat: true, edge: 'falling', debounce: 50 }); diff --git a/apps/acmaze/app.js b/apps/acmaze/app.js index fba317aea..c3157f087 100644 --- a/apps/acmaze/app.js +++ b/apps/acmaze/app.js @@ -206,7 +206,7 @@ function Maze(n) { return false; }; this.tick = function() { - accel = Bangle.getAccel(); + let accel = Bangle.getAccel(); if (this.ball_x%this.wall_length) { this.try_move_horizontally(accel.x); } else if (this.ball_y%this.wall_length) { diff --git a/apps/activepedom/widget.js b/apps/activepedom/widget.js index 638449288..81df22173 100644 --- a/apps/activepedom/widget.js +++ b/apps/activepedom/widget.js @@ -32,10 +32,10 @@ } function storeData() { - now = new Date(); - month = now.getMonth() + 1; //month is 0-based + let now = new Date(); + let month = now.getMonth() + 1; //month is 0-based if (month < 10) month = "0" + month; //leading 0 - filename = filename = "activepedom" + now.getFullYear() + month + now.getDate() + ".data"; //new file for each day + let filename = "activepedom" + now.getFullYear() + month + now.getDate() + ".data"; //new file for each day dataFile = s.open(filename,"a"); if (dataFile) { //check if filen already exists if (dataFile.getLength() == 0) { @@ -231,7 +231,7 @@ stepsTooLong = pedomData.stepsTooLong; stepsOutsideTime = pedomData.stepsOutsideTime; } - pedomdata = 0; //reset pedomdata to save memory + pedomdata = 0; //reset pedomdata to save memory - TODO: Should `pedomdata` have been `pedomData` here? setStepSensitivity(setting('stepSensitivity')); //set step sensitivity (80 is standard, 400 is muss less sensitive) /*timerStoreData =*/ setInterval(storeData, storeDataInterval); //store data regularly diff --git a/apps/antonclkplus/app.js b/apps/antonclkplus/app.js index 409d7d487..4e5128a4e 100644 --- a/apps/antonclkplus/app.js +++ b/apps/antonclkplus/app.js @@ -107,7 +107,7 @@ let isoStr = function(date) { let calWeekBuffer = [false,false,false]; //buffer tz, date, week no (once calculated until other tz or date is requested) let ISO8601calWeek = function(date) { //copied from: https://gist.github.com/IamSilviu/5899269#gistcomment-3035480 - dateNoTime = date; dateNoTime.setHours(0,0,0,0); + const dateNoTime = date; dateNoTime.setHours(0,0,0,0); if (calWeekBuffer[0] === date.getTimezoneOffset() && calWeekBuffer[1] === dateNoTime) return calWeekBuffer[2]; calWeekBuffer[0] = date.getTimezoneOffset(); calWeekBuffer[1] = dateNoTime; diff --git a/apps/aptsciclk/app.js b/apps/aptsciclk/app.js index f32a52870..311a8cd77 100644 --- a/apps/aptsciclk/app.js +++ b/apps/aptsciclk/app.js @@ -136,6 +136,7 @@ else if (img == "apetureLaboratoriesLight"){ function drawStart(){ g.clear(); g.reset(); + let apSciLab; if (g.theme.dark){apSciLab = getImg("apetureLaboratories");} else {apSciLab = getImg("apetureLaboratoriesLight");} g.drawImage(apSciLab, xyCenter-apSciLab.width/2, xyCenter-apSciLab.height/2); @@ -241,7 +242,7 @@ function buttonPressed(){ if (curWarning < maxWarning) curWarning += 1; else curWarning = 0; g.reset(); - buttonImg = getImg("butPress"); + const buttonImg = getImg("butPress"); g.drawImage(buttonImg, 0, 0); warningImg = getImg("w"+String(curWarning)); @@ -251,7 +252,7 @@ function buttonPressed(){ } function buttonUnpressed(){ if (!pause){ - buttonImg = getImg("butUnpress"); + const buttonImg = getImg("butUnpress"); g.drawImage(buttonImg, 0, 0); } else{ @@ -277,11 +278,12 @@ function draw() { g.reset(); // default draw styles //draw watchface + let apSciWatch; if (g.theme.dark){apSciWatch = getImg("apetureWatch");} else {apSciWatch = getImg("apetureWatchLight");} g.drawImage(apSciWatch, xyCenter-apSciWatch.width/2, xyCenter-apSciWatch.height/2); - potato = getImg("potato"); + const potato = getImg("potato"); g.drawImage(potato, 118, 118); g.drawImage(warningImg, 1, g.getWidth()-61);//update warning diff --git a/apps/astrocalc/astrocalc-app.js b/apps/astrocalc/astrocalc-app.js index 293cd9386..cd1965290 100644 --- a/apps/astrocalc/astrocalc-app.js +++ b/apps/astrocalc/astrocalc-app.js @@ -23,7 +23,7 @@ function drawMoon(phase, x, y) { "waning-crescent", ]; - img = require("Storage").read(`${moonImgFiles[phase]}.img`); + const img = require("Storage").read(`${moonImgFiles[phase]}.img`); // image width & height = 92px g.drawImage(img, x - parseInt(92 / 2), y); } diff --git a/apps/awairmonitor/app.js b/apps/awairmonitor/app.js index 9123a9c2c..ef2f33a9e 100644 --- a/apps/awairmonitor/app.js +++ b/apps/awairmonitor/app.js @@ -80,7 +80,7 @@ function draw() { g.drawString(""+bt_current_humi, 123, 110); g.drawString(""+bt_current_temp, 158, 110); - for (i = 0; i < 10; i++) { + for (let i = 0; i < 10; i++) { if (display_frozen) { g.setColor("#888"); } // max height = 32 diff --git a/apps/balltastic/app.js b/apps/balltastic/app.js index d0262c3cb..d9241591e 100644 --- a/apps/balltastic/app.js +++ b/apps/balltastic/app.js @@ -1,4 +1,4 @@ -BANGLEJS2 = process.env.HWVERSION==2; +const BANGLEJS2 = process.env.HWVERSION==2; Bangle.setLCDBrightness(1); if (!BANGLEJS2) Bangle.setLCDMode("doublebuffered"); Bangle.setLCDTimeout(0); diff --git a/apps/banglexercise/app.js b/apps/banglexercise/app.js index c29671258..f4addc05a 100644 --- a/apps/banglexercise/app.js +++ b/apps/banglexercise/app.js @@ -148,7 +148,7 @@ function accelHandler(accel) { // slope for Z if (exerciseType.useZaxis) { - l = historyAvgZ.length; + let l = historyAvgZ.length; if (l > 1) { const p1 = historyAvgZ[l - 2]; const p2 = historyAvgZ[l - 1]; diff --git a/apps/batchart/app.js b/apps/batchart/app.js index c25617365..b93f004d4 100644 --- a/apps/batchart/app.js +++ b/apps/batchart/app.js @@ -101,6 +101,7 @@ function loadLinesFromFile(requestedLineCount, fileName) { var readFile = Storage.open(fileName, "r"); + let nextLine; while ((nextLine = readFile.readLine())) { if(nextLine) { allLines.push(nextLine); diff --git a/apps/bigdclock/bigdclock.app.js b/apps/bigdclock/bigdclock.app.js index a8e2b38df..f01d3df78 100644 --- a/apps/bigdclock/bigdclock.app.js +++ b/apps/bigdclock/bigdclock.app.js @@ -31,7 +31,7 @@ function draw() { var dow = require("date_utils").dows(0,1)[date.getDay()]; if ((date.getTime() >= lastBattCheck + 15*60000) || Bangle.isCharging()) { - lastBattcheck = date.getTime(); + lastBattcheck = date.getTime(); // TODO: should `lastBattcheck` have been `lastBattCheck` ? width = E.getBattery(); width += width/2; } diff --git a/apps/bikespeedo/app.js b/apps/bikespeedo/app.js index 2310f1656..429e9eb23 100644 --- a/apps/bikespeedo/app.js +++ b/apps/bikespeedo/app.js @@ -409,7 +409,7 @@ function updateClock() { if ( emulator ) { max.spd++; max.alt++; - d=new Date(); sec=d.getSeconds(); + const d=new Date(); sec=d.getSeconds(); onGPS(lf); } } diff --git a/apps/binwatch/app.js b/apps/binwatch/app.js index 8e21a06a0..a25595bf5 100644 --- a/apps/binwatch/app.js +++ b/apps/binwatch/app.js @@ -136,7 +136,7 @@ var cgimg; */ function drawSquare(gfx, x, y, data, numOfBits) { - for(i = numOfBits; i > 0 ; i--) { + for(let i = numOfBits; i > 0 ; i--) { if( (data & 1) != 0) { gfx.fillRect(x + (i - 1) * x_step, y, x + i * x_step , y + y_step); @@ -245,7 +245,7 @@ function drawBattery(gfx, level) { var pos_y = bat_pos_y - 1; var stepLevel = Math.round((level + 10) / 20); - for(i = 0; i < stepLevel; i++) { + for(let i = 0; i < stepLevel; i++) { pos_y -= bat_size_y + 2; gfx.fillRect(bat_pos_x, pos_y, bat_pos_x + bat_size_x, pos_y + bat_size_y); diff --git a/apps/bowserWF/app.js b/apps/bowserWF/app.js index 956c43602..e93617b18 100644 --- a/apps/bowserWF/app.js +++ b/apps/bowserWF/app.js @@ -34,10 +34,10 @@ const background = { ), }; -numbersDims = { +/*const numbersDims = { width: 20, height: 44, -}; +};*/ const numbers = [ require("heatshrink").decompress( atob( @@ -88,7 +88,7 @@ const numbers = [ ) ), ]; -digitPositions = [ +const digitPositions = [ // relative to the box { x: 13, y: 6 }, { x: 32, y: 6 }, diff --git a/apps/breath/app.js b/apps/breath/app.js index 309189c9a..f9abf9d6b 100644 --- a/apps/breath/app.js +++ b/apps/breath/app.js @@ -51,9 +51,9 @@ g.setFont("6x8", 2); function circle() { g.clear(); - adjusted_radius = max_radius * Math.abs(origin); + const adjusted_radius = max_radius * Math.abs(origin); g.drawCircle(120, 120, adjusted_radius); - radius = Math.abs(Math.sin(origin)); + //const radius = Math.abs(Math.sin(origin)); angle += 2; origin = angle * (Math.PI / 180); if (angle >= 0 && angle < 90) { diff --git a/apps/bthrm/lib.js b/apps/bthrm/lib.js index a792167ca..18af4f3ae 100644 --- a/apps/bthrm/lib.js +++ b/apps/bthrm/lib.js @@ -6,7 +6,7 @@ exports.enable = () => { var log = function(text, param){ if (global.showStatusInfo) - showStatusInfo(text); + global.showStatusInfo(text); if (settings.debuglog){ var logline = new Date().toISOString() + " - " + text; if (param) logline += ": " + JSON.stringify(param); diff --git a/apps/bthrm/recorder.js b/apps/bthrm/recorder.js index fcfed47c3..c3019b465 100644 --- a/apps/bthrm/recorder.js +++ b/apps/bthrm/recorder.js @@ -16,7 +16,7 @@ name : "BT HR", fields : ["BT Heartrate", "BT Battery", "Energy expended", "Contact", "RR"], getValues : () => { - result = [bpm,bat,energy,contact,rr]; + const result = [bpm,bat,energy,contact,rr]; bpm = ""; rr = ""; bat = ""; diff --git a/apps/bthrv/recorder.js b/apps/bthrv/recorder.js index 0fce6971e..f1e1d5040 100644 --- a/apps/bthrv/recorder.js +++ b/apps/bthrv/recorder.js @@ -31,7 +31,7 @@ } } } - result = [hrv]; + const result = [hrv]; hrv = ""; rrHistory = []; return result; diff --git a/apps/calibration/app.js b/apps/calibration/app.js index 049430d45..b5faa8f81 100644 --- a/apps/calibration/app.js +++ b/apps/calibration/app.js @@ -129,7 +129,7 @@ class BanglejsApp { E.srand(Date.now()); -calibration = new BanglejsApp(); +const calibration = new BanglejsApp(); calibration.load_settings(); Bangle.disableCalibration = true; diff --git a/apps/chess/engine.js b/apps/chess/engine.js index f67ecc456..c30e2587d 100644 --- a/apps/chess/engine.js +++ b/apps/chess/engine.js @@ -14,7 +14,7 @@ if (this.imports !== undefined && this.printerr !== undefined){//seed or gjs p4_log = function(){ var args = Array.prototype.slice.call(arguments); - printerr(args.join(', ')); + this.printerr(args.join(', ')); }; } else if (this.console === undefined){//MSIE diff --git a/apps/clickms/click-master.js b/apps/clickms/click-master.js index 55027e733..a5b3d1a7e 100644 --- a/apps/clickms/click-master.js +++ b/apps/clickms/click-master.js @@ -19,7 +19,7 @@ function drawPlayers() { g.clear(1); g.setFont("6x8",2); var l = [{name:ME,cnt:mycounter}]; - for (p of players) l.push(p); + for (const p of players) l.push(p); l.sort((a,b)=>a.cnt-b.cnt); var y=0; l.forEach(player=>{ diff --git a/apps/clkinfosunrise/clkinfo.js b/apps/clkinfosunrise/clkinfo.js index f8ea7f4c7..69df208f4 100644 --- a/apps/clkinfosunrise/clkinfo.js +++ b/apps/clkinfosunrise/clkinfo.js @@ -49,6 +49,7 @@ let day = true; let d = date.getTime(); let dayLength = sunset.getTime()-sunrise.getTime(); + let timePast; let timeTotal; if (d < sunrise.getTime()) { day = false; // early morning diff --git a/apps/contacts/contacts.app.js b/apps/contacts/contacts.app.js index a16bd1917..8d20e8646 100644 --- a/apps/contacts/contacts.app.js +++ b/apps/contacts/contacts.app.js @@ -66,7 +66,7 @@ function showNumpad(text, key_, callback) { s = key + text.substr(key.length, 999); g.setFont("Vector:24").setFontAlign(1,0).drawString(s,g.getWidth(),12); } - ds="12%"; + const ds="12%"; var numPad = new Layout ({ type:"v", c: [{ type:"v", c: [ diff --git a/apps/devstopwatch/app.js b/apps/devstopwatch/app.js index 30424d19d..747573c0c 100644 --- a/apps/devstopwatch/app.js +++ b/apps/devstopwatch/app.js @@ -65,7 +65,7 @@ function chronometer() { } currentLap = calculateLap(state.whenStarted); - total = calculateLap(state.whenStartedTotal); + const total = calculateLap(state.whenStartedTotal); state.laps[0] = total; state.laps[1] = currentLap; diff --git a/apps/diract/diract.js b/apps/diract/diract.js index 69f0a88e4..d80109345 100644 --- a/apps/diract/diract.js +++ b/apps/diract/diract.js @@ -513,11 +513,12 @@ function encodeAcceleration() { function updateSensorData() { // Update the battery measurement each time the cyclic count resets + let encodedBattery; if(cyclicCount === 0) { encodedBattery = encodeBatteryPercentage(); } - encodedAcceleration = encodeAcceleration(); + let encodedAcceleration = encodeAcceleration(); sensorData[0] = ((encodedAcceleration.x << 2) & 0xfc) | ((encodedAcceleration.y >> 4) & 0x3f); diff --git a/apps/edisonsball/app.js b/apps/edisonsball/app.js index 6e58ffcc1..39b764dfe 100644 --- a/apps/edisonsball/app.js +++ b/apps/edisonsball/app.js @@ -118,8 +118,8 @@ function checkHR() { if(HR_samples.length == 5){ g.clear(); - average_HR = average(HR_samples).toFixed(0); - stdev_HR = getStandardDeviation (HR_samples).toFixed(1); + let average_HR = average(HR_samples).toFixed(0); + let stdev_HR = getStandardDeviation (HR_samples).toFixed(1); if (ISBANGLEJS1) { g.drawString("HR: " + average_HR, 120,100); diff --git a/apps/espruinoterm/app.js b/apps/espruinoterm/app.js index 348190db4..1253b253a 100644 --- a/apps/espruinoterm/app.js +++ b/apps/espruinoterm/app.js @@ -7,7 +7,7 @@ var R = Bangle.appRect; var termg = Graphics.createArrayBuffer(R.w, R.h, 1, {msb:true}); var termVisible = false; termg.setFont("6x8"); -term = require("VT100").connect(termg, { +let term = require("VT100").connect(termg, { charWidth : 6, charHeight : 8 }); diff --git a/apps/fclock/fclock.app.js b/apps/fclock/fclock.app.js index b010d0536..ca47a7238 100644 --- a/apps/fclock/fclock.app.js +++ b/apps/fclock/fclock.app.js @@ -86,7 +86,7 @@ const drawSec = function (sections, color) { const drawClock = function () { - currentTime = new Date(); + const currentTime = new Date(); //Get date as a string date = dateStr(currentTime); @@ -163,11 +163,11 @@ const drawHR = function () { } if (grow) { - color = settings.hr.color; + const color = settings.hr.color; g.setColor(color); g.fillCircle(settings.hr.x, settings.hr.y, size); } else { - color = "#000000"; + const color = "#000000"; g.setColor(color); g.drawCircle(settings.hr.x, settings.hr.y, size); } diff --git a/apps/flashcards/app.js b/apps/flashcards/app.js index d2118f8cb..43dde213e 100644 --- a/apps/flashcards/app.js +++ b/apps/flashcards/app.js @@ -39,7 +39,7 @@ while (str.length > maxLength) { let found = false; // Inserts new line at first whitespace of the line - for (i = maxLength - 1; i > 0; i--) { + for (let i = maxLength - 1; i > 0; i--) { if (str.charAt(i)==' ') { res = res + [str.slice(0, i), "\n"].join(''); str = str.slice(i + 1); diff --git a/apps/flow/app.js b/apps/flow/app.js index 5f4da8f35..1a8095327 100644 --- a/apps/flow/app.js +++ b/apps/flow/app.js @@ -193,7 +193,7 @@ let intervalId; if (BTN.read()) { for (let i = 0; i < 10; i++) { - color = getColor(i); + const color = getColor(i); g.setColor(color[0], color[1], color[2]); g.fillRect((i / 10) * h, 0, ((i + 1) / 10) * h, h); } diff --git a/apps/forge/forge.app.js b/apps/forge/forge.app.js index b179fb540..5169a04e9 100644 --- a/apps/forge/forge.app.js +++ b/apps/forge/forge.app.js @@ -2,9 +2,9 @@ "Bangle.loadWidgets()"; // Facilitates fastloading to this app via Fastload Utils, while still not loading widgets on standard `load` calls. -st = require('Storage'); +const st = require('Storage'); -l = /^a\..*\.js$/; +let l = /^a\..*\.js$/; //l = /.*\.js/; l = st.list(l, {sf:false}); diff --git a/apps/ftclock/mkFourTwentyTz.js b/apps/ftclock/mkFourTwentyTz.js index 4e7829aa3..6c420382f 100644 --- a/apps/ftclock/mkFourTwentyTz.js +++ b/apps/ftclock/mkFourTwentyTz.js @@ -1,3 +1,4 @@ +/* eslint-env node */ let fs = require('fs'); let csv = require('csv'); diff --git a/apps/golfview/golfview.js b/apps/golfview/golfview.js index 537bd93dd..cd2db019d 100644 --- a/apps/golfview/golfview.js +++ b/apps/golfview/golfview.js @@ -41,8 +41,8 @@ function rotateVec(a, theta) { x: 0, y: 0 }; - c = Math.cos(theta); - s = Math.sin(theta); + const c = Math.cos(theta); + const s = Math.sin(theta); pt.x = c * a.x - s * a.y; pt.y = s * a.x + c * a.y; return pt; @@ -124,7 +124,7 @@ function drawHole(l) { nodelist.push(node.x); nodelist.push(node.y); }); - newnodelist = g.transformVertices(nodelist, transform); + const newnodelist = g.transformVertices(nodelist, transform); g.fillPoly(newnodelist, true); //console.log(feature.type); @@ -139,7 +139,7 @@ function drawHole(l) { waynodelist.push(node.y); }); - newnodelist = g.transformVertices(waynodelist, transform); + const newnodelist = g.transformVertices(waynodelist, transform); g.setColor(0, 1, 1); // cyan g.drawPoly(newnodelist); } diff --git a/apps/golfview/maptools.js b/apps/golfview/maptools.js index e475c798b..07a1f67d5 100644 --- a/apps/golfview/maptools.js +++ b/apps/golfview/maptools.js @@ -40,8 +40,8 @@ function rotateVec(a, theta) { x: 0, y: 0 }; - c = Math.cos(theta); - s = Math.sin(theta); + const c = Math.cos(theta); + const s = Math.sin(theta); pt.x = c * a.x - s * a.y; pt.y = s * a.x + c * a.y; return pt; diff --git a/apps/gpsnav/app.js b/apps/gpsnav/app.js index 68bd2cbda..b5f749740 100644 --- a/apps/gpsnav/app.js +++ b/apps/gpsnav/app.js @@ -157,7 +157,7 @@ function stopdraw() { function startTimers() { candraw=true; - intervalRefSec = setInterval(function() { + /*intervalRefSec =*/ setInterval(function() { heading = newHeading(course,heading); if (course!=heading) drawCompass(heading); },200); diff --git a/apps/gpsnav/app.min.js b/apps/gpsnav/app.min.js index a01b251e0..71f0b6baa 100644 --- a/apps/gpsnav/app.min.js +++ b/apps/gpsnav/app.min.js @@ -5,7 +5,7 @@ function bearing(a,c){var b=radians(c.lon-a.lon),d=radians(a.lat),e=radians(c.la function drawN(){var a=loc.speed(speed);buf.setColor(1);buf.setFont("6x8",2);buf.drawString("o",100,0);buf.setFont("6x8",1);buf.drawString(a.substring(a.length-3),220,40);buf.setFont("Vector",48);var c=course.toString();c=10>course?"00"+c:100>course?"0"+c:c;buf.drawString(c,10,0);buf.drawString(a.substring(0,a.length-3),140,4);flip(buf,Yoff+70);buf.setColor(1);buf.setFont("Vector",24);a=brg.toString();a=10>brg?"00"+a:100>brg?"0"+a:a;buf.setColor(3);buf.drawString("Brg: ",0,0);buf.drawString("Dist: ", 0,30);buf.setColor(selected?1:2);buf.drawString(wp.name,140,0);buf.setColor(1);buf.drawString(a,60,0);buf.drawString(loc.distance(dist),60,30);flip(buf,Yoff+130);g.setFont("6x8",1);g.setColor(0,0,0);g.fillRect(10,230,60,239);g.setColor(1,1,1);g.drawString("Sats "+satellites.toString(),10,230)}var savedfix; function onGPS(a){savedfix=a;void 0!==a&&(course=isNaN(a.course)?course:Math.round(a.course),speed=isNaN(a.speed)?speed:a.speed,satellites=a.satellites);candraw&&(void 0!==a&&1==a.fix&&(dist=distance(a,wp),isNaN(dist)&&(dist=0),brg=bearing(a,wp),isNaN(brg)&&(brg=0)),drawN())}var intervalRef;function stopdraw(){candraw=!1;intervalRef&&clearInterval(intervalRef)} -function startTimers(){candraw=!0;intervalRefSec=setInterval(function(){heading=newHeading(course,heading);course!=heading&&drawCompass(heading)},200)}function drawAll(){g.setColor(1,.5,.5);g.fillPoly([120,Yoff+50,110,Yoff+70,130,Yoff+70]);g.setColor(1,1,1);drawN();drawCompass(heading)}function startdraw(){g.clear();Bangle.drawWidgets();startTimers();drawAll()} +function startTimers(){candraw=!0;setInterval(function(){heading=newHeading(course,heading);course!=heading&&drawCompass(heading)},200)}function drawAll(){g.setColor(1,.5,.5);g.fillPoly([120,Yoff+50,110,Yoff+70,130,Yoff+70]);g.setColor(1,1,1);drawN();drawCompass(heading)}function startdraw(){g.clear();Bangle.drawWidgets();startTimers();drawAll()} function setButtons(){setWatch(nextwp.bind(null,-1),BTN1,{repeat:!0,edge:"falling"});setWatch(doselect,BTN2,{repeat:!0,edge:"falling"});setWatch(nextwp.bind(null,1),BTN3,{repeat:!0,edge:"falling"})}var SCREENACCESS={withApp:!0,request:function(){this.withApp=!1;stopdraw();clearWatch()},release:function(){this.withApp=!0;startdraw();setButtons()}};Bangle.on("lcdPower",function(a){SCREENACCESS.withApp&&(a?startdraw():stopdraw())});var waypoints=require("waypoints").load(); wp=waypoints[0];function nextwp(a){selected&&(wpindex+=a,wpindex>=waypoints.length&&(wpindex=0),0>wpindex&&(wpindex=waypoints.length-1),wp=waypoints[wpindex],drawN())}function doselect(){selected&&0!=wpindex&&void 0===waypoints[wpindex].lat&&savedfix.fix&&(waypoints[wpindex]={name:"@"+wp.name,lat:savedfix.lat,lon:savedfix.lon},wp=waypoints[wpindex],require("waypoints").save(waypoints));selected=!selected;drawN()}g.clear();Bangle.setLCDBrightness(1);Bangle.loadWidgets();Bangle.drawWidgets(); Bangle.setGPSPower(1);drawAll();startTimers();Bangle.on("GPS",onGPS);setButtons(); diff --git a/apps/gpsnav/app_b2.js b/apps/gpsnav/app_b2.js index ee6519c92..189cdf363 100644 --- a/apps/gpsnav/app_b2.js +++ b/apps/gpsnav/app_b2.js @@ -168,7 +168,7 @@ function stopdraw() { function startTimers() { candraw = true; - intervalRefSec = setInterval(function() { + /*intervalRefSec =*/ setInterval(function() { heading = newHeading(course, heading); if (course != heading) drawCompass(heading); }, 200); diff --git a/apps/gsat/app.js b/apps/gsat/app.js index 3a7d443fe..5c4c81b80 100644 --- a/apps/gsat/app.js +++ b/apps/gsat/app.js @@ -21,7 +21,7 @@ function drawTime() { Bangle.buzz(); return; } - min = seconds / secsinmin; + const min = seconds / secsinmin; if (seconds < quickfixperiod) { g.setFont('Vector', 20); g.drawString('Quick Fix', 125, 50); diff --git a/apps/guitarsongs/app.js b/apps/guitarsongs/app.js index 2536e1c46..c03fe70e3 100644 --- a/apps/guitarsongs/app.js +++ b/apps/guitarsongs/app.js @@ -116,7 +116,7 @@ function drawChordCached(chord, x, y, options) { if (chordCache[chord[0]]) { image = chordCache[chord[0]] } else { - arrbuff = Graphics.createArrayBuffer(chordWidth,chordHeight,1,{msb:true}); + let arrbuff = Graphics.createArrayBuffer(chordWidth,chordHeight,1,{msb:true}); drawChord(arrbuff, chord, 0, 0, options); image = {width: arrbuff.getWidth(), height: arrbuff.getHeight(), bpp:arrbuff.getBPP(), buffer: arrbuff.buffer, transparent:0} chordCache[chord[0]] = image; diff --git a/apps/ha/ha.lib.js b/apps/ha/ha.lib.js index 93ba2416e..7b26b02b2 100644 --- a/apps/ha/ha.lib.js +++ b/apps/ha/ha.lib.js @@ -3,7 +3,7 @@ * configured and send a trigger to homeassistant. */ function _getIcon(trigger){ - icon = trigger.icon; + const icon = trigger.icon; if(icon == "light"){ return { width : 48, height : 48, bpp : 1, diff --git a/apps/hamloc/app.js b/apps/hamloc/app.js index ac608a5f4..3ac792c0b 100644 --- a/apps/hamloc/app.js +++ b/apps/hamloc/app.js @@ -1,4 +1,4 @@ -latLonToGridSquare=function(o,a){var t,e,n,s,l,i,r,h,M,f=-100,g=0,u="ABCDEFGHIJKLMNOPQRSTUVWX",d=u.toLowerCase();function N(o){return"number"==typeof o?o:"string"==typeof o?parseFloat(o):"function"==typeof o?parseFloat(o()):void E.showMessage("can't convert \ninput: "+o)}return"object"==typeof o?2===o.length?(f=N(o[0]),g=N(o[1])):"lat"in o&&"lon"in o?(f=N(o.lat),g=N(o.lon)):"latitude"in o&&"longitude"in o?(f=N(o.latitude),g=N(o.longitude)):E.showMessage("can't convert \nobject "+o):(f=N(o),g=N(a)),isNaN(f)&&E.showMessage("lat is NaN"),isNaN(g)&&E.showMessage("lon is NaN"),90===Math.abs(f)&&E.showMessage("grid invalid \nat N/S"),90editAlarm(-1) }; alarms.forEach((alarm,idx)=>{ - txt = (alarm.on?"on ":"off ")+formatTime(alarm.hr); + let txt = (alarm.on?"on ":"off ")+formatTime(alarm.hr); if (alarm.rp) txt += " (repeat)"; menu[txt] = function() { editAlarm(idx); diff --git a/apps/hcclock/hcclock.app.js b/apps/hcclock/hcclock.app.js index 8cf7b35b5..f4703d597 100644 --- a/apps/hcclock/hcclock.app.js +++ b/apps/hcclock/hcclock.app.js @@ -147,7 +147,7 @@ function drawDigits(x, value) function drawChar(i, xMin, yMin, xMax, yMax) { numbers[i].forEach(rect => { - r = place(rect, xMin, yMin, xMax, yMax); + const r = place(rect, xMin, yMin, xMax, yMax); g.setColor(fg,fg,fg); g.fillRect(r[0], r[1], r[2], r[3]); }); diff --git a/apps/heart/app.js b/apps/heart/app.js index c10185b5f..4955bc291 100644 --- a/apps/heart/app.js +++ b/apps/heart/app.js @@ -214,7 +214,7 @@ function graphRecord(n) { var measure; while (line !== undefined) { - currentLine = line; + const currentLine = line; line = f.readLine(); tempCount++; if (tempCount == startLine) { @@ -259,7 +259,7 @@ function graphRecord(n) { positionX++; if (parseInt(currentLine.split(",")[2]) >= 70) { g.setColor(1, 0.3, 0.3); - oldPositionY = positionY; + const oldPositionY = positionY; measure = parseInt(currentLine.split(",")[1]); positionY = GraphYZero - measure + MinMeasurement; if (positionY > GraphYZero) { diff --git a/apps/hidbkbd/hid-binary-keyboard.js b/apps/hidbkbd/hid-binary-keyboard.js index 4b0401699..1d4d5baf0 100644 --- a/apps/hidbkbd/hid-binary-keyboard.js +++ b/apps/hidbkbd/hid-binary-keyboard.js @@ -71,8 +71,8 @@ function show(chars,callback) { return; } var m = chars.length/2; - charl=chars.slice(0,m); - charr=chars.slice(m); + let charl=chars.slice(0,m); + let charr=chars.slice(m); showChars(0,charl); showChars(120,charr); setWatch(() => { diff --git a/apps/homework/app.js b/apps/homework/app.js index 8440f0dee..c88f82ee5 100644 --- a/apps/homework/app.js +++ b/apps/homework/app.js @@ -135,7 +135,7 @@ function checkPreciseHomework(subjectnum) { // P A I N checkPreciseHomeworkMenu[subject] = function() {}, checkPreciseHomeworkMenu[taskmsg] = function() {}, checkPreciseHomeworkMenu[statusmsg] = function() { - status = "Status: Finished"; + status = "Status: Finished"; // TODO: Should this have been called `statusmsg`? var d = new Date(); var currenttime = require("locale").time(d, 1); var currentdate = require("locale").date(d); diff --git a/apps/hworldclock/app.js b/apps/hworldclock/app.js index d97b98319..0c06a16c2 100644 --- a/apps/hworldclock/app.js +++ b/apps/hworldclock/app.js @@ -4,6 +4,7 @@ const SETTINGSFILE = "hworldclock.json"; let secondsMode; let showSunInfo; +let singleOffsetSmall; let colorWhenDark; let rotationTarget; // ------- Settings file @@ -155,7 +156,7 @@ let updatePos = function() { let coord = require("Storage").readJSON(LOCATION_FILE,1)|| {"lat":0,"lon":0,"location":"-"}; //{"lat":53.3,"lon":10.1,"location":"Pattensen"}; if (coord.lat != 0 && coord.lon != 0) { //pos = SunCalc.getPosition(Date.now(), coord.lat, coord.lon); - times = SunCalc.getTimes(Date.now(), coord.lat, coord.lon); + const times = SunCalc.getTimes(Date.now(), coord.lat, coord.lon); rise = "^" + times.sunrise.toString().split(" ")[4].substr(0,5); set = "v" + times.sunset.toString().split(" ")[4].substr(0,5); //noonpos = SunCalc.getPosition(times.solarNoon, coord.lat, coord.lon); @@ -253,7 +254,7 @@ let draw = function() { // Loop through offset(s) and render offsets.forEach((offset, index) => { - dx = getCurrentTimeFromOffset(gmt, offset[OFFSET_HOURS]); + const dx = getCurrentTimeFromOffset(gmt, offset[OFFSET_HOURS]); hours = doublenum(dx.getHours()); minutes = doublenum(dx.getMinutes()); diff --git a/apps/icons/gen/generate.js b/apps/icons/gen/generate.js index edf49e212..b91eedcdc 100755 --- a/apps/icons/gen/generate.js +++ b/apps/icons/gen/generate.js @@ -5,6 +5,8 @@ // Icons from https://fonts.google.com/icons +/* eslint-env node */ + var imageconverter = require("../../../webtools/imageconverter.js").imageconverter; var icons = JSON.parse(require("fs").readFileSync(__dirname+"/icon_names.json")); const imgOptions = { diff --git a/apps/infoclk/configLoad.js b/apps/infoclk/configLoad.js index a9d43826e..ac810b83e 100644 --- a/apps/infoclk/configLoad.js +++ b/apps/infoclk/configLoad.js @@ -109,7 +109,7 @@ function isDictionary(object) { function merge(overlay, base) { let result = base; - for (objectKey in overlay) { + for (const objectKey in overlay) { if (!Object.keys(base).includes(objectKey)) result[objectKey] = overlay[objectKey]; // If the key isn't there, add it else if (isDictionary(base[objectKey]) && isDictionary(overlay[objectKey])) // If the key is a dictionary in both, do recursive call result[objectKey] = merge(overlay[objectKey], base[objectKey]); diff --git a/apps/kineticscroll/boot.js b/apps/kineticscroll/boot.js index 1f1b7923a..71234596e 100644 --- a/apps/kineticscroll/boot.js +++ b/apps/kineticscroll/boot.js @@ -124,7 +124,7 @@ } velocity = E.clip(velocity,-MAX_VELOCITY,MAX_VELOCITY); - lastDrag=Date.now(); + //lastDrag=Date.now(); if (!scheduledDraw){ scheduledDraw = setTimeout(draw,0); } diff --git a/apps/kineticscroll/boot.min.js b/apps/kineticscroll/boot.min.js index 42f0afa67..60c6002ca 100644 --- a/apps/kineticscroll/boot.min.js +++ b/apps/kineticscroll/boot.min.js @@ -1,4 +1,4 @@ (function(){E.showScroller=function(c){function k(a){return a*c.h+b.y-l}function h(a){return Math.floor((a+l-b.y)/c.h)}if(!c)return Bangle.setUI();let p,e=0,m=0,w=setInterval(()=>{e*=.9},50),q=0,b=Bangle.appRect,n=0|c.scrollMin,r=c.h*c.c-b.h;r{g.reset().clearRect(b).setClipRect(b.x,b.y,b.x2,b.y2);for(var a=h(b.y),d=Math.min(h(b.y2),c.c-1);a<=d;a++)c.draw(a,{x:b.x,y:k(a),w:b.w,h:c.h});g.setClipRect(0,0,g.getWidth()-1,g.getHeight()-1)},u=()=>{var a=e;f.scroll-a>r&& (a=f.scroll-r,e=0);f.scroll-aa){a=Math.max(b.y2-(1-a),b.y);g.setClipRect(b.x,a,b.x2,b.y2);var d=h(a);for(a=k(d);ab.y-c.h;a-=c.h)c.draw(d,{x:b.x,y:a,w:b.w,h:c.h}),d--;g.setClipRect(0,0,g.getWidth()-1,g.getHeight()- -1)}};let v={mode:"custom",back:c.back,drag:a=>{if(0>e&&0a.dy)e*=-1,m=5*e;0{if(!(d.yn||0<=a)&&a{p&&clearTimeout(p);clearInterval(w);c.remove()});Bangle.setUI(v);let f={scroll:E.clip(0|c.scroll, +1)}};let v={mode:"custom",back:c.back,drag:a=>{if(0>e&&0a.dy)e*=-1,m=5*e;0{if(!(d.yn||0<=a)&&a{p&&clearTimeout(p);clearInterval(w);c.remove()});Bangle.setUI(v);let f={scroll:E.clip(0|c.scroll, n,r),draw:()=>{g.reset().clearRect(b).setClipRect(b.x,b.y,b.x2,b.y2);var a=h(b.y);let d=Math.min(h(b.y2),c.c-1);for(;a<=d;a++)c.draw(a,{x:b.x,y:k(a),w:b.w,h:c.h});g.setClipRect(0,0,g.getWidth()-1,g.getHeight()-1)},drawItem:a=>{let d=k(a);g.reset().setClipRect(b.x,Math.max(d,b.y),b.x2,Math.min(d+c.h,b.y2));c.draw(a,{x:b.x,y:d,w:b.w,h:c.h});g.setClipRect(0,0,g.getWidth()-1,g.getHeight()-1)},isActive:()=>Bangle.uiRedraw==t},l=f.scroll&-2;f.draw();g.flip();return f}})() \ No newline at end of file diff --git a/apps/macwatch/app.js b/apps/macwatch/app.js index fb9712a36..72072186a 100644 --- a/apps/macwatch/app.js +++ b/apps/macwatch/app.js @@ -4,6 +4,8 @@ function draw() { g.reset(); g.setFontCustom(font, 48, 8, 1801); g.setFontAlign(0, -1, 0); + let line1; + let line2; if (showDate) { if (g.theme.dark) { g.setColor("#00ffff"); // cyan date numbers for dark mode diff --git a/apps/macwatch2/app.js b/apps/macwatch2/app.js index 36917a988..fab2ec036 100644 --- a/apps/macwatch2/app.js +++ b/apps/macwatch2/app.js @@ -36,9 +36,9 @@ function draw() { g.drawString(hh, 52, 65, true); g.drawString(mm, 132, 65, true); g.drawString(':', 93,65); - dd = ("0"+(new Date()).getDate()).substr(-2); - mo = ("0"+((new Date()).getMonth()+1)).substr(-2); - yy = ("0"+((new Date()).getFullYear())).substr(-2); + const dd = ("0"+(new Date()).getDate()).substr(-2); + const mo = ("0"+((new Date()).getMonth()+1)).substr(-2); + const yy = ("0"+((new Date()).getFullYear())).substr(-2); g.setFontCustom(font, 48, 8, 521); g.drawString(dd + ':' + mo + ':' + yy, 88, 120, true); } diff --git a/apps/messageicons/icons/generate.js b/apps/messageicons/icons/generate.js index 4b52ae167..854e04143 100755 --- a/apps/messageicons/icons/generate.js +++ b/apps/messageicons/icons/generate.js @@ -5,6 +5,8 @@ // default icon must come first in icon_names +/* eslint-env node */ + var imageconverter = require("../../../webtools/imageconverter.js"); var icons = JSON.parse(require("fs").readFileSync(__dirname+"/icon_names.json")); const imgOptions = { diff --git a/apps/miclock2/clock-mixed.js b/apps/miclock2/clock-mixed.js index e6bc0c094..828a02783 100644 --- a/apps/miclock2/clock-mixed.js +++ b/apps/miclock2/clock-mixed.js @@ -69,7 +69,7 @@ const drawMixedClock = function() { buf.drawString(dateArray[3], 237, 176, true); // draw hour and minute dots - for (i = 0; i < 60; i++) { + for (let i = 0; i < 60; i++) { radius = (i % 5) ? 2 : 4; rotatePoint(0, Radius.dots, i * 6, Center, point); buf.fillCircle(point[0], point[1], radius); diff --git a/apps/miplant/app.js b/apps/miplant/app.js index b6c4ab89a..939b9105f 100644 --- a/apps/miplant/app.js +++ b/apps/miplant/app.js @@ -21,7 +21,7 @@ function parseDevice(device) { var l = d.getUint8(offset+2); var code = d.getUint16(offset,true); if (!deviceInfo[device.id]) deviceInfo[device.id]={id:device.id}; - event = deviceInfo[device.id]; + let event = deviceInfo[device.id]; switch (code) { case 0x1004: event.temperature = d.getInt16(offset+3,true)/10; break; case 0x1006: event.humidity = d.getInt16(offset+3)/10; break; diff --git a/apps/mosaic/mosaic.app.js b/apps/mosaic/mosaic.app.js index 7fcb631f1..98ed9645c 100644 --- a/apps/mosaic/mosaic.app.js +++ b/apps/mosaic/mosaic.app.js @@ -76,7 +76,7 @@ g.clear(); loadSettings(); loadThemeColors(); -offset_widgets = settings.showWidgets ? 24 : 0; +const offset_widgets = settings.showWidgets ? 24 : 0; let available_height = g.getHeight() - offset_widgets; // Calculate grid size and offsets diff --git a/apps/multiclock/big.face.js b/apps/multiclock/big.face.js index 2db4ee4d4..10513e2e8 100644 --- a/apps/multiclock/big.face.js +++ b/apps/multiclock/big.face.js @@ -7,7 +7,7 @@ const F = 132*H/240; // reasonable approximation function drawTime() { - d = new Date() + const d = new Date() g.reset(); var da = d.toString().split(" "); var time = da[4].substr(0, 5).split(":"); diff --git a/apps/multiclock/dk.face.js b/apps/multiclock/dk.face.js index bd815da96..dbe4af3a2 100644 --- a/apps/multiclock/dk.face.js +++ b/apps/multiclock/dk.face.js @@ -9,12 +9,12 @@ function drawClock(){ var now=Date(); - d=now.toString().split(' '); - var min=d[4].substr(3,2); + let d=now.toString().split(' '); + //var min=d[4].substr(3,2); //var sec=d[4].substr(-2); var tm=d[4].substring(0,5); //var hr=d[4].substr(0,2); - lastmin=min; + //lastmin=min; g.reset(); g.clearRect(0,24,W-1,H-1); g.setColor(g.theme.fg); diff --git a/apps/multitimer/alarm.js b/apps/multitimer/alarm.js index b202ae662..6d7c03184 100644 --- a/apps/multitimer/alarm.js +++ b/apps/multitimer/alarm.js @@ -17,6 +17,7 @@ function hardMode(tries, max) { g.reset(); g.setClipRect(R.x,R.y,R.x2,R.y2); var code = Math.abs(E.hwRand()%4); + let dir; if (code == 0) dir = "up"; else if (code == 1) dir = "right"; else if (code == 2) dir = "down"; diff --git a/apps/mylocation/settings.js b/apps/mylocation/settings.js index fcae0389c..09640b67a 100644 --- a/apps/mylocation/settings.js +++ b/apps/mylocation/settings.js @@ -51,7 +51,7 @@ function setFromGPS() { } function setFromWaypoint() { - wpmenu = { + const wpmenu = { '': { 'title': /*LANG*/'Waypoint' }, '< Back': ()=>{ showMainMenu(); }, }; diff --git a/apps/neonx/neonx.app.js b/apps/neonx/neonx.app.js index 7fcf01bde..2b5ce4e21 100644 --- a/apps/neonx/neonx.app.js +++ b/apps/neonx/neonx.app.js @@ -115,7 +115,7 @@ function drawAnimated(){ queueDraw(); // Animate draw through different colors - speed = 25; + const speed = 25; setTimeout(function() { _draw(false, 1); setTimeout(function() { diff --git a/apps/nixie/app.js b/apps/nixie/app.js index 2b948b120..8c06a4abc 100644 --- a/apps/nixie/app.js +++ b/apps/nixie/app.js @@ -237,7 +237,7 @@ for (let idx=0; idx*2 < points6.length; idx++) { points9[idx*2+1] = 99-points6[idx*2+1]; } -pointsArray = [points0, points1, points2, points3, points4, points5, points6, points7, points8, points9]; +const pointsArray = [points0, points1, points2, points3, points4, points5, points6, points7, points8, points9]; function eraseDigit(d, x, y) { if(d < 0 || d > 9) return; diff --git a/apps/notanalog/notanalog.app.js b/apps/notanalog/notanalog.app.js index c0c5fc077..3e19780fa 100644 --- a/apps/notanalog/notanalog.app.js +++ b/apps/notanalog/notanalog.app.js @@ -274,7 +274,7 @@ function handleState(fastUpdate){ // Set weather state.has_weather = true; try { - weather = require('weather').get(); + const weather = require('weather').get(); if (weather === undefined){ state.has_weather = false; state.temp = "-"; diff --git a/apps/ohmcalc/app.js b/apps/ohmcalc/app.js index 5ef30aaa5..5b7d470aa 100644 --- a/apps/ohmcalc/app.js +++ b/apps/ohmcalc/app.js @@ -325,7 +325,7 @@ function calculateValue(calculatedVariable, variableValues) { // Move down for the next entry let nextTitleY = (i + 1 < titlePositions.length) ? titlePositions[i + 1] : titleY + 1.5 * fontSize + lineSpacing; - yPosition = nextTitleY; + //yPosition = nextTitleY; } g.flip(); }; diff --git a/apps/openstmap/app.js b/apps/openstmap/app.js index 2d14fbd2a..3882df946 100644 --- a/apps/openstmap/app.js +++ b/apps/openstmap/app.js @@ -252,7 +252,7 @@ function showMap() { hasScrolled = true; drawLocation(); } else if (hasScrolled) { - delta = getTime() - startDrag; + const delta = getTime() - startDrag; startDrag = 0; hasScrolled = false; if (delta < 0.2) { diff --git a/apps/orloj/app.js b/apps/orloj/app.js index 166cbdb29..4bfcb1548 100644 --- a/apps/orloj/app.js +++ b/apps/orloj/app.js @@ -297,17 +297,17 @@ function drawBorders() { } { d = new Date(); - sun = SunCalc.getTimes(d, lat, lon); + const sun = SunCalc.getTimes(d, lat, lon); g.setColor(0.5, 0.5, 0); print("sun", sun); drawTimeIcon(sun.sunset, img_sunrise, { rotate: Math.PI, scale: 2 }); drawTimeIcon(sun.sunrise, img_sunrise, { scale: 2 }); g.setColor(0, 0, 0); - moon = SunCalc.getMoonTimes(d, lat, lon); + const moon = SunCalc.getMoonTimes(d, lat, lon); print("moon", moon); drawTimeIcon(moon.set, img_moonrise, { rotate: Math.PI, scale: 2 }); drawTimeIcon(moon.rise, img_sunrise, { scale: 2 }); - pos = SunCalc.getPosition(d, lat, lon); + let pos = SunCalc.getPosition(d, lat, lon); print("sun:", pos); if (pos.altitude > -0.1) { g.setColor(0.5, 0.5, 0); diff --git a/apps/owmweather/settings.js b/apps/owmweather/settings.js index a4d21dd7c..4007981e8 100644 --- a/apps/owmweather/settings.js +++ b/apps/owmweather/settings.js @@ -70,7 +70,7 @@ E.showMenu(buildMainMenu()); }); } else { - E.showPrompt("Install a text input lib"),then(()=>{ + E.showPrompt("Install a text input lib"),then(()=>{ // TODO: Should `,then` have been `.then` ? E.showMenu(buildMainMenu()); }); } diff --git a/apps/podadrem/app.js b/apps/podadrem/app.js index 6f8721126..5407e3ec4 100644 --- a/apps/podadrem/app.js +++ b/apps/podadrem/app.js @@ -16,7 +16,7 @@ let dark = g.theme.dark; // bool let gfx = function() { widgetUtils.hide(); R = Bangle.appRect; - marigin = 8; + const marigin = 8; // g.drawString(str, x, y, solid) g.clearRect(R); g.reset(); @@ -53,9 +53,9 @@ let gfx = function() { // Touch handler for main layout let touchHandler = function(_, xy) { - x = xy.x; - y = xy.y; - len = (R.wb-1 instead of a>=b. if ((R.x-1 { //const w0 = lengths[min]; let widths = ''; for (c = min, o = 0; c <= max; c++) { - for (i = 0, j = offsets[c]; i < lengths[c]; i++) { + for (let i = 0, j = offsets[c]; i < lengths[c]; i++) { xoffs[j] = asc + body + adjustments[c] - 1; ypos[j++] = o++; } @@ -113,7 +113,7 @@ const prepFont = (name, data) => { return x; }; -res = ` +let res = ` const heatshrink = require('heatshrink'); const dec = x => E.toString(heatshrink.decompress(atob(x))); `; diff --git a/apps/pooqround/resourcer.js b/apps/pooqround/resourcer.js index 91b6aa6db..fd6e8ffc4 100644 --- a/apps/pooqround/resourcer.js +++ b/apps/pooqround/resourcer.js @@ -92,7 +92,7 @@ const prepFont = (name, data) => { //const w0 = lengths[min]; let widths = ''; for (c = min, o = 0; c <= max; c++) { - for (i = 0, j = offsets[c]; i < lengths[c]; i++) { + for (let i = 0, j = offsets[c]; i < lengths[c]; i++) { xoffs[j] = asc + body + adjustments[c] - 1; ypos[j++] = o++; } @@ -113,7 +113,7 @@ const prepFont = (name, data) => { return x; }; -res = ` +let res = ` const heatshrink = require('heatshrink'); const dec = x => E.toString(heatshrink.decompress(atob(x))); `; diff --git a/apps/promenu/boot.js b/apps/promenu/boot.js index bd813a812..a3d96a255 100644 --- a/apps/promenu/boot.js +++ b/apps/promenu/boot.js @@ -1,6 +1,6 @@ E.showMenu = function(items) { function RectRnd(x1,y1,x2,y2,r) { - pp = []; + let pp = []; pp.push.apply(pp,g.quadraticBezier([x2-r,y1, x2,y1,x2,y1+r])); pp.push.apply(pp,g.quadraticBezier([x2,y2-r,x2,y2,x2-r,y2])); pp.push.apply(pp,g.quadraticBezier([x1+r,y2,x1,y2,x1,y2-r])); diff --git a/apps/promenu/bootb2.js b/apps/promenu/bootb2.js index c84e0d894..b02803a7a 100644 --- a/apps/promenu/bootb2.js +++ b/apps/promenu/bootb2.js @@ -1,6 +1,6 @@ E.showMenu = function(items) { function RectRnd(x1,y1,x2,y2,r) { - pp = []; + let pp = []; pp.push.apply(pp,g.quadraticBezier([x2-r,y1, x2,y1,x2,y1+r])); pp.push.apply(pp,g.quadraticBezier([x2,y2-r,x2,y2,x2-r,y2])); pp.push.apply(pp,g.quadraticBezier([x1+r,y2,x1,y2,x1,y2-r])); diff --git a/apps/qcenter/settings.js b/apps/qcenter/settings.js index 5d38b079e..ab7d561d1 100644 --- a/apps/qcenter/settings.js +++ b/apps/qcenter/settings.js @@ -143,7 +143,7 @@ showMainMenu(); }; let timeoutvalues = [10,20,30,60]; - for (c in timeoutvalues){ + for (const c in timeoutvalues){ let v = timeoutvalues[c]; timeoutMenu[v+"s"] = function () { save("timeout", v); diff --git a/apps/quoteclock/app.js b/apps/quoteclock/app.js index 63b3ea032..981c972ff 100644 --- a/apps/quoteclock/app.js +++ b/apps/quoteclock/app.js @@ -105,12 +105,12 @@ function drawStrCenter(str, colour) { g.setColor(colour); g.setFont("Vector", 13); str = "\"" + str + "\""; - maxLength = 24; + const maxLength = 24; var ta = []; let index = 0; let linestart = 0; while (index < str.length) { - newIndex = str.indexOf(" ", index); + const newIndex = str.indexOf(" ", index); if (newIndex == -1) { if ((str.length - linestart) > maxLength) { ta.push(str.substring(linestart, index)); @@ -122,7 +122,7 @@ function drawStrCenter(str, colour) { linestart = index; } else index = newIndex + 1; } - y = 110 - ta.length * 5; + let y = 110 - ta.length * 5; ta.forEach((e) => { g.setFontAlign(0, -1).drawString(e.trim(), 88, y); y += 12; diff --git a/apps/random/app.js b/apps/random/app.js index c3001a6d1..6b9b2f17e 100644 --- a/apps/random/app.js +++ b/apps/random/app.js @@ -110,8 +110,8 @@ function showCardMenu() { }, 'Go': () => { n = Math.min(n, 52); - SUITS = ['Spades', 'Diamonds', 'Clubs', 'Hearts']; - RANKS = ['Ace', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'Jack', 'Queen', 'King']; + const SUITS = ['Spades', 'Diamonds', 'Clubs', 'Hearts']; + const RANKS = ['Ace', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'Jack', 'Queen', 'King']; class Card { constructor(suit, rank) { this.suit = suit; diff --git a/apps/rclock/rclock.app.js b/apps/rclock/rclock.app.js index 2d6f84dc4..6bc5977c9 100644 --- a/apps/rclock/rclock.app.js +++ b/apps/rclock/rclock.app.js @@ -90,17 +90,17 @@ const drawSecArc = function (sections, color) { const drawClock = function () { g.reset(); - currentTime = new Date(); + let currentTime = new Date(); //Set to initial time when started if (first == true) { minutes = currentTime.getMinutes(); seconds = currentTime.getSeconds(); - for (count = 0; count <= minutes; count++) { + for (let count = 0; count <= minutes; count++) { drawMinArc(count, settings.circle.colormin); } - for (count = 0; count <= seconds; count++) { + for (let count = 0; count <= seconds; count++) { drawSecArc(count, settings.circle.colorsec); } first = false; @@ -110,7 +110,7 @@ const drawClock = function () { if (seconds == 59) { g.setColor('#000000'); g.fillCircle(settings.circle.middle, settings.circle.center, (settings.circle.height / 2)); - for (count = 0; count <= minutes; count++) { + for (let count = 0; count <= minutes; count++) { drawMinArc(count, settings.circle.colormin); } } diff --git a/apps/rebble/rebble.app.js b/apps/rebble/rebble.app.js index bc18d997d..fc5e0ded4 100644 --- a/apps/rebble/rebble.app.js +++ b/apps/rebble/rebble.app.js @@ -313,7 +313,7 @@ Graphics.prototype.setFontKdamThmor = function(scale) { if( Bangle.isCharging() ) { g.setBgColor(settings.bg); - image = ()=> { return require("heatshrink").decompress(atob("j8OwMB/4AD94DC44DCwP//n/gH//EOgE/+AdBh/gAYMH4EAvkDAYP/+/AFAX+FgfzGAnAA=="));} + const image = ()=> { return require("heatshrink").decompress(atob("j8OwMB/4AD94DC44DCwP//n/gH//EOgE/+AdBh/gAYMH4EAvkDAYP/+/AFAX+FgfzGAnAA=="));} g.drawImage(image(),x+3,y+4); } diff --git a/apps/rebbleagenda/app.js b/apps/rebbleagenda/app.js index 3b6eca900..8054f0335 100644 --- a/apps/rebbleagenda/app.js +++ b/apps/rebbleagenda/app.js @@ -250,8 +250,8 @@ let oldPoly2 = CLEAR_POLYS_2[0]; doAnim(i => { i = ease(i); - poly1 = interpolatePoly(CLEAR_POLYS_1, i); - poly2 = interpolatePoly(CLEAR_POLYS_2, i); + const poly1 = interpolatePoly(CLEAR_POLYS_1, i); + const poly2 = interpolatePoly(CLEAR_POLYS_2, i); // Fill in black line g.setColor(TEXT_COLOR); g.fillPoly(poly1); diff --git a/apps/rellotge/rellotge.js b/apps/rellotge/rellotge.js index 437766167..7ae48b745 100644 --- a/apps/rellotge/rellotge.js +++ b/apps/rellotge/rellotge.js @@ -22,6 +22,7 @@ g.setFontAlign(-1, 0); // draw time + let t; if (m >= 0 && m < 2) { t = leshores[d.getHours()] + "\r\nen punt"; } else if (m >= 2 && m < 5) { diff --git a/apps/rings/app.js b/apps/rings/app.js index 72485a763..6fbb0839f 100644 --- a/apps/rings/app.js +++ b/apps/rings/app.js @@ -145,7 +145,7 @@ function drawMonthCircleText( text, circleSize, range, value){ grimg.transparent = 1; monthCircleTextBuffer.setColor(1,1,1); - for(z=0; z < text.length; z++){ + for(let z=0; z < text.length; z++){ tobj = { x:watch.screen.centerX, y:watch.screen.centerY, scale:1, rotate: ((z + 1) / range) * (Math.PI * 2) }; tver = [-1, 0, 1, 0, 1, -circleSize, -1, -(circleSize -21)]; tran = monthCircleTextBuffer.transformVertices(tver, tobj); diff --git a/apps/rndmclk/widget.js b/apps/rndmclk/widget.js index 479d8b2c3..ceb517d74 100644 --- a/apps/rndmclk/widget.js +++ b/apps/rndmclk/widget.js @@ -19,7 +19,7 @@ // Only update the file if the clock really changed to be nice to the FLASH mem if (clockApps[clockIndex].src != currentClock) { currentClock = clockApps[clockIndex].src; - settings = require("Storage").readJSON('setting.json', 1); + const settings = require("Storage").readJSON('setting.json', 1); settings.clock = clockApps[clockIndex].src; require("Storage").write('setting.json', settings); diff --git a/apps/rtorch/app.js b/apps/rtorch/app.js index 03a50ee10..e81e0c329 100644 --- a/apps/rtorch/app.js +++ b/apps/rtorch/app.js @@ -1,7 +1,7 @@ Bangle.setLCDPower(1); Bangle.setLCDTimeout(0); g.reset(); -c = 1; +let c = 1; function setColor(delta){ c+=delta; diff --git a/apps/ruuviwatch/ruuviwatch.app.js b/apps/ruuviwatch/ruuviwatch.app.js index 90d83d0c7..be4855539 100644 --- a/apps/ruuviwatch/ruuviwatch.app.js +++ b/apps/ruuviwatch/ruuviwatch.app.js @@ -16,9 +16,9 @@ let paused = false; const SCAN_FREQ = 1000 * 30; // ALERT LIMITS -LIMIT_SAUNA = 60; -LIMIT_FRIDGE = 4; -LIMIT_FREEZER = -18; +const LIMIT_SAUNA = 60; +const LIMIT_FRIDGE = 4; +const LIMIT_FREEZER = -18; // TODO add wine cellar limits // TODO configurable limits diff --git a/apps/score/score.app.js b/apps/score/score.app.js index 56c5a52bf..b2a81c251 100644 --- a/apps/score/score.app.js +++ b/apps/score/score.app.js @@ -96,7 +96,6 @@ function setupMatch() { function showSettingsMenu() { settingsMenuOpened = getSecondsTime(); - l = null; settingsMenu(function (s, reset) { E.showMenu(); diff --git a/apps/seiko-5actus/app.js b/apps/seiko-5actus/app.js index 7d5e34f7c..39cc59c70 100644 --- a/apps/seiko-5actus/app.js +++ b/apps/seiko-5actus/app.js @@ -120,7 +120,7 @@ function drawHands() { else {g.setColor(g.theme.bg);} g.drawString(weekDay[0].toUpperCase(), 137, 90); - handLayers = [ + const handLayers = [ {x:cx, y:cy, image:imgHour, @@ -148,7 +148,7 @@ function drawBackground() { g.clear(1); g.setBgColor(g.theme.bg); g.setColor(g.theme.fg); - bgLayer = [ + const bgLayer = [ {x:cx, y:cy, image:imgBg, diff --git a/apps/setting/settings.js b/apps/setting/settings.js index df7fe2b3e..99a8971fb 100644 --- a/apps/setting/settings.js +++ b/apps/setting/settings.js @@ -761,7 +761,7 @@ function showLauncherMenu() { } function showSetTimeMenu() { - d = new Date(); + let d = new Date(); const timemenu = { '': { 'title': /*LANG*/'Date & Time' }, '< Back': function () { diff --git a/apps/showimg/app.js b/apps/showimg/app.js index e00385bd7..cc1a0222a 100644 --- a/apps/showimg/app.js +++ b/apps/showimg/app.js @@ -1,7 +1,7 @@ g.reset(); g.clear(); g.drawImage(require("Storage").read("showimg.user.img"),0,0); -drawTimeout = setTimeout(function() { +/*let drawTimeout =*/ setTimeout(function() { load(); }, 60000); setWatch(function() { diff --git a/apps/speedalt2/app.js b/apps/speedalt2/app.js index 3e58e1001..2f9677603 100644 --- a/apps/speedalt2/app.js +++ b/apps/speedalt2/app.js @@ -329,7 +329,7 @@ function drawClock() { y=0; buf.setFontAlign(1,-1); buf.setFontVector(94); - time = require("locale").time(new Date(),1); + const time = require("locale").time(new Date(),1); buf.setColor(1); diff --git a/apps/sunclock/app.js b/apps/sunclock/app.js index 1685bc218..add39c8ec 100644 --- a/apps/sunclock/app.js +++ b/apps/sunclock/app.js @@ -3,10 +3,10 @@ Peter Bernschneider 30.12.2021 Update current latitude and longitude in My Location app Update current Timezone in Settings app, menu item "System" Update for summer time by incrementing Timezone += 1 */ -setting = require("Storage").readJSON("setting.json",1); +const setting = require("Storage").readJSON("setting.json",1); E.setTimeZone(setting.timezone); // timezone = 1 for MEZ, = 2 for MESZ -SunCalc = require("suncalc.js"); -loc = require('locale'); +const SunCalc = require("suncalc.js"); +const loc = require('locale'); const LOCATION_FILE = "mylocation.json"; const xyCenter = g.getWidth() / 2 + 3; const yposTime = 60; @@ -28,9 +28,9 @@ function updatePos() { altitude: Math.round( pos.altitude / rad) }; } - coord = require("Storage").readJSON(LOCATION_FILE,1)|| {"lat":53.3,"lon":10.1,"location":"Pattensen"}; + const coord = require("Storage").readJSON(LOCATION_FILE,1)|| {"lat":53.3,"lon":10.1,"location":"Pattensen"}; pos = radToDeg(SunCalc.getPosition(Date.now(), coord.lat, coord.lon)); - times = SunCalc.getTimes(Date.now(), coord.lat, coord.lon); + const times = SunCalc.getTimes(Date.now(), coord.lat, coord.lon); rise = times.sunrise.toString().split(" ")[4].substr(0,5); set = times.sunset.toString().split(" ")[4].substr(0,5); noonpos = radToDeg(SunCalc.getPosition(times.solarNoon, coord.lat, coord.lon)); diff --git a/apps/sunrise/app.js b/apps/sunrise/app.js index 6b82d3c65..9f2a31806 100644 --- a/apps/sunrise/app.js +++ b/apps/sunrise/app.js @@ -88,7 +88,7 @@ Date.prototype.sunriseSet = function (latitude, longitude, sunrise, zenith) { sinDec = 0.39782 * Math.sinDeg(sunTrueLongitude); cosDec = Math.cosDeg(Math.asinDeg(sinDec)); - cosLocalHourAngle = ((Math.cosDeg(zenith)) - (sinDec * (Math.sinDeg(latitude)))) / (cosDec * (Math.cosDeg(latitude))); + const cosLocalHourAngle = ((Math.cosDeg(zenith)) - (sinDec * (Math.sinDeg(latitude)))) / (cosDec * (Math.cosDeg(latitude))); localHourAngle = Math.acosDeg(cosLocalHourAngle); @@ -190,7 +190,7 @@ function drawSinuses () { g.setColor(1, 1, 1); let y = ypos(x); while (x < w) { - y2 = ypos(x + sinStep); + const y2 = ypos(x + sinStep); g.drawLine(x, y, x + sinStep, y2); y = y2; x += sinStep; // no need to draw all steps diff --git a/apps/supmariodark/supmariodark.js b/apps/supmariodark/supmariodark.js index 00a20e5fb..cf913c8f7 100644 --- a/apps/supmariodark/supmariodark.js +++ b/apps/supmariodark/supmariodark.js @@ -46,10 +46,10 @@ const drawBanner = (h) =>{ const updateTimeBanner = (h,m)=>{ m = (m<10?'0':'')+m; h = (h<10?'0':'')+h; - bx1=g.getWidth()/2-90; - by1=50+10; - bx2=g.getWidth()/2+90; - by2=50+62; + const bx1=g.getWidth()/2-90; + const by1=50+10; + const bx2=g.getWidth()/2+90; + const by2=50+62; g.setFontCustom(eval(s.read("supmario30x24.bin")), 48, eval(s.read("supmario30x24.wdt")), 24); g.setClipRect(bx1,by1,bx2,by2).clearRect(bx1,by1,bx2,by2); diff --git a/apps/swipeinv/settings.js b/apps/swipeinv/settings.js index 6ce16d00a..e32b75e60 100644 --- a/apps/swipeinv/settings.js +++ b/apps/swipeinv/settings.js @@ -11,7 +11,7 @@ } function appMenu() { - menu = { + let menu = { "" : { "title" : /*LANG*/"Swipe inversion apps" }, "< Back" : () => { writeSettings(); mainMenu();} }; diff --git a/apps/swscroll/boot.js b/apps/swscroll/boot.js index a2dc5277d..48ce2aa67 100644 --- a/apps/swscroll/boot.js +++ b/apps/swscroll/boot.js @@ -34,7 +34,7 @@ Bangle.setUI({ remove : options.remove, redraw : draw, swipe : (_,UD)=>{ - pixels = 120; + const pixels = 120; var dy = UD*pixels; if (s.scroll - dy > menuScrollMax) dy = s.scroll - menuScrollMax-8; // Makes it so the last 'page' has the same position as previous pages. This should be done dynamically (change the static 8 to be a variable) so the offset is correct even when no widget field or title field is present. diff --git a/apps/synthwave/app.js b/apps/synthwave/app.js index 21da76bd4..41711d950 100644 --- a/apps/synthwave/app.js +++ b/apps/synthwave/app.js @@ -701,7 +701,7 @@ function probe() { stride = 68; } */ - stride = 68; + let stride = 68; lcdBuffer = start; print('Found lcdBuffer at ' + lcdBuffer.toString(16) + ' stride=' + stride); diff --git a/apps/teatimer/app.js b/apps/teatimer/app.js index fbaed4d62..d9d2eb2b1 100644 --- a/apps/teatimer/app.js +++ b/apps/teatimer/app.js @@ -22,7 +22,7 @@ function appTitle() { } function currentTime() { - min = Date().getMinutes(); + let min = Date().getMinutes(); if (min < 10) min = "0" + min; return Date().getHours() + ":" + min; } diff --git a/apps/tempmonitor/tempmonitor.app.js b/apps/tempmonitor/tempmonitor.app.js index c8ea0131e..303c536f4 100644 --- a/apps/tempmonitor/tempmonitor.app.js +++ b/apps/tempmonitor/tempmonitor.app.js @@ -30,7 +30,8 @@ if (readFreq>saveFreq) console.log("Read refresh freq should be higher than savi if (v_mode_debug>0) console.log("original BG/FG color="+v_color_erase+" / "+v_color); - +let v_font_size1; +let v_font_size2; function SetVariables(){ //EMSCRIPTEN,EMSCRIPTEN2 if (v_model=='BANGLEJS'||v_model=='EMSCRIPTEN') { @@ -209,7 +210,7 @@ g.drawString("Mode debug: "+v_mode_debug, x, y - ((v_font_size1*1)+2)); g.drawString("Read frq(ms): "+readFreq, x, y ); g.drawString("Save file: "+v_saveToFile, x, y+ ((v_font_size1*1)+2) ); g.drawString("Save frq(ms):"+saveFreq, x, y+((v_font_size1*2)+2) ); -fr=require("Storage").read(v_filename+"\1");//suffix required +const fr=require("Storage").read(v_filename+"\1");//suffix required if (fr) g.drawString("Filesize:"+fr.length.toString()+"kb", x, y+((v_font_size1*3)+2) ); else g.drawString("File not exist", x, y+((v_font_size1*3)+2)); } diff --git a/apps/testuserinput/app.js b/apps/testuserinput/app.js index a0e2c1c40..dc65bda13 100644 --- a/apps/testuserinput/app.js +++ b/apps/testuserinput/app.js @@ -156,6 +156,7 @@ function PrintUserInput(boton){ //Call info banner g.setFontVector(30).drawString(boton, 63, 55); if ((boton=='Touch 1')||(boton=='Touch 2')){ + let v_y_opt; if (v_selected_row==1) v_y_opt=v_y_optionrow1; else if (v_selected_row==2) v_y_opt=v_y_optionrow2; DrawRoundOption(20,v_y_opt,190,v_y_opt,boton); diff --git a/apps/tictactoe/app.js b/apps/tictactoe/app.js index 725f47910..e381a6577 100644 --- a/apps/tictactoe/app.js +++ b/apps/tictactoe/app.js @@ -69,7 +69,7 @@ function calcWin(){ //draw check // drawChk is sum absolute value of array, if drawChk = 9 then there is a draw - drawChk = 0; + let drawChk = 0; for(let i = 0; i<3; i++){ for(let j = 0; j<3; j++){ drawChk = drawChk + Math.abs(arr[i][j]); @@ -94,6 +94,7 @@ function calcWin(){ function draw(){ g.clear(); + let playerIcon; if (player ==1){ playerIcon = "X"; } else if(player == -1){ diff --git a/apps/tilthydro/app.js b/apps/tilthydro/app.js index 011a19eb6..ebace5aea 100644 --- a/apps/tilthydro/app.js +++ b/apps/tilthydro/app.js @@ -48,7 +48,7 @@ var TILT_DEVICES = { function takeReading() { // scan for 5 seconds max NRF.setScan(function(device) { - d = new DataView(device.manufacturerData); + const d = new DataView(device.manufacturerData); if (d.getUint8(4) == 0xbb) { var hexData = arrayBufferToHex(device.manufacturerData); var tempF = d.getUint16(18); diff --git a/apps/timecal/timecal.settings.js b/apps/timecal/timecal.settings.js index 8a7867c0d..3a38eed09 100644 --- a/apps/timecal/timecal.settings.js +++ b/apps/timecal/timecal.settings.js @@ -1,6 +1,6 @@ // Settings menu for Time calendar clock (function(exit) { - ABR_DAY = require("locale") && require("locale").abday ? require("locale").abday : ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]; + const ABR_DAY = require("locale") && require("locale").abday ? require("locale").abday : ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]; var FILE = "timecal.settings.json"; @@ -19,7 +19,7 @@ calBrdr:false }; - validSttngs = require("Storage").readJSON(FILE, 1) || {}; + let validSttngs = require("Storage").readJSON(FILE, 1) || {}; for (const k in validSttngs) if (!DEFAULTS.hasOwnProperty(k)) delete this.validSttngs[k]; //remove invalid settings for (const k in DEFAULTS) if(!validSttngs.hasOwnProperty(k)) validSttngs[k] = DEFAULTS[k]; //assign missing defaults fixed diff --git a/apps/tinyVario/app.js b/apps/tinyVario/app.js index 63fc6e94e..87ed671be 100644 --- a/apps/tinyVario/app.js +++ b/apps/tinyVario/app.js @@ -5,9 +5,9 @@ To do: -navigation */ -getAltitude = (p,baseP) => (44330 * (1.0 - Math.pow(p/baseP, 0.1903))); -getFL = () => (44330 * (1.0 - Math.pow(pressure/1013.25, 0.1903))).toFixed(0); -getTimeString = () => (settings.localTime) ? (require("locale").time(Date(),1)):(Date().toUTCString().slice(Date().toUTCString().length-12,Date().toUTCString().length-7)); +const getAltitude = (p,baseP) => (44330 * (1.0 - Math.pow(p/baseP, 0.1903))); +//const getFL = () => (44330 * (1.0 - Math.pow(pressure/1013.25, 0.1903))).toFixed(0); +const getTimeString = () => (settings.localTime) ? (require("locale").time(Date(),1)):(Date().toUTCString().slice(Date().toUTCString().length-12,Date().toUTCString().length-7)); var fg=g.getColor(); //var bg=g.getBgColor(); @@ -146,7 +146,7 @@ function initPFD() { //samples=1; //-------------------- pfdHandle = setInterval(function() { - t1=Date().getTime(); + //const t1=Date().getTime(); //process pressure readings if (samples) { pressure=rawP/samples; diff --git a/apps/tinydraw/app.js b/apps/tinydraw/app.js index 52460bc79..5ba3ed50c 100644 --- a/apps/tinydraw/app.js +++ b/apps/tinydraw/app.js @@ -164,14 +164,14 @@ Bangle.on("lock", function() { case 'circle': var XS = (to.x - from.x) / 32; var YS = (to.y - from.y) / 32; - for (i = 0; i < 32; i++) { + for (let i = 0; i < 32; i++) { g.fillCircle(from.x + (i * XS), from.y + (i * YS), 4, 4); } break; case 'square': var XS = (to.x - from.x) / 32; var YS = (to.y - from.y) / 32; - for (i = 0; i < 32; i++) { + for (let i = 0; i < 32; i++) { const posX = from.x + (i * XS); const posY = from.y + (i * YS); g.fillRect(posX - 10, posY - 10, posX + 10, posY + 10); diff --git a/apps/trex/trex.js b/apps/trex/trex.js index 3baca101b..543a6dcae 100644 --- a/apps/trex/trex.js +++ b/apps/trex/trex.js @@ -19,7 +19,7 @@ if (process.env.HWVERSION==2) { BTNR = { read : _=>tap.b && tap.x > 88}; // use button for jump BTNU = BTN1; - greal = g; + const greal = g; g = Graphics.createArrayBuffer(88,64,1,{msb:true}); g.flip = function() { greal.drawImage({ @@ -33,7 +33,7 @@ if (process.env.HWVERSION==2) { BTNL = BTN2; BTNR = BTN3; BTNU = BTN1; - greal = g; + const greal = g; g = Graphics.createArrayBuffer(120,64,1,{msb:true}); g.flip = function() { greal.drawImage({ diff --git a/apps/usgs/app.js b/apps/usgs/app.js index e6f2efa1e..90509284e 100644 --- a/apps/usgs/app.js +++ b/apps/usgs/app.js @@ -8,7 +8,7 @@ var FILE = "usgs.json"; tempUnitF: true, }, require('Storage').readJSON(FILE, true) || {}); function fetchStartup() { - uri = "https://labs.waterdata.usgs.gov/sta/v1.1/Things('USGS-" + + const uri = "https://labs.waterdata.usgs.gov/sta/v1.1/Things('USGS-" + settings.loc + "')/Datastreams?$expand=Observations($orderby=phenomenonTime%20desc;$top=1;$select=result)&$select=unitOfMeasurement,description"; if (Bangle.http) { @@ -17,8 +17,10 @@ function fetchStartup() { } function handleStartup(data) { for (var key1 in data) { - desc = data[key1].description.split(" / ")[0]; + const desc = data[key1].description.split(" / ")[0]; if (settings.keys[desc]) { + let symbol; + let result; if (data[key1].unitOfMeasurement.symbol === "degC" && settings.tempUnitF) { symbol = "F"; result = (data[key1].Observations[0].result * 9 / 5) + 32; @@ -42,10 +44,11 @@ function displayData(dataStreams) { g.clear(); g.setFont("Vector",20); g.setFontAlign(0,0); - string = ""; + let string = ""; for (var key in dataStreams) { - unit = dataStreams[key].unit; - value = dataStreams[key].value; + const unit = dataStreams[key].unit; + const value = dataStreams[key].value; + let name; if (settings.shortenedName[key]) { name = settings.shortenedName[key]; } else { diff --git a/apps/usgs/settings.js b/apps/usgs/settings.js index 1ddde4c60..8a12197dc 100644 --- a/apps/usgs/settings.js +++ b/apps/usgs/settings.js @@ -68,7 +68,7 @@ function popSubMenuData(data) { function getDataStreams() { - uri = "https://labs.waterdata.usgs.gov/sta/v1.1/Things('USGS-" + + const uri = "https://labs.waterdata.usgs.gov/sta/v1.1/Things('USGS-" + settings.loc + "')/Datastreams?$select=description"; if (Bangle.http) { diff --git a/apps/warpdrive/app.js b/apps/warpdrive/app.js index 3f52fba58..b16766f47 100644 --- a/apps/warpdrive/app.js +++ b/apps/warpdrive/app.js @@ -572,7 +572,7 @@ function probe() { stride = 68; } */ - stride = 68; + let stride = 68; lcdBuffer = start; print('Found lcdBuffer at ' + lcdBuffer.toString(16) + ' stride=' + stride); diff --git a/apps/waypointer/app.js b/apps/waypointer/app.js index b71cf3270..ff2412730 100644 --- a/apps/waypointer/app.js +++ b/apps/waypointer/app.js @@ -209,13 +209,13 @@ var intervalRef; function stopdraw() { candraw=false; - prev_course = -1; + //prev_course = -1; if(intervalRef) {clearInterval(intervalRef);} } function startTimers() { candraw=true; - intervalRefSec = setInterval(function() { + /*intervalRefSec =*/ setInterval(function() { read_compass(); }, 500); } diff --git a/apps/widalt/widalt.settings.js b/apps/widalt/widalt.settings.js index 57993474e..1178c6fcf 100644 --- a/apps/widalt/widalt.settings.js +++ b/apps/widalt/widalt.settings.js @@ -2,7 +2,7 @@ var settings = Object.assign({ interval: 5000, }, require('Storage').readJSON("widalt.json", true) || {}); - o=Bangle.getOptions(); + const o=Bangle.getOptions(); Bangle.getPressure().then((p)=>{ E.showMenu({ "" : { "title" : "Altimeter Widget" }, diff --git a/apps/widbaroalarm/widget.js b/apps/widbaroalarm/widget.js index 2947b60f3..c7532f443 100644 --- a/apps/widbaroalarm/widget.js +++ b/apps/widbaroalarm/widget.js @@ -219,7 +219,7 @@ function barometerPressureHandler(e) { const pressure = e.pressure; if (isValidPressureValue(pressure)) { currentPressures.unshift(pressure); - median = currentPressures.slice().sort(); + let median = currentPressures.slice().sort(); if (median.length > 10) { var mid = median.length >> 1; diff --git a/apps/widbgjs/widget.js b/apps/widbgjs/widget.js index 12af79c8e..c95ecd032 100644 --- a/apps/widbgjs/widget.js +++ b/apps/widbgjs/widget.js @@ -65,8 +65,8 @@ break; } // turn the arrow thanks to (https://forum.espruino.com/conversations/344607/) - /* const p180 = Math.PI / 180; + /* // a is defined above var r = 21; var x = r * Math.sin(a * p180); @@ -116,7 +116,7 @@ console.log(settings.unitIsMmol.toString()); loadVals(); - outpt = getBG(storedData.bg); + let outpt = getBG(storedData.bg); if (outpt === null) { // this means no value has been received yet outpt = "BG"; diff --git a/apps/widcw/widget.js b/apps/widcw/widget.js index e33ad0aad..71ea3a554 100644 --- a/apps/widcw/widget.js +++ b/apps/widcw/widget.js @@ -7,7 +7,7 @@ var date = new Date(); // Calculate calendar week (https://stackoverflow.com/a/6117889) - getCW= function(date){ + const getCW= function(date){ var d=new Date(date.getFullYear(), date.getMonth(), date.getDate()); var dayNum = d.getDay() || 7; d.setDate(d.getDate() + 4 - dayNum); diff --git a/apps/widhwbttm/widhwbttm.wid.js b/apps/widhwbttm/widhwbttm.wid.js index e2a55c6c4..72cdd6cfe 100644 --- a/apps/widhwbttm/widhwbttm.wid.js +++ b/apps/widhwbttm/widhwbttm.wid.js @@ -26,7 +26,7 @@ } else { // text prefix has to be 4char - stor=require("Storage").getStats(); + const stor=require("Storage").getStats(); if (v_count==4) { v_str_hw="Fre "+process.memory().free; //+"/"+process.memory().total; diff --git a/apps/widmnth/widget.js b/apps/widmnth/widget.js index c4eca155a..472434d2b 100644 --- a/apps/widmnth/widget.js +++ b/apps/widmnth/widget.js @@ -5,7 +5,7 @@ function getDaysLeft(day) { let year = day.getMonth() == 11 ? day.getFullYear() + 1 : day.getFullYear(); // rollover if december. - next_month = new Date(year, (day.getMonth() + 1) % 12, 1, 0, 0, 0); + const next_month = new Date(year, (day.getMonth() + 1) % 12, 1, 0, 0, 0); let days_left = Math.floor((next_month - day) / 86400000); // ms left in month divided by ms in a day return days_left; } diff --git a/apps/widmpsh/widget.js b/apps/widmpsh/widget.js index 9115a4719..0ab27001a 100644 --- a/apps/widmpsh/widget.js +++ b/apps/widmpsh/widget.js @@ -1,6 +1,6 @@ WIDGETS["widmoonsh"] = { area: "tr", width: 24, draw: function() { const MC = 29.5305882, NM = 694039.09; - var r = 11, mx = this.x + 12; my = this.y + 12; + var r = 11, mx = this.x + 12, my = this.y + 12; function moonPhase(d) { var tmp, month = d.getMonth(), year = d.getFullYear(), day = d.getDate(); diff --git a/apps/worldclock/app.js b/apps/worldclock/app.js index 91b4be4f6..81ca7c37d 100644 --- a/apps/worldclock/app.js +++ b/apps/worldclock/app.js @@ -117,7 +117,7 @@ function draw() { // Loop through offset(s) and render offsets.forEach((offset, index) => { - dx = getCurrentTimeFromOffset(gmt, offset[OFFSET_HOURS]); + const dx = getCurrentTimeFromOffset(gmt, offset[OFFSET_HOURS]); hours = doublenum(dx.getHours()); minutes = doublenum(dx.getMinutes()); diff --git a/apps/wristlight/app.js b/apps/wristlight/app.js index 24bc1eab2..a0e883c04 100644 --- a/apps/wristlight/app.js +++ b/apps/wristlight/app.js @@ -8,13 +8,13 @@ function draw(color) { } function draw2Pattern() { - colors = ["ff0000", "8080ff", "00ff00", + const colors = ["ff0000", "8080ff", "00ff00", "ffffff"]; drawPattern(2, colors); } function draw3Pattern() { - colors = ["ff0000", "00ff00", "0000ff", + const colors = ["ff0000", "00ff00", "0000ff", "ff00ff", "ffffff", "00ffff", "ffff00", "ff8000", "ff0080"]; drawPattern(3, colors); diff --git a/apps/xxlmessage/lib-unbuffered.js b/apps/xxlmessage/lib-unbuffered.js index 68fb2a7a2..36f5392f5 100644 --- a/apps/xxlmessage/lib-unbuffered.js +++ b/apps/xxlmessage/lib-unbuffered.js @@ -66,7 +66,7 @@ var xxl = { }, draw: function() { - wh = 24; // widgets height + const wh = 24; // widgets height var gw = g.getWidth(); var h = (g.getHeight() - wh)/2; // height of drawing area per stripe