buffgym: Code style vs linter

Pass redraw as parameter to Workout, instead of using global variable.
Make code to honor eslint linebreak-style (use Windows linebreak).
Change eslintrc indent rule to match code style.
Add missing semicolons.
master
Tuukka Ikkala 2020-05-23 22:41:18 +03:00
parent 0bacb71bbd
commit 9e69fd2e74
6 changed files with 269 additions and 267 deletions

View File

@ -15,7 +15,8 @@
"rules": {
"indent": [
"error",
2
2,
{ "SwitchCase": 1 }
],
"linebreak-style": [
"error",

View File

@ -150,4 +150,4 @@ exports = class Exercise {
workout.emit("redraw");
}
}
};

View File

@ -1 +1 @@
require("heatshrink").decompress(atob("mEwxH+ACPI5AUSADAtB5vNGFQtBAIfNF95hoF4wwoF5AwmF5BhmXYbAEF/6QbF1QwIF04qB54ADAwIwoF4oRKBoIvsB4gvZ58kkgCDFxoxaF5wuHGDQcMF5IwXDZwLDGDmlDIWlkgJDSwIABCRAwPDQohCFgIABDQIOCFwYABr4RCCQIvQDYguEAAwtFF5owJDZAvHFw4vFOYQvKFAowMBxIvFMQwvPAB4wFUQ4vJGDYvUGC4vNdgyuEGDIsNFwYwGNAgAPExAvMGIdfTIovfTpYvrfRCOkZ44ugF44NGF05gUFyQvKGIoueGKIufGJ4uhG5oupGItfr4vvAAgvlGAQvt/wrEF9oEGF841IF9QGHX0oGIAD8kAAYJOFzwEBBQoMFACA="))
require("heatshrink").decompress(atob("mEwxH+ACPI5AUSADAtB5vNGFQtBAIfNF95hoF4wwoF5AwmF5BhmXYbAEF/6QbF1QwIF04qB54ADAwIwoF4oRKBoIvsB4gvZ58kkgCDFxoxaF5wuHGDQcMF5IwXDZwLDGDmlDIWlkgJDSwIABCRAwPDQohCFgIABDQIOCFwYABr4RCCQIvQDYguEAAwtFF5owJDZAvHFw4vFOYQvKFAowMBxIvFMQwvPAB4wFUQ4vJGDYvUGC4vNdgyuEGDIsNFwYwGNAgAPExAvMGIdfTIovfTpYvrfRCOkZ44ugF44NGF05gUFyQvKGIoueGKIufGJ4uhG5oupGItfr4vvAAgvlGAQvt/wrEF9oEGF841IF9QGHX0oGIAD8kAAYJOFzwEBBQoMFACA="));

View File

@ -25,4 +25,4 @@ exports = class Set {
if (this.reps <= this.minReps) return;
this.reps--;
}
}
};

View File

@ -3,7 +3,7 @@ exports = class Workout {
this.title = params.title;
this.exercises = [];
this.completed = false;
this.on("redraw", redraw.bind(null, this));
this.on("redraw", params.redraw.bind(null, this));
}
addExercises(exercises) {
@ -27,11 +27,12 @@ exports = class Workout {
return !!this.completed;
}
static fromJSON(workoutJSON) {
static fromJSON(workoutJSON, redraw) {
const Set = require("buffgym-set.js");
const Exercise = require("buffgym-exercise.js");
const workout = new this({
title: workoutJSON.title,
redraw: redraw,
});
const exercises = workoutJSON.exercises.map(exerciseJSON => {
const exercise = new Exercise({
@ -80,4 +81,4 @@ exports = class Workout {
// Call current exercise state machine
this.currentExercise().next(this);
}
}
};

View File

@ -248,7 +248,7 @@ function getWorkoutIndex() {
function buildWorkout(fName) {
const Workout = require("buffgym-workout.js");
const workoutJSON = require("Storage").readJSON(fName);
const workout = Workout.fromJSON(workoutJSON);
const workout = Workout.fromJSON(workoutJSON, redraw);
return workout;
}