Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
149 changes: 78 additions & 71 deletions profile-viewer/calculate.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,81 +136,88 @@ async function getStats(username, key, uuid, uuidjson, profilenum, profilejson)
}

function write_slot(slot) {
if (slot.tag) {
let display = "";
let line = "";
let stylecodes = {
"§0": "color: #000000",
"§1": "color: #0000aa",
"§2": "color: #00aa00",
"§3": "color: #00aaaa",
"§4": "color: #aa0000",
"§5": "color: #aa00aa",
"§6": "color: #ffaa00",
"§7": "color: #aaaaaa",
"§8": "color: #555555",
"§9": "color: #5555ff",
"§a": "color: #55ff55",
"§b": "color: #55ffff",
"§c": "color: #ff5555",
"§d": "color: #ff55ff",
"§e": "color: #ffff55",
"§f": "color: #ffffff",
"§l": "font-weight:bold"
}
display = display + format_line(slot.tag.display.Name, stylecodes);
display = display + format_line("", stylecodes);
for (let i = 0; i < slot.tag.display.Lore.length; i++) {
display = display + format_line(slot.tag.display.Lore[i], stylecodes);
}
document.getElementById("itemview").innerHTML = display;
}
if (slot.tag) {
let display = "";
let line = "";
let stylecodes = {
"§0": "color: #000000",
"§1": "color: #0000aa",
"§2": "color: #00aa00",
"§3": "color: #00aaaa",
"§4": "color: #aa0000",
"§5": "color: #aa00aa",
"§6": "color: #ffaa00",
"§7": "color: #aaaaaa",
"§8": "color: #555555",
"§9": "color: #5555ff",
"§a": "color: #55ff55",
"§b": "color: #55ffff",
"§c": "color: #ff5555",
"§d": "color: #ff55ff",
"§e": "color: #ffff55",
"§f": "color: #ffffff",
"§l": "font-weight:bold",
"§m": "text-decoration: line-through",
"§n": "text-decoration: underline",
"§o": "font-style: italic;",
}
display = display + format_line(slot.tag.display.Name, stylecodes);
display = display + format_line("", stylecodes);
for (let i = 0; i < slot.tag.display.Lore.length; i++) {
display = display + format_line(slot.tag.display.Lore[i], stylecodes);
}
document.getElementById("itemview").innerHTML = display;
}
}

function format_line(line, stylecodes) {
let display_line = "<span class=\"loreline\">";
let where = line.search("§");
let style;
let styles = {};
let close = false;
let lineadd = false;
let y;
while (where != -1) {
y = 1;
styles = {};
while (stylecodes[line.slice(where+(2*(y-1)), where+(2*y))] != undefined) {
if (!(line.slice(where+(2*(y-1)), where+(2*y)) in styles)) {
let newstyle = line.slice(where+(2*(y-1)), where+(2*y))
styles[newstyle] = 1;
}
y = y + 1;
}
line = line.replaceAll('§k','');
line = line.replaceAll('§r','');
line = line.replaceAll('§L','');
let display_line = "<span class=\"loreline\">";
let where = line.search("§");
let style;
let styles = {};
let close = false;
let lineadd = false;
let y;
while (where != -1) {
y = 1;
styles = {};
while (stylecodes[line.slice(where+(2*(y-1)), where+(2*y))] != undefined) {
if (!(line.slice(where+(2*(y-1)), where+(2*y)) in styles)) {
let newstyle = line.slice(where+(2*(y-1)), where+(2*y))
styles[newstyle] = 1;
}
y = y + 1;
}

if (close == true) {
display_line = display_line + line.slice(0, where) + "</span>";
} else {
close = true;
}

if (close == true) {
display_line = display_line + line.slice(0, where) + "</span>";
} else {
close = true;
}

let styles_string = "";
for (const property in styles) {
styles_string = styles_string + stylecodes[`${property}`] + "; ";
}
if (styles_string != "") {
display_line = display_line + "<span style=\"" + styles_string + "\">"
} else {
display_line = display_line + "<span>"
}

line = line.slice(where + (2*(y-1)));
where = line.search("§");
lineadd = true;
}
if (lineadd == true) {
display_line = display_line + line + "</span>";
}
display_line = display_line + "</span>\n";
return display_line;
let styles_string = "";
for (const property in styles) {
styles_string = styles_string + stylecodes[`${property}`] + "; ";
}
if (styles_string != "") {
display_line = display_line + "<span style=\"" + styles_string + "\">"
} else {
display_line = display_line + "<span>"
}

line = line.slice(where + (2*(y-1)));
where = line.search("§");
lineadd = true;
}

if (lineadd == true) {
display_line = display_line + line + "</span>";
}
display_line = display_line + "</span>\n";
return display_line;
}

document.documentElement.addEventListener("mousemove", e => {
Expand Down