-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdecode.js
More file actions
57 lines (56 loc) · 1.51 KB
/
decode.js
File metadata and controls
57 lines (56 loc) · 1.51 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
out = document.getElementById("output")
function getkey(object, value) {
return Object.keys(object).find(key => object[key] === value);
}
function isLetter(str) {
for (z of str.toString().split("")){
if ("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".split("").includes(z) === false){
return false
}
}
return true
}
document.getElementById("input").onkeyup = function(){
function create_err(text){
out.value = text
out.value += "\n\n"+document.getElementById("input").value+"\n"+errorpointer
}
out.value = ""
errorpointer = "^"
text = document.getElementById("input").value.trim().split(' ')
for (j of text){
if (j === "+"){
out.value += " "
}else if (isLetter(j)){
if (j.length !== 1){
create_err("ERROR. You can. only have one letter in a block")
break
}
out.value += j
}else if (Number(j)){
if (Number(j) < 1 || Number(j) > 119){
create_err("ERROR. There is no such element with the atomic number of \""+j+"\"")
break
}if (Number(j) % 1 !== 0){
create_err("ERROR. That is not a number")
break
}
out.value += getkey(symbols, Number(j))
}else if (j.match(/(a[1-26])/)){
out.value += ("ABCDEFGHIJKLMNOPQRSTUVWXYZ".split("")[Number(j.substring(1)) - 1])
}
else{
out.value += ""
}
for (let k = 0;k<=j.length;k++){
errorpointer = "-"+errorpointer
}
}
}
window.addEventListener('message', e => {
if (e.data.type == 'disable links'){
document.querySelectorAll("a").forEach(e=>{
e.setAttribute("href", "javascript:void(0)")
})
}
});