JavaScript versioning and logout URL.

This commit is contained in:
marcins78@gmail.com
2012-04-10 13:06:24 +00:00
parent 0eb0952c55
commit 40a73bdbf8
23 changed files with 236 additions and 213 deletions

View File

@@ -67,6 +67,13 @@ public class ServerResource extends AbstractResource {
}
}
@Path("/logout")
@POST
public void logout(
@Context HttpServletRequest request) throws Exception {
logoutUser(request);
}
@Path("/register")
@POST
@Produces("text/html")
@@ -202,6 +209,10 @@ public class ServerResource extends AbstractResource {
request.getSession().setAttribute("logged", login);
}
private void logoutUser(HttpServletRequest request) {
request.getSession().removeAttribute("logged");
}
private String getUserNameIfLogged(HttpServletRequest request) {
return (String) request.getSession().getAttribute("logged");
}

View File

@@ -93,16 +93,16 @@
<script type="text/javascript" src="js/jquery/jquery.layout.js"></script>
<script type="text/javascript" src="js/jquery/jquery.touchSwipe.js"></script>
<script type="text/javascript" src="js/inheritance.js"></script>
<script type="text/javascript" src="js/common.js"></script>
<script type="text/javascript" src="js/communication.js"></script>
<script type="text/javascript" src="js/deliveryService.js"></script>
<script type="text/javascript" src="js/jCardGroup.js"></script>
<script type="text/javascript" src="js/jCards.js"></script>
<script type="text/javascript" src="js/logging.js"></script>
<script type="text/javascript" src="js/commonUi.js"></script>
<script type="text/javascript" src="js/deckBuildingUi.js"></script>
<script type="text/javascript" src="js/cardFilter.js"></script>
<script type="text/javascript" src="js/gemp-001/inheritance.js"></script>
<script type="text/javascript" src="js/gemp-001/common.js"></script>
<script type="text/javascript" src="js/gemp-001/communication.js"></script>
<script type="text/javascript" src="js/gemp-001/deliveryService.js"></script>
<script type="text/javascript" src="js/gemp-001/jCardGroup.js"></script>
<script type="text/javascript" src="js/gemp-001/jCards.js"></script>
<script type="text/javascript" src="js/gemp-001/logging.js"></script>
<script type="text/javascript" src="js/gemp-001/commonUi.js"></script>
<script type="text/javascript" src="js/gemp-001/deckBuildingUi.js"></script>
<script type="text/javascript" src="js/gemp-001/cardFilter.js"></script>
<script type="text/javascript">

View File

