Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: jaramir/houserule
base: caa9e2dca7
...
head fork: jaramir/houserule
compare: c077744fcc
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 23 files changed
  • 0 commit comments
  • 1 contributor
Commits on Mar 05, 2012
@jaramir tidy static
e3025b0
Commits on Mar 08, 2012
@jaramir qunit & common fixture
c077744
View
100 fixture/search_game.json
@@ -1,100 +0,0 @@
-[
- {"image": "http://cf.geekdo-images.com/images/pic1115825_t.jpg", "name": "7 Wonders: Catan Island"},
- {"image": "http://cf.geekdo-images.com/images/pic213744_t.jpg", "name": "Atlantis: Szenarien & Varianten zu Die Siedler von Catan"},
- {"image": "http://cf.geekdo-images.com/images/pic454336_t.jpg", "name": "CATAN 3D Collector's Edition"},
- {"image": "http://cf.geekdo-images.com/images/pic159473_t.jpg", "name": "Catan Austria / Wien meets Catan"},
- {"image": "http://cf.geekdo-images.com/images/pic135066_t.jpg", "name": "Catan Card Game"},
- {"image": "http://cf.geekdo-images.com/images/pic976200_t.jpg", "name": "Catan Dice Game"},
- {"image": "http://cf.geekdo-images.com/images/pic505434_t.jpg", "name": "Catan Dice Game Plus"},
- {"image": "http://cf.geekdo-images.com/images/pic501922_t.jpg", "name": "Catan Dice Game XXL Variant"},
- {"image": "http://cf.geekdo-images.com/images/pic595410_t.jpg", "name": "Catan Geographies: Bayern Edition"},
- {"image": "http://cf.geekdo-images.com/images/pic770449_t.jpg", "name": "Catan Geographies: Delmarva"},
- {"image": "http://cf.geekdo-images.com/images/pic594446_t.jpg", "name": "Catan Geographies: Germany"},
- {"image": "http://cf.geekdo-images.com/images/pic551862_t.jpg", "name": "Catan Geographies: Indiana & Ohio"},
- {"image": "http://cf.geekdo-images.com/images/pic389862_t.jpg", "name": "Catan Geographies: North Rhine - Westphalia"},
- {"image": "http://cf.geekdo-images.com/images/pic1038302_t.jpg", "name": "Catan Geographies: Penn-Jersey"},
- {"image": "http://cf.geekdo-images.com/images/pic259818_t.jpg", "name": "Catan Geographies: Settlers of Hesse"},
- {"image": "http://cf.geekdo-images.com/images/pic685614_t.jpg", "name": "Settlers of America: Trails to Rails"},
- {"image": "http://cf.geekdo-images.com/images/pic329096_t.jpg", "name": "Struggle for Rome"},
- {"image": "http://cf.geekdo-images.com/images/pic1172540_t.jpg", "name": "Catan Scenarios: Oil Springs"},
- {"image": "http://cf.geekdo-images.com/images/pic268845_t.jpg", "name": "Catan: Cities & Knights"},
- {"image": "http://cf.geekdo-images.com/images/pic268842_t.jpg", "name": "Catan: Cities & Knights - 5-6 Player Extension"},
- {"image": "http://cf.geekdo-images.com/images/pic38906_t.jpg", "name": "Catan: Das Kartenspiel; CD-Rom"},
- {"image": "http://cf.geekdo-images.com/images/pic289674_t.jpg", "name": "Die Siedler von N\u00fcrnberg"},
- {"image": "http://cf.geekdo-images.com/images/pic160314_t.jpg", "name": "Catan: Event Cards"},
- {"image": "http://cf.geekdo-images.com/images/pic1200270_t.jpg", "name": "Catan: Junior"},
- {"image": "http://cf.geekdo-images.com/images/pic268841_t.jpg", "name": "Catan: Seafarers"},
- {"image": "http://cf.geekdo-images.com/images/pic268843_t.jpg", "name": "Catan: Seafarers - 5-6 Player Extension"},
- {"image": "http://cf.geekdo-images.com/images/pic353394_t.jpg", "name": "Catan: Traders & Barbarians"},
- {"image": "http://cf.geekdo-images.com/images/pic387929_t.jpg", "name": "Catan: Traders & Barbarians: 5-6 Player Extension"},
- {"image": "http://cf.geekdo-images.com/images/pic55678_t.jpg", "name": "The Communication in Catan"},
- {"image": "http://cf.geekdo-images.com/images/pic121747_t.jpg", "name": "Elasund: The First City of Catan"},
- {"image": "http://cf.geekdo-images.com/images/pic845298_t.jpg", "name": "Die Helfer von Catan"},
- {"image": "http://cf.geekdo-images.com/images/pic890806_t.jpg", "name": "Hexen, Zauberer & Drachen (Fan expansion to Catan: Cities and Knights)"},
- {"image": "http://cf.geekdo-images.com/images/pic106752_t.jpg", "name": "Im Zeichen des Sechsecks - Klaus Teuber & Die Siedler von Catan"},
- {"image": "http://cf.geekdo-images.com/images/pic222987_t.jpg", "name": "The Kids of Catan"},
- {"image": "http://cf.geekdo-images.com/images/pic891139_t.jpg", "name": "Kirche, Glaube & Reformation (Fan expansion to Catan: Cities and Knights)"},
- {"image": "http://cf.geekdo-images.com/images/pic542713_t.jpg", "name": "Kolonisten van Catan Lage Landen"},
- {"image": "http://cf.geekdo-images.com/images/pic123506_t.jpg", "name": "De Kolonisten van Catan: De Diamanten"},
- {"image": "http://cf.geekdo-images.com/images/pic279156_t.jpg", "name": "De Kolonisten van Catan: De Koloni\u00ebn"},
- {"image": "http://cf.geekdo-images.com/images/pic654178_t.jpg", "name": "De Kolonisten van Catan: De Specialisten"},
- {"image": "http://cf.geekdo-images.com/images/pic123663_t.jpg", "name": "De Kolonisten van Catan: De Wereldwonderen"},
- {"image": "http://cf.geekdo-images.com/images/pic123693_t.jpg", "name": "De Kolonisten van Catan: De Woestijnruiters"},
- {"image": "http://cf.geekdo-images.com/images/pic449532_t.jpg", "name": "De Kolonisten van Catan: De drie Handelsteden van Noord-Nederland"},
- {"image": "http://cf.geekdo-images.com/images/pic123592_t.jpg", "name": "De Kolonisten van Catan: Het Grote Kanaal"},
- {"image": "http://cf.geekdo-images.com/images/pic360139_t.jpg", "name": "De Kolonisten van Catan: Het Kaartspel; Goud & Piraten"},
- {"image": "http://cf.geekdo-images.com/images/pic285215_t.jpg", "name": "De Kolonisten van Catan: Wegwerpcatan"},
- {"image": "http://cf.geekdo-images.com/images/pic850850_t.jpg", "name": "The Rivals for Catan"},
- {"image": "http://cf.geekdo-images.com/images/pic1101867_t.jpg", "name": "The Rivals for Catan: Age of Darkness"},
- {"image": "http://cf.geekdo-images.com/images/pic118001_t.jpg", "name": "Saggsen-Gadan - De s\u00e4ggs'schn Siedler / Catan-OFFENSIVE in Chemnitz"},
- {"image": "http://cf.geekdo-images.com/images/pic268839_t.jpg", "name": "The Settlers of Catan"},
- {"image": "http://cf.geekdo-images.com/images/pic255527_t.jpg", "name": "The Settlers of Catan Card Game Expansions"},
- {"image": "http://cf.geekdo-images.com/images/pic508907_t.jpg", "name": "The Settlers of Catan Card Game: Artisans & Benefactors"},
- {"image": "http://cf.geekdo-images.com/images/pic91182_t.jpg", "name": "Settlers of Catan Card Game: Barbarians and Traders Upgrade Kit"},
- {"image": "http://cf.geekdo-images.com/images/pic268840_t.jpg", "name": "The Settlers of Catan: 5-6 Player Extension"},
- {"image": "http://cf.geekdo-images.com/images/pic1248578_t.jpg", "name": "Settlers of Catan: Gallery Edition"},
- {"image": "http://cf.geekdo-images.com/images/pic85261_t.jpg", "name": "Settlers of Catan: Rockman Edition"},
- {"image": "http://cf.geekdo-images.com/images/pic154599_t.jpg", "name": "The Settlers of Catan: The Fishermen of Catan"},
- {"image": "http://cf.geekdo-images.com/images/pic162701_t.jpg", "name": "The Settlers of Catan: The Great River"},
- {"image": "http://cf.geekdo-images.com/images/pic420435_t.jpg", "name": "The Settlers of Catan: Travel Edition"},
- {"image": "http://cf.geekdo-images.com/images/pic44794_t.jpg", "name": "Settlers of New Catan (and extra modules)"},
- {"image": "http://cf.geekdo-images.com/images/pic515731_t.jpg", "name": "Die Siedler von Catan - Das W\u00fcrfelspiel - XXL-Ausgabe"},
- {"image": "http://cf.geekdo-images.com/images/pic377907_t.jpg", "name": "Die Siedler von Luxemburg"},
- {"image": "http://cf.geekdo-images.com/images/pic674059_t.jpg", "name": "Die Siedler von Catan - Einsteiger-Variante"},
- {"image": "http://cf.geekdo-images.com/images/pic215049_t.jpg", "name": "Die Siedler von Catan - Kartenspiel: Handel & Wandel"},
- {"image": "http://cf.geekdo-images.com/images/pic214552_t.jpg", "name": "Die Siedler von Catan - Kartenspiel: Politik & Intrige"},
- {"image": "http://cf.geekdo-images.com/images/pic214534_t.jpg", "name": "Die Siedler von Catan - Kartenspiel: Ritter & H\u00e4ndler"},
- {"image": "http://cf.geekdo-images.com/images/pic214548_t.jpg", "name": "Die Siedler von Catan - Kartenspiel: Wissenschaft & Fortschritt"},
- {"image": "http://cf.geekdo-images.com/images/pic214545_t.jpg", "name": "Die Siedler von Catan - Kartenspiel: Zauberer & Drachen"},
- {"image": null, "name": "Die Siedler von Catan - Th\u00fcringen Edition"},
- {"image": "http://cf.geekdo-images.com/images/pic1043525_t.jpg", "name": "Die Siedler von Catan: Aufbruch der H\u00e4ndler"},
- {"image": "http://cf.geekdo-images.com/images/pic677813_t.jpg", "name": "Die Siedler von Catan: Das Buch zum Spielen"},
- {"image": "http://cf.geekdo-images.com/images/pic976404_t.png", "name": "Die Siedler von Catan: Das Kartenspiel - Sonderkarte 2003"},
- {"image": "http://cf.geekdo-images.com/images/pic976406_t.png", "name": "Die Siedler von Catan: Das Kartenspiel - Sonderkarte 2004"},
- {"image": "http://cf.geekdo-images.com/images/pic976407_t.png", "name": "Die Siedler von Catan: Das Kartenspiel - Sonderkarte 2005"},
- {"image": "http://cf.geekdo-images.com/images/pic976408_t.png", "name": "Die Siedler von Catan: Das Kartenspiel - Sonderkarte 2006"},
- {"image": "http://cf.geekdo-images.com/images/pic976222_t.png", "name": "Die Siedler von Catan: Das Kartenspiel - Sonderkarte 2007"},
- {"image": "http://cf.geekdo-images.com/images/pic976175_t.png", "name": "Die Siedler von Catan: Das Kartenspiel - Sonderkarte 2008"},
- {"image": "http://cf.geekdo-images.com/images/pic976174_t.png", "name": "Die Siedler von Catan: Das Kartenspiel - Sonderkarte 2009"},
- {"image": "http://cf.geekdo-images.com/images/pic293835_t.jpg", "name": "Die Siedler von Catan: Das Kartenspiel; 10th Anniversary Special Edition Tin Box"},
- {"image": "http://cf.geekdo-images.com/images/pic202307_t.jpg", "name": "Siedler von Catan: Das Turnier-Set zum Kartenspiel"},
- {"image": "http://cf.geekdo-images.com/images/pic851519_t.jpg", "name": "Die Siedler von Catan: Der Schokoladenmarkt"},
- {"image": "http://cf.geekdo-images.com/images/pic901061_t.jpg", "name": "Die Siedler von Catan: Die Pioniere (fan expansion for The Settlers of Catan)"},
- {"image": "http://cf.geekdo-images.com/images/pic155197_t.jpg", "name": "Die Siedler von Catan: Die gro\u00dfe Karawane"},
- {"image": "http://cf.geekdo-images.com/images/pic126215_t.jpg", "name": "Die Siedler von Catan: Historische Szenarien"},
- {"image": "http://cf.geekdo-images.com/images/pic319503_t.jpg", "name": "Die Siedler von Catan: Historische Szenarien II"},
- {"image": "http://cf.geekdo-images.com/images/pic95149_t.jpg", "name": "Die Siedler von Catan: Paper & Pencil"},
- {"image": "http://cf.geekdo-images.com/images/pic258583_t.jpg", "name": "Die Siedler von Catan: Renaissance in der Steiermark & Burgbau auf Chaffenberch"},
- {"image": "http://cf.geekdo-images.com/images/pic359344_t.jpg", "name": "Die Siedler von Catan: Rincewind und der Tourist"},
- {"image": "http://cf.geekdo-images.com/images/pic585637_t.jpg", "name": "Die Siedler von Catan: Sch\u00e4tze, Drachen & Entdecker"},
- {"image": "http://cf.geekdo-images.com/images/pic835734_t.jpg", "name": "Die Siedler von Catan: \u00d6sterreich Edition"},
- {"image": "http://cf.geekdo-images.com/images/pic195977_t.jpg", "name": "Simply Catan"},
- {"image": "http://cf.geekdo-images.com/images/pic1210879_t.jpg", "name": "Star Trek Catan"},
- {"image": "http://cf.geekdo-images.com/images/pic159131_t.jpg", "name": "Starfarers of Catan"},
- {"image": "http://cf.geekdo-images.com/images/pic163914_t.jpg", "name": "Starfarers of Catan 5-6 Player Expansion"},
- {"image": "http://cf.geekdo-images.com/images/pic149643_t.jpg", "name": "Starship Catan"},
- {"image": "http://cf.geekdo-images.com/images/pic196562_t.jpg", "name": "Starship Catan - 1st Mission: The Space Amoeba"},
- {"image": "http://cf.geekdo-images.com/images/pic196588_t.jpg", "name": "Starship Catan - 2nd Mission: The Asteroid"},
- {"image": "http://cf.geekdo-images.com/images/pic196497_t.jpg", "name": "Starship Catan - 3rd Mission: The Diplomatic Station"},
- {"image": "http://cf.geekdo-images.com/images/pic918589_t.jpg", "name": "The Struggle for Catan"}
-]
View
19 static/css/main.css
@@ -0,0 +1,19 @@
+#games {
+ border: 2px solid black;
+ height: 300px;
+ overflow-y: scroll;
+}
+
+#games .game {
+ border: 1px solid #CCCCCC;
+ display: inline-block;
+ height: 190px;
+ text-align: center;
+ width: 220px;
+ vertical-align: middle; /* viene ignorata ma serve!? o_O */
+}
+
+#games .game span {
+ display: block;
+ font-size: smaller;
+}
View
0  static/qunit.css → static/css/qunit.css
File renamed without changes
View
9 static/fixture/search_game.json
@@ -0,0 +1,9 @@
+[
+ {"image": "http://cf.geekdo-images.com/images/pic1115825_t.jpg", "name": "7 Wonders: Catan Island"},
+ {"image": "http://cf.geekdo-images.com/images/pic135066_t.jpg", "name": "Catan Card Game"},
+ {"image": "http://cf.geekdo-images.com/images/pic976200_t.jpg", "name": "Catan Dice Game"},
+ {"image": null, "name": "Die Siedler von Catan - Th\u00fcringen Edition"},
+ {"image": "http://cf.geekdo-images.com/images/pic195977_t.jpg", "name": "Simply Catan"},
+ {"image": "http://cf.geekdo-images.com/images/pic1210879_t.jpg", "name": "Star Trek Catan"},
+ {"image": "http://cf.geekdo-images.com/images/pic918589_t.jpg", "name": "The Struggle for Catan"}
+]
View
0  static/jquery-1.7.1.min.js → static/js/jquery-1.7.1.min.js
File renamed without changes
View
0  static/jquery-ui-1.8.18.custom.min.js → static/js/jquery-ui-1.8.18.custom.min.js
File renamed without changes
View
409 static/js/jquery.mockjax.js
@@ -0,0 +1,409 @@
+/*!
+ * MockJax - jQuery Plugin to Mock Ajax requests
+ *
+ * Version: 1.5.0pre
+ * Released:
+ * Home: http://github.com/appendto/jquery-mockjax
+ * Author: Jonathan Sharp (http://jdsharp.com)
+ * License: MIT,GPL
+ *
+ * Copyright (c) 2011 appendTo LLC.
+ * Dual licensed under the MIT or GPL licenses.
+ * http://appendto.com/open-source-licenses
+ */
+(function($) {
+ var _ajax = $.ajax,
+ mockHandlers = [];
+
+ function parseXML(xml) {
+ if ( window['DOMParser'] == undefined && window.ActiveXObject ) {
+ DOMParser = function() { };
+ DOMParser.prototype.parseFromString = function( xmlString ) {
+ var doc = new ActiveXObject('Microsoft.XMLDOM');
+ doc.async = 'false';
+ doc.loadXML( xmlString );
+ return doc;
+ };
+ }
+
+ try {
+ var xmlDoc = ( new DOMParser() ).parseFromString( xml, 'text/xml' );
+ if ( $.isXMLDoc( xmlDoc ) ) {
+ var err = $('parsererror', xmlDoc);
+ if ( err.length == 1 ) {
+ throw('Error: ' + $(xmlDoc).text() );
+ }
+ } else {
+ throw('Unable to parse XML');
+ }
+ } catch( e ) {
+ var msg = ( e.name == undefined ? e : e.name + ': ' + e.message );
+ $(document).trigger('xmlParseError', [ msg ]);
+ return undefined;
+ }
+ return xmlDoc;
+ }
+
+ $.extend({
+ ajax: function(url, origSettings) {
+ // If url is an object, simulate pre-1.5 signature
+ if ( typeof url === "object" ) {
+ origSettings = url;
+ url = undefined;
+ } else {
+ // work around to support 1.5 signature
+ origSettings.url = url;
+ }
+ var s = jQuery.extend(true, {}, jQuery.ajaxSettings, origSettings),
+ mock = false;
+ // Iterate over our mock handlers (in registration order) until we find
+ // one that is willing to intercept the request
+ $.each(mockHandlers, function(k, v) {
+ if ( !mockHandlers[k] ) {
+ return;
+ }
+ var m = null;
+ // If the mock was registered with a function, let the function decide if we
+ // want to mock this request
+ if ( $.isFunction(mockHandlers[k]) ) {
+ m = mockHandlers[k](s);
+ } else {
+ m = mockHandlers[k];
+ // Inspect the URL of the request and check if the mock handler's url
+ // matches the url for this ajax request
+ if ( $.isFunction(m.url.test) ) {
+ // The user provided a regex for the url, test it
+ if ( !m.url.test( s.url ) ) {
+ m = null;
+ }
+ } else {
+ // Look for a simple wildcard '*' or a direct URL match
+ var star = m.url.indexOf('*');
+ if (m.url !== s.url && star === -1 || !new RegExp(m.url.replace(/[-[\]{}()+?.,\\^$|#\s]/g, "\\$&").replace('*', '.+')).test(s.url)) {
+ m = null;
+ }
+ }
+ if ( m ) {
+ // Inspect the data submitted in the request (either POST body or GET query string)
+ if ( m.data && s.data ) {
+ var identical = false;
+ // Deep inspect the identity of the objects
+ (function ident(mock, live) {
+ // Test for situations where the data is a querystring (not an object)
+ if (typeof live === 'string') {
+ // Querystring may be a regex
+ identical = $.isFunction( mock.test ) ? mock.test(live) : mock == live;
+ return identical;
+ }
+ $.each(mock, function(k, v) {
+ if ( live[k] === undefined ) {
+ identical = false;
+ return false;
+ } else {
+ identical = true;
+ if ( typeof live[k] == 'object' ) {
+ return ident(mock[k], live[k]);
+ } else {
+ if ( $.isFunction( mock[k].test ) ) {
+ identical = mock[k].test(live[k]);
+ } else {
+ identical = ( mock[k] == live[k] );
+ }
+ return identical;
+ }
+ }
+ });
+ })(m.data, s.data);
+ // They're not identical, do not mock this request
+ if ( identical == false ) {
+ m = null;
+ }
+ }
+ // Inspect the request type
+ if ( m && m.type && m.type.toLowerCase() != s.type.toLowerCase() ) {
+ // The request type doesn't match (GET vs. POST)
+ m = null;
+ }
+ }
+ }
+ if ( m ) {
+ mock = true;
+
+ // Handle console logging
+ var c = $.extend({}, $.mockjaxSettings, m);
+ if ( c.log && $.isFunction(c.log) ) {
+ c.log('MOCK ' + s.type.toUpperCase() + ': ' + s.url, $.extend({}, s));
+ }
+
+ var jsre = /=\?(&|$)/, jsc = (new Date()).getTime();
+
+ // Handle JSONP Parameter Callbacks, we need to replicate some of the jQuery core here
+ // because there isn't an easy hook for the cross domain script tag of jsonp
+ if ( s.dataType === "jsonp" ) {
+ if ( s.type.toUpperCase() === "GET" ) {
+ if ( !jsre.test( s.url ) ) {
+ s.url += (/\?/.test( s.url ) ? "&" : "?") + (s.jsonp || "callback") + "=?";
+ }
+ } else if ( !s.data || !jsre.test(s.data) ) {
+ s.data = (s.data ? s.data + "&" : "") + (s.jsonp || "callback") + "=?";
+ }
+ s.dataType = "json";
+ }
+
+ // Build temporary JSONP function
+ if ( s.dataType === "json" && (s.data && jsre.test(s.data) || jsre.test(s.url)) ) {
+ jsonp = s.jsonpCallback || ("jsonp" + jsc++);
+
+ // Replace the =? sequence both in the query string and the data
+ if ( s.data ) {
+ s.data = (s.data + "").replace(jsre, "=" + jsonp + "$1");
+ }
+
+ s.url = s.url.replace(jsre, "=" + jsonp + "$1");
+
+ // We need to make sure
+ // that a JSONP style response is executed properly
+ s.dataType = "script";
+
+ // Handle JSONP-style loading
+ window[ jsonp ] = window[ jsonp ] || function( tmp ) {
+ data = tmp;
+ success();
+ complete();
+ // Garbage collect
+ window[ jsonp ] = undefined;
+
+ try {
+ delete window[ jsonp ];
+ } catch(e) {}
+
+ if ( head ) {
+ head.removeChild( script );
+ }
+ };
+ }
+
+ var rurl = /^(\w+:)?\/\/([^\/?#]+)/,
+ parts = rurl.exec( s.url ),
+ remote = parts && (parts[1] && parts[1] !== location.protocol || parts[2] !== location.host);
+
+ // Test if we are going to create a script tag (if so, intercept & mock)
+ if ( s.dataType === "script" && s.type.toUpperCase() === "GET" && remote ) {
+ // Synthesize the mock request for adding a script tag
+ var callbackContext = origSettings && origSettings.context || s;
+
+ function success() {
+ // If a local callback was specified, fire it and pass it the data
+ if ( s.success ) {
+ s.success.call( callbackContext, ( m.response ? m.response.toString() : m.responseText || ''), status, {} );
+ }
+
+ // Fire the global callback
+ if ( s.global ) {
+ trigger( "ajaxSuccess", [{}, s] );
+ }
+ }
+
+ function complete() {
+ // Process result
+ if ( s.complete ) {
+ s.complete.call( callbackContext, {} , status );
+ }
+
+ // The request was completed
+ if ( s.global ) {
+ trigger( "ajaxComplete", [{}, s] );
+ }
+
+ // Handle the global AJAX counter
+ if ( s.global && ! --jQuery.active ) {
+ jQuery.event.trigger( "ajaxStop" );
+ }
+ }
+
+ function trigger(type, args) {
+ (s.context ? jQuery(s.context) : jQuery.event).trigger(type, args);
+ }
+
+ if ( m.response && $.isFunction(m.response) ) {
+ m.response(origSettings);
+ } else {
+ $.globalEval(m.responseText);
+ }
+ success();
+ complete();
+ return false;
+ }
+
+ m.data = s.data;
+ m.cache = s.cache;
+ m.timeout = s.timeout;
+ m.global = s.global;
+
+ mock = _ajax.call($, $.extend(true, {}, origSettings, {
+ // Mock the XHR object
+ xhr: function() {
+ // Extend with our default mockjax settings
+ m = $.extend({}, $.mockjaxSettings, m);
+
+ if (typeof m.headers === 'undefined') {
+ m.headers = {};
+ }
+ if ( m.contentType ) {
+ m.headers['content-type'] = m.contentType;
+ }
+
+ // Return our mock xhr object
+ return {
+ status: m.status,
+ readyState: 1,
+ open: function() { },
+ send: function() {
+
+ mockHandlers[k].fired = true;
+
+ // This is a substitute for < 1.4 which lacks $.proxy
+ var process = (function(that) {
+ return function() {
+ return (function() {
+ // The request has returned
+ this.status = m.status;
+ this.readyState = 4;
+
+ // We have an executable function, call it to give
+ // the mock handler a chance to update it's data
+ if ( $.isFunction(m.response) ) {
+ m.response(origSettings);
+ }
+ // Copy over our mock to our xhr object before passing control back to
+ // jQuery's onreadystatechange callback
+ if ( s.dataType == 'json' && ( typeof m.responseText == 'object' ) ) {
+ this.responseText = JSON.stringify(m.responseText);
+ } else if ( s.dataType == 'xml' ) {
+ if ( typeof m.responseXML == 'string' ) {
+ this.responseXML = parseXML(m.responseXML);
+ } else {
+ this.responseXML = m.responseXML;
+ }
+ } else {
+ this.responseText = m.responseText;
+ }
+ if( typeof m.status == 'number' || typeof m.status == 'string' ) {
+ this.status = m.status;
+ }
+ // jQuery < 1.4 doesn't have onreadystate change for xhr
+ if ( $.isFunction(this.onreadystatechange) ) {
+ this.onreadystatechange( m.isTimeout ? 'timeout' : undefined );
+ }
+ }).apply(that);
+ };
+ })(this);
+
+ if ( m.proxy ) {
+ // We're proxying this request and loading in an external file instead
+ _ajax({
+ global: false,
+ url: m.proxy,
+ type: m.proxyType,
+ data: m.data,
+ dataType: s.dataType,
+ complete: function(xhr, txt) {
+ m.responseXML = xhr.responseXML;
+ m.responseText = xhr.responseText;
+ m.status = xhr.status;
+ this.responseTimer = setTimeout(process, m.responseTime || 0);
+ }
+ });
+ } else {
+ // type == 'POST' || 'GET' || 'DELETE'
+ if ( s.async === false ) {
+ // TODO: Blocking delay
+ process();
+ } else {
+ this.responseTimer = setTimeout(process, m.responseTime || 50);
+ }
+ }
+ },
+ abort: function() {
+ clearTimeout(this.responseTimer);
+ },
+ setRequestHeader: function(header, value) {
+ m.headers[header] = value;
+ },
+ getResponseHeader: function(header) {
+ // 'Last-modified', 'Etag', 'content-type' are all checked by jQuery
+ if ( m.headers && m.headers[header] ) {
+ // Return arbitrary headers
+ return m.headers[header];
+ } else if ( header.toLowerCase() == 'last-modified' ) {
+ return m.lastModified || (new Date()).toString();
+ } else if ( header.toLowerCase() == 'etag' ) {
+ return m.etag || '';
+ } else if ( header.toLowerCase() == 'content-type' ) {
+ return m.contentType || 'text/plain';
+ }
+ },
+ getAllResponseHeaders: function() {
+ var headers = '';
+ $.each(m.headers, function(k, v) {
+ headers += k + ': ' + v + "\n";
+ });
+ return headers;
+ }
+ };
+ }
+ }));
+ return false;
+ }
+ });
+ // We don't have a mock request, trigger a normal request
+ if ( !mock ) {
+ return _ajax.apply($, arguments);
+ } else {
+ return mock;
+ }
+ }
+ });
+
+ $.mockjaxSettings = {
+ //url: null,
+ //type: 'GET',
+ log: function(msg) {
+ window['console'] && window.console.log && window.console.log(msg);
+ },
+ status: 200,
+ responseTime: 500,
+ isTimeout: false,
+ contentType: 'text/plain',
+ response: '',
+ responseText: '',
+ responseXML: '',
+ proxy: '',
+ proxyType: 'GET',
+
+ lastModified: null,
+ etag: '',
+ headers: {
+ etag: 'IJF@H#@923uf8023hFO@I#H#',
+ 'content-type' : 'text/plain'
+ }
+ };
+
+ $.mockjax = function(settings) {
+ var i = mockHandlers.length;
+ mockHandlers[i] = settings;
+ return i;
+ };
+ $.mockjaxClear = function(i) {
+ if ( arguments.length == 1 ) {
+ mockHandlers[i] = null;
+ } else {
+ mockHandlers = [];
+ }
+ };
+ $.mockjax.handler = function(i) {
+ if ( arguments.length == 1 ) {
+ return mockHandlers[i];
+ }
+ };
+})(jQuery);
View
30 static/js/main.js
@@ -0,0 +1,30 @@
+(function( $ ) {
+
+$.widget( "hr.game_finder", {
+ _create: function() {
+ var o = this.options;
+ var e = this.element;
+ },
+ search: function( term ) {
+ var hdlr = this;
+ $.getJSON(
+ "/search/game", { term: term },
+ function( data, textStatus, jqXHR ) {
+ $.each( data, function( idx, item ) {
+ hdlr.add_item( item );
+ } );
+ }
+ );
+ },
+ add_item: function( item ) {
+ if( item.image )
+ $(this.element).append( '<div class="game"><img src="' + item.image + '" /><span>' + item.name + '</span></div>' );
+ else
+ $(this.element).append( '<div class="game"><span>' + item.name + '</span></div>' );
+ },
+ destroy: function() {
+ this.element.children().remove();
+ }
+} );
+
+})( jQuery );
View
0  static/qunit.js → static/js/qunit.js
File renamed without changes
View
43 static/js/test.js
@@ -0,0 +1,43 @@
+$.mockjax( {
+ url: '/search/game', // ?term=catan
+ proxy: '/static/fixture/search_game.json'
+} );
+
+module( "game_finder", {
+ setup: function() {
+ var onclick = "$('#finder').data('game_finder').search($('#term').val());"
+ $("#qunit-fixture").html(
+ '<div id="finder"></div>' +
+ '<input type="text" id="term" />' +
+ '<input type="button" id="goto" onclick="' + onclick + '" />'
+ );
+ $("#finder").game_finder();
+ }
+} );
+
+test( "we can search for catan", function() {
+ $( '#term', $("#qunit-fixture") ).val( "catan" );
+ $( '#goto', $("#qunit-fixture") ).click();
+
+ expect( 3 );
+ stop(); // give it some time..
+
+ setTimeout( function() {
+ equal(
+ $( '.game', $("#finder") ).length, 7,
+ "game_finder should contain seven .game elements"
+ );
+ equal(
+ $( '.game img', $("#finder") ).first().attr( "src" ),
+ "http://cf.geekdo-images.com/images/pic1115825_t.jpg",
+ "game_finder should contain 7 Wonders: Catan Island (image)"
+ );
+ equal(
+ $( '.game span', $("#finder") ).first().html(),
+ "7 Wonders: Catan Island",
+ "game_finder should contain 7 Wonders: Catan Island (text)"
+ );
+ start();
+ }, 750 );
+
+} );
View
3  static/main.css
@@ -1,3 +0,0 @@
-.hilite {
- background-color: green;
-}
View
46 static/main.js
@@ -1,46 +0,0 @@
-(function( $ ) {
-
-$.widget( "hr.game_finder", {
- options: {
- },
- _create: function() {
- var o = this.options;
- var e = $(this.element);
-
- this.text = $( '<input type="text"/>' );
- e.append(this.text);
-
- this.button = $( '<input type="button" value="Cerca"/>' );
- e.append(this.button);
-
- this.button.bind( "click.game_finder", $.proxy( this, "search" ) );
- },
- search: function() {
- this.add_item( { name: "Catan", image: null } );
- /*
- $.ajax( {
- type: "GET",
- url: "/search/game",
- data: {
- term: $("#game_search").val()
- },
- dataType: "json",
- success: function( data, textStatus, jqXHR ) {
- var r = $( "#game_search_results" );
- r.html( "" );
- $.each( data, function( idx, item ) {
- r.append( $( '<div class="game"><img src="' + item.image + '" /><span>' + item.name + '</span></div>' ) );
- } );
- }
- } );
- */
- },
- add_item: function( item ) {
- $(this.element).append( '<div class="game"><img src="' + item.iamge + '" /><span>' + item.name + '</span></div>' );
- },
- destroy: function() {
- this.element.children().remove();
- }
-} );
-
-})( jQuery );
View
0  static/banner.jpg → static/media/banner.jpg
File renamed without changes
View
0  static/banner2.jpg → static/media/banner2.jpg
File renamed without changes
View
0  static/bgg_cornerlogo.png → static/media/bgg_cornerlogo.png
File renamed without changes
View
0  static/favicon.ico → static/media/favicon.ico
File renamed without changes
View
0  static/logo.jpg → static/media/logo.jpg
File renamed without changes
View
50 static/test.js
@@ -1,50 +0,0 @@
-test( "fixture is working", function() {
- $("#qunit-fixture").html( '<div id="test_element"></div>' );
-
- ok(
- $( "#test_element", $("#qunit-fixture") ).length == 1,
- "qunit-fixture is not working"
- );
-} );
-
-test( "can create a game finder", function() {
- $("#qunit-fixture").html( '<div id="test_search_game"></div>' );
- $("#test_search_game").game_finder();
-
- ok(
- $( "#test_search_game", $("#qunit-fixture") ).length == 1,
- "game_finder initialization failed"
- );
-} );
-
-test( "game finder has an input", function() {
- $("#qunit-fixture").html( '<div id="test_search_game"></div>' );
- $("#test_search_game").game_finder();
-
- ok(
- $( 'input[type="text"]', $("#test_search_game") ).length == 1,
- 'game_finder should contain an input[type="text"] element'
- );
-} );
-
-test( "game finder has a button", function() {
- $("#qunit-fixture").html( '<div id="test_search_game"></div>' );
- $("#test_search_game").game_finder();
-
- ok(
- $( 'input[type="button"]', $("#test_search_game") ).length == 1,
- 'game_finder should contain an input[type="button"] element'
- );
-} );
-
-test( "we can search for catan", function() {
- $("#qunit-fixture").html( '<div id="test_search_game"></div>' );
- $("#test_search_game").game_finder();
- $( 'input[type="text"]', $("#test_search_game") ).val( "catan" );
- $( 'input[type="button"]', $("#test_search_game") ).click();
-
- ok(
- $( '.game', $("#test_search_game") ).length > 0,
- "game_finder should contain some .game elements"
- );
-} );
View
12 templates/layout.html
@@ -2,14 +2,14 @@
<html>
<head>
<title>HouseRule</title>
- <link rel="stylesheet" href="{{ url_for( 'static', filename='main.css' ) }}" />
- <link rel="shortcut icon" href="{{ url_for( 'static', filename='favicon.ico' ) }}" />
+ <link rel="stylesheet" href="{{ url_for( 'static', filename='css/main.css' ) }}" />
+ <link rel="shortcut icon" href="{{ url_for( 'static', filename='media/favicon.ico' ) }}" />
{% block css %}{% endblock %}
</head>
<body>
<a href="{{ url_for( "index" ) }}">
- <img id="logo" src="{{ url_for( "static", filename="logo.jpg" ) }}">
+ <img id="logo" src="{{ url_for( "static", filename="media/logo.jpg" ) }}">
</a>
{% with messages = get_flashed_messages() %}
@@ -40,9 +40,9 @@
</script>
<!-- google analytics end -->
- <script type="text/javascript" src="{{ url_for( "static", filename="jquery-1.7.1.min.js" ) }}"></script>
- <script type="text/javascript" src="{{ url_for( "static", filename="jquery-ui-1.8.18.custom.min.js" ) }}"></script>
- <script type="text/javascript" src="{{ url_for( "static", filename="main.js" ) }}"></script>
+ <script type="text/javascript" src="{{ url_for( "static", filename="js/jquery-1.7.1.min.js" ) }}"></script>
+ <script type="text/javascript" src="{{ url_for( "static", filename="js/jquery-ui-1.8.18.custom.min.js" ) }}"></script>
+ <script type="text/javascript" src="{{ url_for( "static", filename="js/main.js" ) }}"></script>
{% block js %}{% endblock %}
</body>
View
6 templates/match.html
@@ -3,7 +3,9 @@
{% block body %}
<div>
- <div id="game_finder"></div>
+ <input type="text" id="term"/>
+ <input type="button" value="Cerca" onclick="$('#games').data('game_finder').search($('#term').val());"/>
+ <div id="games"></div>
</div>
<form method="POST" action="{{ url_for( "match" ) }}">
@@ -18,7 +20,7 @@
<script type="text/javascript">
$(document).ready( function() {
- $("#game_finder").game_finder();
+ $("#games").game_finder();
} );
</script>
View
7 templates/qunit.html
@@ -1,7 +1,7 @@
{% extends "layout.html" %}
{% block css %}
- <link rel="stylesheet" href="{{ url_for( "static", filename="qunit.css" ) }}">
+ <link rel="stylesheet" href="{{ url_for( "static", filename="css/qunit.css" ) }}">
{% endblock %}
{% block body %}
@@ -10,6 +10,7 @@
{% endblock %}
{% block js %}
- <script src="{{ url_for( "static", filename="qunit.js" ) }}"></script>
- <script src="{{ url_for( "static", filename="test.js" ) }}"></script>
+ <script src="{{ url_for( "static", filename="js/jquery.mockjax.js" ) }}"></script>
+ <script src="{{ url_for( "static", filename="js/qunit.js" ) }}"></script>
+ <script src="{{ url_for( "static", filename="js/test.js" ) }}"></script>
{% endblock %}
View
4 templates/splash.html
@@ -2,11 +2,11 @@
<html>
<head>
<title>HouseRule</title>
- <link rel="shortcut icon" href="{{ url_for( 'static', filename='favicon.ico' ) }}" />
+ <link rel="shortcut icon" href="{{ url_for( 'static', filename='media/favicon.ico' ) }}" />
<meta name="description" content="HouseRule: Troviamoci a Giocare! Un sito per organizzare partite di BoardGame e cercare giocatori" />
<style type="text/css">
#banner {
- background: url(/static/banner2.jpg) no-repeat center center;
+ background: url(/static/media/banner2.jpg) no-repeat center center;
height: 600px;
}
</style>
View
32 test.py
@@ -1,12 +1,32 @@
#!/usr/bin/python
# coding: utf-8
+class MockPyBGGBoardGame( object ):
+ def __init__( self, *args, **kwargs ):
+ self.__dict__ = kwargs
+
+class MockPyBGG( object ):
+ def search( self, term, prefetch=False ):
+ return [
+ MockPyBGGBoardGame( thumbnail="http://cf.geekdo-images.com/images/pic1115825_t.jpg", name="7 Wonders: Catan Island" ),
+ MockPyBGGBoardGame( thumbnail="http://cf.geekdo-images.com/images/pic135066_t.jpg", name="Catan Card Game" ),
+ MockPyBGGBoardGame( thumbnail="http://cf.geekdo-images.com/images/pic976200_t.jpg", name="Catan Dice Game" ),
+ MockPyBGGBoardGame( thumbnail=None, name=u"Die Siedler von Catan - Th\u00fcringen Edition" ),
+ MockPyBGGBoardGame( thumbnail="http://cf.geekdo-images.com/images/pic195977_t.jpg", name="Simply Catan" ),
+ MockPyBGGBoardGame( thumbnail="http://cf.geekdo-images.com/images/pic1210879_t.jpg", name="Star Trek Catan" ),
+ MockPyBGGBoardGame( thumbnail="http://cf.geekdo-images.com/images/pic918589_t.jpg", name="The Struggle for Catan" )
+ ]
+
+import sys
+sys.modules["pyBGG"] = MockPyBGG()
+
import os
os.environ["SECRET_KEY"] = "unittest"
os.environ["HEROKU_SHARED_POSTGRESQL_ORANGE_URL"] = "sqlite://"
import unittest
import houserule
+import json
houserule.app.config["TESTING"] = True
houserule.app.config["CSRF_ENABLED"] = False
@@ -78,5 +98,17 @@ def test_create_match( self ):
self.assertEqual( match.game.name, data["game_name"] )
self.assertEqual( match.user.username, "ciccio" )
+ def test_game_search( self ):
+ # check the fixture in common with the client side
+ with open( "static/fixture/search_game.json" ) as fp:
+ fixture = json.load( fp )
+
+ self.test_login()
+ response = self.client.get( "/search/game?term=catan" )
+ self.assertEqual( 200, response.status_code )
+ data = json.loads( response.data )
+ self.assertListEqual( data, fixture )
+
+
if __name__ == '__main__':
unittest.main()

No commit comments for this range

Something went wrong with that request. Please try again.