Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions background.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ chrome.runtime.onInstalled.addListener(function() {
}],
'settings': {
'hour24': false,
'labels': true
}
'labels': true,
'customColor': '30, 30, 30',
'customOpacity': '.05'
},
});

chrome.storage.local.set({
Expand Down
8 changes: 8 additions & 0 deletions options.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@
</head>
<body>
<main>
<section id="colors">
<input id="rval" value = "red">
<input id="gval" value = "green">
<input id="bval" value = "blue">
</section>
<section id="opacity">
<input id="opacityval">
</section>
<section id="clocks">
<template id="clock">
<article class="inputs">
Expand Down
18 changes: 18 additions & 0 deletions scripts/newtab.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,25 @@ chrome.storage.local.get([
'scheme': mode
});
}



});

chrome.storage.sync.get([
'settings'
], function(results) {
const {settings} = results;
yy = getComputedStyle(document.documentElement).getPropertyValue("--background-rgb")
console.log("current color: ", yy)
console.log("chosen color: ", settings.customOpacity)
document.documentElement.style.setProperty("--background-rgb", settings.customColor);
document.documentElement.style.setProperty("--hand-opacity", settings.customOpacity);
})




chrome.storage.sync.get([
'clocks',
'settings'
Expand Down Expand Up @@ -64,6 +81,7 @@ chrome.storage.sync.get([

hand.style.transform = `rotate(${degree}deg)`;


return update;
}(), 1000);

Expand Down
25 changes: 21 additions & 4 deletions scripts/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ chrome.storage.sync.get([
const { clocks, settings } = results;
const section = {
'clocks': document.querySelector('#clocks'),
'settings': document.querySelector('#settings')
'settings': document.querySelector('#settings'),
'customOpacity': document.querySelector('#opacityval'),
'rval' : document.querySelector('#rval'),
'gval' : document.querySelector('#gval'),
'bval' : document.querySelector('#bval'),
};
const button = {
'save': document.querySelector('[name="save"]'),
Expand All @@ -32,18 +36,26 @@ chrome.storage.sync.get([
event.target.closest('article').remove();
}
});


/// populating settings
clocks.forEach(clock => {
addRow(clock);
});

['hour24', 'labels'].forEach(name => {
const attribute = `[name="${name}"]`;
const input = section.settings.querySelector(attribute);

console.log("hey ", settings)
input.checked = settings[name];
});

section.customOpacity.value = settings['customOpacity'];
rgbArray = settings['customColor'].split(",");
section.rval.value = rgbArray[0];
section.gval.value = rgbArray[1];
section.bval.value = rgbArray[2];


button.save.addEventListener('click', function() {
let object = {
'clocks': [],
Expand All @@ -57,15 +69,20 @@ chrome.storage.sync.get([
});
});

//getting values
['hour24', 'labels'].forEach(name => {
const attribute = `[name="${name}"]`;
const input = section.settings.querySelector(attribute);

object.settings[name] = input.checked;
});

object.settings['customOpacity'] = section.customOpacity.value;
rgbString = `${section.rval.value},${section.gval.value},${section.bval.value}`
object.settings['customColor'] = rgbString;


chrome.storage.sync.set(object, window.close);
});

button.add.addEventListener('click', addRow);
});
4 changes: 2 additions & 2 deletions styles/newtab.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
@media (prefers-color-scheme: dark) {
:root {
--color-rgb: 185, 186, 188;
--background-rgb: 32, 33, 36;
--hand-opacity: 0.01;
--background-rgb: 0, 0, 0;
--hand-opacity: 0.05;
}
}

Expand Down
1 change: 1 addition & 0 deletions styles/options.css
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ button {
border: 1px solid;
border-radius: 4px;
outline: 0px;
text-align: start;
}

input,
Expand Down