@@ -318,16 +318,16 @@ body {
<script type="text/javascript" src="js/jquery/jquery.spinnercontrol.js"></script>
<script type="text/javascript" src="js/jquery/jquery.touchSwipe.js"></script>
<script type="text/javascript" src="js/inheritance.js"></script>
<script type="text/javascript" src="js/communication.js"></script>
<script type="text/javascript" src="js/common.js"></script>
<script type="text/javascript" src="js/chat.js"></script>
<script type="text/javascript" src="js/commonUi.js"></script>
<script type="text/javascript" src="js/gameUi.js"></script>
<script type="text/javascript" src="js/gameAnimations.js"></script>
<script type="text/javascript" src="js/jCardGroup.js"></script>
<script type="text/javascript" src="js/jCards.js"></script>
<script type="text/javascript" src="js/logging.js"></script>
<script type="text/javascript" src="js/gemp-001/inheritance.js"></script>
<script type="text/javascript" src="js/gemp-001/communication.js"></script>
<script type="text/javascript" src="js/gemp-001/common.js"></script>
<script type="text/javascript" src="js/gemp-001/chat.js"></script>
<script type="text/javascript" src="js/gemp-001/commonUi.js"></script>
<script type="text/javascript" src="js/gemp-001/gameUi.js"></script>
<script type="text/javascript" src="js/gemp-001/gameAnimations.js"></script>
<script type="text/javascript" src="js/gemp-001/jCardGroup.js"></script>
<script type="text/javascript" src="js/gemp-001/jCards.js"></script>
<script type="text/javascript" src="js/gemp-001/logging.js"></script>
<script type="text/javascript">
var ui;

View File

@@ -150,18 +150,18 @@
<script type="text/javascript" src="js/jquery/jquery-1.6.2.js"></script>
<script type="text/javascript" src="js/jquery/jquery-ui-1.8.16.custom.min.js"></script>
<script type="text/javascript" src="js/inheritance.js"></script>
<script type="text/javascript" src="js/common.js"></script>
<script type="text/javascript" src="js/logging.js"></script>
<script type="text/javascript" src="js/chat.js"></script>
<script type="text/javascript" src="js/commonUi.js"></script>
<script type="text/javascript" src="js/hallUi.js"></script>
<script type="text/javascript" src="js/leagueResultsUi.js"></script>
<script type="text/javascript" src="js/communication.js"></script>
<script type="text/javascript" src="js/gemp-001/inheritance.js"></script>
<script type="text/javascript" src="js/gemp-001/common.js"></script>
<script type="text/javascript" src="js/gemp-001/logging.js"></script>
<script type="text/javascript" src="js/gemp-001/chat.js"></script>
<script type="text/javascript" src="js/gemp-001/commonUi.js"></script>
<script type="text/javascript" src="js/gemp-001/hallUi.js"></script>
<script type="text/javascript" src="js/gemp-001/leagueResultsUi.js"></script>
<script type="text/javascript" src="js/gemp-001/communication.js"></script>
<!-- This is needed for delivery -->
<script type="text/javascript" src="js/deliveryService.js"></script>
<script type="text/javascript" src="js/jCardGroup.js"></script>
<script type="text/javascript" src="js/jCards.js"></script>
<script type="text/javascript" src="js/gemp-001/deliveryService.js"></script>
<script type="text/javascript" src="js/gemp-001/jCardGroup.js"></script>
<script type="text/javascript" src="js/gemp-001/jCards.js"></script>
<script type="text/javascript">
var chat;
@@ -203,11 +203,11 @@
var infoDialog = $("<div></div>")
.dialog({
autoOpen: false,
closeOnEscape: true,
resizable: false,
title: "Card information"
});
autoOpen: false,
closeOnEscape: true,
resizable: false,
title: "Card information"
});
$("body").click(
function (event) {

View File

@@ -21,9 +21,9 @@
<script type="text/javascript" src="js/jquery/jquery-1.6.2.js"></script>
<script type="text/javascript" src="js/jquery/jquery-ui-1.8.16.custom.min.js"></script>
<script type="text/javascript" src="js/inheritance.js"></script>
<script type="text/javascript" src="js/logging.js"></script>
<script type="text/javascript" src="js/communication.js"></script>
<script type="text/javascript" src="js/gemp-001/inheritance.js"></script>
<script type="text/javascript" src="js/gemp-001/logging.js"></script>
<script type="text/javascript" src="js/gemp-001/communication.js"></script>
<script type="text/javascript">
function getUrlParam(param) {

View File

@@ -62,16 +62,16 @@ var ChatBoxUI = Class.extend({
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.");
}
});
"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) {
var code = (e.keyCode ? e.keyCode : e.which);

View File

@@ -18,6 +18,18 @@ var GempLotrCommunication = Class.extend({
};
},
logout: function(callback, errorMap) {
$.ajax({
type: "POST",
url: this.url + "/logout",
cache: false,
data: {
participantId: getUrlParam("participantId")},
success: this.deliveryCheck(callback),
error: this.errorCheck(errorMap)
});
},
getDelivery: function(callback) {
$.ajax({
type: "GET",

View File

@@ -145,10 +145,10 @@ var GempLotrDeckBuildingUI = Class.extend({
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.");
}
});
"404": function() {
alert("Couldn't find the deck to rename on the server.");
}
});
}
});
@@ -244,11 +244,11 @@ var GempLotrDeckBuildingUI = Class.extend({
this.infoDialog = $("<div></div>")
.dialog({
autoOpen: false,
closeOnEscape: true,
resizable: false,
title: "Card information"
});
autoOpen: false,
closeOnEscape: true,
resizable: false,
title: "Card information"
});
var swipeOptions = {
threshold: 20,
@@ -296,14 +296,14 @@ var GempLotrDeckBuildingUI = Class.extend({
if (that.deckListDialog == null) {
that.deckListDialog = $("<div></div>")
.dialog({
title: "Your stored decks",
autoOpen: false,
closeOnEscape: true,
resizable: true,
width: 400,
height: 400,
modal: true
});
title: "Your stored decks",
autoOpen: false,
closeOnEscape: true,
resizable: true,
width: 400,
height: 400,
modal: true
});
}
that.deckListDialog.html("");
@@ -418,14 +418,14 @@ var GempLotrDeckBuildingUI = Class.extend({
if (this.selectionDialog == null) {
this.selectionDialog = $("<div></div>")
.dialog({
title: "Choose one",
autoOpen: false,
closeOnEscape: true,
resizable: true,
width: 400,
height: 200,
modal: true
});
title: "Choose one",
autoOpen: false,
closeOnEscape: true,
resizable: true,
width: 400,
height: 200,
modal: true
});
this.selectionGroup = new NormalCardGroup(this.selectionDialog, function(card) {
return true;
@@ -662,10 +662,10 @@ var GempLotrDeckBuildingUI = Class.extend({
that.checkDeckStatsDirty();
}, that.checkDirtyInterval);
}, {
"400": function() {
alert("Invalid deck for getting stats.");
}
});
"400": function() {
alert("Invalid deck for getting stats.");
}
});
} else {
$("#deckStats").html("Deck has no Ring, Ring-bearer or all 9 sites");
setTimeout(

View File

@@ -70,40 +70,40 @@ var GameAnimations = Class.extend({
var cardWidth = card.getWidthForHeight(cardHeight);
$(cardDiv).css(
{
position: "absolute",
left: (gameWidth / 2 - cardWidth / 4),
top: gameHeight * (3 / 8),
width: cardWidth / 2,
height: cardHeight / 2,
"z-index": 100,
opacity: 0});
{
position: "absolute",
left: (gameWidth / 2 - cardWidth / 4),
top: gameHeight * (3 / 8),
width: cardWidth / 2,
height: cardHeight / 2,
"z-index": 100,
opacity: 0});
$(cardDiv).animate(
{
left: "-=" + cardWidth / 4,
top: "-=" + (gameHeight / 8),
width: "+=" + (cardWidth / 2),
height: "+=" + (cardHeight / 2),
opacity: 1},
{
duration: that.getAnimationLength(that.playEventDuration / 8),
easing: "linear",
queue: false,
complete: next});
{
left: "-=" + cardWidth / 4,
top: "-=" + (gameHeight / 8),
width: "+=" + (cardWidth / 2),
height: "+=" + (cardHeight / 2),
opacity: 1},
{
duration: that.getAnimationLength(that.playEventDuration / 8),
easing: "linear",
queue: false,
complete: next});
}).queue(
function(next) {
setTimeout(next, that.getAnimationLength(that.playEventDuration * (5 / 8)));
}).queue(
function(next) {
$(cardDiv).animate(
{
opacity: 0},
{
duration: that.getAnimationLength(that.playEventDuration / 4),
easing: "easeOutQuart",
queue: false,
complete: next});
{
opacity: 0},
{
duration: that.getAnimationLength(that.playEventDuration / 4),
easing: "easeOutQuart",
queue: false,
complete: next});
}).queue(
function(next) {
$(cardDiv).remove();
@@ -157,26 +157,26 @@ var GameAnimations = Class.extend({
}
$(cardDiv).css(
{
position: "absolute",
left: shadowStartPosX,
top: shadowStartPosY,
width: shadowWidth,
height: shadowHeight,
"z-index": 100,
opacity: 1});
{
position: "absolute",
left: shadowStartPosX,
top: shadowStartPosY,
width: shadowWidth,
height: shadowHeight,
"z-index": 100,
opacity: 1});
$(cardDiv).animate(
{
opacity: 0,
left: "-=" + (shadowWidth / 2),
top: "-=" + (shadowHeight / 2),
width: "+=" + shadowWidth,
height: "+=" + shadowHeight},
{
duration: that.getAnimationLength(that.cardAffectsCardDuration),
easing: "easeInQuart",
queue: false,
complete: null});
{
opacity: 0,
left: "-=" + (shadowWidth / 2),
top: "-=" + (shadowHeight / 2),
width: "+=" + shadowWidth,
height: "+=" + shadowHeight},
{
duration: that.getAnimationLength(that.cardAffectsCardDuration),
easing: "easeInQuart",
queue: false,
complete: null});
}
}
@@ -190,7 +190,7 @@ var GameAnimations = Class.extend({
$(this).remove();
}
}
);
);
next();
});
}
@@ -224,9 +224,9 @@ var GameAnimations = Class.extend({
else if (zone == "DEAD")
that.game.deadPileDialogs[participantId].append(cardDiv);
else if (zone == "ADVENTURE_DECK")
that.game.adventureDeckDialogs[participantId].append(cardDiv);
else
$("#main").append(cardDiv);
that.game.adventureDeckDialogs[participantId].append(cardDiv);
else
$("#main").append(cardDiv);
if (targetCardId != null) {
var targetCardData = $(".card:cardId(" + targetCardId + ")").data("card");
@@ -268,29 +268,29 @@ var GameAnimations = Class.extend({
var cardWidth = card.getWidthForHeight(cardHeight);
$(cardDiv).css(
{
position: "absolute",
left: (gameWidth / 2 - cardWidth / 4),
top: gameHeight * (3 / 8),
width: cardWidth / 2,
height: cardHeight / 2,
"z-index": 100,
opacity: 0});
{
position: "absolute",
left: (gameWidth / 2 - cardWidth / 4),
top: gameHeight * (3 / 8),
width: cardWidth / 2,
height: cardHeight / 2,
"z-index": 100,
opacity: 0});
$(cardDiv).animate(
{
opacity: 1},
{
duration: that.getAnimationLength(that.putCardIntoPlayDuration / 8),
easing: "linear",
step: function(now, fx) {
layoutCardElem(cardDiv,
(gameWidth / 2 - cardWidth / 4) - now * (cardWidth / 4),
gameHeight * (3 / 8) - now * (gameHeight / 8),
cardWidth / 2 + now * (cardWidth / 2),
cardHeight / 2 + now * (cardHeight / 2), 100);
},
complete: next});
{
opacity: 1},
{
duration: that.getAnimationLength(that.putCardIntoPlayDuration / 8),
easing: "linear",
step: function(now, fx) {
layoutCardElem(cardDiv,
(gameWidth / 2 - cardWidth / 4) - now * (cardWidth / 4),
gameHeight * (3 / 8) - now * (gameHeight / 8),
cardWidth / 2 + now * (cardWidth / 2),
cardHeight / 2 + now * (cardHeight / 2), 100);
},
complete: next});
}).queue(
function(next) {
setTimeout(next, that.getAnimationLength(that.putCardIntoPlayDuration * (5 / 8)));
@@ -305,20 +305,20 @@ var GameAnimations = Class.extend({
var startHeight = cardDiv.height();
$(cardDiv).animate(
{
left: oldValues["left"]},
{
duration: that.getAnimationLength(that.putCardIntoPlayDuration / 4),
easing: "linear",
step: function(now, fx) {
var state = fx.state;
layoutCardElem(cardDiv,
startLeft + (oldValues["left"] - startLeft) * state,
startTop + (oldValues["top"] - startTop) * state,
startWidth + (oldValues["width"] - startWidth) * state,
startHeight + (oldValues["height"] - startHeight) * state, 100);
},
complete: next});
{
left: oldValues["left"]},
{
duration: that.getAnimationLength(that.putCardIntoPlayDuration / 4),
easing: "linear",
step: function(now, fx) {
var state = fx.state;
layoutCardElem(cardDiv,
startLeft + (oldValues["left"] - startLeft) * state,
startTop + (oldValues["top"] - startTop) * state,
startWidth + (oldValues["width"] - startWidth) * state,
startHeight + (oldValues["height"] - startHeight) * state, 100);
},
complete: next});
}).queue(
function(next) {
var cardDiv = $(".card:cardId(" + cardId + ")");
@@ -354,7 +354,7 @@ var GameAnimations = Class.extend({
if (index != -1)
cardData.attachedCards.splice(index, 1);
}
);
);
var card = $(".card:cardId(" + cardId + ")");
var cardData = card.data("card");
@@ -390,12 +390,12 @@ var GameAnimations = Class.extend({
function(next) {
$(".card:cardId(" + cardRemovedIds + ")")
.animate(
{
opacity: 0},
{
duration: that.getAnimationLength(that.removeCardFromPlayDuration),
easing: "easeOutQuart",
queue: false});
{
opacity: 0},
{
duration: that.getAnimationLength(that.removeCardFromPlayDuration),
easing: "easeOutQuart",
queue: false});
setTimeout(next, that.getAnimationLength(that.removeCardFromPlayDuration));
});
}
@@ -420,7 +420,7 @@ var GameAnimations = Class.extend({
if (index != -1)
cardData.attachedCards.splice(index, 1);
}
);
);
}
card.remove();

