-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
131 lines (116 loc) · 3.6 KB
/
main.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
const bgCol = document.getElementById("bgCol");
const shadowCol = document.getElementById("shadowCol");
const boxCol = document.getElementById("boxCol");
const infoTool=document.getElementById("infoTool");
const bg = document.getElementById("testingBox");
const info= document.getElementById("infoToolkit");
const x=document.getElementById("xVal");
const y=document.getElementById("yVal");
const z=document.getElementById("zVal");
const w=document.getElementById("wVal");
x.value = -50;
y.value = -50;
const navigator= document.getElementById("navigator");
const mobileResult = document.getElementById("screen");
const ci= document.getElementById("ci");
const themeButton = document.getElementById("themeCont");
const themeCursor=document.querySelectorAll("#themeCont svg");
let currentShadow;
const copyBtn = document.getElementById("copyBtn");
console.log(ci);
ci.isConnected=false;
const textA=document.getElementById("resultT")
//border-radius: x y z w color
const color = "#ff88cc"
const box=document.getElementById("resultBox");
let seeResult = false;
let theme = true; //false for dark - true for light
bgCol.value="#efefef";
boxCol.value="#9999ff";
shadowCol.value= "#ff5555"
navigator.addEventListener("click",e=>{
if(!seeResult){
mobileResult.style.transform = "translateY(-100%)";
seeResult = !seeResult;
}else{
mobileResult.style.transform = "translateY(0%)";
seeResult = !seeResult;
}
})
const informate=(message)=>{
infoTool.innerText = message
info.style.transform = "translateY(0%)";
setTimeout(()=>{
info.style.transform = "translateY(-200%)"
},3000)
}
copyBtn.addEventListener("click",e=>{ //COPY DOESNT WORK TO BE SOLVED !
// currentShadow.setSelectionRange(0,500,"forward");
// document.execCommand("copy",true,currentShadow);
informate("Copied to clipboard successfully !");
})
const changeProps=(check)=>{
requestAnimationFrame(changeProps);
if(ci.checked){
box.style.borderRadius = "50%";
}else{
box.style.borderRadius = "0";
}
xval = x.value;
yval = y.value;
zval = z.value;
wval = w.value;
if(xval ==''){
xval=0
}
if(yval ==''){
yval=0
}
if(zval ==''){
zval=0
}
if(wval ==''){
wval=0
}
currentShadow =xval+ "px " + yval + "px " + zval + "px " + wval + "px "+ shadowCol.value;
box.style.boxShadow= currentShadow;
box.style.background = boxCol.value;
bg.style.background = bgCol.value;
textA.value = currentShadow;
};changeProps();
const darkTheme= document.styleSheets[1];
const lightTheme= document.styleSheets[0];
console.log(lightTheme);
let themeSetter=(firstTime =false)=>{
var time = new Date();
time = time.getUTCHours();
if(firstTime){
if((time >0 && time < 8)||(time > 18)){
theme = false;
}else{
theme= true;
}
}
console.log(time);
theme = !theme;
informate(theme?"Light" +" theme set !":"Dark" +" theme set !");
if(theme){
for(let i=0;i<2;i++){
themeCursor[i].style.transform= "translate(0%)"
}
darkTheme.disabled = true;
lightTheme.disabled = false;
}else{
for(let i=0;i<2;i++){
themeCursor[i].style.transform= "translate(-100%)"
}
darkTheme.disabled = false;
lightTheme.disabled = true;
}
};
themeButton.addEventListener("click",()=>{
themeSetter()
})
const init=()=>{
themeSetter(true);
};init();