Minor tweaks after reviewing lint changes

pull/3261/head
Gordon Williams 2024-03-14 11:39:04 +00:00
parent ab75c85f11
commit ff04564e2a
20 changed files with 45 additions and 82 deletions

View File

@ -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

View File

@ -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;
}

View File

@ -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);
}
}

View File

@ -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();
}

View File

@ -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);
}
};

View File

@ -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

View File

@ -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"}],

View File

@ -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<offsets.length; i++) {
for (let i=0; i<offsets.length; i++) {
let o = offsets[i].toString();
fs.write(fd, ` case ${o}: return ${JSON.stringify(offsdict[o])};\n`, handleWrite);
}

View File

@ -135,7 +135,7 @@ function checkPreciseHomework(subjectnum) { // P A I N
checkPreciseHomeworkMenu[subject] = function() {},
checkPreciseHomeworkMenu[taskmsg] = function() {},
checkPreciseHomeworkMenu[statusmsg] = function() {
status = "Status: Finished"; // TODO: Should this have been called `statusmsg`?
statusmsg = "Status: Finished";
var d = new Date();
var currenttime = require("locale").time(d, 1);
var currentdate = require("locale").date(d);
@ -160,11 +160,11 @@ function checkPreciseHomework(subjectnum) { // P A I N
}
/*
function pushHomework(subject, status, datetimehwdone) {
homework = require("Storage").readJSON("homework.txt", "r");
}
*/
function addNewHomework(subject) { // Pass subject
console.log(subject);

View File

@ -1,3 +1,3 @@
0.01: New library
0.02: Minor code improvements
0.03: Minor code improvements

View File

@ -1,7 +1,7 @@
{
"id": "icons",
"name": "Icons",
"version": "0.03",
"version": "0.02",
"description": "Library containing useful icons for apps",
"icon": "app.png",
"type": "module",

View File

@ -353,13 +353,6 @@ module.exports = {
"no-unused-vars"
]
},
"homework/app.js": {
"hash": "4bc5694ed77e47f116d2b9cbdb5083c6b218e09899809f977f1a2cbcc53318cf",
"rules": [
"no-unused-vars",
"no-undef"
]
},
"hidmsicswipe/hidmsicswipe.js": {
"hash": "8c8c2058315c6debaec71b65b1409ebf5725233c72dbcc2ac921bec0d238fd4f",
"rules": [
@ -687,12 +680,6 @@ module.exports = {
"no-undef"
]
},
"testuserinput/app.js": {
"hash": "83ec7fe0b9f0590715d47fc362fe48caf5b33af0f3d840acc70f16be72a0cef9",
"rules": [
"no-undef"
]
},
"terminal/app.js": {
"hash": "19d4913fed5a8817e3e60caf04aa6b45413ed683cf5b2c5b6859bd9080d37a34",
"rules": [
@ -915,12 +902,6 @@ module.exports = {
"no-undef"
]
},
"owmweather/settings.js": {
"hash": "e1df731fee42428a0a45e8bba2415d48c82b357df56806555bab70682f1e7236",
"rules": [
"no-undef"
]
},
"owmweather/boot.js": {
"hash": "10fe98e871a7df3338fc764d62ac4db65c20c44774aad112f5faf26c7497f78e",
"rules": [
@ -1221,12 +1202,6 @@ module.exports = {
"no-undef"
]
},
"ftclock/mkFourTwentyTz.js": {
"hash": "c1db4878121aea068481bcdb83a2725755032c6a56250c698fe2d5f96135cd7c",
"rules": [
"no-undef"
]
},
"fontclock/fontclock.js": {
"hash": "478c96b1319d548a79727c5af3191b77ac9753c6314789570e900e512a99a152",
"rules": [
@ -1383,12 +1358,6 @@ module.exports = {
"no-undef"
]
},
"bigdclock/bigdclock.app.js": {
"hash": "f7bde42d4a5b95e1b11dbe79b6c7a885900678828abb893375d2492fb25efca8",
"rules": [
"no-undef"
]
},
"beebclock/beebclock.js": {
"hash": "f2860eb523d6394de737d249303a87a96c619ce925943026238d2aedc2441133",
"rules": [
@ -1473,12 +1442,6 @@ module.exports = {
"no-undef"
]
},
"activepedom/widget.js": {
"hash": "b60792cb3017f9b7ce43471828434501bfa255f327fde6c52ae36a7a06f84d6f",
"rules": [
"no-undef"
]
},
"accelrec/app.js": {
"hash": "b5369a60afc8f360f0b33f71080eb3f5d09a1bf3703acfcf07cd80dd19f1997d",
"rules": [

View File

@ -4,8 +4,7 @@ function draw() {
g.reset();
g.setFontCustom(font, 48, 8, 1801);
g.setFontAlign(0, -1, 0);
let line1;
let line2;
let line1, line2;
if (showDate) {
if (g.theme.dark) {
g.setColor("#00ffff"); // cyan date numbers for dark mode

View File

@ -6,4 +6,3 @@
0.05: Add message icon for 'jira'
0.06: Add message icon for 'molly' and 'threema libre'
0.07: Minor code improvements
0.08: Minor code improvements

View File

@ -1,7 +1,7 @@
{
"id": "messageicons",
"name": "Message Icons",
"version": "0.08",
"version": "0.07",
"description": "Library containing a list of icons and colors for apps",
"icon": "app.png",
"type": "module",

View File

@ -70,7 +70,7 @@
E.showMenu(buildMainMenu());
});
} else {
E.showPrompt("Install a text input lib"),then(()=>{ // TODO: Should `,then` have been `.then` ?
E.showAlert("Install a text input lib").then(()=>{
E.showMenu(buildMainMenu());
});
}

View File

@ -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);
}
}

View File

@ -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 =()=>{

View File

@ -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();
UserInput();

View File

@ -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);