View File

@@ -25,24 +25,24 @@
for (var name in prop) {
// Check if we're overwriting an existing function
prototype[name] = typeof prop[name] == "function" &&
typeof _super[name] == "function" && fnTest.test(prop[name]) ?
(function(name, fn) {
return function() {
var tmp = this._super;
typeof _super[name] == "function" && fnTest.test(prop[name]) ?
(function(name, fn) {
return function() {
var tmp = this._super;
// Add a new ._super() method that is the same method
// but on the super-class
this._super = _super[name];
// Add a new ._super() method that is the same method
// but on the super-class
this._super = _super[name];
// The method only need to be bound temporarily, so we
// remove it when we're done executing
var ret = fn.apply(this, arguments);
this._super = tmp;
// The method only need to be bound temporarily, so we
// remove it when we're done executing
var ret = fn.apply(this, arguments);
this._super = tmp;
return ret;
};
})(name, prop[name]) :
prop[name];
return ret;
};
})(name, prop[name]) :
prop[name];
}
// The dummy class constructor

View File

@@ -128,7 +128,7 @@ var AdvPathCardGroup = CardGroup.extend({
function(first, second) {
return (first.data("card").siteNumber - second.data("card").siteNumber);
}
);
);
var cardCount = cardsToLayout.length;
var totalHeight = 0;

