-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcustom_functions.js
44 lines (37 loc) · 968 Bytes
/
custom_functions.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
function showHover(e){
x=e.offsetX;
y=e.offsetY;
if (cursorInCopyButton(x,y)) {
e.target.style.cssText += "--color: orange"
} else {
e.target.style.cssText += "--color: white"
}
}
function leaveElement(e){
e.target.style.cssText += "--color: white"
}
function clickCopy(e){
x=e.offsetX;
y=e.offsetY;
el = e.target;
if (cursorInCopyButton(x,y)) {
selectText = el.textContent;
navigator.clipboard
.writeText(selectText)
.then(() => {
el.style.cssText += "--color: #a6e22e"
setTimeout(function(){
el.style.cssText += "--color: white"
}, 500);
})
.catch((error) => {
alert(`Copy failed! ${error}`);
});
}
}
function cursorInCopyButton(x,y) {
if ((x >= 1087) && (x <= 1146) && (y >= 6) && (y <= 35)) {
return true
}
return false
}