Skip to content

Commit

Permalink
squeeze and pause
Browse files Browse the repository at this point in the history
  • Loading branch information
nalbam committed Nov 11, 2019
1 parent 843ad08 commit ac46f7f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 20 deletions.
26 changes: 16 additions & 10 deletions public/timer.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class Timer {
li.innerText = this.format(this.times);
this.results.appendChild(li);

console.log(this.format(this.times));
console.log(`record ${this.format(this.times)}`);

this.latest = this.times;
this.records.push(this.times);
Expand All @@ -155,7 +155,7 @@ class Timer {
return;
}

console.log(this.format(this.records[0]));
console.log(`remove ${this.format(this.records[0])}`);

this.latest = null;
this.records.splice(0, 1);
Expand All @@ -171,7 +171,9 @@ class Timer {
return;
}

console.log(this.format(this.latest));
console.log(`squeeze ${this.format(this.latest)}`);

this.pause();

this.times[2] += this.latest[2];
this.times[1] += this.latest[1];
Expand All @@ -190,7 +192,11 @@ class Timer {
if (this.times[2] < 0) {
this.times[2] = 0;
}

this.start();

this.latest = null;
this.results.removeChild(this.results.lastChild);
}

format(times) {
Expand Down Expand Up @@ -269,13 +275,13 @@ function exec(name) {
}

let key_map = {
'81': 'start',
'87': 'pause',
'69': 'passed',
'82': 'reset',
'84': 'clear',
'89': 'remove',
'71': 'squeeze',
'81': 'start', // q
'87': 'pause', // w
'69': 'passed', // e
'82': 'reset', // r
'84': 'clear', // t
'89': 'remove', // y
'71': 'squeeze', // g
};

document.addEventListener('keydown', function (event) {
Expand Down
24 changes: 14 additions & 10 deletions public/timer.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class Timer {
li.innerText = this.format(this.times);
this.results.appendChild(li);

console.log(this.format(this.times));
console.log(`record ${this.format(this.times)}`);

this.latest = this.times;
this.records.push(this.times);
Expand All @@ -153,7 +153,7 @@ class Timer {
return;
}

console.log(this.format(this.records[0]));
console.log(`remove ${this.format(this.records[0])}`);

this.latest = null;
this.records.splice(0, 1);
Expand All @@ -169,7 +169,9 @@ class Timer {
return;
}

console.log(this.format(this.latest));
console.log(`squeeze ${this.format(this.latest)}`);

this.pause();

this.times[2] += this.latest[2];
this.times[1] += this.latest[1];
Expand All @@ -189,6 +191,8 @@ class Timer {
this.times[2] = 0;
}

this.start();

this.latest = null;
this.results.removeChild(this.results.lastChild);
}
Expand Down Expand Up @@ -290,13 +294,13 @@ function exec(name) {
}

let key_map = {
'81': 'start',
'87': 'pause',
'69': 'passed',
'82': 'reset',
'84': 'clear',
'89': 'remove',
'71': 'squeeze',
'81': 'start', // q
'87': 'pause', // w
'69': 'passed', // e
'82': 'reset', // r
'84': 'clear', // t
'89': 'remove', // y
'71': 'squeeze', // g
};

document.addEventListener('keydown', function (event) {
Expand Down

0 comments on commit ac46f7f

Please sign in to comment.