View File

@@ -9,12 +9,12 @@ var LeagueResultsUI = Class.extend({
this.questionDialog = $("<div></div>")
.dialog({
autoOpen: false,
closeOnEscape: true,
resizable: false,
modal: true,
title: "League operation"
});
autoOpen: false,
closeOnEscape: true,
resizable: false,
modal: true,
title: "League operation"
});
this.loadResults();
},

View File

@@ -68,20 +68,20 @@ var GempLotrMerchantUI = Class.extend({
this.infoDialog = $("<div></div>")
.dialog({
autoOpen: false,
closeOnEscape: true,
resizable: false,
title: "Card information"
});
autoOpen: false,
closeOnEscape: true,
resizable: false,
title: "Card information"
});
this.questionDialog = $("<div></div>")
.dialog({
autoOpen: false,
closeOnEscape: true,
resizable: false,
modal: true,
title: "Merchant operation"
});
autoOpen: false,
closeOnEscape: true,
resizable: false,
modal: true,
title: "Merchant operation"
});
var swipeOptions = {
threshold: 20,

View File

@@ -93,16 +93,16 @@
<script type="text/javascript" src="js/jquery/jquery.layout.js"></script>
<script type="text/javascript" src="js/jquery/jquery.touchSwipe.js"></script>
<script type="text/javascript" src="js/inheritance.js"></script>
<script type="text/javascript" src="js/common.js"></script>
<script type="text/javascript" src="js/communication.js"></script>
<script type="text/javascript" src="js/deliveryService.js"></script>
<script type="text/javascript" src="js/jCardGroup.js"></script>
<script type="text/javascript" src="js/jCards.js"></script>
<script type="text/javascript" src="js/logging.js"></script>
<script type="text/javascript" src="js/commonUi.js"></script>
<script type="text/javascript" src="js/merchantUi.js"></script>
<script type="text/javascript" src="js/cardFilter.js"></script>
<script type="text/javascript" src="js/gemp-001/inheritance.js"></script>
<script type="text/javascript" src="js/gemp-001/common.js"></script>
<script type="text/javascript" src="js/gemp-001/communication.js"></script>
<script type="text/javascript" src="js/gemp-001/deliveryService.js"></script>
<script type="text/javascript" src="js/gemp-001/jCardGroup.js"></script>
<script type="text/javascript" src="js/gemp-001/jCards.js"></script>
<script type="text/javascript" src="js/gemp-001/logging.js"></script>
<script type="text/javascript" src="js/gemp-001/commonUi.js"></script>
<script type="text/javascript" src="js/gemp-001/merchantUi.js"></script>
<script type="text/javascript" src="js/gemp-001/cardFilter.js"></script>
<script type="text/javascript">