mirror of
https://github.com/zyqunix/tools.git
synced 2025-07-06 06:20:30 +02:00
updated color randomizer, allows for custom color visualization now too
This commit is contained in:
parent
71924663d8
commit
4008467462
8 changed files with 106 additions and 8 deletions
|
@ -2,6 +2,8 @@ const colorButton = document.getElementById('colorButton');
|
|||
const fullColor = document.getElementById('fullColor');
|
||||
const main = document.getElementById('main');
|
||||
const offscreenAlert = document.getElementById('offscreenalert');
|
||||
const colorInput = document.getElementById('colorInput');
|
||||
const inputButton = document.getElementById('inputButton');
|
||||
|
||||
const chars = "0123456789ABCDEF";
|
||||
|
||||
|
@ -38,3 +40,25 @@ main.addEventListener('click', () => {
|
|||
const colorText = fullColor.textContent || fullColor.innerHTML;
|
||||
copyToClipboard(colorText).then(showAlert);
|
||||
});
|
||||
|
||||
colorInput.addEventListener("keydown", function(event) {
|
||||
if (event.key === "Enter") {
|
||||
const inputValue = colorInput.value;
|
||||
if (/^#[0-9A-F]{6}$/i.test(inputValue)) {
|
||||
applyColor(inputValue);
|
||||
} else {
|
||||
document.getElementById('hint').innerHTML = "Invalid color format. Please enter a valid hex color code. EG #aabbcc";
|
||||
}
|
||||
event.preventDefault();
|
||||
}
|
||||
});
|
||||
|
||||
inputButton.addEventListener("click", function(event) {
|
||||
const inputValue = colorInput.value;
|
||||
if (/^#[0-9A-F]{6}$/i.test(inputValue)) {
|
||||
applyColor(inputValue);
|
||||
} else {
|
||||
document.getElementById('hint').innerHTML = "Invalid color format. Please enter a valid hex color code. EG #aabbcc";
|
||||
}
|
||||
event.preventDefault();
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue