From f7909eb55076a093b351e5b96e274630a5ef0d44 Mon Sep 17 00:00:00 2001 From: Jeremy Dixon Date: Fri, 22 Jan 2021 16:02:10 -0600 Subject: [PATCH] add sound on sound change --- script_foreground.js | 32 +++++++++++++++++++++----------- styles.css | 3 ++- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/script_foreground.js b/script_foreground.js index ae4e7ed..31b9f69 100644 --- a/script_foreground.js +++ b/script_foreground.js @@ -31,7 +31,10 @@ let state = { } console.log('saving settings ', saveData) localStorage.setItem('config',JSON.stringify(saveData)) - if(property=="sound-select"){state.render["sound-select"]()}; + if(property=="sound-select"){ + state.render["sound-select"](); + sendAlert("skip frequency"); + }; if(property=="volume"){state.render["volume"]()}; } else { @@ -107,6 +110,22 @@ let state = { } } +function sendAlert(skipFrequency){ + let message = { + message:{ + flag:"alert", options:{ + frequency:state["alert-frequency"], + sound: state["sound-select"], + volume: state["volume"] + } + }}; + if(skipFrequency){ + message.message.options.frequency = 1000; + } + console.log(`requesting alert ${message}`) + chrome.runtime.sendMessage(message); +} + function appendTool(html){ // fetch the list of possible alerts from the background script chrome.runtime.sendMessage( @@ -142,16 +161,7 @@ function appendTool(html){ timer = setInterval(function(){ var refresh_btn = document.querySelector('[data-qa-action-id="refresh-queue"]'); if(newQuestion()){ - let message = { - message:{ - flag:"alert", options:{ - frequency:state["alert-frequency"], - sound: state["sound-select"], - volume: state["volume"] - } - }}; - console.log('New Question Detected - sending alert to background', message); - chrome.runtime.sendMessage(message); + sendAlert(); }; }, state["watch-frequency"]*1000); return timer; diff --git a/styles.css b/styles.css index 625833b..8e88cf7 100644 --- a/styles.css +++ b/styles.css @@ -2,8 +2,9 @@ outline: 0px solid transparent; } #volume { - margin-left: 1rem; position: relative; + top: 4px; + margin-left: 1rem; height: 25px; width: 50px; float: left;