-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
63 lines (55 loc) · 1.79 KB
/
script.js
File metadata and controls
63 lines (55 loc) · 1.79 KB
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
document.addEventListener("DOMContentLoaded", () => {
fetch("/header.html")
.then(response => response.text())
.then(html => {
document.getElementById("header").innerHTML = html;
});
});
function hash(string) {
const utf8 = new TextEncoder().encode(string);
return crypto.subtle.digest('SHA-256', utf8).then((hashBuffer) => {
const hashArray = Array.from(new Uint8Array(hashBuffer));
const hashHex = hashArray
.map((bytes) => bytes.toString(16).padStart(2, '0'))
.join('');
return hashHex;
});
}
function Encode() {
let toEncode = document.getElementById("toEncode").value;
let encoded = window.btoa(toEncode);
let output = `Encoded: ${encoded}`
document.getElementById("encoded").innerHTML = output;
}
function Decode() {
let toDecode = document.getElementById("toDecode").value;
let output = document.getElementById("decoded").innerHTML;
let decoded = window.atob(toDecode);
output = `Decoded: ${decoded}`
}
var coll = document.getElementsByClassName("collapsible");
var i;
for (i = 0; i < coll.length; i++) {
coll[i].addEventListener("click", function() {
this.classList.toggle("active");
var content = this.nextElementSibling;
if (content.style.display === "block") {
content.style.display = "none";
} else {
content.style.display = "block";
}
});
}
var xhr = new XMLHttpRequest(); {
xhr.open("POST", "main.py", true);
xhr.setRequestHeader("Content-Type", "application/json");
xhr.send(JSON.stringify(data));
}
// Get the modal
var modal = document.getElementById('id01');
// When the user clicks anywhere outside of the modal, close it
window.onclick = function(event) {
if (event.target == modal) {
modal.style.display = "none";
}
}