diff --git a/README.md b/README.md index e34490c..0b806a4 100644 --- a/README.md +++ b/README.md @@ -29,3 +29,4 @@ | Reset | R | | Clear | T | | Squeeze | Y | +| Drop | D | diff --git a/public/timer.css b/public/timer.css index 4f87d08..9d0097a 100644 --- a/public/timer.css +++ b/public/timer.css @@ -54,6 +54,10 @@ html { color: #ddd; } +.btn_drop { + color: #93e; +} + .limiter { font-size: 6vw; position: fixed; diff --git a/public/timer.js b/public/timer.js index d430013..754308e 100644 --- a/public/timer.js +++ b/public/timer.js @@ -191,6 +191,20 @@ class Timer { this.start(); } + drop() { + console.log(`running drop`); + if (this.records.length == 0) { + return; + } + console.log(`drop ${this.results.lastChild.innerText}`); + this.results.removeChild(this.results.lastChild); + // update bestlap + this.records.splice(this.records.length - 1, 1); + this.sorted = this.records.slice(); + this.sorted.sort(compare); + this.bestlap.innerText = this.format(this.sorted[0]); + } + format(times) { return `${lpad(times[0], 2)}:${lpad(times[1], 2)}.${lpad(Math.floor(times[2]), 3)}`; } @@ -265,6 +279,9 @@ function exec(name) { case 'squeeze': timer.squeeze(); break; + case 'drop': + timer.drop(); + break; } } @@ -275,6 +292,7 @@ let key_map = { '82': 'reset', // r '84': 'clear', // t '89': 'squeeze', // y + '68': 'drop', // d }; document.addEventListener('keydown', function (event) { @@ -294,3 +312,4 @@ document.getElementById('btn_pause').addEventListener('click', btn_listener); document.getElementById('btn_passed').addEventListener('click', btn_listener); document.getElementById('btn_reset').addEventListener('click', btn_listener); document.getElementById('btn_clear').addEventListener('click', btn_listener); +document.getElementById('btn_drop').addEventListener('click', btn_listener); diff --git a/src/http/get-timer/index.js b/src/http/get-timer/index.js index fc867ea..6264995 100644 --- a/src/http/get-timer/index.js +++ b/src/http/get-timer/index.js @@ -28,6 +28,7 @@ exports.handler = async function http(req) { Passed Reset Clear + Drop
diff --git a/views/timer.ejs b/views/timer.ejs index a1b4939..1fc10a4 100644 --- a/views/timer.ejs +++ b/views/timer.ejs @@ -14,6 +14,7 @@ Passed Reset Clear + Drop