* Fix some cases of not all decks being listed because the javascript code assumed that duplicate weights would never occur.

* Re-enable view cards page.
This commit is contained in:
Andy Janata 2018-02-27 13:59:56 -08:00
parent a94ba4a31c
commit d143791321
3 changed files with 16 additions and 23 deletions

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?>
<%--
Copyright (c) 2012-2017, Andy Janata
Copyright (c) 2012-2018, Andy Janata
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted
@ -132,11 +132,9 @@ HttpSession hSession = request.getSession(true);
</div>
<div id="menubar_right">
Current timer duration: <span id="current_timer">0</span> seconds
<%-- disabled as this page can kill the database server without caching
<input type="button" id="view_cards" value="View Cards"
title="Open a new window to view all cards in the game."
onclick="window.open('viewcards.jsp', 'viewcards');" />
--%>
<input type="button" id="logout" value="Log out" />
</div>
</div>

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, Andy Janata
* Copyright (c) 2012-2018, Andy Janata
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted
@ -177,6 +177,8 @@ cah.CardSet.prototype.getWeight = function() {
cah.CardSet.populateCardSets = function(cardSets) {
cah.CardSet.list = {};
cah.CardSet.byWeight = {};
// the server already sends us an ordered list, so let's just use that ordering
var i = 0;
for ( var key in cardSets) {
var cardSetData = cardSets[key];
var cardSet = new cah.CardSet(cardSetData[cah.$.CardSetData.ID],
@ -186,7 +188,7 @@ cah.CardSet.populateCardSets = function(cardSets) {
cardSetData[cah.$.CardSetData.BLACK_CARDS_IN_DECK],
cardSetData[cah.$.CardSetData.WHITE_CARDS_IN_DECK], cardSetData[cah.$.CardSetData.WEIGHT]);
cah.CardSet.list[cardSet.getId()] = cardSet;
cah.CardSet.byWeight[cardSetData[cah.$.CardSetData.WEIGHT]] = cardSet;
cah.CardSet.byWeight[i++] = cardSet;
}
// not sure if there's a better way to call this...

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?>
<%--
Copyright (c) 2013, Andy Janata
Copyright (c) 2013-2018, Andy Janata
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted
@ -26,7 +26,7 @@ Interface to view and search all existing cards and card sets.
@author Andy Janata (ajanata@socialgamer.net)
--%>
<%--
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.HashMap" %>
@ -36,6 +36,8 @@ Interface to view and search all existing cards and card sets.
<%@ page import="java.util.Map" %>
<%@ page import="java.util.Set" %>
<%@ page import="com.google.inject.Injector" %>
<%@ page import="com.google.inject.Key" %>
<%@ page import="net.socialgamer.cah.CahModule.IncludeInactiveCardsets" %>
<%@ page import="net.socialgamer.cah.HibernateUtil" %>
<%@ page import="net.socialgamer.cah.StartupUtils" %>
<%@ page import="net.socialgamer.cah.db.PyxBlackCard" %>
@ -48,15 +50,16 @@ Interface to view and search all existing cards and card sets.
ServletContext servletContext = pageContext.getServletContext();
Injector injector = (Injector) servletContext.getAttribute(StartupUtils.INJECTOR);
Properties props = injector.getInstance(Properties.class);
boolean includeInactive = injector.getInstance(Key.get(Boolean.TYPE, IncludeInactiveCardsets.class));
// cheap way to make sure we can close the hibernate session at the end of the page
try {
// load from db
@SuppressWarnings("unchecked")
List<PyxCardSet> cardSets = hibernateSession
.createQuery(PyxCardSet.getCardsetQuery(props))
.createQuery(PyxCardSet.getCardsetQuery(includeInactive))
.setReadOnly(true)
.setCacheable(true)
.list();
// all of the data to send to the client
@ -72,6 +75,7 @@ try {
Map<Integer, Object> cardSetsData = new HashMap<Integer, Object>();
data.put("cardSets", cardSetsData);
int i = 0;
for (PyxCardSet cardSet: cardSets) {
Map<String, Object> cardSetData = new HashMap<String, Object>();
cardSetData.put("name", cardSet.getName());
@ -100,7 +104,7 @@ try {
}
cardSetData.put("blackCards", blackCardIds);
cardSetsData.put(cardSet.getWeight(), cardSetData);
cardSetsData.put(i++, cardSetData);
}
Map<Integer, Object> blackCardsData = new HashMap<Integer, Object>();
@ -142,6 +146,7 @@ try {
<script type="text/javascript" src="js/QTransform.js"></script>
<script type="text/javascript" src="js/jquery-ui.min.js"></script>
<script type="text/javascript" src="js/jquery.tablesorter.js"></script>
<link rel="stylesheet" type="text/css" href="cah.css" media="screen" />
<link rel="stylesheet" type="text/css" href="jquery-ui.min.css" media="screen" />
<jsp:include page="analytics.jsp" />
<script type="text/javascript">
@ -208,7 +213,7 @@ table td {
}
</style>
</head>
<body>
<body style="overflow: scroll">
<div style="float: left;">
Show only cards from card sets (hold ctrl or cmd to select multiple):
<br/>
@ -243,15 +248,3 @@ table td {
hibernateSession.close();
}
%>
--%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Pretend You're Xyzzy: View Cards</title>
</head>
<body>
<p>This page has been disabled as it causes excess strain on server resources.</p>
</body>
</html>