From 95c6bb907279aa2a7979081f2111b129f007adc7 Mon Sep 17 00:00:00 2001 From: Klemek Date: Fri, 18 Oct 2024 17:35:35 +0200 Subject: [PATCH] small starting delays + cannot start without sounds --- index.html | 6 +++--- main.js | 16 ++++++++++------ 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/index.html b/index.html index d0234fb..787b999 100644 --- a/index.html +++ b/index.html @@ -16,7 +16,7 @@

Startle Machine

Generates silence occasionally broken up by random sound effects.
Click the button below and leave this tab to start the prank.

- +

Configuration

@@ -27,12 +27,12 @@ - + - + diff --git a/main.js b/main.js index dfd75f2..4b47a68 100644 --- a/main.js +++ b/main.js @@ -65,8 +65,8 @@ let app = { return { sounds: [], started: false, - minDelay: 15, - maxDelay: 45, + minDelay: 5, + maxDelay: 10, volume: 50, randomPitch: true, hidePrank: true, @@ -75,7 +75,11 @@ let app = { fakes: FAKES, }; }, - computed: {}, + computed: { + canStart() { + return this.sounds.filter(sound => sound.active).length > 0; + }, + }, watch: { minDelay() { this.maxDelay = Math.max(this.minDelay, this.maxDelay); @@ -146,9 +150,9 @@ let app = { }, trigger() { this.started = true; - const time = random.int(this.minDelay, this.maxDelay); - console.log(`Next in ${time} minutes`); - setTimeout(this.playRandomSound, time * 60 * 1000); + const time = random.int(this.minDelay * 60 * 1000, this.maxDelay * 60 * 1000); + console.log(`Next in ${Math.round(time / (60 * 1000))} minutes`); + setTimeout(this.playRandomSound, time); }, selectAll() { this.sounds.forEach(sound => {
{{ minDelay }} minutes
{{ maxDelay }} minutes