$(function() { function display(bool) { if (bool) { $("body").show(); } else { $("body").hide(); } } function characterCreatorMenu(bool) { if (bool) { $("#characterCreator").fadeIn("slow"); $("#characterEditor, #exitGameMenu, #deleteCharacterMenu, #spawnLocation").hide(); return; } $("#characterCreator").fadeOut("slow"); } function characterEditorMenu(bool) { if (bool) { $("#characterEditor").fadeIn("slow"); $("#characterCreator, #exitGameMenu, #deleteCharacterMenu, #spawnLocation").hide(); return; } $("#characterEditor").fadeOut("slow"); } function exitGameMenu(bool) { if (bool) { $("#exitGameMenu").fadeIn("slow"); $("#characterCreator, #characterEditor, #deleteCharacterMenu, #spawnLocation").hide(); return; } $("#exitGameMenu").fadeOut("slow"); } function confirmDeleteMenu(bool) { if (bool) { $("#deleteCharacterMenu").fadeIn("slow"); $("#characterCreator, #characterEditor, #exitGameMenu, #spawnLocation").hide(); return; } $("#deleteCharacterMenu").fadeOut("slow"); } function spawnMenu(bool) { if (bool) { $("#spawnLocation").fadeIn("slow"); $("#characterCreator, #characterEditor, #exitGameMenu, #deleteCharacterMenu").hide(); return; } $("#spawnLocation").fadeOut("slow"); } window.addEventListener("message", function(event) { const item = event.data; if (item.type === "ui") { if (item.status) { $("#serverName").text(item.serverName); $("body").css("background-image", "url(" + item.background + ")"); display(true); } else { display(false); } } $("#playerAmount").text(item.characterAmount); if (item.type === "setSpawns") { $("#spawnMenuContainer").empty(); setTimeout(function(){ $("#tpDoNot").data("id", item.id); JSON.parse(item.spawns).forEach((location) => { $("#spawnMenuContainer").append(``); }); $(".spawnButtons").click(function() { $.post(`https://${GetParentResourceName()}/tpToLocation`, JSON.stringify({ x: $(this).data("x"), y: $(this).data("y"), z: $(this).data("z") })); spawnMenu(false); setTimeout(function(){ $("#spawnMenuContainer").empty(); }, 550); return; }); $("#tpDoNot").click(function() { $.post(`https://${GetParentResourceName()}/tpDoNot`, JSON.stringify({ id: $("#tpDoNot").data("id") })); spawnMenu(false) setTimeout(function(){ $("#spawnMenuContainer").empty(); }, 550); return; }); }, 10); } if (item.type === "givePerms") { JSON.parse(item.deptRoles).forEach((dept) => { $(".departments").append($("