From eb71794f385f6e9a02af3f945437f5d86b5fffb7 Mon Sep 17 00:00:00 2001 From: "jakub.salavec" Date: Mon, 16 Jun 2025 13:23:52 +0200 Subject: [PATCH] Refactor - fixed indents in hall js file --- .../src/main/web/js/gemp-022/hallUi.js | 413 +++++++++--------- 1 file changed, 204 insertions(+), 209 deletions(-) diff --git a/gemp-lotr/gemp-lotr-async/src/main/web/js/gemp-022/hallUi.js b/gemp-lotr/gemp-lotr-async/src/main/web/js/gemp-022/hallUi.js index 61e177b21..05a86ebcc 100644 --- a/gemp-lotr/gemp-lotr-async/src/main/web/js/gemp-022/hallUi.js +++ b/gemp-lotr/gemp-lotr-async/src/main/web/js/gemp-022/hallUi.js @@ -58,17 +58,17 @@ var GempLotrHallUI = Class.extend({ this.chat = chat; this.chat.tournamentCallback = function(from, message) { - var thisName = that.userInfo.name + var thisName = that.userInfo.name if (from == "TournamentSystem" && that.inTournament) { that.showDialog("Tournament Update", message, 320); } else if (from.startsWith("TournamentSystemTo:")) { - // Extract and split the user list - let users = from.split(":")[1].split(";"); + // Extract and split the user list + let users = from.split(":")[1].split(";"); - // Check if thisName is in the list - if (users.includes(thisName)) { - that.showDialog("Tournament Update", message, 320); - } + // Check if thisName is in the list + if (users.includes(thisName)) { + that.showDialog("Tournament Update", message, 320); + } } }; @@ -826,57 +826,57 @@ var GempLotrHallUI = Class.extend({ })(queue)); actionsField.append(but); - if (queue.getAttribute("startable") == "true") { - var startBut = $(""); - $(startBut).button().click(( - function(queueInfo) { - return function() { - var queueId = queueInfo.getAttribute("id"); - that.comm.startQueue(queueId, function (xml) { - var result = that.processResponse(xml); - }); - } - })(queue)); - actionsField.append(startBut); - } + if (queue.getAttribute("startable") == "true") { + var startBut = $(""); + $(startBut).button().click(( + function(queueInfo) { + return function() { + var queueId = queueInfo.getAttribute("id"); + that.comm.startQueue(queueId, function (xml) { + var result = that.processResponse(xml); + }); + } + })(queue)); + actionsField.append(startBut); + } - if (+queue.getAttribute("readyCheckSecsRemaining") > -1) { - if ($("button:contains('READY CHECK')").length === 0 && queue.getAttribute("confirmedReadyCheck") == "false") { - that.showDialog("Ready Check", "Ready Check started for the " + queue.getAttribute("queue") - + " tournament.

To confirm you are present, click the Ready Check button within next " - + queue.getAttribute("readyCheckSecsRemaining") + " seconds.", 230); - } - var checkBut = $(""); - $(checkBut).button().click(( - function(queueInfo) { - return function() { - var queueId = queueInfo.getAttribute("id"); - that.comm.confirmReadyCheckQueue(queueId, function (xml) { - var result = that.processResponse(xml); - }); - } - })(queue)); - actionsField.append(checkBut); - if (queue.getAttribute("confirmedReadyCheck") == "true") { - $(checkBut).prop("disabled", true).text("Waiting for others - " + queue.getAttribute("readyCheckSecsRemaining") + " s"); - } - } + if (+queue.getAttribute("readyCheckSecsRemaining") > -1) { + if ($("button:contains('READY CHECK')").length === 0 && queue.getAttribute("confirmedReadyCheck") == "false") { + that.showDialog("Ready Check", "Ready Check started for the " + queue.getAttribute("queue") + + " tournament.

To confirm you are present, click the Ready Check button within next " + + queue.getAttribute("readyCheckSecsRemaining") + " seconds.", 230); + } + var checkBut = $(""); + $(checkBut).button().click(( + function(queueInfo) { + return function() { + var queueId = queueInfo.getAttribute("id"); + that.comm.confirmReadyCheckQueue(queueId, function (xml) { + var result = that.processResponse(xml); + }); + } + })(queue)); + actionsField.append(checkBut); + if (queue.getAttribute("confirmedReadyCheck") == "true") { + $(checkBut).prop("disabled", true).text("Waiting for others - " + queue.getAttribute("readyCheckSecsRemaining") + " s"); + } + } + } + var type = queue.getAttribute("type"); + if(type !== null) + type = type.toLowerCase(); + if(type === "sealed") { + type = "Sealed"; + } + else if (type === "solodraft") { + type = "Solo Draft"; + } + else if (type === "table_solodraft") { + type = "Solo Table Draft"; + } + else if (type === "table_draft") { + type = "Table Draft"; } - var type = queue.getAttribute("type"); - if(type !== null) - type = type.toLowerCase(); - if(type === "sealed") { - type = "Sealed"; - } - else if (type === "solodraft") { - type = "Solo Draft"; - } - else if (type === "table_solodraft") { - type = "Solo Table Draft"; - } - else if (type === "table_draft") { - type = "Table Draft"; - } var rowstr = "" + queue.getAttribute("format") + ""; var startTd = "" + queue.getAttribute("start") + ""; @@ -891,10 +891,10 @@ var GempLotrHallUI = Class.extend({ ""; } else if (type.includes("Sealed") || type.includes("Draft")) { // No prizes and cost displayed for limited games - rowstr += "" + type + ""; + rowstr += "" + type + ""; rowstr += "" + startTd + @@ -916,25 +916,25 @@ var GempLotrHallUI = Class.extend({ row.append(actionsField); // Row for tournament queue waiting table - var tablesRow = $(""); - tablesRow.append("" + queue.getAttribute("format") + ""); - let htmlTd = " "; - if (isWC) { - htmlTd += "WC"; - } else { - htmlTd += "Tournament" - } - htmlTd += " - " + type + " -
"; - tablesRow.append(htmlTd); - tablesRow.append("" + queue.getAttribute("start") + ""); - tablesRow.append("" + queue.getAttribute("playerList") + ""); - var actionsFieldClone = actionsField.clone(true); - tablesRow.append(actionsFieldClone); - if (joined == "true") + var tablesRow = $(""); + tablesRow.append("" + queue.getAttribute("format") + ""); + let htmlTd = " "; + if (isWC) { + htmlTd += "WC"; + } else { + htmlTd += "Tournament" + } + htmlTd += " - " + type + " -
"; + tablesRow.append(htmlTd); + tablesRow.append("" + queue.getAttribute("start") + ""); + tablesRow.append("" + queue.getAttribute("playerList") + ""); + var actionsFieldClone = actionsField.clone(true); + tablesRow.append(actionsFieldClone); + if (joined == "true") tablesRow.addClass("played"); if (action == "add") { @@ -942,45 +942,44 @@ var GempLotrHallUI = Class.extend({ $("table.wc-queues", this.tablesDiv) .append(row); } else if (type.includes("Sealed")) { - $("table.sealedQueues", this.tablesDiv) - .append(row); - } else if (type.includes("Draft")) { + $("table.sealedQueues", this.tablesDiv) + .append(row); + } else if (type.includes("Draft")) { $("table.draftQueues", this.tablesDiv) .append(row); } else { $("table.queues", this.tablesDiv) .append(row); } - // Display queues with waiting players also as waiting tables - if (queue.getAttribute("playerCount") != 0 || isWC) { - $("table.waitingTables", this.tablesDiv) - .append(tablesRow); - } + // Display queues with waiting players also as waiting tables + if (queue.getAttribute("playerCount") != 0 || isWC) { + $("table.waitingTables", this.tablesDiv) + .append(tablesRow); + } } else if (action == "update") { $(".queue" + id, this.tablesDiv).replaceWith(row); - // Display queues with waiting players also as waiting tables - if (queue.getAttribute("playerCount") != 0) { - var existingRow = $(".table" + id, this.tablesDiv); - if (existingRow.length > 0) { - // If the row exists, replace it - existingRow.replaceWith(tablesRow); - } else { - // If the row does not exist, append it - $("table.waitingTables", this.tablesDiv).append(tablesRow); - } - } else if (queue.getAttribute("playerCount") == 0) { - // Remove tournaments displayed as tables - $(".table" + id, this.tablesDiv).remove(); - } + // Display queues with waiting players also as waiting tables + if (queue.getAttribute("playerCount") != 0) { + var existingRow = $(".table" + id, this.tablesDiv); + if (existingRow.length > 0) { + // If the row exists, replace it + existingRow.replaceWith(tablesRow); + } else { + // If the row does not exist, append it + $("table.waitingTables", this.tablesDiv).append(tablesRow); + } + } else if (queue.getAttribute("playerCount") == 0) { + // Remove tournaments displayed as tables + $(".table" + id, this.tablesDiv).remove(); + } } this.animateRowUpdate(".queue" + id); } else if (action == "remove") { - $(".queue" + id, this.tablesDiv).remove(); - // Remove tournaments displayed as tables - $(".table" + id, this.tablesDiv).remove(); - + $(".queue" + id, this.tablesDiv).remove(); + // Remove tournaments displayed as tables + $(".table" + id, this.tablesDiv).remove(); } } @@ -1013,55 +1012,52 @@ var GempLotrHallUI = Class.extend({ that.inTournament = true; debugger; if(type === "solodraft" && (stage === "deck-building" || stage === "registering decks" || stage === "awaiting kickoff")) { - var but = $(""); - $(but).button().click(( - function(tourneyInfo) { - var tourneyId = tournament.getAttribute("id"); - - return function() { - var win = window.open("/gemp-lotr/soloDraft.html?eventId=" + tourneyId, '_blank'); - if (win) { - //Browser has allowed it to be opened - win.focus(); - } - } + var but = $(""); + $(but).button().click(( + function(tourneyInfo) { + var tourneyId = tournament.getAttribute("id"); + return function() { + var win = window.open("/gemp-lotr/soloDraft.html?eventId=" + tourneyId, '_blank'); + if (win) { + //Browser has allowed it to be opened + win.focus(); + } } - )(tournament)); - actionsField.append(but); + } + )(tournament)); + actionsField.append(but); } if(type === "table_solodraft" && (stage === "deck-building" || stage === "registering decks" || stage === "awaiting kickoff")) { - var but = $(""); - $(but).button().click(( - function(tourneyInfo) { - var tourneyId = tournament.getAttribute("id"); - - return function() { - var win = window.open("/gemp-lotr/tableDraft.html?eventId=" + tourneyId, '_blank'); - if (win) { - //Browser has allowed it to be opened - win.focus(); - } - } + var but = $(""); + $(but).button().click(( + function(tourneyInfo) { + var tourneyId = tournament.getAttribute("id"); + return function() { + var win = window.open("/gemp-lotr/tableDraft.html?eventId=" + tourneyId, '_blank'); + if (win) { + //Browser has allowed it to be opened + win.focus(); + } } - )(tournament)); - actionsField.append(but); + } + )(tournament)); + actionsField.append(but); } if(type === "table_draft" && stage === "drafting") { - var but = $(""); - $(but).button().click(( - function(tourneyInfo) { - var tourneyId = tournament.getAttribute("id"); - - return function() { - var win = window.open("/gemp-lotr/tableDraft.html?eventId=" + tourneyId, '_blank'); - if (win) { - //Browser has allowed it to be opened - win.focus(); - } - } + var but = $(""); + $(but).button().click(( + function(tourneyInfo) { + var tourneyId = tournament.getAttribute("id"); + return function() { + var win = window.open("/gemp-lotr/tableDraft.html?eventId=" + tourneyId, '_blank'); + if (win) { + //Browser has allowed it to be opened + win.focus(); + } } - )(tournament)); - actionsField.append(but); + } + )(tournament)); + actionsField.append(but); } if((type === "sealed" || type === "solodraft" || type === "table_solodraft" || type === "table_draft") && (stage === "deck-building" || stage === "registering decks" || stage === "awaiting kickoff" || stage === "paused between rounds")) { var but = $(""); @@ -1134,7 +1130,7 @@ var GempLotrHallUI = Class.extend({ } else if (type === "table_solodraft") { rowstr += "Solo Table Draft"; - } + } else if (type === "table_draft") { rowstr += "Table Draft"; } @@ -1143,44 +1139,43 @@ var GempLotrHallUI = Class.extend({ } } rowstr += "" + tournament.getAttribute("name") + "" + - "" + tournament.getAttribute("system") + ""; - if (tournament.hasAttribute("timeRemaining")) { - rowstr += "" + tournament.getAttribute("stage") + " - " + tournament.getAttribute("timeRemaining") + ""; - } else { - rowstr += "" + tournament.getAttribute("stage") + ""; - } - rowstr += "" + tournament.getAttribute("round") + "" + - "
" + tournament.getAttribute("playerCount") + "
"; + "" + tournament.getAttribute("system") + ""; + if (tournament.hasAttribute("timeRemaining")) { + rowstr += "" + tournament.getAttribute("stage") + " - " + tournament.getAttribute("timeRemaining") + ""; + } else { + rowstr += "" + tournament.getAttribute("stage") + ""; + } + rowstr += "" + tournament.getAttribute("round") + "" + + "
" + tournament.getAttribute("playerCount") + "
"; var row = $(rowstr); row.append(actionsField); - - // Row for tournament playing table - var displayType = type; - if(type === "sealed") { - displayType = "Sealed"; - } - else if (type === "solodraft") { - displayType = "Solo Draft"; - } - else if (type === "table_solodraft") { - displayType = "Solo Table Draft"; - } - else if (type === "table_draft") { - displayType = "Table Draft"; - } - var tablesRow = $(""); - tablesRow.append("" + tournament.getAttribute("format") + ""); - tablesRow.append(" Tournament - " + displayType + " - " + tournament.getAttribute("name") + ""); - if (tournament.hasAttribute("timeRemaining")) { - tablesRow.append("" + tournament.getAttribute("stage") + " - " + tournament.getAttribute("timeRemaining") + ""); - } else { - tablesRow.append("" + tournament.getAttribute("stage") + ""); - } - tablesRow.append("" + tournament.getAttribute("playerList") + ""); - var actionsFieldClone = actionsField.clone(true); - tablesRow.append(actionsFieldClone); + // Row for tournament playing table + var displayType = type; + if(type === "sealed") { + displayType = "Sealed"; + } + else if (type === "solodraft") { + displayType = "Solo Draft"; + } + else if (type === "table_solodraft") { + displayType = "Solo Table Draft"; + } + else if (type === "table_draft") { + displayType = "Table Draft"; + } + var tablesRow = $(""); + tablesRow.append("" + tournament.getAttribute("format") + ""); + tablesRow.append(" Tournament - " + displayType + " - " + tournament.getAttribute("name") + ""); + if (tournament.hasAttribute("timeRemaining")) { + tablesRow.append("" + tournament.getAttribute("stage") + " - " + tournament.getAttribute("timeRemaining") + ""); + } else { + tablesRow.append("" + tournament.getAttribute("stage") + ""); + } + tablesRow.append("" + tournament.getAttribute("playerList") + ""); + var actionsFieldClone = actionsField.clone(true); + tablesRow.append(actionsFieldClone); if (joined == "true") tablesRow.addClass("played"); // red highlight @@ -1192,43 +1187,43 @@ var GempLotrHallUI = Class.extend({ $("table.tournaments", this.tablesDiv) .append(row); } - // Display running tournaments also as playing tables - $("table.playingTables", this.tablesDiv) - .append(tablesRow) + // Display running tournaments also as playing tables + $("table.playingTables", this.tablesDiv) + .append(tablesRow) - if (joined == "true") { - // Open draft window - if ((type === "table_solodraft" && (stage === "deck-building" || stage === "registering decks" || stage === "awaiting kickoff")) - || (type === "table_draft" && stage === "drafting")) { - var tourneyId = tournament.getAttribute("id"); - window.open("/gemp-lotr/tableDraft.html?eventId=" + tourneyId, '_blank'); - this.PlaySound("gamestart"); - } else if (type === "solodraft" && (stage === "deck-building" || stage === "registering decks" || stage === "awaiting kickoff")) { - var tourneyId = tournament.getAttribute("id"); - window.open("/gemp-lotr/soloDraft.html?eventId=" + tourneyId, '_blank'); - this.PlaySound("gamestart"); - } - } + if (joined == "true") { + // Open draft window + if ((type === "table_solodraft" && (stage === "deck-building" || stage === "registering decks" || stage === "awaiting kickoff")) + || (type === "table_draft" && stage === "drafting")) { + var tourneyId = tournament.getAttribute("id"); + window.open("/gemp-lotr/tableDraft.html?eventId=" + tourneyId, '_blank'); + this.PlaySound("gamestart"); + } else if (type === "solodraft" && (stage === "deck-building" || stage === "registering decks" || stage === "awaiting kickoff")) { + var tourneyId = tournament.getAttribute("id"); + window.open("/gemp-lotr/soloDraft.html?eventId=" + tourneyId, '_blank'); + this.PlaySound("gamestart"); + } + } } else if (action == "update") { - $(".tournament" + id, this.tablesDiv).replaceWith(row); + $(".tournament" + id, this.tablesDiv).replaceWith(row); - // Display tournaments also as playing tables - var existingRow = $(".table" + id, this.tablesDiv); - if (existingRow.length > 0) { - // If the row exists, replace it - existingRow.replaceWith(tablesRow); - } else { - // If the row does not exist, append it - $("table.playingTables", this.tablesDiv).append(tablesRow); - } + // Display tournaments also as playing tables + var existingRow = $(".table" + id, this.tablesDiv); + if (existingRow.length > 0) { + // If the row exists, replace it + existingRow.replaceWith(tablesRow); + } else { + // If the row does not exist, append it + $("table.playingTables", this.tablesDiv).append(tablesRow); + } } this.animateRowUpdate(".tournament" + id); } else if (action == "remove") { - $(".tournament" + id, this.tablesDiv).remove(); - // Remove tournaments displayed as tables - $(".table" + id, this.tablesDiv).remove(); + $(".tournament" + id, this.tablesDiv).remove(); + // Remove tournaments displayed as tables + $(".table" + id, this.tablesDiv).remove(); } }