diff --git a/gemp-lotr/gemp-lotr-web/src/main/webapp/js/gemp-014/hallUi.js b/gemp-lotr/gemp-lotr-web/src/main/webapp/js/gemp-014/hallUi.js index 2c65113a8..92db320c9 100644 --- a/gemp-lotr/gemp-lotr-web/src/main/webapp/js/gemp-014/hallUi.js +++ b/gemp-lotr/gemp-lotr-web/src/main/webapp/js/gemp-014/hallUi.js @@ -68,17 +68,17 @@ var GempLotrHallUI = Class.extend({ this.createTableButton = $(""); $(this.createTableButton).button().click( - function () { - that.supportedFormatsSelect.hide(); - that.decksSelect.hide(); - that.createTableButton.hide(); - var format = that.supportedFormatsSelect.val(); - var deck = that.decksSelect.val(); - if (deck != null) - that.comm.createTable(format, deck, function (xml) { - that.processResponse(xml); - }); - }); + function () { + that.supportedFormatsSelect.hide(); + that.decksSelect.hide(); + that.createTableButton.hide(); + var format = that.supportedFormatsSelect.val(); + var deck = that.decksSelect.val(); + if (deck != null) + that.comm.createTable(format, deck, function (xml) { + that.processResponse(xml); + }); + }); this.createTableButton.hide(); this.decksSelect = $(""); @@ -90,10 +90,10 @@ var GempLotrHallUI = Class.extend({ this.leaveTableButton = $(""); $(this.leaveTableButton).button().click( - function () { - that.leaveTableButton.hide(); - that.comm.leaveTable(); - }); + function () { + that.leaveTableButton.hide(); + that.comm.leaveTable(); + }); this.leaveTableButton.hide(); this.buttonsDiv.append(this.leaveTableButton); @@ -117,13 +117,13 @@ var GempLotrHallUI = Class.extend({ }); toggleContent.css({width: "13px", height: "15px"}); toggleContent.click( - function() { - if (toggleContent.button("option", "icons")["primary"] == "ui-icon-circlesmall-minus") - toggleContent.button("option", "icons", {primary: "ui-icon-circlesmall-plus"}); - else - toggleContent.button("option", "icons", {primary: "ui-icon-circlesmall-minus"}); - content.toggle("blind", {}, 200); - }); + function() { + if (toggleContent.button("option", "icons")["primary"] == "ui-icon-circlesmall-minus") + toggleContent.button("option", "icons", {primary: "ui-icon-circlesmall-plus"}); + else + toggleContent.button("option", "icons", {primary: "ui-icon-circlesmall-minus"}); + content.toggle("blind", {}, 200); + }); header.append(toggleContent); header.append(" Tournament queues"); header.append(" (0)"); @@ -149,13 +149,13 @@ var GempLotrHallUI = Class.extend({ }); toggleContent.css({width: "13px", height: "15px"}); toggleContent.click( - function() { - if (toggleContent.button("option", "icons")["primary"] == "ui-icon-circlesmall-minus") - toggleContent.button("option", "icons", {primary: "ui-icon-circlesmall-plus"}); - else - toggleContent.button("option", "icons", {primary: "ui-icon-circlesmall-minus"}); - content.toggle("blind", {}, 200); - }); + function() { + if (toggleContent.button("option", "icons")["primary"] == "ui-icon-circlesmall-minus") + toggleContent.button("option", "icons", {primary: "ui-icon-circlesmall-plus"}); + else + toggleContent.button("option", "icons", {primary: "ui-icon-circlesmall-minus"}); + content.toggle("blind", {}, 200); + }); header.append(toggleContent); header.append(" Tournaments in progress"); header.append(" (0)"); @@ -181,13 +181,13 @@ var GempLotrHallUI = Class.extend({ }); toggleContent.css({width: "13px", height: "15px"}); toggleContent.click( - function() { - if (toggleContent.button("option", "icons")["primary"] == "ui-icon-circlesmall-minus") - toggleContent.button("option", "icons", {primary: "ui-icon-circlesmall-plus"}); - else - toggleContent.button("option", "icons", {primary: "ui-icon-circlesmall-minus"}); - content.toggle("blind", {}, 200); - }); + function() { + if (toggleContent.button("option", "icons")["primary"] == "ui-icon-circlesmall-minus") + toggleContent.button("option", "icons", {primary: "ui-icon-circlesmall-plus"}); + else + toggleContent.button("option", "icons", {primary: "ui-icon-circlesmall-minus"}); + content.toggle("blind", {}, 200); + }); header.append(toggleContent); header.append(" Waiting tables"); header.append(" (0)"); @@ -213,13 +213,13 @@ var GempLotrHallUI = Class.extend({ }); toggleContent.css({width: "13px", height: "15px"}); toggleContent.click( - function() { - if (toggleContent.button("option", "icons")["primary"] == "ui-icon-circlesmall-minus") - toggleContent.button("option", "icons", {primary: "ui-icon-circlesmall-plus"}); - else - toggleContent.button("option", "icons", {primary: "ui-icon-circlesmall-minus"}); - content.toggle("blind", {}, 200); - }); + function() { + if (toggleContent.button("option", "icons")["primary"] == "ui-icon-circlesmall-minus") + toggleContent.button("option", "icons", {primary: "ui-icon-circlesmall-plus"}); + else + toggleContent.button("option", "icons", {primary: "ui-icon-circlesmall-minus"}); + content.toggle("blind", {}, 200); + }); header.append(toggleContent); header.append(" Playing tables"); header.append(" (0)"); @@ -245,13 +245,13 @@ var GempLotrHallUI = Class.extend({ }); toggleContent.css({width: "13px", height: "15px"}); toggleContent.click( - function() { - if (toggleContent.button("option", "icons")["primary"] == "ui-icon-circlesmall-minus") - toggleContent.button("option", "icons", {primary: "ui-icon-circlesmall-plus"}); - else - toggleContent.button("option", "icons", {primary: "ui-icon-circlesmall-minus"}); - content.toggle("blind", {}, 200); - }); + function() { + if (toggleContent.button("option", "icons")["primary"] == "ui-icon-circlesmall-minus") + toggleContent.button("option", "icons", {primary: "ui-icon-circlesmall-plus"}); + else + toggleContent.button("option", "icons", {primary: "ui-icon-circlesmall-minus"}); + content.toggle("blind", {}, 200); + }); header.append(toggleContent); header.append(" Finished tables"); header.append(" (0)"); @@ -272,26 +272,61 @@ var GempLotrHallUI = Class.extend({ getHall: function() { var that = this; - this.comm.getHall(function(xml) { - that.processHall(xml); - }); + this.comm.getHall( + function(xml) { + that.processHall(xml); + }, this.hallErrorMap()); }, updateHall:function () { var that = this; this.comm.updateHall( - function (xml) { - that.processHall(xml); - }, this.hallChannelId, - { - "409":function() { - that.chat.appendMessage("You have accessed Game Hall in another browser, press F5 (refresh) to regain access in this window"); - }, - "410":function() { - that.chat.appendMessage("You have been inactive for too long, press F5 (refresh) to enter Game Hall again"); - } - }); + function (xml) { + that.processHall(xml); + }, this.hallChannelId, this.hallErrorMap()); + }, + + hallErrorMap:function() { + var that = this; + return { + "0": function() { + that.showErrorDialog("Server connection error", "Unable to connect to server. Either server is down or there is a problem with your internet connection.", true, false); + }, + "401":function() { + that.showErrorDialog("Authentication error", "You are not logged in", false, true); + }, + "409":function() { + that.showErrorDialog("Concurrent access error", "You are accessing Game Hall from another browser or window. Close this window or if you wish to access Game Hall from here, click \"Refresh page\".", true, false); + }, + "410":function() { + that.showErrorDialog("Inactivity error", "You were inactive for too long and you have been removed from the Game Hall. If you wish to re-enter, clich \"Refresh page\".", true, false); + } + }; + }, + + showErrorDialog:function(title, text, reloadButton, mainPageButton) { + var buttons = {}; + if (reloadButton) { + buttons["Refresh page"] = + function () { + location.reload(true); + }; + } + if (mainPageButton) { + buttons["Go to main page"] = + function() { + location.href = "/gemp-lotr/"; + }; + } + + var dialog = $("
").dialog({ + title: title, + resizable: false, + height: 160, + modal: true, + buttons: buttons + }).text(text); }, updateDecks:function () { @@ -344,7 +379,7 @@ var GempLotrHallUI = Class.extend({ var serverTime = root.getAttribute("serverTime"); if (serverTime != null) - $(".serverTime").text("Server time: "+serverTime); + $(".serverTime").text("Server time: " + serverTime); var busy = root.getAttribute("busy") == "true"; @@ -360,45 +395,45 @@ var GempLotrHallUI = Class.extend({ if (joined != "true") { var but = $(""); $(but).button().click(( - function(queueId) { - return function () { - var deck = that.decksSelect.val(); - if (deck != null) - that.comm.joinQueue(queueId, deck, function (xml) { - that.processResponse(xml); - }); - }; - } - )(id)); + function(queueId) { + return function () { + var deck = that.decksSelect.val(); + if (deck != null) + that.comm.joinQueue(queueId, deck, function (xml) { + that.processResponse(xml); + }); + }; + } + )(id)); actionsField.append(but); } else { var but = $(""); $(but).button().click(( - function(queueId) { - return function() { - that.comm.leaveQueue(queueId, function (xml) { - that.processResponse(xml); - }); - } - })(id)); + function(queueId) { + return function() { + that.comm.leaveQueue(queueId, function (xml) { + that.processResponse(xml); + }); + } + })(id)); actionsField.append(but); } var row = $("" + queue.getAttribute("format") + "" + - "" + queue.getAttribute("collection") + "" + - "" + queue.getAttribute("queue") + "" + - "" + queue.getAttribute("start") + "" + - "" + queue.getAttribute("system") + "" + - "" + queue.getAttribute("playerCount") + "" + - "" + formatPrice(queue.getAttribute("cost")) + "" + - "" + queue.getAttribute("prizes") + "" + - ""); + "" + queue.getAttribute("collection") + "" + + "" + queue.getAttribute("queue") + "" + + "" + queue.getAttribute("start") + "" + + "" + queue.getAttribute("system") + "" + + "" + queue.getAttribute("playerCount") + "" + + "" + formatPrice(queue.getAttribute("cost")) + "" + + "" + queue.getAttribute("prizes") + "" + + ""); row.append(actionsField); if (action == "add") { $("table.queues", this.tablesDiv) - .append(row); + .append(row); } else if (action == "update") { $(".queue" + id, this.tablesDiv).replaceWith(row); } @@ -419,31 +454,31 @@ var GempLotrHallUI = Class.extend({ if (joined == "true") { var but = $(""); $(but).button().click(( - function(tournamentId) { - return function () { - that.comm.dropFromTournament(tournamentId, function (xml) { - that.processResponse(xml); - }); - }; - } - )(id)); + function(tournamentId) { + return function () { + that.comm.dropFromTournament(tournamentId, function (xml) { + that.processResponse(xml); + }); + }; + } + )(id)); actionsField.append(but); } var row = $("" + tournament.getAttribute("format") + "" + - "" + tournament.getAttribute("collection") + "" + - "" + tournament.getAttribute("name") + "" + - "" + tournament.getAttribute("system") + "" + - "" + tournament.getAttribute("stage") + "" + - "" + tournament.getAttribute("round") + "" + - "" + tournament.getAttribute("playerCount") + "" + - ""); + "" + tournament.getAttribute("collection") + "" + + "" + tournament.getAttribute("name") + "" + + "" + tournament.getAttribute("system") + "" + + "" + tournament.getAttribute("stage") + "" + + "" + tournament.getAttribute("round") + "" + + "" + tournament.getAttribute("playerCount") + "" + + ""); row.append(actionsField); if (action == "add") { $("table.tournaments", this.tablesDiv) - .append(row); + .append(row); } else if (action == "update") { $(".tournament" + id, this.tablesDiv).replaceWith(row); } @@ -491,15 +526,15 @@ var GempLotrHallUI = Class.extend({ var but = $(""); $(but).button().click(( - function(tableId) { - return function() { - var deck = that.decksSelect.val(); - if (deck != null) - that.comm.joinTable(tableId, deck, function (xml) { - that.processResponse(xml); - }); - }; - })(id)); + function(tableId) { + return function() { + var deck = that.decksSelect.val(); + if (deck != null) + that.comm.joinTable(tableId, deck, function (xml) { + that.processResponse(xml); + }); + }; + })(id)); lastField.append(but); } @@ -521,13 +556,13 @@ var GempLotrHallUI = Class.extend({ if (action == "add") { if (status == "WAITING") { $("table.waitingTables", this.tablesDiv) - .append(row); + .append(row); } else if (status == "PLAYING") { $("table.playingTables", this.tablesDiv) - .append(row); + .append(row); } else if (status == "FINISHED") { $("table.finishedTables", this.tablesDiv) - .append(row); + .append(row); } } else if (action == "update") { if (status == "WAITING") { @@ -536,7 +571,7 @@ var GempLotrHallUI = Class.extend({ } else { $(".table" + id, this.tablesDiv).remove(); $("table.waitingTables", this.tablesDiv) - .append(row); + .append(row); } } else if (status == "PLAYING") { if ($(".table" + id, $("table.playingTables")).length > 0) { @@ -544,7 +579,7 @@ var GempLotrHallUI = Class.extend({ } else { $(".table" + id, this.tablesDiv).remove(); $("table.playingTables", this.tablesDiv) - .append(row); + .append(row); } } else if (status == "FINISHED") { if ($(".table" + id, $("table.finishedTables")).length > 0) { @@ -552,7 +587,7 @@ var GempLotrHallUI = Class.extend({ } else { $(".table" + id, this.tablesDiv).remove(); $("table.finishedTables", this.tablesDiv) - .append(row); + .append(row); } } }