diff --git a/background.js b/background.js index b891724..0cbef91 100644 --- a/background.js +++ b/background.js @@ -73,12 +73,7 @@ function formatTime(time) { // Function to notify break time function notifyBreakTime() { - chrome.notifications.create("breakTimeNotification", { - type: "basic", - iconUrl: "images/hourglass.png", - title: "Take a break!", - message: "It's time to take a break. Look at something 20 feet away for 20 seconds." - }); + chrome.runtime.sendMessage({ type: "breakTimeNotification"}); } // Function to start short break timer diff --git a/options.html b/options.html index 95fd0e5..9a6de51 100644 --- a/options.html +++ b/options.html @@ -17,7 +17,17 @@

Keyboard Shortcut

Press the desired key combination and click Save.

+
+

Custom Alert Message

+

Set a custom alert message for yourself as a reminder

+
+ + +
+
+

+ diff --git a/options.js b/options.js index cd9f8bd..86f4d02 100644 --- a/options.js +++ b/options.js @@ -44,3 +44,10 @@ shortcutInput.addEventListener('keydown', function(e) { console.log(`Captured keys: ${keys.join('+')}`); shortcutInput.value = keys.join('+'); }); + +document.getElementById('saveMessage').addEventListener('click', function() { + const message = document.getElementById('userinput').value; + chrome.storage.sync.set({ customMessage: message }, function() { + document.getElementById('messagesaved').textContent = 'Message saved successfully!'; + }); +}); \ No newline at end of file diff --git a/popup.js b/popup.js index 315608e..86ea6f9 100644 --- a/popup.js +++ b/popup.js @@ -4,6 +4,13 @@ const startButton = document.getElementById("start"); const resumeButton = document.getElementById("resume"); const resetButton = document.getElementById("reset"); const themeToggle = document.getElementById("theme-toggle"); +let custom_message="It's time to take a break. Look at something 20 feet away for 20 seconds."; + +chrome.storage.sync.get('customMessage', (data)=> { + if (data.customMessage) { + custom_message=data.customMessage; + } +}); // Schedule Tab elements const startTimeInput = document.getElementById("startTime"); @@ -73,8 +80,21 @@ chrome.runtime.onMessage.addListener(function(message, sender, sendResponse) { if (message.type === "updateTimer") { timerElement.textContent = message.time; } + else if(message.type === "breakTimeNotification"){ + chrome.notifications.create("breakTimeNotification", { + type: "basic", + iconUrl: "images/hourglass.png", + title: "Take a break!", + message: custom_message + }); + } + + }); + + + // Function to save the schedule saveScheduleButton.addEventListener("click", function() { const startTime = startTimeInput.value;