-
Notifications
You must be signed in to change notification settings - Fork 0
/
mainscript.js
30 lines (23 loc) · 1.09 KB
/
mainscript.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
"use strict";
let mainBox = document.getElementById("mainBox");
let inputRgb = document.getElementById("mainInput");
let getRandomRGBColorBtn = document.getElementById("mainbtn");
let copyBtn = document.getElementById("copyBtn");
function getRandomRGBColor() {
mainBox.style.background = `rgb(${getRandomInt(0, 255)}, ${getRandomInt(0, 255)}, ${getRandomInt(0, 255)})`;
let body = document.body;
body.style.background = mainBox.style.background;
inputRgb.value = mainBox.style.background + ';';
// inputRgb.style.color = mainBox.style.background;
// getRandomRGBColorBtn.style.background = `rgb(${getRandomInt(0, 255)}, ${getRandomInt(0, 255)}, ${getRandomInt(0, 255)})`;
// getRandomRGBColorBtn.style.color = `rgb(${getRandomInt(0, 255)}, ${getRandomInt(0, 255)}, ${getRandomInt(0, 255)})`;
}
getRandomRGBColorBtn.addEventListener('click', getRandomRGBColor);
copyBtn.addEventListener('click', () => {
inputRgb.select();
document.execCommand("copy");
})
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min)) + min;
}
getRandomRGBColor();