-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
61 lines (52 loc) · 2.04 KB
/
index.html
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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<link rel="stylesheet" type="text/css" href="index.css" />
<title>CS:GO Crosshairs</title>
</head>
<body>
<h1>CS:GO crosshairs</h1>
<h2>Click on image to copy code</h2>
<div id="main-container" class="crosshairs-container"></div>
<script src="crosshair_codes.js"></script>
<script>
let lastCopiedId = -1;
const onImageClick = id => {
if (lastCopiedId > -1 && lastCopiedId <= crosshairs.length) {
document.getElementById(`copy-hint${lastCopiedId}`).style.opacity = 0;
document.getElementById(`img${lastCopiedId}`).style.opacity = 1;
}
document.getElementById(`copy-hint${id}`).style.opacity = 1;
document.getElementById(`img${id}`).style.opacity = 0.3;
navigator.clipboard.writeText(crosshairs[id - 1]);
lastCopiedId = id;
};
const createCrosshairInfo = id => {
infoDiv = document.createElement('div');
infoDiv.id = `crosshair${id}`;
infoDiv.className = 'crosshair-info';
infoDiv.onclick = () => onImageClick(id);
image = document.createElement('img');
image.id = `img${id}`;
image.src = `img/${id}.jpg`;
image.width = 128;
copyHint = document.createElement('div');
copyHint.id = `copy-hint${id}`;
copyHint.className = 'copy-text';
copyHint.innerHTML = 'Copied!';
copyHint.style.color = 'green';
infoDiv.appendChild(document.createElement('span'));
infoDiv.appendChild(document.createElement('span'));
infoDiv.appendChild(document.createElement('span'));
infoDiv.appendChild(document.createElement('span'));
infoDiv.appendChild(image);
infoDiv.appendChild(copyHint);
return infoDiv;
};
for (let i = 1; i < crosshairs.length + 1; i++) {
document.getElementById('main-container').appendChild(createCrosshairInfo(i));
}
</script>
</body>
</html>