-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
86 lines (82 loc) · 1.7 KB
/
script.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
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
85
86
function convertir() {
try {
var json = JSON.parse(document.getElementById("input").value);
} catch (error) {
new Toast({
message: "Invalid JSON! 🤨",
type: "danger",
});
return
}
var styledText = "/itemname ";
for (itemN in json) {
var convWord = "";
var item = json[itemN];
var text = item.text;
var color = item.color;
if (text === "") {
continue;
}
if (color) {
if (color.startsWith("#")) {
convWord += "{" + color + "}";
} else {
convWord += getColor(color);
}
}else{
convWord += "&r"
}
if (item.bold) {
convWord += "&l";
}
if (item.italic) {
convWord += "&o";
}
if (item.underlined) {
convWord += "&n";
}
convWord += text;
styledText += convWord;
}
document.getElementById("commandOutput").value = styledText;
document.getElementById("input").value = "";
document.getElementById("input").focus();
copyTextToClipboard(styledText);
}
function getColor(color) {
switch (color) {
case "yellow":
return "&e";
case "gold":
return "&6";
case "red":
return "&c";
case "dark_red":
return "&4";
case "light_purple":
return "&d";
case "dark_purple":
return "&5";
case "blue":
return "&9";
case "dark_blue":
return "&1";
case "dark_aqua":
return "&3";
case "aqua":
return "&b";
case "dark_green":
return "&2";
case "green":
return "&a";
case "dark_gray":
return "&8";
case "gray":
return "&7";
case "black":
return "&0";
case "white":
return "&f";
}
}
document.getElementById("input").focus();