mirror of
https://github.com/wassname/cardsforscience.git
synced 2026-08-02 12:30:06 +08:00
Tests work with webpack and a new favicon
This commit is contained in:
+25
-7
@@ -1,6 +1,18 @@
|
||||
/** Custom google analystics events **/
|
||||
var Helpers = require("js/helpers");
|
||||
|
||||
// google analystics async code
|
||||
(function (i, s, o, g, r, a, m) {
|
||||
i['GoogleAnalyticsObject'] = r;
|
||||
i[r] = i[r] || function () {
|
||||
(i[r].q = i[r].q || []).push(arguments);
|
||||
}, i[r].l = 1 * new Date();
|
||||
a = s.createElement(o),
|
||||
m = s.getElementsByTagName(o)[0];
|
||||
a.async = 1;
|
||||
a.src = g;
|
||||
m.parentNode.insertBefore(a, m);
|
||||
})(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');
|
||||
|
||||
var analytics = module.exports =
|
||||
{
|
||||
@@ -32,9 +44,13 @@ var analytics = module.exports =
|
||||
return;
|
||||
}
|
||||
|
||||
ga('create', Helpers.analytics,'auto');
|
||||
ga('set', { 'appName': 'Cards For Science', 'appId': '', 'appVersion': '0.6' });
|
||||
ga('set', 'anonymizeIp', true);
|
||||
// TODO replace with angular analtcs
|
||||
if(ga){
|
||||
ga('create', Helpers.analytics,'auto');
|
||||
ga('set', { 'appName': 'Cards For Science', 'appId': '', 'appVersion': '0.6' });
|
||||
ga('set', 'anonymizeIp', true);
|
||||
ga('send','pageview');
|
||||
}
|
||||
|
||||
|
||||
$('#myModal').on('show.bs.modal', function (e) {
|
||||
@@ -64,8 +80,9 @@ var analytics = module.exports =
|
||||
if (!analytics.enabled || typeof type === 'undefined') {
|
||||
return;
|
||||
}
|
||||
|
||||
ga('send', 'screenview', { 'screenName': type });
|
||||
if(ga){
|
||||
ga('send', 'screenview', { 'screenName': type });
|
||||
}
|
||||
},
|
||||
|
||||
sendEvent: function(category, action, label, value)
|
||||
@@ -73,7 +90,8 @@ var analytics = module.exports =
|
||||
if (!analytics.enabled || typeof category === 'undefined' || typeof action === 'undefined' || typeof label === 'undefined' || typeof value === 'undefined') {
|
||||
return;
|
||||
}
|
||||
|
||||
//ga('send', 'event', category, action, label, value, {'screenName': analytics.screens.main });
|
||||
if(ga){
|
||||
ga('send', 'event', category, action, label, value, {'screenName': analytics.screens.main });
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
+9
-1
@@ -12,6 +12,8 @@ var jqueryCookie = require("js-cookie");
|
||||
var angular = require("angular");
|
||||
var angularDragdrop = require("angular-dragdrop");
|
||||
var angularAnimate = require("angular-animate");
|
||||
var angulartics = require('angulartics');
|
||||
var angularticsGoogleAnalytics = require('angulartics-google-analytics');
|
||||
|
||||
//app
|
||||
var ObjectStorage = require("js/storage");
|
||||
@@ -24,7 +26,13 @@ var Rules = require("js/rules.js");
|
||||
var app = (function (Helpers,analytics,Game,Rules) {
|
||||
Helpers.validateSaveVersion();
|
||||
|
||||
var app = angular.module('cardsForScience', ['ngDragDrop','ngAnimate']);
|
||||
var app = angular.module('cardsForScience', ['ngDragDrop','ngAnimate','angulartics', angularticsGoogleAnalytics]);
|
||||
|
||||
// config
|
||||
app.config(function ($analyticsProvider) {
|
||||
$analyticsProvider.firstPageview(true); /* Records pages that don't use $state or $route */
|
||||
$analyticsProvider.withAutoBase(true); /* Records full path */
|
||||
});
|
||||
|
||||
// directives
|
||||
|
||||
|
||||
+5
-3
@@ -1,9 +1,9 @@
|
||||
/**
|
||||
* Game object load/saves game resources and stores game objects
|
||||
*/
|
||||
var ObjectStorage = require("js/storage");
|
||||
var Helpers = require("js/helpers");
|
||||
var GameObjects = require("js/gameobjects");
|
||||
var ObjectStorage = require("js/storage.js");
|
||||
var Helpers = require("js/helpers.js");
|
||||
var GameObjects = require("js/gameobjects.js");
|
||||
var Rules = require("js/rules.js");
|
||||
var cards = require("json/cards.json");
|
||||
var achievements = require("json/achievements.json");
|
||||
@@ -26,6 +26,8 @@ var Game = module.exports =(function (Helpers, GameObjects, ObjectStorage,Rules,
|
||||
|
||||
this.lastCards= [];
|
||||
this.incorrectCards= [];
|
||||
this.rules=Rules.rules;
|
||||
this.Rule=Rules.Rule;
|
||||
};
|
||||
|
||||
Game.prototype.load = function ($http, $q) {
|
||||
|
||||
+12
-3
@@ -1,9 +1,18 @@
|
||||
|
||||
|
||||
|
||||
// polyfill and conditional import so this will load in the browser too
|
||||
if (!module) module=function(){};
|
||||
var chai;
|
||||
if (!chai){
|
||||
chair = require("chai");
|
||||
}
|
||||
|
||||
/**
|
||||
* Rules objects for game
|
||||
* @param {[type]} function functionName( [description]
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
var chai = require("chai");
|
||||
var Rules = module.exports = (function functionName(_,chai) {
|
||||
|
||||
|
||||
@@ -64,12 +73,12 @@ var Rules = module.exports = (function functionName(_,chai) {
|
||||
var reason;
|
||||
try {
|
||||
result = this.ruleFunc(card, lastCards, allCards, this.options);
|
||||
if (result instanceof chai.Assertion) {
|
||||
if ((chai&&result instanceof chai.Assertion)||result.name==='Assertion'||result.constructor.name==='Assertion') {
|
||||
reason = result;
|
||||
result = true;
|
||||
}
|
||||
} catch (e) {
|
||||
if (e instanceof chai.AssertionError) {
|
||||
if ((chai&&e instanceof chai.AssertionError)||e.name=='AssertionError') {
|
||||
result = false;
|
||||
reason = e;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user