diff --git a/apps/activepedom/widget.js b/apps/activepedom/widget.js index 81df22173..3288b5ae4 100644 --- a/apps/activepedom/widget.js +++ b/apps/activepedom/widget.js @@ -222,16 +222,17 @@ if (on) WIDGETS["activepedom"].draw(); }); - //Read data from file and set variables - let pedomData = s.readJSON(PEDOMFILE,1); - if (pedomData) { - if (pedomData.lastUpdate) lastUpdate = new Date(pedomData.lastUpdate); - stepsCounted = pedomData.stepsToday|0; - stepsTooShort = pedomData.stepsTooShort; - stepsTooLong = pedomData.stepsTooLong; - stepsOutsideTime = pedomData.stepsOutsideTime; + // Read data from file and set variables + { // new scope ensures pedomData gets freed + let pedomData = s.readJSON(PEDOMFILE,1); + if (pedomData) { + if (pedomData.lastUpdate) lastUpdate = new Date(pedomData.lastUpdate); + stepsCounted = pedomData.stepsToday|0; + stepsTooShort = pedomData.stepsTooShort; + stepsTooLong = pedomData.stepsTooLong; + stepsOutsideTime = pedomData.stepsOutsideTime; + } } - 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/bigdclock/bigdclock.app.js b/apps/bigdclock/bigdclock.app.js index f01d3df78..3f8607495 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(); // TODO: should `lastBattcheck` have been `lastBattCheck` ? + lastBattCheck = date.getTime(); width = E.getBattery(); width += width/2; } diff --git a/apps/bikespeedo/app.js b/apps/bikespeedo/app.js index 429e9eb23..a1f0b53ce 100644 --- a/apps/bikespeedo/app.js +++ b/apps/bikespeedo/app.js @@ -409,7 +409,8 @@ function updateClock() { if ( emulator ) { max.spd++; max.alt++; - const d=new Date(); sec=d.getSeconds(); + const d=new Date(); + sec=d.getSeconds(); onGPS(lf); } } diff --git a/apps/diract/diract.js b/apps/diract/diract.js index d80109345..d4effca89 100644 --- a/apps/diract/diract.js +++ b/apps/diract/diract.js @@ -74,6 +74,7 @@ let digestTime = new Uint8Array([ 0, 0, 0 ]); let numberOfDigestPages = 0; let sensorData = [ 0x82, 0x08, 0x3f ]; let cyclicCount = 0; +let encodedBattery = 0; let lastDigestTime = Math.round(getTime()); let lastResetTime = Math.round(getTime()); let isExciterPresent = false; @@ -513,7 +514,6 @@ function encodeAcceleration() { function updateSensorData() { // Update the battery measurement each time the cyclic count resets - let encodedBattery; if(cyclicCount === 0) { encodedBattery = encodeBatteryPercentage(); } diff --git a/apps/fclock/fclock.app.js b/apps/fclock/fclock.app.js index ca47a7238..52607b9fc 100644 --- a/apps/fclock/fclock.app.js +++ b/apps/fclock/fclock.app.js @@ -163,12 +163,10 @@ const drawHR = function () { } if (grow) { - const color = settings.hr.color; - g.setColor(color); + g.setColor(settings.hr.color); g.fillCircle(settings.hr.x, settings.hr.y, size); } else { - const color = "#000000"; - g.setColor(color); + g.setColor("#000000"); g.drawCircle(settings.hr.x, settings.hr.y, size); } }; diff --git a/apps/ftclock/ChangeLog b/apps/ftclock/ChangeLog index 7077ad2c2..c30dae69f 100644 --- a/apps/ftclock/ChangeLog +++ b/apps/ftclock/ChangeLog @@ -2,4 +2,3 @@ 0.02: RAM efficient version of `fourTwentyTz.js` (as suggested by @gfwilliams). 0.03: `mkFourTwentyTz.js` now handles new timezonedb.com CSV format 0.04: Tell clock widgets to hide. -0.05: Minor code improvements diff --git a/apps/ftclock/metadata.json b/apps/ftclock/metadata.json index 1e980a61e..96a4f84b9 100644 --- a/apps/ftclock/metadata.json +++ b/apps/ftclock/metadata.json @@ -1,7 +1,7 @@ { "id": "ftclock", "name": "Four Twenty Clock", - "version": "0.05", + "version": "0.04", "description": "A clock that tells when and where it's going to be 4:20 next", "icon": "app.png", "screenshots": [{"url":"screenshot.png"}, {"url":"screenshot1.png"}], diff --git a/apps/ftclock/mkFourTwentyTz.js b/apps/ftclock/mkFourTwentyTz.js index 6c420382f..7c6d25995 100644 --- a/apps/ftclock/mkFourTwentyTz.js +++ b/apps/ftclock/mkFourTwentyTz.js @@ -1,3 +1,4 @@ +/* This file is designed to be run on the desktop, not Bangle.js */ /* eslint-env node */ let fs = require('fs'); let csv = require('csv'); @@ -31,7 +32,7 @@ fs.createReadStream(__dirname+'/country.csv') } else { country = countries[r[1]]; // e.g. United States } - zone = zones[r[0]] || { "name": `${city}, ${country}` }; + let zone = zones[r[0]] || { "name": `${city}, ${country}` }; let starttime = parseInt(r[3] || "0"), // Bugger. They're feeding us blanks for UTC now offs = parseInt(r[4]); if (offs<0) { @@ -44,15 +45,15 @@ fs.createReadStream(__dirname+'/country.csv') zones[r[0]] = zone; }) .on('end', () => { - for (z in zones) { - zone = zones[z]; + for (let z in zones) { + let zone = zones[z]; if (zone.offs%60) continue; // One a dem funky timezones. Ignore. - zonelist = offsdict[zone.offs] || []; + let zonelist = offsdict[zone.offs] || []; zonelist.push(zone.name); offsdict[zone.offs] = zonelist; } - offsets = []; - for (o in offsdict) { + let offsets = []; + for (let o in offsdict) { offsets.unshift(parseInt(o)); } fs.open("fourTwentyTz.js","w", (err, fd) => { @@ -68,7 +69,7 @@ fs.createReadStream(__dirname+'/country.csv') fs.write(fd, ";\n", handleWrite); fs.write(fd, "exports.timezones = function(offs) {\n", handleWrite); fs.write(fd, " switch (offs) {\n", handleWrite); - for (i=0; i{ // TODO: Should `,then` have been `.then` ? + E.showAlert("Install a text input lib").then(()=>{ E.showMenu(buildMainMenu()); }); } diff --git a/apps/rebble/rebble.app.js b/apps/rebble/rebble.app.js index fc5e0ded4..3f97dc5cb 100644 --- a/apps/rebble/rebble.app.js +++ b/apps/rebble/rebble.app.js @@ -313,8 +313,8 @@ Graphics.prototype.setFontKdamThmor = function(scale) { if( Bangle.isCharging() ) { g.setBgColor(settings.bg); - const image = ()=> { return require("heatshrink").decompress(atob("j8OwMB/4AD94DC44DCwP//n/gH//EOgE/+AdBh/gAYMH4EAvkDAYP/+/AFAX+FgfzGAnAA=="));} - g.drawImage(image(),x+3,y+4); + const image = require("heatshrink").decompress(atob("j8OwMB/4AD94DC44DCwP//n/gH//EOgE/+AdBh/gAYMH4EAvkDAYP/+/AFAX+FgfzGAnAA==")); + g.drawImage(image,x+3,y+4); } } diff --git a/apps/supmariodark/supmariodark.js b/apps/supmariodark/supmariodark.js index cf913c8f7..f4c22229e 100644 --- a/apps/supmariodark/supmariodark.js +++ b/apps/supmariodark/supmariodark.js @@ -45,15 +45,15 @@ const drawBanner = (h) =>{ const updateTimeBanner = (h,m)=>{ m = (m<10?'0':'')+m; - h = (h<10?'0':'')+h; - const bx1=g.getWidth()/2-90; + h = (h<10?'0':'')+h; + 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); - g.drawString(h,bx1+35,75).drawString(":",g.getWidth()/2,75).drawString(m,bx1+110,75).flip(); + 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); + g.drawString(h,bx1+35,75).drawString(":",g.getWidth()/2,75).drawString(m,bx1+110,75).flip(); }; let om = 0; const onHalfSecond =()=>{ diff --git a/apps/testuserinput/app.js b/apps/testuserinput/app.js index dc65bda13..89e60177a 100644 --- a/apps/testuserinput/app.js +++ b/apps/testuserinput/app.js @@ -158,7 +158,7 @@ function PrintUserInput(boton){ 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; + else if (v_selected_row==2) v_y_opt=v_y_optionrow2; DrawRoundOption(20,v_y_opt,190,v_y_opt,boton); //set the option value in an array array_r_option[v_selected_row]=boton; @@ -249,6 +249,7 @@ function DrawRowSelArrow(v_drawRow, v_clearRow){ //for clear previous draw arrow if (v_clearRow!== undefined) { g.setColor(colbackg); + let v_y_arrow; if (v_clearRow==1) v_y_arrow=v_y_optionrow1+14; else if (v_clearRow==2) v_y_arrow=v_y_optionrow2+14; else if (v_clearRow==3) v_y_arrow=v_y_optionrow3+14; @@ -257,6 +258,7 @@ function DrawRowSelArrow(v_drawRow, v_clearRow){ } //draw an arrow to select a row if (v_drawRow!== undefined) { + let v_y_arrow; if (v_drawRow==1) v_y_arrow=v_y_optionrow1+14; else if (v_drawRow==2) v_y_arrow=v_y_optionrow2+14; else if (v_drawRow==3) v_y_arrow=v_y_optionrow3+14; @@ -329,4 +331,4 @@ function UserInput(){ //end optional PrintHelp(); - UserInput(); \ No newline at end of file + UserInput(); diff --git a/apps/widcw/widget.js b/apps/widcw/widget.js index 71ea3a554..bce6a1e92 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) - const 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);