diff --git a/.gitignore b/.gitignore index 4d21628..81eeb92 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ src/lib/ .DS_Store src/1.js src/2.js +src/audio/*.wav diff --git a/README.md b/README.md index d5e8b24..cad3c80 100644 --- a/README.md +++ b/README.md @@ -37,3 +37,7 @@ GitHub Actions are used to perform automated code quality checks upon PR creatio Spell checking via CSpell See `spelling.json` for custom dictionary + +## Credits + +* the notification sound `481151__matrixxx__cow-bells-01.wav` is from [freesound.org](https://freesound.org/people/MATRIXXX_/sounds/481151/) diff --git a/scripts/sync_to_server.sh b/scripts/sync_to_server.sh index e07a8d5..b9e2695 100755 --- a/scripts/sync_to_server.sh +++ b/scripts/sync_to_server.sh @@ -7,3 +7,4 @@ cd $script_dir/.. rsync -rvhu --delete --no-perms --exclude *.test.js src/*.js entorb@entorb.net:html/eta/ rsync -rvhu --delete --no-perms src/*.html entorb@entorb.net:html/eta/ rsync -rvhu --delete --no-perms src/*.css entorb@entorb.net:html/eta/ +rsync -rvhu --delete --no-perms src/audio/*.mp3 entorb@entorb.net:html/eta/audio/ diff --git a/src/audio/481151__matrixxx__cow-bells-01.mp3 b/src/audio/481151__matrixxx__cow-bells-01.mp3 new file mode 100644 index 0000000..26c4986 Binary files /dev/null and b/src/audio/481151__matrixxx__cow-bells-01.mp3 differ diff --git a/src/helper.js b/src/helper.js index be70177..c260103 100644 --- a/src/helper.js +++ b/src/helper.js @@ -276,6 +276,24 @@ function read_html_input_number(html_input) { return Number(value_str); } +/** + * play a sound of mp3 format + * @param {*} url of mp3 sound file + */ +function playSound(url) { + const audio = new Audio(url); + audio.play(); +} + +/** + * Play sound file for timer done + */ +function playSoundTimerDone() { + playSound('audio/481151__matrixxx__cow-bells-01.mp3'); +} + + + // Export functions, needed for Jest unittests // Using this hack it works for both, jest and browser. // from https://stackoverflow.com/questions/66349868/jest-unit-testing-module-export-error-in-browser-console @@ -295,4 +313,6 @@ module.exports = { calc_row_new_delta, sort_data, read_html_input_number, + playSound, + playSoundTimerDone, }; diff --git a/src/main.js b/src/main.js index f7691e8..8b2ba8e 100644 --- a/src/main.js +++ b/src/main.js @@ -32,11 +32,14 @@ prevent entering non-numbers add delta1 html placeholders weighted linreg instead, to put more weight on the latest items +play notification sound when estimated time is reached TODO/IDEAS chart: choose to display remaining instead of items tabulator: use global data, and update column speed name upon switching unit echarts: use global data, and update speed unit +store "hide_intro" as setting +add simple time-only countdown+notification */ // @@ -178,6 +181,7 @@ function update_runtime_and_remaining() { let ms_remaining = total_timestamp_eta - Date.now(); if (ms_remaining < 0) { ms_remaining = 0; + playSoundTimerDone(); // stop timer clearInterval(interval_auto_refresh); }