-
Notifications
You must be signed in to change notification settings - Fork 0
/
newtab.js
52 lines (44 loc) · 1.74 KB
/
newtab.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
document.addEventListener('DOMContentLoaded', function() {
var setFocusButton = document.getElementById('setFocusButton');
var newFocusInput = document.getElementById('newFocusInput');
var focusText = document.getElementById('focusText');
var focusCheckbox = document.getElementById('focusCheckbox');
newFocusInput.focus();
function celebrateCompletion() {
// Celebration logic (e.g., change background color, display a message, etc.)
alert('Congratulations on completing your task!'); // Example celebration
}
function resetFocus() {
focusText.style.display = 'block';
focusText.textContent = 'No daily focus set for today.';
newFocusInput.value = '';
focusCheckbox.checked = false;
}
setFocusButton.addEventListener('click', function() {
chrome.storage.local.set({ 'dailyFocus': newFocusInput.value }, function() {
updateFocusDisplay();
resetFocus();
});
});
newFocusInput.addEventListener('keypress', function(event) {
if (event.key === 'Enter') {
chrome.storage.local.set({ 'dailyFocus': newFocusInput.value }, function() {
updateFocusDisplay();
resetFocus();
});
}
});
focusCheckbox.addEventListener('click', function() {
if (focusCheckbox.checked) {
focusText.style.display = 'none';
celebrateCompletion();
chrome.storage.local.set({ 'dailyFocus': '' });
}
});
function updateFocusDisplay() {
chrome.storage.local.get('dailyFocus', function(data) {
focusText.textContent = data.dailyFocus || 'No daily focus set for today.';
});
}
updateFocusDisplay();
});