-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from obayomi96/ft-new-features
[Feature]: Update version with additional features & fixes
- Loading branch information
Showing
9 changed files
with
167 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
## What does this PR do? | ||
|
||
|
||
## How can this PR (Update) be manually tested? | ||
|
||
|
||
## Other Information / Background Context | ||
|
||
|
||
## Issue Information | ||
|
||
- Summary of Issue (In your own words): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Chrome notification API | ||
const options = { | ||
type: "basic", | ||
title: "Blink Alert! - Take a break", | ||
message: | ||
"Look away from your computer for 20 seconds. (click here to take full exercise)", | ||
iconUrl: "../images/eyeIcon_128.png", | ||
}; | ||
|
||
let selectedDuration; | ||
let intervalId; | ||
|
||
const createNotification = () => { | ||
chrome.notifications.create(options); | ||
}; | ||
|
||
const createExerciseTab = () => { | ||
chrome.tabs.create({ url: "exercise.html" }); | ||
}; | ||
|
||
chrome.notifications.onClicked.addListener(createExerciseTab); | ||
|
||
chrome.runtime.onMessage.addListener((message, sender, sendResponse) => { | ||
if (message.updateInterval) { | ||
chrome.storage.local.get("duration", ({ duration }) => { | ||
selectedDuration = duration; | ||
if (intervalId) { | ||
clearInterval(intervalId); | ||
} | ||
intervalId = setInterval(createNotification, +selectedDuration); | ||
}); | ||
} | ||
}); | ||
|
||
chrome.runtime.onInstalled.addListener(() => { | ||
// Set an initial alarm when the extension is installed or updated | ||
chrome.storage.local.get("duration", ({ duration }) => { | ||
selectedDuration = duration; | ||
intervalId = setInterval(createNotification, +selectedDuration); | ||
}); | ||
}); | ||
|
||
const keepAlive = () => setInterval(chrome.runtime.getPlatformInfo, 20e3); | ||
chrome.runtime.onStartup.addListener(keepAlive); | ||
keepAlive(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,71 +1,45 @@ | ||
// // Chrome notification API | ||
const options = { | ||
type: "basic", | ||
title: "Blink Alert! - Its been 20 minutes!", | ||
message: | ||
"Look away from your Computer, Look at something 20 feet away for 20 seconds. (CLICK HERE TO TAKE EXERCISE)", | ||
iconUrl: "images/eyeIcon_128.png", | ||
}; | ||
|
||
let selectedDuration; | ||
|
||
const durationBtn1 = document.getElementById("durationBtn1"); | ||
const durationBtn2 = document.getElementById("durationBtn2"); | ||
const durationBtn3 = document.getElementById("durationBtn3"); | ||
|
||
const checkSelectedBtn = (value) => { | ||
if (value === "1200000") { | ||
if (value === 1200000) { | ||
durationBtn1.classList.add("btnSelected"); | ||
durationBtn2.classList.remove("btnSelected"); | ||
durationBtn3.classList.remove("btnSelected"); | ||
} else if (value === "3600000") { | ||
} else if (value === 3600000) { | ||
durationBtn2.classList.add("btnSelected"); | ||
durationBtn1.classList.remove("btnSelected"); | ||
durationBtn3.classList.remove("btnSelected"); | ||
} else if (value === "7200000") { | ||
} else if (value === 7200000) { | ||
durationBtn3.classList.add("btnSelected"); | ||
durationBtn1.classList.remove("btnSelected"); | ||
durationBtn2.classList.remove("btnSelected"); | ||
} | ||
}; | ||
|
||
chrome.storage.local.get("duration", ({ duration }) => { | ||
selectedDuration = duration || 1200000; | ||
checkSelectedBtn(duration); | ||
}); | ||
const durationBtn1 = document.getElementById("durationBtn1"); | ||
const durationBtn2 = document.getElementById("durationBtn2"); | ||
const durationBtn3 = document.getElementById("durationBtn3"); | ||
|
||
durationBtn1.addEventListener("click", () => { | ||
chrome.storage.local.set({ duration: "1200000" }, () => { | ||
selectedDuration = 1200000; | ||
}); | ||
chrome.storage.local.get("duration", ({ duration }) => { | ||
checkSelectedBtn(duration); | ||
const setDuration = (value) => { | ||
chrome.storage.local.set({ duration: value }, () => { | ||
// Send a message to the background script to update the interval | ||
chrome.runtime.sendMessage({ updateInterval: true }); | ||
checkSelectedBtn(value); | ||
}); | ||
}); | ||
}; | ||
|
||
durationBtn2.addEventListener("click", () => { | ||
chrome.storage.local.set({ duration: "3600000" }, () => { | ||
selectedDuration = 3600000; | ||
}); | ||
document.addEventListener("DOMContentLoaded", () => { | ||
chrome.storage.local.get("duration", ({ duration }) => { | ||
checkSelectedBtn(duration); | ||
setDuration(duration || 1200000); | ||
}); | ||
}); | ||
|
||
durationBtn3.addEventListener("click", () => { | ||
chrome.storage.local.set({ duration: "7200000" }, () => { | ||
selectedDuration = 7200000; | ||
}); | ||
chrome.storage.local.get("duration", ({ duration }) => { | ||
checkSelectedBtn(duration); | ||
}); | ||
durationBtn1.addEventListener("click", () => { | ||
setDuration(1200000); | ||
}); | ||
|
||
setInterval(() => { | ||
chrome.notifications.create(options); | ||
}, Number(selectedDuration) || 1200000); | ||
durationBtn2.addEventListener("click", () => { | ||
setDuration(3600000); | ||
}); | ||
|
||
// Create a new tab onclick of notification | ||
chrome.notifications.onClicked.addListener(function () { | ||
chrome.tabs.create({ url: "exercise.html" }); | ||
durationBtn3.addEventListener("click", () => { | ||
setDuration(7200000); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.