Merge pull request #343 from paulcockrell/master
BuffGym [Enhancement] - Add web interface for customisationmaster
commit
61d2c84284
11
apps.json
11
apps.json
|
|
@ -1343,20 +1343,21 @@
|
|||
"id": "buffgym",
|
||||
"name": "BuffGym",
|
||||
"icon": "buffgym.png",
|
||||
"version":"0.01",
|
||||
"version":"0.02",
|
||||
"description": "BuffGym is the famous 5x5 workout program for the BangleJS",
|
||||
"tags": "tool,outdoors,gym,exercise",
|
||||
"type": "app",
|
||||
"interface": "buffgym.html",
|
||||
"allow_emulator": false,
|
||||
"readme": "README.md",
|
||||
"storage": [
|
||||
{"name":"buffgym.app.js", "url": "buffgym.app.js"},
|
||||
{"name":"buffgym-set.js","url":"buffgym-set.js"},
|
||||
{"name":"buffgym-exercise.js","url":"buffgym-exercise.js"},
|
||||
{"name":"buffgym-program.js","url":"buffgym-program.js"},
|
||||
{"name":"buffgym-program-a.json","url":"buffgym-program-a.json"},
|
||||
{"name":"buffgym-program-b.json","url":"buffgym-program-b.json"},
|
||||
{"name":"buffgym-program-index.json","url":"buffgym-program-index.json"},
|
||||
{"name":"buffgym-workout.js","url":"buffgym-workout.js"},
|
||||
{"name":"buffgym-workout-a.json","url":"buffgym-workout-a.json"},
|
||||
{"name":"buffgym-workout-b.json","url":"buffgym-workout-b.json"},
|
||||
{"name":"buffgym-workout-index.json","url":"buffgym-workout-index.json"},
|
||||
{"name":"buffgym.img","url":"buffgym-icon.js","evaluate":true}
|
||||
]
|
||||
},
|
||||
|
|
|
|||
|
|
@ -0,0 +1,2 @@
|
|||
0.01: Create BuffGym app
|
||||
0.02: Add web interface for personalising workout
|
||||
|
|
@ -2,17 +2,32 @@
|
|||
|
||||
This gym training assistant trains you on the famous [Stronglifts 5x5 workout](https://stronglifts.com/5x5) program.
|
||||
|
||||
## Configuration
|
||||
|
||||
### Setting your start weight values
|
||||
|
||||
You will want to set your own starting weight values for your 5x5 training program. To do this is easy! After installing this app, go to the BangleJS app store, connect to your watch, and navigate to the `My Apps` tab. In there you will find this app in the list, and an icon (a down arrow) to the right of the app title. Click that icon to reveal a configuration page. Enter your weights and other details, and click upload. That is it, you are now ready to train!
|
||||
|
||||
## Usage
|
||||
|
||||
### Start screen
|
||||
|
||||
When you start the app it will wait on a splash screen until you are ready to start the work out. Press any of the buttons to start
|
||||
|
||||

|
||||
|
||||
You are then presented with the programs menu, use BTN1 to move up the list, and BTN3 to move down the list. Once you have made your selection, press BTN2 to select the program.
|
||||
### Workouts menu
|
||||
|
||||
You are then presented with the workouts menu, use BTN1 to move up the list, and BTN3 to move down the list. Once you have made your selection, press BTN2 to select the workout.
|
||||
|
||||

|
||||
|
||||
You will now begin moving through the exercises in the program. You will see the exercise information on the display.
|
||||
### Recording your training
|
||||
|
||||
You will now begin moving through the exercises in the workout. You will see the exercise information on the display.
|
||||
|
||||

|
||||
|
||||
1. At the top is the exercise name, e.g 'Squats'
|
||||
2. Next is the weight you must train
|
||||
3. In the center is where you record the number of *reps* you completed (more on that shortly)
|
||||
|
|
@ -20,13 +35,15 @@ You will now begin moving through the exercises in the program. You will see the
|
|||
5. Below the target reps is the current set you are training, out of the total sets for the exercise.
|
||||
6. The *reps* value is used to store what you achieved for the current set, you enter this after you have trained on your current set. To alter this value, use BTN1 to increase the value (it will stop at the maximum required reps) and BTN3 to decreas the value to a minimum of 0 (this is the default value). Pressing BTN2 will confirm your reps
|
||||
|
||||

|
||||
### Rest timers
|
||||
|
||||
You will then be presented with a rest timer screen, it counts down and automatically moves to the next exercise when it reaches 0. You can cancel the timer early if you wish by pressing BTN2. If it is the last set of an exercise, you don't need to rest, so it lets you know you have completed all the sets in the exercise and can start the next exercise.
|
||||
|
||||

|
||||

|
||||
|
||||
### Workout completed
|
||||
|
||||
Once all exercises are done, you are presented with a pat-on-the-back screen to tell you how awesome you are.
|
||||
|
||||

|
||||
|
|
@ -40,4 +57,4 @@ Once all exercises are done, you are presented with a pat-on-the-back screen to
|
|||
|
||||
## Created by
|
||||
|
||||
[Paul Cockrell](https://github.com/paulcockrell) April 2020.
|
||||
[Paul Cockrell](https://github.com/paulcockrell) April 2020.
|
||||
|
|
|
|||
|
|
@ -1,16 +1,16 @@
|
|||
exports = class Exercise {
|
||||
constructor(params) {
|
||||
this.title = params.title;
|
||||
this.weight = params.weight;
|
||||
this.unit = params.unit;
|
||||
this.restPeriod = params.restPeriod;
|
||||
this.completed = false;
|
||||
this.sets = [];
|
||||
this.title = params.title;
|
||||
this.weight = params.weight;
|
||||
this.weightIncrement = params.weightIncrement;
|
||||
this.unit = params.unit;
|
||||
this.restPeriod = params.restPeriod;
|
||||
this._originalRestPeriod = params.restPeriod;
|
||||
this._restTimeout = null;
|
||||
this._restInterval = null;
|
||||
this._state = null;
|
||||
this._originalRestPeriod = params.restPeriod;
|
||||
this._weightIncrement = params.weightIncrement || 2.5;
|
||||
}
|
||||
|
||||
get humanTitle() {
|
||||
|
|
@ -50,7 +50,7 @@ exports = class Exercise {
|
|||
|
||||
setCompleted() {
|
||||
if (!this.canSetCompleted()) throw "All sets must be completed";
|
||||
if (this.canProgress()) this.weight += this._weightIncrement;
|
||||
if (this.canProgress()) this.weight += this.weightIncrement;
|
||||
this.completed = true;
|
||||
}
|
||||
|
||||
|
|
@ -63,13 +63,22 @@ exports = class Exercise {
|
|||
return (targetRepsTotalSum - completedRepsTotalSum) === 0;
|
||||
}
|
||||
|
||||
startRestTimer(program) {
|
||||
startRestTimer(workout) {
|
||||
this._restTimeout = setTimeout(() => {
|
||||
this.next(program);
|
||||
this.next(workout);
|
||||
}, 1000 * this.restPeriod);
|
||||
|
||||
this._restInterval = setInterval(() => {
|
||||
program.emit("redraw");
|
||||
this.decRestPeriod();
|
||||
|
||||
if (this.restPeriod < 0) {
|
||||
this.resetRestTimer();
|
||||
this.next();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
workout.emit("redraw");
|
||||
}, 1000 );
|
||||
}
|
||||
|
||||
|
|
@ -85,28 +94,28 @@ exports = class Exercise {
|
|||
return this._restTimeout != null;
|
||||
}
|
||||
|
||||
setupStartedButtons(program) {
|
||||
setupStartedButtons(workout) {
|
||||
clearWatch();
|
||||
|
||||
setWatch(() => {
|
||||
this.currentSet().incReps();
|
||||
program.emit("redraw");
|
||||
workout.emit("redraw");
|
||||
}, BTN1, {repeat: true});
|
||||
|
||||
setWatch(program.next.bind(program), BTN2, {repeat: false});
|
||||
setWatch(workout.next.bind(workout), BTN2, {repeat: false});
|
||||
|
||||
setWatch(() => {
|
||||
this.currentSet().decReps();
|
||||
program.emit("redraw");
|
||||
workout.emit("redraw");
|
||||
}, BTN3, {repeat: true});
|
||||
}
|
||||
|
||||
setupRestingButtons(program) {
|
||||
setupRestingButtons(workout) {
|
||||
clearWatch();
|
||||
setWatch(program.next.bind(program), BTN2, {repeat: false});
|
||||
setWatch(workout.next.bind(workout), BTN2, {repeat: false});
|
||||
}
|
||||
|
||||
next(program) {
|
||||
next(workout) {
|
||||
const STARTED = 1;
|
||||
const RESTING = 2;
|
||||
const COMPLETED = 3;
|
||||
|
|
@ -114,12 +123,12 @@ exports = class Exercise {
|
|||
switch(this._state) {
|
||||
case null:
|
||||
this._state = STARTED;
|
||||
this.setupStartedButtons(program);
|
||||
this.setupStartedButtons(workout);
|
||||
break;
|
||||
case STARTED:
|
||||
this._state = RESTING;
|
||||
this.startRestTimer(program);
|
||||
this.setupRestingButtons(program);
|
||||
this.startRestTimer(workout);
|
||||
this.setupRestingButtons(workout);
|
||||
break;
|
||||
case RESTING:
|
||||
this.resetRestTimer();
|
||||
|
|
@ -132,13 +141,13 @@ exports = class Exercise {
|
|||
this._state = null;
|
||||
}
|
||||
// As we are changing state and require it to be reprocessed
|
||||
// invoke the next step of program
|
||||
program.next();
|
||||
// invoke the next step of workout
|
||||
workout.next();
|
||||
break;
|
||||
default:
|
||||
throw "Exercise: Attempting to move to an unknown state";
|
||||
}
|
||||
|
||||
program.emit("redraw");
|
||||
workout.emit("redraw");
|
||||
}
|
||||
}
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
[
|
||||
{
|
||||
"title": "Program A",
|
||||
"file": "buffgym-program-a.json"
|
||||
},
|
||||
{
|
||||
"title": "Program B",
|
||||
"file": "buffgym-program-b.json"
|
||||
}
|
||||
]
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
exports = class Set {
|
||||
constructor(maxReps) {
|
||||
this.minReps = 0;
|
||||
this.maxReps = maxReps;
|
||||
this.reps = 0;
|
||||
this.completed = false;
|
||||
this.minReps = 0;
|
||||
this.reps = 0;
|
||||
this.maxReps = maxReps;
|
||||
}
|
||||
|
||||
isCompleted() {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"title": "Program A",
|
||||
"title": "Workout A",
|
||||
"exercises": [
|
||||
{
|
||||
"title": "Squats",
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"title": "Program B",
|
||||
"title": "Workout B",
|
||||
"exercises": [
|
||||
{
|
||||
"title": "Squats",
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
[
|
||||
{
|
||||
"title": "Workout A",
|
||||
"file": "buffgym-workout-a.json"
|
||||
},
|
||||
{
|
||||
"title": "Workout B",
|
||||
"file": "buffgym-workout-b.json"
|
||||
}
|
||||
]
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
exports = class Program {
|
||||
exports = class Workout {
|
||||
constructor(params) {
|
||||
this.title = params.title;
|
||||
this.exercises = [];
|
||||
|
|
@ -27,6 +27,32 @@ exports = class Program {
|
|||
return !!this.completed;
|
||||
}
|
||||
|
||||
static fromJSON(workoutJSON) {
|
||||
const Set = require("buffgym-set.js");
|
||||
const Exercise = require("buffgym-exercise.js");
|
||||
const workout = new this({
|
||||
title: workoutJSON.title,
|
||||
});
|
||||
const exercises = workoutJSON.exercises.map(exerciseJSON => {
|
||||
const exercise = new Exercise({
|
||||
title: exerciseJSON.title,
|
||||
weight: exerciseJSON.weight,
|
||||
weightIncrement: exerciseJSON.weightIncrement,
|
||||
unit: exerciseJSON.unit,
|
||||
restPeriod: exerciseJSON.restPeriod,
|
||||
});
|
||||
exerciseJSON.sets.forEach(setJSON => {
|
||||
exercise.addSet(new Set(setJSON));
|
||||
});
|
||||
|
||||
return exercise;
|
||||
});
|
||||
|
||||
workout.addExercises(exercises);
|
||||
|
||||
return workout;
|
||||
}
|
||||
|
||||
toJSON() {
|
||||
return {
|
||||
title: this.title,
|
||||
|
|
@ -34,6 +60,7 @@ exports = class Program {
|
|||
return {
|
||||
title: exercise.title,
|
||||
weight: exercise.weight,
|
||||
weightIncrement: exercise.weightIncrement,
|
||||
unit: exercise.unit,
|
||||
sets: exercise.sets.map(set => set.maxReps),
|
||||
restPeriod: exercise.restPeriod,
|
||||
|
|
@ -5,7 +5,7 @@
|
|||
* Created: April 2020
|
||||
*
|
||||
* Inspired by:
|
||||
* - Stronglifts 5x5 training program https://stronglifts.com/5x5/
|
||||
* - Stronglifts 5x5 training workout https://stronglifts.com/5x5/
|
||||
* - Stronglifts smart watch app
|
||||
*/
|
||||
|
||||
|
|
@ -66,10 +66,10 @@ function drawSet(exercise) {
|
|||
g.flip();
|
||||
}
|
||||
|
||||
function drawProgDone() {
|
||||
function drawWorkoutDone() {
|
||||
const title1 = "You did";
|
||||
const title2 = "GREAT!";
|
||||
const msg = "That's the program\ncompleted. Now eat\nsome food and\nget plenty of rest.";
|
||||
const msg = "That's the workout\ncompleted. Now eat\nsome food and\nget plenty of rest.";
|
||||
|
||||
clearWatch();
|
||||
setWatch(Bangle.showLauncher, BTN2, {repeat: false});
|
||||
|
|
@ -85,9 +85,12 @@ function drawProgDone() {
|
|||
g.flip();
|
||||
}
|
||||
|
||||
function drawSetComp() {
|
||||
function drawSetComp(exercise) {
|
||||
const title = "Good work";
|
||||
const msg = "No need to rest\nmove straight on\nto the next\nexercise.Your\nweight has been\nincreased for\nnext time!";
|
||||
const msg1= "No need to rest\nmove straight on\nto the next\nexercise.";
|
||||
const msg2 = exercise.canProgress()?
|
||||
"Your\nweight has been\nincreased for\nnext time!":
|
||||
"You'll\nsmash it next\ntime!";
|
||||
|
||||
g.clear();
|
||||
drawMenu({showBTN2: true});
|
||||
|
|
@ -97,22 +100,12 @@ function drawSetComp() {
|
|||
g.setFont("6x8", 2);
|
||||
g.drawString(title, W / 2, 10);
|
||||
g.setFont("6x8", 1);
|
||||
g.drawString(msg, (W / 2) - 2, 45);
|
||||
g.drawString(msg1 + msg2, (W / 2) - 2, 45);
|
||||
|
||||
g.flip();
|
||||
}
|
||||
|
||||
function drawRestTimer(program) {
|
||||
const exercise = program.currentExercise();
|
||||
const motivation = "Take a breather..";
|
||||
|
||||
if (exercise.restPeriod <= 0) {
|
||||
exercise.resetRestTimer();
|
||||
program.next();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
function drawRestTimer(exercise) {
|
||||
g.clear();
|
||||
drawMenu({showBTN2: true});
|
||||
g.setFontAlign(0, -1);
|
||||
|
|
@ -124,25 +117,23 @@ function drawRestTimer(program) {
|
|||
g.setFont("6x8", 5);
|
||||
g.drawString(exercise.restPeriod, (W / 2) + 2, (H / 2) - 19);
|
||||
g.flip();
|
||||
|
||||
exercise.decRestPeriod();
|
||||
}
|
||||
|
||||
function redraw(program) {
|
||||
const exercise = program.currentExercise();
|
||||
function redraw(workout) {
|
||||
const exercise = workout.currentExercise();
|
||||
g.clear();
|
||||
|
||||
if (program.isCompleted()) {
|
||||
saveProg(program);
|
||||
drawProgDone(program);
|
||||
if (workout.isCompleted()) {
|
||||
saveWorkout(workout);
|
||||
drawWorkoutDone();
|
||||
return;
|
||||
}
|
||||
|
||||
if (exercise.isRestTimerRunning()) {
|
||||
if (exercise.isLastSet()) {
|
||||
drawSetComp(program);
|
||||
drawSetComp(exercise);
|
||||
} else {
|
||||
drawRestTimer(program);
|
||||
drawRestTimer(exercise);
|
||||
}
|
||||
|
||||
return;
|
||||
|
|
@ -151,7 +142,7 @@ function redraw(program) {
|
|||
drawSet(exercise);
|
||||
}
|
||||
|
||||
function drawProgMenu(programs, selProgIdx) {
|
||||
function drawWorkoutMenu(workouts, selWorkoutIdx) {
|
||||
g.clear();
|
||||
g.setFontAlign(0, -1);
|
||||
g.setColor(WHITE);
|
||||
|
|
@ -160,16 +151,16 @@ function drawProgMenu(programs, selProgIdx) {
|
|||
|
||||
g.setFont("6x8", 1);
|
||||
g.setFontAlign(-1, -1);
|
||||
let selectedProgram = programs[selProgIdx].title;
|
||||
let selectedWorkout = workouts[selWorkoutIdx].title;
|
||||
let yPos = 50;
|
||||
programs.forEach(program => {
|
||||
workouts.forEach(workout => {
|
||||
g.setColor("#f05a56");
|
||||
g.fillRect(0, yPos, W, yPos + 11);
|
||||
g.setColor("#ffffff");
|
||||
if (selectedProgram === program.title) {
|
||||
if (selectedWorkout === workout.title) {
|
||||
g.drawRect(0, yPos, W - 1, yPos + 11);
|
||||
}
|
||||
g.drawString(program.title, 10, yPos + 2);
|
||||
g.drawString(workout.title, 10, yPos + 2);
|
||||
yPos += 15;
|
||||
});
|
||||
g.flip();
|
||||
|
|
@ -177,25 +168,25 @@ function drawProgMenu(programs, selProgIdx) {
|
|||
|
||||
function setupMenu() {
|
||||
clearWatch();
|
||||
const progs = getProgIndex();
|
||||
let selProgIdx = 0;
|
||||
drawProgMenu(progs, selProgIdx);
|
||||
const workouts = getWorkoutIndex();
|
||||
let selWorkoutIdx = 0;
|
||||
drawWorkoutMenu(workouts, selWorkoutIdx);
|
||||
|
||||
setWatch(()=>{
|
||||
selProgIdx--;
|
||||
if (selProgIdx< 0) selProgIdx = 0;
|
||||
drawProgMenu(progs, selProgIdx);
|
||||
selWorkoutIdx--;
|
||||
if (selWorkoutIdx< 0) selWorkoutIdx = 0;
|
||||
drawWorkoutMenu(workouts, selWorkoutIdx);
|
||||
}, BTN1, {repeat: true});
|
||||
|
||||
setWatch(()=>{
|
||||
const prog = buildProg(progs[selProgIdx].file);
|
||||
prog.next();
|
||||
const workout = buildWorkout(workouts[selWorkoutIdx].file);
|
||||
workout.next();
|
||||
}, BTN2, {repeat: false});
|
||||
|
||||
setWatch(()=>{
|
||||
selProgIdx++;
|
||||
if (selProgIdx > progs.length - 1) selProgIdx = progs.length - 1;
|
||||
drawProgMenu(progs, selProgIdx);
|
||||
selWorkoutIdx++;
|
||||
if (selWorkoutIdx > workouts.length - 1) selWorkoutIdx = workouts.length - 1;
|
||||
drawWorkoutMenu(workouts, selWorkoutIdx);
|
||||
}, BTN3, {repeat: true});
|
||||
}
|
||||
|
||||
|
|
@ -249,40 +240,22 @@ function drawSplash() {
|
|||
}, BTN3, {repeat: false});
|
||||
}
|
||||
|
||||
function getProgIndex() {
|
||||
const progIdx = require("Storage").readJSON("buffgym-program-index.json");
|
||||
return progIdx;
|
||||
function getWorkoutIndex() {
|
||||
const workoutIdx = require("Storage").readJSON("buffgym-workout-index.json");
|
||||
return workoutIdx;
|
||||
}
|
||||
|
||||
function buildProg(fName) {
|
||||
const Set = require("buffgym-set.js");
|
||||
const Exercise = require("buffgym-exercise.js");
|
||||
const Program = require("buffgym-program.js");
|
||||
const progJSON = require("Storage").readJSON(fName);
|
||||
const prog = new Program({
|
||||
title: progJSON.title,
|
||||
});
|
||||
const exercises = progJSON.exercises.map(exerciseJSON => {
|
||||
const exercise = new Exercise({
|
||||
title: exerciseJSON.title,
|
||||
weight: exerciseJSON.weight,
|
||||
unit: exerciseJSON.unit,
|
||||
restPeriod: exerciseJSON.restPeriod,
|
||||
});
|
||||
exerciseJSON.sets.forEach(setJSON => {
|
||||
exercise.addSet(new Set(setJSON));
|
||||
});
|
||||
function buildWorkout(fName) {
|
||||
const Workout = require("buffgym-workout.js");
|
||||
const workoutJSON = require("Storage").readJSON(fName);
|
||||
const workout = Workout.fromJSON(workoutJSON);
|
||||
|
||||
return exercise;
|
||||
});
|
||||
prog.addExercises(exercises);
|
||||
|
||||
return prog;
|
||||
return workout;
|
||||
}
|
||||
|
||||
function saveProg(program) {
|
||||
const fName = getProgIndex().find(prog => prog.title === program.title).file;
|
||||
require("Storage").writeJSON(fName, program.toJSON());
|
||||
function saveWorkout(workout) {
|
||||
const fName = getWorkoutIndex().find(w => w.title === workout.title).file;
|
||||
require("Storage").writeJSON(fName, workout.toJSON());
|
||||
}
|
||||
|
||||
drawSplash();
|
||||
|
|
@ -0,0 +1,250 @@
|
|||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" href="../../css/spectre.min.css">
|
||||
</head>
|
||||
<body>
|
||||
<h1>BuffGym</h1>
|
||||
<p>
|
||||
Enter in your weights for each exercise, start light and keep consistent with your training. The weight increment field is how much the app will increase your weights for an exercise if you successfully complete all the reps and sets for an exercise. Make sure its a value that matches the weights in your gym.
|
||||
</p>
|
||||
<p>
|
||||
For more information on how to train this program refer the <a href="https://stronglifts.com/5x5/" target="_BLANK">Stronglifts website</a>
|
||||
</p>
|
||||
<form id="workouts-form">
|
||||
<h4>Workout A</h4>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Exercise</th>
|
||||
<th>Sets / Reps</th>
|
||||
<th>Weight</th>
|
||||
<th>Weight increment</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="workout-a-exercises">
|
||||
<tr>
|
||||
<td>
|
||||
Squats
|
||||
</td>
|
||||
<td>
|
||||
5x5
|
||||
</td>
|
||||
<td>
|
||||
<input type="number" value="0" id="buffgym-workout-a-squats-weight" />
|
||||
</td>
|
||||
<td>
|
||||
<input type="number" value="2.5" id="buffgym-workout-a-squats-weight-increment" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
Overhead press
|
||||
</td>
|
||||
<td>
|
||||
5x5
|
||||
</td>
|
||||
<td>
|
||||
<input type="number" value="0" id="buffgym-workout-a-overhead-press-weight" />
|
||||
</td>
|
||||
<td>
|
||||
<input type="number" value="2.5" id="buffgym-workout-a-overhead-press-weight-increment" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
Deadlift
|
||||
</td>
|
||||
<td>
|
||||
1x5
|
||||
</td>
|
||||
<td>
|
||||
<input type="number" value="0" id="buffgym-workout-a-deadlift-weight" />
|
||||
</td>
|
||||
<td>
|
||||
<input type="number" value="2.5" id="buffgym-workout-a-deadlift-weight-increment" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
Pullups
|
||||
</td>
|
||||
<td>
|
||||
3x10
|
||||
</td>
|
||||
<td>
|
||||
<input type="number" value="0" id="buffgym-workout-a-pullups-weight" />
|
||||
</td>
|
||||
<td>
|
||||
<input type="number" value="2.5" id="buffgym-workout-a-pullups-weight-increment" />
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<h4>Workout B</h4>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Exercise</th>
|
||||
<th>Sets / Reps</th>
|
||||
<th>Weight</th>
|
||||
<th>Weight increment</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="workout-b-exercises">
|
||||
<tr>
|
||||
<td>
|
||||
Squats
|
||||
</td>
|
||||
<td>
|
||||
5x5
|
||||
</td>
|
||||
<td>
|
||||
<input type="number" value="0" id="buffgym-workout-b-squats-weight" />
|
||||
</td>
|
||||
<td>
|
||||
<input type="number" value="2.5" id="buffgym-workout-b-squats-weight-increment" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
Bench press
|
||||
</td>
|
||||
<td>
|
||||
5x5
|
||||
</td>
|
||||
<td>
|
||||
<input type="number" value="0" id="buffgym-workout-b-bench-press-weight" />
|
||||
</td>
|
||||
<td>
|
||||
<input type="number" value="2.5" id="buffgym-workout-b-bench-press-weight-increment" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
Row
|
||||
</td>
|
||||
<td>
|
||||
5x5
|
||||
</td>
|
||||
<td>
|
||||
<input type="number" value="0" id="buffgym-workout-b-row-weight" />
|
||||
</td>
|
||||
<td>
|
||||
<input type="number" value="2.5" id="buffgym-workout-b-row-weight-increment" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
Tricep extension
|
||||
</td>
|
||||
<td>
|
||||
3x10
|
||||
</td>
|
||||
<td>
|
||||
<input type="number" value="0" id="buffgym-workout-b-triceps-weight" />
|
||||
</td>
|
||||
<td>
|
||||
<input type="number" value="2.5" id="buffgym-workout-b-triceps-weight-increment" />
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</form>
|
||||
<br><br>
|
||||
<button id="upload" class="btn btn-primary">Upload</button>
|
||||
|
||||
<script src="../../lib/interface.js"></script>
|
||||
|
||||
<script>
|
||||
function workoutA() {
|
||||
return {
|
||||
"title": "Workout A",
|
||||
"exercises": [
|
||||
{
|
||||
"title": "Squats",
|
||||
"weight": Number(document.getElementById("buffgym-workout-a-squats-weight").value),
|
||||
"weightIncrement": Number(document.getElementById("buffgym-workout-a-squats-weight-increment").value),
|
||||
"unit": "Kg",
|
||||
"sets": [5, 5, 5, 5, 5],
|
||||
"restPeriod": 90
|
||||
},
|
||||
{
|
||||
"title": "Overhead press",
|
||||
"weight": Number(document.getElementById("buffgym-workout-a-overhead-press-weight").value),
|
||||
"weightIncrement": Number(document.getElementById("buffgym-workout-a-overhead-press-weight-increment").value),
|
||||
"unit": "Kg",
|
||||
"sets": [5, 5, 5, 5, 5],
|
||||
"restPeriod": 90
|
||||
},
|
||||
{
|
||||
"title": "Deadlift",
|
||||
"weight": Number(document.getElementById("buffgym-workout-a-deadlift-weight").value),
|
||||
"weightIncrement": Number(document.getElementById("buffgym-workout-a-deadlift-weight-increment").value),
|
||||
"unit": "Kg",
|
||||
"sets": [5],
|
||||
"restPeriod": 90
|
||||
},
|
||||
{
|
||||
"title": "Pullups",
|
||||
"weight": Number(document.getElementById("buffgym-workout-a-pullups-weight").value),
|
||||
"weightIncrement": Number(document.getElementById("buffgym-workout-a-pullups-weight-increment").value),
|
||||
"unit": "Kg",
|
||||
"sets": [10, 10, 10],
|
||||
"restPeriod": 90
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
function workoutB() {
|
||||
return {
|
||||
"title": "Workout B",
|
||||
"exercises": [
|
||||
{
|
||||
"title": "Squats",
|
||||
"weight": Number(document.getElementById("buffgym-workout-b-squats-weight").value),
|
||||
"weightIncrement": Number(document.getElementById("buffgym-workout-b-squats-weight-increment").value),
|
||||
"unit": "Kg",
|
||||
"sets": [5, 5, 5, 5, 5],
|
||||
"restPeriod": 90
|
||||
},
|
||||
{
|
||||
"title": "Bench press",
|
||||
"weight": Number(document.getElementById("buffgym-workout-b-bench-press-weight").value),
|
||||
"weightIncrement": Number(document.getElementById("buffgym-workout-b-bench-press-weight-increment").value),
|
||||
"unit": "Kg",
|
||||
"sets": [5, 5, 5, 5, 5],
|
||||
"restPeriod": 90
|
||||
},
|
||||
{
|
||||
"title": "Row",
|
||||
"weight": Number(document.getElementById("buffgym-workout-b-row-weight").value),
|
||||
"weightIncrement": Number(document.getElementById("buffgym-workout-b-row-weight-increment").value),
|
||||
"unit":"Kg",
|
||||
"sets": [5, 5, 5, 5, 5],
|
||||
"restPeriod": 90
|
||||
},
|
||||
{
|
||||
"title": "Tricep extension",
|
||||
"weight": Number(document.getElementById("buffgym-workout-b-triceps-weight").value),
|
||||
"weightIncrement": Number(document.getElementById("buffgym-workout-b-triceps-weight-increment").value),
|
||||
"unit": "Kg",
|
||||
"sets": [10, 10, 10],
|
||||
"restPeriod": 90
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
document.getElementById("upload").addEventListener("click", function() {
|
||||
Puck.eval(`require("Storage").writeJSON("buffgym-workout-a.json",${JSON.stringify(workoutA())})`, ()=>{
|
||||
Puck.eval(`require("Storage").writeJSON("buffgym-workout-b.json",${JSON.stringify(workoutB())})`, ()=>{
|
||||
Puck.eval(`Bangle.buzz()`, () => {
|
||||
console.log("all done");
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Reference in New Issue