diff --git a/profile-viewer/calculate.js b/profile-viewer/calculate.js index df1cd36..9f31679 100644 --- a/profile-viewer/calculate.js +++ b/profile-viewer/calculate.js @@ -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 = ""; - 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 = ""; + 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) + ""; + } else { + close = true; + } - if (close == true) { - display_line = display_line + line.slice(0, where) + ""; - } else { - close = true; - } - - let styles_string = ""; - for (const property in styles) { - styles_string = styles_string + stylecodes[`${property}`] + "; "; - } - if (styles_string != "") { - display_line = display_line + "" - } else { - display_line = display_line + "" - } - - line = line.slice(where + (2*(y-1))); - where = line.search("§"); - lineadd = true; - } - if (lineadd == true) { - display_line = display_line + line + ""; - } - display_line = display_line + "\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 + "" + } else { + display_line = display_line + "" + } + + line = line.slice(where + (2*(y-1))); + where = line.search("§"); + lineadd = true; + } + + if (lineadd == true) { + display_line = display_line + line + ""; + } + display_line = display_line + "\n"; + return display_line; } document.documentElement.addEventListener("mousemove", e => {