From 2ce26f8cb8acb2820de136b5fc8a1631dab61002 Mon Sep 17 00:00:00 2001
From: Andyyy7666 <86536434+Andyyy7666@users.noreply.github.com>
Date: Thu, 21 Jul 2022 22:52:05 +0200
Subject: [PATCH] Fixed bugs
* fixed the issue where an edited character wouldn't update in the editing menu.
* fixed amount of characters displaying correctly.
* improved some old code.
---
ND_CharacterSelection/source/ui/script.js | 62 ++++-------------------
1 file changed, 9 insertions(+), 53 deletions(-)
diff --git a/ND_CharacterSelection/source/ui/script.js b/ND_CharacterSelection/source/ui/script.js
index 150d20d..bb78e56 100644
--- a/ND_CharacterSelection/source/ui/script.js
+++ b/ND_CharacterSelection/source/ui/script.js
@@ -1,14 +1,8 @@
$(function() {
- let displayOn = true
-
- // Hide/show ui function
function display(bool) {
if (bool) {
- displayOn = true;
$("body").show();
- Money(false)
} else {
- displayOn = false;
$("body").hide();
}
}
@@ -52,32 +46,12 @@ $(function() {
}
$("#spawnLocation").fadeOut("slow");
}
- function Money(bool) {
- if (bool) {
- $("#money").show();
- $("body").css("background-image", "none");
- $("body").show();
- if (displayOn === false) {
- $("#overlay").hide();
- }
- } else {
- $("#money").hide();
- $("#overlay").show();
- }
- }
- display(false);
- characterCreatorMenu(false);
- characterEditorMenu(false);
- exitGameMenu(false);
- confirmDeleteMenu(false);
- spawnMenu(false);
- Money(false);
- window.addEventListener('message', function(event) {
+ window.addEventListener("message", function(event) {
const item = event.data;
if (item.type === "ui") {
if (item.status) {
- $('#serverName').text(item.serverName);
+ $("#serverName").text(item.serverName);
$("body").css("background-image", "url(" + item.background + ")");
display(true);
} else {
@@ -85,12 +59,7 @@ $(function() {
}
}
- $('#playerAmount').text(item.characterAmount);
-
- if (item.type === "character") {
- characterCreatorMenu(false);
- createCharacter(item.firstName, item.lastName, item.dateOfBirth, item.gender, item.twtName, item.department, item.startingCash, item.startingBank, item.id);
- }
+ $("#playerAmount").text(item.characterAmount);
if (item.type === "setSpawns") {
$("#spawnMenuContainer").empty();
@@ -113,7 +82,7 @@ $(function() {
if (item.type === "givePerms") {
JSON.parse(item.deptRoles).forEach((dept) => {
- $('.departments').append($('