diff --git a/gemp-lotr/gemp-lotr-web/src/main/java/com/gempukku/lotro/server/CollectionResource.java b/gemp-lotr/gemp-lotr-web/src/main/java/com/gempukku/lotro/server/CollectionResource.java index 1f11a91a5..c443c228e 100644 --- a/gemp-lotr/gemp-lotr-web/src/main/java/com/gempukku/lotro/server/CollectionResource.java +++ b/gemp-lotr/gemp-lotr-web/src/main/java/com/gempukku/lotro/server/CollectionResource.java @@ -102,7 +102,6 @@ public class CollectionResource extends AbstractResource { collectionElem.setAttribute("count", String.valueOf(filteredResult.size())); doc.appendChild(collectionElem); - int index = 0; for (int i = start; i < start + count; i++) { if (i >= 0 && i < filteredResult.size()) { CardCollection.Item item = filteredResult.get(i); diff --git a/gemp-lotr/gemp-lotr-web/src/main/java/com/gempukku/lotro/server/CardLibraryProvider.java b/gemp-lotr/gemp-lotr-web/src/main/java/com/gempukku/lotro/server/provider/CardLibraryProvider.java similarity index 92% rename from gemp-lotr/gemp-lotr-web/src/main/java/com/gempukku/lotro/server/CardLibraryProvider.java rename to gemp-lotr/gemp-lotr-web/src/main/java/com/gempukku/lotro/server/provider/CardLibraryProvider.java index 69a172654..7e108e058 100644 --- a/gemp-lotr/gemp-lotr-web/src/main/java/com/gempukku/lotro/server/CardLibraryProvider.java +++ b/gemp-lotr/gemp-lotr-web/src/main/java/com/gempukku/lotro/server/provider/CardLibraryProvider.java @@ -1,4 +1,4 @@ -package com.gempukku.lotro.server; +package com.gempukku.lotro.server.provider; import com.gempukku.lotro.game.LotroCardBlueprintLibrary; import com.sun.jersey.core.spi.component.ComponentContext; diff --git a/gemp-lotr/gemp-lotr-web/src/main/java/com/gempukku/lotro/server/DaoProvider.java b/gemp-lotr/gemp-lotr-web/src/main/java/com/gempukku/lotro/server/provider/DaoProvider.java similarity index 96% rename from gemp-lotr/gemp-lotr-web/src/main/java/com/gempukku/lotro/server/DaoProvider.java rename to gemp-lotr/gemp-lotr-web/src/main/java/com/gempukku/lotro/server/provider/DaoProvider.java index 4d5f5d34a..15ffefe11 100644 --- a/gemp-lotr/gemp-lotr-web/src/main/java/com/gempukku/lotro/server/DaoProvider.java +++ b/gemp-lotr/gemp-lotr-web/src/main/java/com/gempukku/lotro/server/provider/DaoProvider.java @@ -1,4 +1,4 @@ -package com.gempukku.lotro.server; +package com.gempukku.lotro.server.provider; import com.gempukku.lotro.collection.CollectionSerializer; import com.gempukku.lotro.db.*; diff --git a/gemp-lotr/gemp-lotr-web/src/main/java/com/gempukku/lotro/server/PacksStorageProvider.java b/gemp-lotr/gemp-lotr-web/src/main/java/com/gempukku/lotro/server/provider/PacksStorageProvider.java similarity index 97% rename from gemp-lotr/gemp-lotr-web/src/main/java/com/gempukku/lotro/server/PacksStorageProvider.java rename to gemp-lotr/gemp-lotr-web/src/main/java/com/gempukku/lotro/server/provider/PacksStorageProvider.java index 44798a8c6..be9f15924 100644 --- a/gemp-lotr/gemp-lotr-web/src/main/java/com/gempukku/lotro/server/PacksStorageProvider.java +++ b/gemp-lotr/gemp-lotr-web/src/main/java/com/gempukku/lotro/server/provider/PacksStorageProvider.java @@ -1,4 +1,4 @@ -package com.gempukku.lotro.server; +package com.gempukku.lotro.server.provider; import com.gempukku.lotro.packs.*; import com.sun.jersey.core.spi.component.ComponentContext; diff --git a/gemp-lotr/gemp-lotr-web/src/main/java/com/gempukku/lotro/server/ServerProvider.java b/gemp-lotr/gemp-lotr-web/src/main/java/com/gempukku/lotro/server/provider/ServerProvider.java similarity index 97% rename from gemp-lotr/gemp-lotr-web/src/main/java/com/gempukku/lotro/server/ServerProvider.java rename to gemp-lotr/gemp-lotr-web/src/main/java/com/gempukku/lotro/server/provider/ServerProvider.java index fa5c277ba..bb15e7003 100644 --- a/gemp-lotr/gemp-lotr-web/src/main/java/com/gempukku/lotro/server/ServerProvider.java +++ b/gemp-lotr/gemp-lotr-web/src/main/java/com/gempukku/lotro/server/provider/ServerProvider.java @@ -1,4 +1,4 @@ -package com.gempukku.lotro.server; +package com.gempukku.lotro.server.provider; import com.gempukku.lotro.chat.ChatServer; import com.gempukku.lotro.collection.CollectionsManager; diff --git a/gemp-lotr/gemp-lotr-web/src/main/webapp/js/chat.js b/gemp-lotr/gemp-lotr-web/src/main/webapp/js/chat.js index dcdc28ac5..9097145e3 100644 --- a/gemp-lotr/gemp-lotr-web/src/main/webapp/js/chat.js +++ b/gemp-lotr/gemp-lotr-web/src/main/webapp/js/chat.js @@ -24,27 +24,16 @@ var ChatBoxUI = Class.extend({ this.communication = new GempLotrCommunication(url, function(xhr, ajaxOptions, thrownError) { if (thrownError != "abort") { if (xhr != null) { - if (xhr.status == 401) { - that.appendMessage("You're not logged in, go to the main page to log in", "warningMessage"); - return; - } else if (xhr.status == 404) { - that.appendMessage("Chat room was closed, or you were inactive for too long, please go to the Game Hall.", "warningMessage"); - return; - } else if (xhr.status == 503) { - that.appendMessage("Server is being restarted, please wait for the restart to finish and try again later.", "warningMessage"); - return; + that.retryCount++; + if (that.retryCount <= that.maxRetryCount) { + that.appendMessage("Chat had a problem communicating with the server (error " + xhr.status + "). Retrying (" + that.retryCount + " of " + that.maxRetryCount + ")...", "systemMessage"); + setTimeout(function() { + that.updateChatMessages(); + }, that.chatUpdateInterval); } else { - that.retryCount++; - if (that.retryCount <= that.maxRetryCount) { - that.appendMessage("Chat had a problem communicating with the server (error " + xhr.status + "). Retrying (" + that.retryCount + " of " + that.maxRetryCount + ")...", "systemMessage"); - setTimeout(function() { - that.updateChatMessages(); - }, that.chatUpdateInterval); - } else { - that.appendMessage("Chat has given up on connection retry (tried " + that.maxRetryCount + "), make sure your connection with the Internet is working.", "warningMessage"); - } - return; + that.appendMessage("Chat has given up on connection retry (tried " + that.maxRetryCount + "), make sure your connection with the Internet is working.", "warningMessage"); } + return; } that.retryCount++; if (that.retryCount <= that.maxRetryCount) { @@ -61,8 +50,6 @@ var ChatBoxUI = Class.extend({ this.chatMessagesDiv = $("
"); this.div.append(this.chatMessagesDiv); - var that = this; - if (this.name != null) { this.chatTalkDiv = $(""); if (showList) { @@ -71,8 +58,19 @@ var ChatBoxUI = Class.extend({ } this.div.append(this.chatTalkDiv); - this.communication.startChat(this.name, function(xml) { - that.processMessages(xml, true); + this.communication.startChat(this.name, + function(xml) { + that.processMessages(xml, true); + }, { + "401": function() { + that.appendMessage("You are not logged in, go to the main page to log in.", "warningMessage"); + }, + "403": function() { + that.appendMessage("You have no permission to join this chat.", "warningMessage"); + }, + "404": function() { + that.appendMessage("Chat room was closed, please go to the Game Hall."); + } }); this.chatTalkDiv.bind("keypress", function(e) { @@ -188,16 +186,46 @@ var ChatBoxUI = Class.extend({ if (this.processingMessages != null) { this.communication.sendChatMessage(this.name, this.processingMessages, function(xml) { that.processMessages(xml, true); + }, { + "401": function() { + that.appendMessage("You are not logged in, go to the main page to log in.", "warningMessage"); + }, + "403": function() { + that.appendMessage("You have no permission to send messages to this chat.", "warningMessage"); + }, + "404": function() { + that.appendMessage("Chat room was closed, or you were inactive for too long, please go to the Game Hall."); + } }); } else if (this.unsentMessages.length > 0) { this.communication.sendChatMessage(this.name, this.unsentMessages, function(xml) { that.processMessages(xml, true); + }, { + "401": function() { + that.appendMessage("You are not logged in, go to the main page to log in.", "warningMessage"); + }, + "403": function() { + that.appendMessage("You have no permission to send messages to this chat.", "warningMessage"); + }, + "404": function() { + that.appendMessage("Chat room was closed, or you were inactive for too long, please go to the Game Hall."); + } }); this.processingMessages = this.unsentMessages; this.unsentMessages = new Array(); } else { this.communication.updateChat(this.name, function(xml) { that.processMessages(xml, true); + }, { + "401": function() { + that.appendMessage("You are not logged in, go to the main page to log in.", "warningMessage"); + }, + "403": function() { + that.appendMessage("You have no permission to get message from this chat.", "warningMessage"); + }, + "404": function() { + that.appendMessage("Chat room was closed, or you were inactive for too long, please go to the Game Hall."); + } }); } }, diff --git a/gemp-lotr/gemp-lotr-web/src/main/webapp/js/communication.js b/gemp-lotr/gemp-lotr-web/src/main/webapp/js/communication.js index de67f4d5b..825229d38 100644 --- a/gemp-lotr/gemp-lotr-web/src/main/webapp/js/communication.js +++ b/gemp-lotr/gemp-lotr-web/src/main/webapp/js/communication.js @@ -7,6 +7,17 @@ var GempLotrCommunication = Class.extend({ this.failure = failure; }, + errorCheck: function(errorMap) { + var that = this; + return function(xhr, status, request) { + var errorStatus = "" + xhr.status; + if (errorMap != null && errorMap[errorStatus] != null) + errorMap[errorStatus](xhr, status, request); + else + that.failure(xhr, status, request); + }; + }, + getDelivery: function(callback) { $.ajax({ type: "GET", @@ -30,7 +41,7 @@ var GempLotrCommunication = Class.extend({ }; }, - getGameHistory: function(start, count, callback) { + getGameHistory: function(start, count, callback, errorMap) { $.ajax({ type: "GET", url: this.url + "/gameHistory", @@ -40,12 +51,12 @@ var GempLotrCommunication = Class.extend({ count: count, participantId: getUrlParam("participantId") }, success: this.deliveryCheck(callback), - error: this.failure, + error: this.errorCheck(errorMap), dataType: "xml" }); }, - getLeagues: function(callback) { + getLeagues: function(callback, errorMap) { $.ajax({ type: "GET", url: this.url + "/league", @@ -53,12 +64,12 @@ var GempLotrCommunication = Class.extend({ data: { participanId: getUrlParam("participantId") }, success: this.deliveryCheck(callback), - error: this.failure, + error: this.errorCheck(errorMap), dataType: "xml" }); }, - joinLeague: function(code, callback) { + joinLeague: function(code, callback, errorMap) { $.ajax({ type: "POST", url: this.url + "/league/" + code, @@ -66,44 +77,44 @@ var GempLotrCommunication = Class.extend({ data: { participanId: getUrlParam("participantId") }, success: this.deliveryCheck(callback), - error: this.failure, + error: this.errorCheck(errorMap), dataType: "xml" }); }, - getReplay: function(replayId, callback) { + getReplay: function(replayId, callback, errorMap) { $.ajax({ type: "GET", url: this.url + "/replay/" + replayId, cache: false, success: this.deliveryCheck(callback), - error: this.failure, + error: this.errorCheck(errorMap), dataType: "xml" }); }, - startGameSession: function(callback) { + startGameSession: function(callback, errorMap) { $.ajax({ type: "GET", url: this.url + "/game/" + getUrlParam("gameId"), cache: false, data: { participantId: getUrlParam("participantId") }, success: this.deliveryCheck(callback), - error: this.failure, + error: this.errorCheck(errorMap), dataType: "xml" }); }, - updateGameState: function(callback) { + updateGameState: function(callback, errorMap) { $.ajax({ type: "POST", url: this.url + "/game/" + getUrlParam("gameId"), cache: false, data: { participantId: getUrlParam("participantId") }, success: this.deliveryCheck(callback), - error: this.failure, + error: this.errorCheck(errorMap), dataType: "xml" }); }, - getGameCardModifiers: function(cardId, callback) { + getGameCardModifiers: function(cardId, callback, errorMap) { $.ajax({ type: "GET", url: this.url + "/game/" + getUrlParam("gameId") + "/cardInfo", @@ -111,11 +122,11 @@ var GempLotrCommunication = Class.extend({ data: { cardId: cardId, participantId: getUrlParam("participantId") }, success: this.deliveryCheck(callback), - error: this.failure, + error: this.errorCheck(errorMap), dataType: "html" }); }, - gameDecisionMade: function(decisionId, response, callback) { + gameDecisionMade: function(decisionId, response, callback, errorMap) { $.ajax({ type: "POST", url: this.url + "/game/" + getUrlParam("gameId"), @@ -125,22 +136,22 @@ var GempLotrCommunication = Class.extend({ decisionId: decisionId, decisionValue: response}, success: this.deliveryCheck(callback), - error: this.failure, + error: this.errorCheck(errorMap), dataType: "xml" }); }, - concede: function() { + concede: function(errorMap) { $.ajax({ type: "POST", url: this.url + "/game/" + getUrlParam("gameId") + "/concede", cache: false, data: { participantId: getUrlParam("participantId")}, - error: this.failure, + error: this.errorCheck(errorMap), dataType: "xml" }); }, - getDeck: function(deckName, callback) { + getDeck: function(deckName, callback, errorMap) { $.ajax({ type: "GET", url: this.url + "/deck", @@ -149,11 +160,11 @@ var GempLotrCommunication = Class.extend({ participantId: getUrlParam("participantId"), deckName: deckName}, success: this.deliveryCheck(callback), - error: this.failure, + error: this.errorCheck(errorMap), dataType: "xml" }); }, - getDecks: function(callback) { + getDecks: function(callback, errorMap) { $.ajax({ type: "GET", url: this.url + "/deck/list", @@ -161,11 +172,11 @@ var GempLotrCommunication = Class.extend({ data: { participantId: getUrlParam("participantId")}, success: this.deliveryCheck(callback), - error: this.failure, + error: this.errorCheck(errorMap), dataType: "xml" }); }, - getCollectionTypes: function(callback) { + getCollectionTypes: function(callback, errorMap) { $.ajax({ type: "GET", url: this.url + "/collection", @@ -173,11 +184,11 @@ var GempLotrCommunication = Class.extend({ data: { participantId: getUrlParam("participantId")}, success: this.deliveryCheck(callback), - error: this.failure, + error: this.errorCheck(errorMap), dataType: "xml" }); }, - getMerchant: function(filter, ownedMin, start, count, callback) { + getMerchant: function(filter, ownedMin, start, count, callback, errorMap) { $.ajax({ type: "GET", url: this.url + "/merchant", @@ -189,11 +200,11 @@ var GempLotrCommunication = Class.extend({ start: start, count: count}, success: this.deliveryCheck(callback), - error: this.failure, + error: this.errorCheck(errorMap), dataType: "xml" }); }, - buyItem: function(blueprintId, price, callback) { + buyItem: function(blueprintId, price, callback, errorMap) { $.ajax({ type: "POST", url: this.url + "/merchant/buy", @@ -203,11 +214,11 @@ var GempLotrCommunication = Class.extend({ blueprintId: blueprintId, price: price}, success: this.deliveryCheck(callback), - error: this.failure, + error: this.errorCheck(errorMap), dataType: "xml" }); }, - sellItem: function(blueprintId, price, callback) { + sellItem: function(blueprintId, price, callback, errorMap) { $.ajax({ type: "POST", url: this.url + "/merchant/sell", @@ -217,11 +228,11 @@ var GempLotrCommunication = Class.extend({ blueprintId: blueprintId, price: price}, success: this.deliveryCheck(callback), - error: this.failure, + error: this.errorCheck(errorMap), dataType: "xml" }); }, - tradeInFoil: function(blueprintId, callback) { + tradeInFoil: function(blueprintId, callback, errorMap) { $.ajax({ type: "POST", url: this.url + "/merchant/tradeFoil", @@ -230,11 +241,11 @@ var GempLotrCommunication = Class.extend({ participantId: getUrlParam("participantId"), blueprintId: blueprintId}, success: this.deliveryCheck(callback), - error: this.failure, + error: this.errorCheck(errorMap), dataType: "xml" }); }, - getCollection: function(collectionType, filter, start, count, callback) { + getCollection: function(collectionType, filter, start, count, callback, errorMap) { $.ajax({ type: "GET", url: this.url + "/collection/" + collectionType, @@ -245,11 +256,11 @@ var GempLotrCommunication = Class.extend({ start: start, count: count}, success: this.deliveryCheck(callback), - error: this.failure, + error: this.errorCheck(errorMap), dataType: "xml" }); }, - openPack: function(collectionType, pack, callback) { + openPack: function(collectionType, pack, callback, errorMap) { $.ajax({ type: "POST", url: this.url + "/collection/" + collectionType, @@ -257,14 +268,12 @@ var GempLotrCommunication = Class.extend({ data: { participantId: getUrlParam("participantId"), pack: pack}, - success: function(xml, status, request) { - callback(xml); - }, - error: this.failure, + success: this.deliveryCheck(callback), + error: this.errorCheck(errorMap), dataType: "xml" }); }, - openSelectionPack: function(collectionType, pack, selection, callback) { + openSelectionPack: function(collectionType, pack, selection, callback, errorMap) { $.ajax({ type: "POST", url: this.url + "/collection/" + collectionType, @@ -273,14 +282,12 @@ var GempLotrCommunication = Class.extend({ participantId: getUrlParam("participantId"), pack: pack, selection: selection}, - success: function(xml, status, request) { - callback(xml); - }, - error: this.failure, + success: this.deliveryCheck(callback), + error: this.errorCheck(errorMap), dataType: "xml" }); }, - saveDeck: function(deckName, contents, callback) { + saveDeck: function(deckName, contents, callback, errorMap) { $.ajax({ type: "POST", url: this.url + "/deck", @@ -291,11 +298,11 @@ var GempLotrCommunication = Class.extend({ deckName: deckName, deckContents: contents}, success: this.deliveryCheck(callback), - error: this.failure, + error: this.errorCheck(errorMap), dataType: "xml" }); }, - renameDeck: function(oldDeckName, deckName, callback) { + renameDeck: function(oldDeckName, deckName, callback, errorMap) { $.ajax({ type: "POST", url: this.url + "/deck/rename", @@ -305,11 +312,11 @@ var GempLotrCommunication = Class.extend({ oldDeckName: oldDeckName, deckName: deckName}, success: this.deliveryCheck(callback), - error: this.failure, + error: this.errorCheck(errorMap), dataType: "xml" }); }, - deleteDeck: function(deckName, callback) { + deleteDeck: function(deckName, callback, errorMap) { $.ajax({ type: "POST", url: this.url + "/deck/delete", @@ -318,11 +325,11 @@ var GempLotrCommunication = Class.extend({ participantId: getUrlParam("participantId"), deckName: deckName}, success: this.deliveryCheck(callback), - error: this.failure, + error: this.errorCheck(errorMap), dataType: "xml" }); }, - getDeckStats: function(contents, callback) { + getDeckStats: function(contents, callback, errorMap) { $.ajax({ type: "POST", url: this.url + "/deck/stats", @@ -331,11 +338,11 @@ var GempLotrCommunication = Class.extend({ participantId: getUrlParam("participantId"), deckContents: contents}, success: this.deliveryCheck(callback), - error: this.failure, + error: this.errorCheck(errorMap), dataType: "html" }); }, - startChat: function(room, callback) { + startChat: function(room, callback, errorMap) { $.ajax({ type: "GET", url: this.url + "/chat/" + room, @@ -343,11 +350,11 @@ var GempLotrCommunication = Class.extend({ data: { participantId: getUrlParam("participantId")}, success: this.deliveryCheck(callback), - error: this.failure, + error: this.errorCheck(errorMap), dataType: "xml" }); }, - updateChat: function(room, callback) { + updateChat: function(room, callback, errorMap) { $.ajax({ type: "POST", url: this.url + "/chat/" + room, @@ -355,11 +362,11 @@ var GempLotrCommunication = Class.extend({ data: { participantId: getUrlParam("participantId")}, success: this.deliveryCheck(callback), - error: this.failure, + error: this.errorCheck(errorMap), dataType: "xml" }); }, - sendChatMessage: function(room, messages, callback) { + sendChatMessage: function(room, messages, callback, errorMap) { $.ajax({ type: "POST", url: this.url + "/chat/" + room, @@ -369,11 +376,11 @@ var GempLotrCommunication = Class.extend({ message: messages}, success: this.deliveryCheck(callback), traditional: true, - error: this.failure, + error: this.errorCheck(errorMap), dataType: "xml" }); }, - getHall: function(callback) { + getHall: function(callback, errorMap) { $.ajax({ type: "GET", url: this.url + "/hall", @@ -381,11 +388,11 @@ var GempLotrCommunication = Class.extend({ data: { participantId: getUrlParam("participantId")}, success: this.deliveryCheck(callback), - error: this.failure, + error: this.errorCheck(errorMap), dataType: "xml" }); }, - joinTable: function(tableId, deckName, callback) { + joinTable: function(tableId, deckName, callback, errorMap) { $.ajax({ type: "POST", url: this.url + "/hall/" + tableId, @@ -394,11 +401,11 @@ var GempLotrCommunication = Class.extend({ deckName: deckName, participantId: getUrlParam("participantId")}, success: this.deliveryCheck(callback), - error: this.failure, + error: this.errorCheck(errorMap), dataType: "xml" }); }, - createTable: function(format, deckName, callback) { + createTable: function(format, deckName, callback, errorMap) { $.ajax({ type: "POST", url: this.url + "/hall", @@ -408,22 +415,22 @@ var GempLotrCommunication = Class.extend({ deckName: deckName, participantId: getUrlParam("participantId")}, success: this.deliveryCheck(callback), - error: this.failure, + error: this.errorCheck(errorMap), dataType: "xml" }); }, - leaveTable: function() { + leaveTable: function(errorMap) { $.ajax({ type: "POST", url: this.url + "/hall/leave", cache: false, data: { participantId: getUrlParam("participantId")}, - error: this.failure, + error: this.errorCheck(errorMap), dataType: "xml" }); }, - getStatus: function(callback) { + getStatus: function(callback, errorMap) { $.ajax({ type: "GET", url: this.url + "/", @@ -431,11 +438,11 @@ var GempLotrCommunication = Class.extend({ data: { participantId: getUrlParam("participantId")}, success: this.deliveryCheck(callback), - error: this.failure, + error: this.errorCheck(errorMap), dataType: "html" }); }, - login: function(login, password, callback) { + login: function(login, password, callback, errorMap) { $.ajax({ type: "POST", url: this.url + "/login", @@ -445,11 +452,11 @@ var GempLotrCommunication = Class.extend({ password: password, participantId: getUrlParam("participantId")}, success: this.deliveryCheck(callback), - error: this.failure, + error: this.errorCheck(errorMap), dataType: "html" }); }, - register: function(login, password, callback) { + register: function(login, password, callback, errorMap) { $.ajax({ type: "POST", url: this.url + "/register", @@ -459,11 +466,11 @@ var GempLotrCommunication = Class.extend({ password: password, participantId: getUrlParam("participantId")}, success: this.deliveryCheck(callback), - error: this.failure, + error: this.errorCheck(errorMap), dataType: "html" }); }, - getRegistrationForm: function(callback) { + getRegistrationForm: function(callback, errorMap) { $.ajax({ type: "POST", url: "/gemp-lotr/includes/registrationForm.html", @@ -471,7 +478,7 @@ var GempLotrCommunication = Class.extend({ data: { participantId: getUrlParam("participantId")}, success: this.deliveryCheck(callback), - error: this.failure, + error: this.errorCheck(errorMap), dataType: "html" }); } diff --git a/gemp-lotr/gemp-lotr-web/src/main/webapp/js/deckBuildingUi.js b/gemp-lotr/gemp-lotr-web/src/main/webapp/js/deckBuildingUi.js index d66d45671..3e161786c 100644 --- a/gemp-lotr/gemp-lotr-web/src/main/webapp/js/deckBuildingUi.js +++ b/gemp-lotr/gemp-lotr-web/src/main/webapp/js/deckBuildingUi.js @@ -54,6 +54,10 @@ var GempLotrDeckBuildingUI = Class.extend({ function(filter, start, count, callback) { that.comm.getCollection(that.collectionType, filter, start, count, function(xml) { callback(xml); + }, { + "404": function() { + alert("You don't have collection of that type."); + } }); }, function() { @@ -140,7 +144,11 @@ var GempLotrDeckBuildingUI = Class.extend({ function() { if (confirm("Do you wish to save this deck?")) that.saveDeck(false); - }); + }, { + "404": function() { + alert("Couldn't find the deck to rename on the server."); + } + }); } }); @@ -385,11 +393,19 @@ var GempLotrDeckBuildingUI = Class.extend({ if (confirm("Would you like to open this pack?")) { this.comm.openPack(this.getCollectionType(), selectedCardElem.data("card").blueprintId, function() { that.cardFilter.getCollection(); + }, { + "404": function() { + alert("You have no pack of this type in your collection."); + } }); } } else if (selectedCardElem.hasClass("cardToSelect")) { this.comm.openSelectionPack(this.getCollectionType(), this.packSelectionId, selectedCardElem.data("card").blueprintId, function() { that.cardFilter.getCollection(); + }, { + "404": function() { + alert("You have no pack of this type in your collection or that selection is not available for this pack."); + } }); this.selectionDialog.dialog("close"); } else if (selectedCardElem.hasClass("selectionInCollection")) { @@ -540,6 +556,10 @@ var GempLotrDeckBuildingUI = Class.extend({ this.comm.saveDeck(this.deckName, deckContents, function(xml) { that.deckModified(false); alert("Deck was saved"); + }, { + "400": function() { + alert("Invalid deck format."); + } }); }, @@ -641,7 +661,11 @@ var GempLotrDeckBuildingUI = Class.extend({ function() { that.checkDeckStatsDirty(); }, that.checkDirtyInterval); - }); + }, { + "400": function() { + alert("Invalid deck for getting stats."); + } + }); } else { $("#deckStats").html("Deck has no Ring, Ring-bearer or all 9 sites"); setTimeout(