-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.html
84 lines (77 loc) · 2.8 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ASCII Table</title>
<link rel="stylesheet" href="./css/style.css">
</head>
<body>
<div class="main">
<div class="head">
<h1>ASCII Table</h1>
<label class="switch">
<input type="checkbox">
<span class="slider round toggle b3"></span>
</label>
</div>
<div class="wrapper"></div>
<div class="footer" style="text-align: center; margin-bottom: 20px;">
<img class="b1" src=" https://img.shields.io/badge/Made%20With-JavaScript-yellow?style=for-the-badge&logo=javascript"
alt="js-badge">
<a href="https://github.com/jvnaveenbabu">
<img class="b2" src="https://img.shields.io/badge/On%20Github-jvnaveenbabu-orange?style=for-the-badge&logo=github"
alt="gh-badge" style="margin-left: 1rem;" />
</a>
</div>
</div>
<script>
let content = "";
for (let i = 33; i < 127; i++) {
content += `
<div class="box">
<h1>${String.fromCharCode(i)}</h1>
<div>
<h4>Hex</h4>
<p class="value" onclick="copyHex(${i});">${i.toString(16)}</p>
</div>
<div>
<h4>Octal</h4>
<p class="value" onclick="copy(${i.toString(8)});">${i.toString(8)}</p>
</div>
<div>
<h4>Bin</h4>
<p class="value" onclick="copy(${i.toString(2)});">${i.toString(2)}</p>
</div>
</div>
`;
}
document.querySelector(".wrapper").innerHTML = content;
function copy(a){
copyToClipboard(a);
}
function copyHex(a){
a = a.toString(16);
copyToClipboard(a);
}
function copyToClipboard(text) {
var dummy = document.createElement("textarea");
document.body.appendChild(dummy);
dummy.value = text;
dummy.select();
document.execCommand("copy");
document.body.removeChild(dummy);
}
let toggle = document.querySelector('.toggle');
let badge1 = document.querySelector('.b1');
let badge2 = document.querySelector('.b2');
let badge3 = document.querySelector('.b3');
toggle.addEventListener('click', () => {
document.documentElement.classList.toggle('dark-mode');
badge1.classList.toggle('dark-mode-img');
badge2.classList.toggle('dark-mode-img');
badge3.classList.toggle('dark-mode-img');
});
</script>
</body>
</html>