<commit_before>// Search engine completion functions

String.prototype.validURL = function() {
  var url = this.trimLeft().trimRight();
  if (url.length === 0) return "chrome://newtab";
  if (/^\//.test(url)) url = "file://" + url;
  if (/^(chrome|chrome-extension|file):\/\/\S+$/.test(url)) return url;
  var pattern = new RegExp("^((https?|ftp):\\/\\/)?"+
  "((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|"+
  "((\\d{1,3}\\.){3}\\d{1,3})|"+
  "localhost)" +
  "(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*"+
  "(\\?[;&a-z\\d%_.~+=-]*)?"+
  "(\\#[-a-z\\d_]*)?$","i");
  if (pattern.test(url)) {
    return true;
  }
};

var Complete = {};

Complete.engines = ["google", "wikipedia", "imdb", "amazon", "wolframalpha", "google-image", "ebay", "duckduckgo", "yahoo", "bing"];

Complete.requestUrls = {
  wikipedia:      "https://en.wikipedia.org/wiki/",
  google:         "https://www.google.com/search?q=",
  "google-image": "https://www.google.com/search?site=imghp&tbm=isch&source=hp&q=",
  duckduckgo:     "https://duckduckgo.com/?q=",
  yahoo:          "https://search.yahoo.com/search?p=",
  bing:           "https://www.bing.com/search?q=",
  imdb:           "http://www.imdb.com/find?s=all&q=",
  amazon:         "http://www.amazon.com/s/?field-keywords=",
  wolframalpha:   "https://www.wolframalpha.com/input/?i=",
  ebay:           "https://www.ebay.com/sch/i.html?_sacat=0&_from=R40&_nkw="
};

Complete.parseQuery = {
  wikipedia: function(query) {
    return query.replace(" ", "_");
  },
  bing: function(query) {
    return query + "&FORM=SEEMOR";
  },
  wolframalpha: function(query) {
    return encodeURIComponent(query);
  },
  imdb: function(query) {
    return encodeURIComponent(query);
  }
};

Complete.apis = {
  wikipedia:      "https://en.wikipedia.org/w/api.php?action=opensearch&format=json&search=",
  google:         "https://suggestqueries.google.com/complete/search?client=firefox&q=",
  "google-image": "http://www.google.com/complete/search?client=img&hl=en&gs_rn=43&gs_ri=img&ds=i&cp=1&gs_id=8&q=",
  yahoo:          "https://search.yahoo.com/sugg/gossip/gossip-us-ura/?output=sd1&appid=search.yahoo.com&nresults=10&command=",
  bing:           "http://api.bing.com/osjson.aspx?query=",
  imdb:           "http://sg.media-imdb.com/suggests/",
  amazon:         "http://completion.amazon.com/search/complete?method=completion&search-alias=aps&client=amazon-search-ui&mkt=1&q=",
  wolframalpha:   "https://www.wolframalpha.com/input/autocomplete.jsp?qr=0&i=",
  ebay:           "https://autosug.ebay.com/autosug?kwd="
};

Complete.convertToLink = function(input) {
  var prefix, suffix;
  input = input.replace(/@%/g, document.URL);
  input = input.split(/\s+/).filter(function(e) { return e; });
  input.shift();
  if (input.length === 0) {
    return "";
  }
  if (Complete.engines.indexOf(input[0]) !== -1 && input.length > 1) {
    prefix = Complete.requestUrls[input[0]];
  } else {
    if (input.join(" ").validURL()) {
      if (!/:\/\//.test(input.join(" "))) {
        return "http://" + input.join(" ");
      }
      return input.join(" ");
    }
    return Complete.requestUrls.google + encodeURIComponent(input.join(" "));
  }
  if (Complete.parseQuery.hasOwnProperty(input[0])) {
    suffix = Complete.parseQuery[input[0]](input.slice(1).join(" "));
  } else {
    suffix = input.slice(1).join(" ");
  }
  return prefix + suffix;
};

Complete.xhr = function(url, callback) {
  var xhr = new XMLHttpRequest();
  xhr.open("GET", url);
  xhr.onreadystatechange = function() {
    if (this.readyState === 4 && this.status === 200 && document.activeElement.id === "cVim-command-bar-input" && commandMode) {
      callback(JSON.parse(this.responseText));
    }
  };
  xhr.send(url);
};

Complete.wikipedia = function(query, callback) {
  this.xhr(this.apis.wikipedia + query, function(response) {
    callback(response[1].map(function(e) {
      return ["search"].concat(e);
    }));
  });
};

Complete.google = function(query, callback) {
  this.xhr(this.apis.google + query, function(response) {
    callback(response[1].map(function(e) {
      return ["search"].concat(e);
    }));
  });
};

Complete["google-image"] = function(query, callback) {
  var xhr = new XMLHttpRequest();
  xhr.open("GET", this.apis["google-image"] + query);
  xhr.onreadystatechange = function() {
    if (this.readyState === 4 && this.status === 200 && document.activeElement.id === "cVim-command-bar-input" && commandMode) {
      callback(JSON.parse(this.responseText.replace(/^[^\(]+\(|\)$/g, ""))[1].map(function(e) {
        return ["search", e[0].replace(/<[^>]+>/g, "")];
      }));
    }
  };
  xhr.send();
};

Complete.amazon = function(query, callback) {
  this.xhr(this.apis.amazon + encodeURIComponent(query), function(response) {
    callback(response[1].map(function(e) {
      return ["search"].concat(e);
    }));
  });
};

Complete.yahoo = function(query, callback) {
  this.xhr(this.apis.yahoo + encodeURIComponent(query), function(response) {
    var _ret = [];
    for (var key in response.r) {
      if (response.r[key].hasOwnProperty("k")) {
        _ret.push(["search", response.r[key].k]);
      }
    }
    callback(_ret);
  });
};

Complete.bing = function(query, callback) {
  this.xhr(this.apis.bing + query, function(response) {
    callback(response[1].map(function(e) {
      return ["search"].concat(e);
    }));
  });
};

Complete.ebay = function(query, callback) {
  var xhr = new XMLHttpRequest();
  xhr.open("GET", this.apis.ebay + encodeURIComponent(query));
  xhr.onreadystatechange = function() {
    if (this.readyState === 4 && this.status === 200 && document.activeElement.id === "cVim-command-bar-input" && commandMode) {
      var _ret = JSON.parse(xhr.responseText.replace(/^[^\(]+\(|\)$/g, ""));
      if (!_ret.res) {
        return false;
      }
      callback(_ret.res.sug.map(function(e) {
        return ["search", e];
      }));
    }
  };
  xhr.send();
};

Complete.wolframalpha = function(query, callback) {
  this.xhr(this.apis.wolframalpha + encodeURIComponent(query), function(response) {
    callback(response.results.map(function(e) {
      return ["search", e.input];
    }));
  });
};

Complete.imdb = function(query, callback) {
  var xhr = new XMLHttpRequest();
  xhr.open("GET", this.apis.imdb + query[0] + "/" + query.replace(" ", "_") + ".json");
  xhr.onreadystatechange = function() {
    if (this.readyState === 4 && this.status === 200 && document.activeElement.id === "cVim-command-bar-input" && commandMode) {
      var _ret = JSON.parse(xhr.responseText.replace(/^[^\(]+\(|\)$/g, ""));
      callback(_ret.d.map(function(e) {
        if (/:\/\//.test(e.id)) {
          return ["search", e.l, e.id];
        }
        var _url = "http://www.imdb.com/" + (e.id.indexOf("nm") === 0 ? "name" : "title") + "/" + e.id;
        if (e.q) {
          return ["search", e.l + " - " + e.q + ", " + e.s + " (" + e.y + ")", _url];
        }
        return ["search", e.l + " - " + e.s, _url];
      }));
    }
  };
  xhr.send();
};
<commit_msg>Added google trends, finance, and urbandictionary to search engine list<commit_after>// Search engine completion functions

String.prototype.validURL = function() {
  var url = this.trimLeft().trimRight();
  if (url.length === 0) return "chrome://newtab";
  if (/^\//.test(url)) url = "file://" + url;
  if (/^(chrome|chrome-extension|file):\/\/\S+$/.test(url)) return url;
  var pattern = new RegExp("^((https?|ftp):\\/\\/)?"+
  "((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|"+
  "((\\d{1,3}\\.){3}\\d{1,3})|"+
  "localhost)" +
  "(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*"+
  "(\\?[;:&a-z\\d%_.~+=-]*)?"+
  "(\\#[#:-a-z\\d_]*)?$","i");
  if (pattern.test(url)) {
    return true;
  }
};

var Complete = {};

Complete.engines = ["google", "wikipedia", "imdb", "amazon", "wolframalpha", "google-image", "ebay", "urbandictionary", "duckduckgo", "google-trends", "google-finance", "yahoo", "bing"];

Complete.requestUrls = {
  wikipedia:      "https://en.wikipedia.org/wiki/",
  google:         "https://www.google.com/search?q=",
  "google-image": "https://www.google.com/search?site=imghp&tbm=isch&source=hp&q=",
  duckduckgo:     "https://duckduckgo.com/?q=",
  yahoo:          "https://search.yahoo.com/search?p=",
  bing:           "https://www.bing.com/search?q=",
  imdb:           "http://www.imdb.com/find?s=all&q=",
  amazon:         "http://www.amazon.com/s/?field-keywords=",
  wolframalpha:   "https://www.wolframalpha.com/input/?i=",
  ebay:           "https://www.ebay.com/sch/i.html?_sacat=0&_from=R40&_nkw=",
  urbandictionary: "http://www.urbandictionary.com/define.php?term=",
  "google-trends": "http://www.google.com/trends/explore#q=",
  "google-finance": "https://www.google.com/finance?q="
};

Complete.parseQuery = {
  wikipedia: function(query) {
    return query.replace(" ", "_");
  },
  bing: function(query) {
    return query + "&FORM=SEEMOR";
  },
  wolframalpha: function(query) {
    return encodeURIComponent(query);
  },
  imdb: function(query) {
    return encodeURIComponent(query);
  },
  "google-finance": function(query) {
    return encodeURIComponent(query);
  }
};

Complete.apis = {
  wikipedia:      "https://en.wikipedia.org/w/api.php?action=opensearch&format=json&search=",
  google:         "https://suggestqueries.google.com/complete/search?client=firefox&q=",
  "google-image": "http://www.google.com/complete/search?client=img&hl=en&gs_rn=43&gs_ri=img&ds=i&cp=1&gs_id=8&q=",
  yahoo:          "https://search.yahoo.com/sugg/gossip/gossip-us-ura/?output=sd1&appid=search.yahoo.com&nresults=10&command=",
  bing:           "http://api.bing.com/osjson.aspx?query=",
  imdb:           "http://sg.media-imdb.com/suggests/",
  amazon:         "http://completion.amazon.com/search/complete?method=completion&search-alias=aps&client=amazon-search-ui&mkt=1&q=",
  wolframalpha:   "https://www.wolframalpha.com/input/autocomplete.jsp?qr=0&i=",
  ebay:           "https://autosug.ebay.com/autosug?kwd=",
  urbandictionary: "http://api.urbandictionary.com/v0/autocomplete?term=",
  "google-trends": "http://www.google.com/trends/entitiesQuery?tn=10&q=",
  "google-finance": "https://www.google.com/finance/match?matchtype=matchall&q="
};

Complete.convertToLink = function(input) {
  var prefix, suffix;
  input = input.replace(/@%/g, document.URL);
  input = input.split(/\s+/).filter(function(e) { return e; });
  input.shift();
  if (input.length === 0) {
    return "";
  }
  if (Complete.engines.indexOf(input[0]) !== -1 && input.length > 1) {
    prefix = Complete.requestUrls[input[0]];
  } else {
    if (input.join(" ").validURL()) {
      if (!/:\/\//.test(input.join(" "))) {
        return "http://" + input.join(" ");
      }
      return input.join(" ");
    }
    return Complete.requestUrls.google + encodeURIComponent(input.join(" "));
  }
  if (Complete.parseQuery.hasOwnProperty(input[0])) {
    suffix = Complete.parseQuery[input[0]](input.slice(1).join(" "));
  } else {
    suffix = input.slice(1).join(" ");
  }
  return prefix + suffix;
};

Complete.xhr = function(url, callback) {
  var xhr = new XMLHttpRequest();
  xhr.open("GET", url);
  xhr.onreadystatechange = function() {
    if (this.readyState === 4 && this.status === 200 && document.activeElement.id === "cVim-command-bar-input" && commandMode) {
      callback(JSON.parse(this.responseText));
    }
  };
  xhr.send(url);
};

Complete.wikipedia = function(query, callback) {
  this.xhr(this.apis.wikipedia + query, function(response) {
    callback(response[1].map(function(e) {
      return ["search"].concat(e);
    }));
  });
};

Complete.google = function(query, callback) {
  this.xhr(this.apis.google + query, function(response) {
    callback(response[1].map(function(e) {
      return ["search"].concat(e);
    }));
  });
};

Complete["google-image"] = function(query, callback) {
  var xhr = new XMLHttpRequest();
  xhr.open("GET", this.apis["google-image"] + query);
  xhr.onreadystatechange = function() {
    if (this.readyState === 4 && this.status === 200 && document.activeElement.id === "cVim-command-bar-input" && commandMode) {
      callback(JSON.parse(this.responseText.replace(/^[^\(]+\(|\)$/g, ""))[1].map(function(e) {
        return ["search", e[0].replace(/<[^>]+>/g, "")];
      }));
    }
  };
  xhr.send();
};

Complete["google-trends"] = function(query, callback) {
  this.xhr(this.apis["google-trends"] + encodeURIComponent(query), function(response) {
    callback(response.entityList.map(function(e) {
      return ["search", e.title + " - " + e.type, Complete.requestUrls["google-trends"] + encodeURIComponent(e.mid)];
    }));
  });
};

Complete["google-finance"] = function(query, callback) {
  this.xhr(this.apis["google-finance"] + encodeURIComponent(query), function(response) {
    callback(response.matches.map(function(e) {
      return ["search", e.t + " - " + e.n + " - " + e.e, Complete.requestUrls["google-finance"] + e.e + ":" + e.t];
    }));
  });
}

Complete.amazon = function(query, callback) {
  this.xhr(this.apis.amazon + encodeURIComponent(query), function(response) {
    callback(response[1].map(function(e) {
      return ["search"].concat(e);
    }));
  });
};

Complete.yahoo = function(query, callback) {
  this.xhr(this.apis.yahoo + encodeURIComponent(query), function(response) {
    var _ret = [];
    for (var key in response.r) {
      if (response.r[key].hasOwnProperty("k")) {
        _ret.push(["search", response.r[key].k]);
      }
    }
    callback(_ret);
  });
};

Complete.bing = function(query, callback) {
  this.xhr(this.apis.bing + query, function(response) {
    callback(response[1].map(function(e) {
      return ["search"].concat(e);
    }));
  });
};

Complete.ebay = function(query, callback) {
  var xhr = new XMLHttpRequest();
  xhr.open("GET", this.apis.ebay + encodeURIComponent(query));
  xhr.onreadystatechange = function() {
    if (this.readyState === 4 && this.status === 200 && document.activeElement.id === "cVim-command-bar-input" && commandMode) {
      var _ret = JSON.parse(xhr.responseText.replace(/^[^\(]+\(|\)$/g, ""));
      if (!_ret.res) {
        return false;
      }
      callback(_ret.res.sug.map(function(e) {
        return ["search", e];
      }));
    }
  };
  xhr.send();
};

Complete.wolframalpha = function(query, callback) {
  this.xhr(this.apis.wolframalpha + encodeURIComponent(query), function(response) {
    callback(response.results.map(function(e) {
      return ["search", e.input];
    }));
  });
};

Complete.urbandictionary = function(query, callback) {
  this.xhr(this.apis.urbandictionary + encodeURIComponent(query), function(response) {
    callback(response.slice(1).map(function(e) {
      return ["search", e];
    }));
  });
};

Complete.imdb = function(query, callback) {
  var xhr = new XMLHttpRequest();
  xhr.open("GET", this.apis.imdb + query[0] + "/" + query.replace(" ", "_") + ".json");
  xhr.onreadystatechange = function() {
    if (this.readyState === 4 && this.status === 200 && document.activeElement.id === "cVim-command-bar-input" && commandMode) {
      var _ret = JSON.parse(xhr.responseText.replace(/^[^\(]+\(|\)$/g, ""));
      callback(_ret.d.map(function(e) {
        if (/:\/\//.test(e.id)) {
          return ["search", e.l, e.id];
        }
        var _url = "http://www.imdb.com/" + (e.id.indexOf("nm") === 0 ? "name" : "title") + "/" + e.id;
        if (e.q) {
          return ["search", e.l + " - " + e.q + ", " + e.s + " (" + e.y + ")", _url];
        }
        return ["search", e.l + " - " + e.s, _url];
      }));
    }
  };
  xhr.send();
};
<|endoftext|>


<commit_before>'use strict';

// MODULES //

var tape = require( 'tape' );
var getKeys = require( 'object-keys' ).shim();
var stats = require( './../lib' );

// TESTS //

tape( 'main export is an object', function test( t ) {
	t.ok( true, __filename );
	t.equal( typeof stats, 'object', 'main export is an object' );
	t.end();
});

tape( 'the exported object contains stats number generators', function test( t ) {
	var keys = getKeys( stats );
	t.equal( keys.length > 0, true, 'has keys' );
	t.end();
});
<commit_msg>Fix test description<commit_after>'use strict';

// MODULES //

var tape = require( 'tape' );
var getKeys = require( 'object-keys' ).shim();
var stats = require( './../lib' );

// TESTS //

tape( 'main export is an object', function test( t ) {
	t.ok( true, __filename );
	t.equal( typeof stats, 'object', 'main export is an object' );
	t.end();
});

tape( 'the exported object contains statistical functions', function test( t ) {
	var keys = getKeys( stats );
	t.equal( keys.length > 0, true, 'has keys' );
	t.end();
});
<|endoftext|>


<commit_before>'use strict';

/**
 * @file
 * ProfileLibraries displays a users favorite libraries.
 */

import React from 'react';
import {find} from 'lodash';

const ProfileLibrary = React.createClass({
  displayName: 'ProfileLibrary',

  propTypes: {
    actions: React.PropTypes.object.isRequired,
    editable: React.PropTypes.bool.isRequired,
    library: React.PropTypes.object.isRequired,
    pickupLocationText: React.PropTypes.string.isRequired,
    setAsText: React.PropTypes.string.isRequired,
    store: React.PropTypes.object.isRequired
  },

  componentDidMount() {
    this.props.actions.libraryIdUpdated.trigger(this.props.library.agencyID);
  },

  setDefaultLibrary() {
    if (this.props.library.default !== 1) {
      this.props.actions.setLibraryAsDefault(this.props.library.agencyID);
    }
  },

  removeFavoriteLibrary() {
    this.props.actions.removeLibraryFromFavorites(this.props.library.agencyID);
  },

  render: function () {
    let library = find(this.props.store.favoriteLibrariesResolved, {branchId: this.props.library.agencyID});
    let libContent = (

);

    if (library) {
      libContent = (

{library.branchNameDan}

{library.agencyName}

                  Ret lånerdata

                  Fjern bibliotek fra favoritter

                  {(this.props.library.default === 1 ? '' : this.props.setAsText + ' ') + this.props.pickupLocationText}

      );
    }

    return libContent;
  }
});

export default ProfileLibrary;
<commit_msg>Accumulated commit of the following from branch 'origin/ready/jph-us103':<commit_after>'use strict';

/**
 * @file
 * ProfileLibraries displays a users favorite libraries.
 */

import React from 'react';
import {find} from 'lodash';

const ProfileLibrary = React.createClass({
  displayName: 'ProfileLibrary',

  propTypes: {
    actions: React.PropTypes.object.isRequired,
    editable: React.PropTypes.bool.isRequired,
    library: React.PropTypes.object.isRequired,
    pickupLocationText: React.PropTypes.string.isRequired,
    setAsText: React.PropTypes.string.isRequired,
    store: React.PropTypes.object.isRequired
  },

  componentDidMount() {
    this.props.actions.libraryIdUpdated.trigger(this.props.library.agencyID);
  },

  setDefaultLibrary() {
    if (this.props.library.default !== 1) {
      this.props.actions.setLibraryAsDefault(this.props.library.agencyID);
    }
  },

  removeFavoriteLibrary() {
    this.props.actions.removeLibraryFromFavorites(this.props.library.agencyID);
  },

  render: function () {
    let library = find(this.props.store.favoriteLibrariesResolved, {branchId: this.props.library.agencyID});
    let libContent = (

);

    if (library) {
      libContent = (

{library.branchNameDan}

{library.agencyName}

                  Ret lånerdata

                  Fjern bibliotek fra favoritter

                  {(this.props.library.default === 1 ? '' : this.props.setAsText + ' ') + this.props.pickupLocationText}

      );
    }

    return libContent;
  }
});

export default ProfileLibrary;
<|endoftext|>


<commit_before>#!/usr/bin/env node

require('coffee-script').register()

var fs = require('fs'),
    indentation = require('../lib/indentation'),
    buf, emblemFile, hbsFile, output;

if (process.argv.length < 3) {
  console.log('USAGE: emblem2hbs filetoconvert.emblem')
} else {
  emblemFile = process.argv[2];
  hbsFile = emblemFile.substr(0, emblemFile.lastIndexOf('.')) + '.hbs';
  buf = fs.readFileSync(emblemFile, 'utf8');
  output = require('emblem').default.compile(buf);
  fs.writeFileSync(hbsFile, indentation.indent(output));
}
<commit_msg>Allow for input steam from stdin<commit_after>#!/usr/bin/env node

require('coffee-script').register()

var fs = require('fs'),
    indentation = require('../lib/indentation'),
    buf, emblemFile, hbsFile, output;

if (process.argv.length < 3) {
  if (process.stdin.isTTY) {
    console.log('USAGE: emblem2hbs filetoconvert.emblem or in piped format `pbcopy | emblem2hbs | pbpaste`');
    return;
  }
  else {
    processFromPipe();
  }
} else {
  emblemFile = process.argv[2];
  hbsFile = emblemFile.substr(0, emblemFile.lastIndexOf('.')) + '.hbs';
  buf = fs.readFileSync(emblemFile, 'utf8');
  output = require('emblem').default.compile(buf);
  fs.writeFileSync(hbsFile, indentation.indent(output));
}

function processFromPipe() {
  var input = process.stdin;
  var output = process.stdout;
  var error = null;
  var data = '';

  input.setEncoding('utf8');

  input.on('data', function(chunk){
    data += chunk;
  });

  input.on('end', function(){
    var converted = require('emblem').default.compile(data);
    output.end(indentation.indent(converted));
  });

  output.on('error', function(err) {
    error = err;
  });
}
<|endoftext|>


<commit_before>exports.BattleScripts = {
        init: function() {
                for (var i in this.data.FormatsData)
                        this.data.FormatsData[i].dreamWorldRelease = true;

	this.modData('Pokedex', 'azumarill').types = ["Water","Fairy"];
 	this.modData('Learnsets', 'azumarill').learnset.lunardance = ['5L0'];
 	this.modData('Learnsets', 'azumarill').learnset.mysticcrash = ['5L0'];

	this.modData('Pokedex', 'gardevoir').types = ["Psychic","Fairy"];
	this.modData('Learnsets', 'gardevoir').learnset.fairywind = ['5L0'];
	this.modData('Learnsets', 'gardevoir').learnset.lunardance = ['5L0'];
	this.modData('Learnsets', 'gardevoir').learnset.drainingkiss = ['5L0'];
	this.modData('Learnsets', 'gardevoir').learnset.closecombat = ['5L0'];
	this.modData('Pokedex', 'gardevoir').baseStats = {hp:99,atk:140,def:145,spa:70,spd:140,spe:142};

	this.modData('Pokedex', 'clefable').types = ["Normal","Fairy"];
	this.modData('Learnsets', 'clefable').learnset.fairywind = ['5L0'];
	this.modData('Learnsets', 'clefable').learnset.lunardance = ['5L0'];
	this.modData('Learnsets', 'clefable').learnset.topsyturvy = ['5L0'];

	this.modData('Pokedex', 'gallade').types = ["Fighting","Fairy"];
	this.modData('Learnsets', 'gallade').learnset.fairywind = ['5L0'];
	this.modData('Learnsets', 'gallade').lunardance = ['5L0'];
	this.modData('Learnsets', 'gallade').drainingkiss = ['5L0'];
	this.modData('Learnsets', 'gallade').lunardance = ['5L0'];
	this.modData('Learnsets', 'gallade').mysticcrash = ['5L0'];

	this.modData('Learnsets', 'yveltal').learnset.toxic = ['5L0'];
	this.modData('Learnsets', 'yveltal').learnset.doubleedge = ['5L0'];
	this.modData('Learnsets', 'yveltal').learnset.oblivionwing = ['5L0'];
	this.modData('Learnsets', 'yveltal').learnset.darkpulse = ['5L0'];
	this.modData('Learnsets', 'yveltal').learnset.airslash = ['5L0'];
	this.modData('Learnsets', 'yveltal').learnset.hurricane = ['5L0'];
	this.modData('Learnsets', 'yveltal').learnset.aurasphere = ['5L0'];
	this.modData('Learnsets', 'yveltal').learnset.dragondance = ['5L0'];
	this.modData('Learnsets', 'yveltal').learnset.focusblast = ['5L0'];
	this.modData('Learnsets', 'yveltal').learnset.superpower = ['5L0'];
	this.modData('Learnsets', 'yveltal').learnset.roost = ['5L0'];

	this.modData('Learnsets', 'xerneas').learnset.toxic = ['5L0'];
	this.modData('Learnsets', 'yveltal').learnset.doubleedge = ['5L0'];
	this.modData('Learnsets', 'yveltal').learnset.geomancy = ['5L0'];
	this.modData('Learnsets', 'yveltal').learnset.fairywind = ['5L0'];
	this.modData('Learnsets', 'yveltal').learnset.gigadrain = ['5L0'];
	this.modData('Learnsets', 'yveltal').learnset.leafstorm = ['5L0'];
	this.modData('Learnsets', 'yveltal').learnset.aurasphere = ['5L0'];
	this.modData('Learnsets', 'yveltal').learnset.calmmind = ['5L0'];
	this.modData('Learnsets', 'yveltal').learnset.lunardance = ['5L0'];
	this.modData('Learnsets', 'yveltal').learnset.powerwhip = ['5L0'];
	this.modData('Learnsets', 'yveltal').learnset.superpower = ['5L0'];
	this.modData('Learnsets', 'yveltal').learnset.recover = ['5L0'];
		}
};
<commit_msg>Update scripts.js<commit_after>exports.BattleScripts = {
        init: function() {
                for (var i in this.data.FormatsData)
                        this.data.FormatsData[i].dreamWorldRelease = true;

	this.modData('Pokedex', 'azumarill').types = ["Water","Fairy"];
 	this.modData('Learnsets', 'azumarill').learnset.lunardance = ['5L0'];
 	this.modData('Learnsets', 'azumarill').learnset.mysticcrash = ['5L0'];

	this.modData('Pokedex', 'gardevoir').types = ["Psychic","Fairy"];
	this.modData('Learnsets', 'gardevoir').learnset.fairywind = ['5L0'];
	this.modData('Learnsets', 'gardevoir').learnset.lunardance = ['5L0'];
	this.modData('Learnsets', 'gardevoir').learnset.drainingkiss = ['5L0'];
	this.modData('Learnsets', 'gardevoir').learnset.closecombat = ['5L0'];
	this.modData('Pokedex', 'gardevoir').baseStats = {hp:99,atk:140,def:145,spa:70,spd:140,spe:142};

	this.modData('Pokedex', 'clefable').types = ["Normal","Fairy"];
	this.modData('Learnsets', 'clefable').learnset.fairywind = ['5L0'];
	this.modData('Learnsets', 'clefable').learnset.lunardance = ['5L0'];
	this.modData('Learnsets', 'clefable').learnset.topsyturvy = ['5L0'];

	this.modData('Pokedex', 'gallade').types = ["Fighting","Fairy"];
	this.modData('Learnsets', 'gallade').learnset.fairywind = ['5L0'];
	this.modData('Learnsets', 'gallade').lunardance = ['5L0'];
	this.modData('Learnsets', 'gallade').drainingkiss = ['5L0'];
	this.modData('Learnsets', 'gallade').lunardance = ['5L0'];
	this.modData('Learnsets', 'gallade').mysticcrash = ['5L0'];

	this.modData('Learnsets', 'yveltal').learnset.toxic = ['5L0'];
	this.modData('Learnsets', 'yveltal').learnset.doubleedge = ['5L0'];
	this.modData('Learnsets', 'yveltal').learnset.oblivionwing = ['5L0'];
	this.modData('Learnsets', 'yveltal').learnset.darkpulse = ['5L0'];
	this.modData('Learnsets', 'yveltal').learnset.airslash = ['5L0'];
	this.modData('Learnsets', 'yveltal').learnset.hurricane = ['5L0'];
	this.modData('Learnsets', 'yveltal').learnset.aurasphere = ['5L0'];
	this.modData('Learnsets', 'yveltal').learnset.dragondance = ['5L0'];
	this.modData('Learnsets', 'yveltal').learnset.focusblast = ['5L0'];
	this.modData('Learnsets', 'yveltal').learnset.superpower = ['5L0'];
	this.modData('Learnsets', 'yveltal').learnset.roost = ['5L0'];

	this.modData('Learnsets', 'xerneas').learnset.toxic = ['5L0'];
	this.modData('Learnsets', 'xerneas').learnset.doubleedge = ['5L0'];
	this.modData('Learnsets', 'xerneas').learnset.geomancy = ['5L0'];
	this.modData('Learnsets', 'xerneas').learnset.fairywind = ['5L0'];
	this.modData('Learnsets', 'xerneas').learnset.gigadrain = ['5L0'];
	this.modData('Learnsets', 'xerneas').learnset.leafstorm = ['5L0'];
	this.modData('Learnsets', 'xerneas').learnset.aurasphere = ['5L0'];
	this.modData('Learnsets', 'xerneas').learnset.calmmind = ['5L0'];
	this.modData('Learnsets', 'xerneas').learnset.lunardance = ['5L0'];
	this.modData('Learnsets', 'xerneas').learnset.powerwhip = ['5L0'];
	this.modData('Learnsets', 'xerneas').learnset.superpower = ['5L0'];
	this.modData('Learnsets', 'xerneas').learnset.recover = ['5L0'];
		}
};
<|endoftext|>


<commit_before>import React, { Component } from "react";
import Link from "gatsby-link";
import Helmet from "react-helmet";
import { FormattedDate } from "react-intl";
import styled from "styled-components";
import { space, color, fontSize, responsiveStyle } from "styled-system";
import { Flex, Box, Grid } from "grid-styled";
import { rem, borderRadius } from "polished";
import breakpoint from "../styles/breakpoints";
import theme from "../styles/theme";
import Icon from "../components/icons";
import Container from "../components/container";
import Button from "../components/button";
import {
  Breadcrumbs,
  PageTitle,
  ArticleLink,
  FeaturedImage,
  ArticlePreview,
  ArticleDate,
  ArticleTitle,
  ArticleBlurb,
  ReadMore,
} from "../styles/global";

class ArticlesPage extends Component {
  render() {
    const meta = this.props.data.site.siteMetadata;
    const articles = this.props.data.allArticles.edges;

    return (
      <Container>
        <Helmet>
          <title>
            Thoughts on technology, people management, & adventures…
          </title>
          <meta
            property="og:title"
            content={`Thoughts on technology, work, and adventuring…`}
          />
          <meta property="og:site_name" content="pixelsonly" />
          <meta property="og:type" content="website" />
          <meta
            property="og:url"
            content="https://www.pixelsonly.com/articles"
          />
          <meta property="og:locale" content="en_US" />
          <meta property="twitter:site" content="@pixelsonly" />
          <meta
            property="twitter:title"
            content={`Thoughts on technology, work, and adventuring…`}
          />
          <link rel="canonical" href="https://www.pixelsonly.com/articles" />
        </Helmet>
        <Flex column>
          <Box width={[1]}>
            <PageTitle fontSize={[4, 5]} px={[1, 1, 4]} mt={[3]} mb={[3]}>
              Thoughts on technology, work, and adventuring…
            </PageTitle>

              <Breadcrumbs
                is="ul"
                direction="row"
                justify="flex-start"
                m={[0]}
                px={[1, 1, 0]}
                pb={[2]}
                fontSize={[1]}>

                  <Link to={`/`}>Home</Link>

/

              </Breadcrumbs>

          </Box>
          <Box width={[1]} pb={[2]}>
            {articles.map((article, i) => {
              const {
                node: {
                  id,
                  title: { title: title },
                  slug,
                  featuredImage: { file: { url: featuredImage } },
                  blurb: { blurb: blurb },
                  date,
                  category: { title: category },
                },
              } = article;
              return (

                  <ArticleLink to={`/articles/${slug}`}>
                    <FeaturedImage
                      src={`${featuredImage}?q=80&w=900&h=420&fl=progressive&fit=fill`}
                      alt=""
                      itemProp="image"
                    />
                    <Flex justify={["flex-start"]} column px={[1, 2]} pb={[3]}>
                      <ArticlePreview
                        width={[1]}
                        mt={[-4]}
                        px={[1, 2]}
                        py={[1, 2]}>
                        <ArticleDate
                          f={[0, 1]}
                          m={[0]}
                          p={[0]}
                          itemProp="datePublished"
                          content={date}>
                          <FormattedDate
                            value={date}
                            year="numeric"
                            month="long"
                            day="2-digit"
                          />
                        </ArticleDate>
                        <ArticleTitle my={[1]} itemProp="headline">
                          {title}
                        </ArticleTitle>
                        <ArticleBlurb
                          mt={[0]}
                          mb={[1]}
                          fontSize={[1]}
                          itemProp="description">
                          {blurb}
                        </ArticleBlurb>
                        <ReadMore>Read more</ReadMore>
                      </ArticlePreview>
                    </Flex>
                  </ArticleLink>

              );
            })}
          </Box>
        </Flex>
      </Container>
    );
  }
}

export default ArticlesPage;

export const pageQuery = graphql`
  query ArticlesPageQuery {
    site {
      siteMetadata {
        title
        description
      }
    }
    allArticles: allContentfulPost(
      limit: 1000
      sort: { fields: [date], order: DESC }
    ) {
      edges {
        node {
          id
          slug
          title {
            title
          }
          featuredImage {
            file {
              url
            }
            responsiveSizes(maxWidth: 900, quality: 80) {
              src
              srcSet
              sizes
            }
            responsiveResolution(width: 400, height: 400) {
              src
              srcSet
              width
              height
            }
          }
          blurb {
            blurb
            childMarkdownRemark {
              html
            }
          }
          body {
            childMarkdownRemark {
              html
            }
          }
          date(formatString: "YYYY-MM-DD")
          author {
            name
            website
            biography {
              biography
              childMarkdownRemark {
                html
              }
            }
            profilePhoto {
              title
              file {
                url
              }
            }
          }
          category {
            title
          }
          comments
        }
      }
    }
  }
`;
<commit_msg>increase PageTitle px<commit_after>import React, { Component } from "react";
import Link from "gatsby-link";
import Helmet from "react-helmet";
import { FormattedDate } from "react-intl";
import styled from "styled-components";
import { space, color, fontSize, responsiveStyle } from "styled-system";
import { Flex, Box, Grid } from "grid-styled";
import { rem, borderRadius } from "polished";
import breakpoint from "../styles/breakpoints";
import theme from "../styles/theme";
import Icon from "../components/icons";
import Container from "../components/container";
import Button from "../components/button";
import {
  Breadcrumbs,
  PageTitle,
  ArticleLink,
  FeaturedImage,
  ArticlePreview,
  ArticleDate,
  ArticleTitle,
  ArticleBlurb,
  ReadMore,
} from "../styles/global";

class ArticlesPage extends Component {
  render() {
    const meta = this.props.data.site.siteMetadata;
    const articles = this.props.data.allArticles.edges;

    return (
      <Container>
        <Helmet>
          <title>
            Thoughts on technology, people management, & adventures…
          </title>
          <meta
            property="og:title"
            content={`Thoughts on technology, work, and adventuring…`}
          />
          <meta property="og:site_name" content="pixelsonly" />
          <meta property="og:type" content="website" />
          <meta
            property="og:url"
            content="https://www.pixelsonly.com/articles"
          />
          <meta property="og:locale" content="en_US" />
          <meta property="twitter:site" content="@pixelsonly" />
          <meta
            property="twitter:title"
            content={`Thoughts on technology, work, and adventuring…`}
          />
          <link rel="canonical" href="https://www.pixelsonly.com/articles" />
        </Helmet>
        <Flex column>
          <Box width={[1]}>
            <PageTitle fontSize={[5]} px={[2, 2, 4]} mt={[3]} mb={[3]}>
              Thoughts on technology, work, and adventuring…
            </PageTitle>

              <Breadcrumbs
                is="ul"
                direction="row"
                justify="flex-start"
                m={[0]}
                px={[1, 1, 0]}
                pb={[2]}
                fontSize={[1]}>

                  <Link to={`/`}>Home</Link>

/

              </Breadcrumbs>

          </Box>
          <Box width={[1]} pb={[2]}>
            {articles.map((article, i) => {
              const {
                node: {
                  id,
                  title: { title: title },
                  slug,
                  featuredImage: { file: { url: featuredImage } },
                  blurb: { blurb: blurb },
                  date,
                  category: { title: category },
                },
              } = article;
              return (

                  <ArticleLink to={`/articles/${slug}`}>
                    <FeaturedImage
                      src={`${featuredImage}?q=80&w=900&h=420&fl=progressive&fit=fill`}
                      alt=""
                      itemProp="image"
                    />
                    <Flex justify={["flex-start"]} column px={[1, 2]} pb={[3]}>
                      <ArticlePreview
                        width={[1]}
                        mt={[-4]}
                        px={[1, 2]}
                        py={[1, 2]}>
                        <ArticleDate
                          f={[0, 1]}
                          m={[0]}
                          p={[0]}
                          itemProp="datePublished"
                          content={date}>
                          <FormattedDate
                            value={date}
                            year="numeric"
                            month="long"
                            day="2-digit"
                          />
                        </ArticleDate>
                        <ArticleTitle my={[1]} itemProp="headline">
                          {title}
                        </ArticleTitle>
                        <ArticleBlurb
                          mt={[0]}
                          mb={[1]}
                          fontSize={[1]}
                          itemProp="description">
                          {blurb}
                        </ArticleBlurb>
                        <ReadMore>Read more</ReadMore>
                      </ArticlePreview>
                    </Flex>
                  </ArticleLink>

              );
            })}
          </Box>
        </Flex>
      </Container>
    );
  }
}

export default ArticlesPage;

export const pageQuery = graphql`
  query ArticlesPageQuery {
    site {
      siteMetadata {
        title
        description
      }
    }
    allArticles: allContentfulPost(
      limit: 1000
      sort: { fields: [date], order: DESC }
    ) {
      edges {
        node {
          id
          slug
          title {
            title
          }
          featuredImage {
            file {
              url
            }
            responsiveSizes(maxWidth: 900, quality: 80) {
              src
              srcSet
              sizes
            }
            responsiveResolution(width: 400, height: 400) {
              src
              srcSet
              width
              height
            }
          }
          blurb {
            blurb
            childMarkdownRemark {
              html
            }
          }
          body {
            childMarkdownRemark {
              html
            }
          }
          date(formatString: "YYYY-MM-DD")
          author {
            name
            website
            biography {
              biography
              childMarkdownRemark {
                html
              }
            }
            profilePhoto {
              title
              file {
                url
              }
            }
          }
          category {
            title
          }
          comments
        }
      }
    }
  }
`;
<|endoftext|>


<commit_before>// Globals
var active_file,
	current_buffer,
	debugData,
	tree,
	lstor,
	workspace,
	worker,
	HOST,
	SOURCE;

init_local_storage();

/** document.ready
 *
 */
$(document).ready(function() {

	init_ace();

	init_canvas();

	init_jquery_ui();

	init_editor_events();

 	load_file_tree();

 	init_toolbar();

});

/** init_local_storage
 * Sets up localStorage (lstor), creating default workspace if none
 * already exists in lstor. Initilizes workspace buffer object from lstor.
 */
function init_local_storage() {

	// abbreviation for window.localStorage
	lstor = window.localStorage;

	// If no workspace is represented in the lstor, create a default:
	if (lstor.getItem("scales_workspace")) {
		// nothing
	} else {
		lstor.setItem("scales_workspace", "[{\"title\":\"default.scala\",\"key\":\"1\",\"contents\":\"this is the contents of the file\",\"language\":\"scala\",\"dirty\":false},{\"title\":\"resource.scala\",\"key\":\"2\",\"contents\":\"/*This is an example of a second file in your project.*/\",\"language\":\"scala\",\"dirty\":false}]");
	}

	// Populate the workspace buffer from the lstor:
	workspace = JSON.parse(lstor.getItem("scales_workspace"));
}

/** load_file_tree
 * Initializes fancy tree element using the urrent workspace object
 * as its JSON source.
 */
function load_file_tree() {

	// Create the fancytree object:
	$('#tree').fancytree({
		source: workspace,
		debugLevel: 0,
		// When a node is activated (clicked/keyboard):
		activate: function(event, data){
			var node = data.node;

			// Enable the ACE editor:

			// If this is the first file activated this session:
			if (editor.getReadOnly()) {
				editor.setReadOnly(false);

			// Else, the user has just switched from another file
			} else {

			}

	        // Set active_file to the newly activated file:
			active_file = node;

			// Load document contents into editor:
			editor.setValue(workspace[get_index()].contents);
		},
		// Apply jQueryUI theme:
		extensions: ["themeroller"]
	  });

	// Initialize global variable tree to the fancyTree object:
	tree  = $("#tree").fancytree("getTree");
}

/** init_toolbar
 * Creates event listeners for the icons in the toolbar
 */
function init_toolbar() {

	// New File button
	$('#new-file-button').click( function() {
		// New file
		file_name = prompt("Enter a name for the file:");
		if (file_name) {
  		workspace.push({
  		  "title": file_name,
  		  "language": "scala",
  		  "key": tree.count() +1,
  		  "contents": "",
  		  "dirty": false
		  });
		}

		// Save the workspace to local storage
		$('#save-changes-button').trigger("click");

	});

	// Save Changes button
	// Saves the current workspace buffer into the local storage object
	$('#save-changes-button').click( function() {
		lstor.setItem("scales_workspace", JSON.stringify(workspace));
		console.log("clicked.");
		tree.reload();
	});

	// Zoom out button
	// Decreases editor font size
	$('#zoom-out-button').click( function() {
		editor.setOption('fontSize', editor.getOption('fontSize') - 2);
	});

	// Zoom In button
	// Increases editor font size
	$('#zoom-in-button').click( function() {
		editor.setOption('fontSize', editor.getOption('fontSize') + 2);
	});
	// Editor Options button
	// Shows ace's options menu
	$('#editor-options-button').click( function() {
		editor.execCommand("showSettingsMenu");
	});
	// Build & Run button
	// Executes XHR's to dynamically load and run javascript files
	// created by the server.
	$('#build-run-button').click( function() {
		HOST = "/compile";
		// Save the workspace to local storage
		$('save-changes-button').click();

		// Send the source code to the compiler and execute the result:
		var build_request = $.ajax({
			type: "POST",
			url: HOST,
			data: JSON.stringify(workspace),
			dataType: "json",
			contentType: "application/json",

			// If it compiles, get the scripts it produced:
			success: function (data) {
				// TODO: remove hard-coded file names
				console.log(data);
				$.ajax({
					url: data.url,
					dataType: "script",
					success: function() {
						Foo().main();
					}

				});
			}
		});
	});
}

/** init_ace
 * Initializes the ACE editor.
 */
function init_ace() {
	// Turn the editor div (#editor) into an Ace editor:
	editor = ace.edit('editor');
	editor.setTheme('ace/theme/monokai');
	editor.getSession().setMode('ace/mode/scala');

	// Wrap text based on size of editor panel:
	var valstr = "/* Welcome to the Scales IDE.";
	valstr += "\nTo use this editor, either choose a file from the list on the left\n";
	valstr += "or create a New File using the button at the top.";
	editor.setValue(valstr);
	editor.setOption("wrap", "free");
	editor.setOption('fontSize', 14);
	editor.setReadOnly(true);

	editor.commands.addCommands([{
   		name: 'buildAndRun',
    	bindKey: {win: 'Ctrl-Enter',  mac: 'Command-Return'},
    	exec: function(editor) {
        //...
        	$('#build-run-button').trigger("click");
    	},
    	readOnly: true // false if this command should not apply in readOnly mode
	}, {
		name: 'zoomIn',
		bindKey: {win: 'Ctrl-Alt-=', mac: 'Command-Alt-='},
		exec: function(editor) {
			$('#zoom-in-button').click();
		},
		readOnly: true
	}, {
		name: 'zoomOut',
		bindKey: {win: 'Ctrl-Alt--', mac: 'Command-Alt--'},
		exec: function(editor) {
			$('#zoom-out-button').click();
		},
		readOnly: true
	}]);
}

/** init_canvas
 * Sets the canvas' html attributes 'width' and 'height' to be the same as
 * its parent container's css attributes for 'width' and 'height'.
 *
 * Changing the canvas' css attributes directly seems to stretch the image.
 */
function init_canvas() {
	$('canvas').attr('width', $('#autodiv').css('width'));
	$('canvas').attr('height', $('#autodiv').css('height'));
	render(); //Redraw canvas
}

/** init_jquery_ui
 * Initializes jQueryUI elements (resizable, draggable, etc.)
 */
function init_jquery_ui() {

	// Make header resizable with a handle on the bottom.
	$('#header').resizable({
		handles: "s",
	});

	// Triggered on header resize: resize other elements to fit:
	// (Magic numbers used to ensure accomodation for resize handles.)
	$('#header').resize( function() {
		$('#panels').css('top', parseInt($(this).css('height')) + 9 + "px");
		$('#autodiv').css("left", $("#resizable").css("width"));
	    $('#autodiv').css("right", "0");
		$('#context-list').css('top',
			parseInt($(this).css('height')) + 9 + "px");
		$('canvas').attr('width', $('#autodiv').css('width'));
		$('canvas').attr('height', $('#autodiv').css('height'));
		render(); // Redraw canvas
	});

	// Make context-list resizable with a handle on the right:
	$('#context-list').resizable( {
    	handles: "e"
  	});

	// Triggered on context-list (project explorer) resize...
	// Automatically resize the panels to the right:
	// (Magic numbers used to ensure accomodation for resize handles.)
	$('#context-list').on("resize", function() {
		$('#panels').css('left',
			parseInt($('#context-list').css('width'))-10 + 'px');
		$('canvas').attr('width', $('#autodiv').css('width'));
		$('canvas').attr('height', $('#autodiv').css('height'));
		render(); // Redraw canvas
  	});

	// Set resizable container for Ace editor with handle to right:
	$( "#resizable" ).resizable( {
    	handles: "e"
  	});

	// Triggered when Ace editor panel is resized:
  	$("#resizable").resize( function() {

		// Notify Ace to update its size:
	    editor.resize();

		// Automatically resize right panel to fill the
		// remainder of div#panels:
	    $('#autodiv').css("left", $("#resizable").css("width"));
	    $('#autodiv').css("right", "0");
		$('#current-file').css('right',$('#resizable').css('right'));
		$('canvas').attr('width', $('#autodiv').css('width'));
		$('canvas').attr('height', $('#autodiv').css('height'));
		render(); // Redraw canvas
	  });
}

/** exec_parser
 *  Executes the PEG.js parser
 */
function exec_parser() {

    try {
      editor.getSession().clearAnnotations();
      parser.parse(editor.getValue());
    } catch(exn) {
      if (!editor.getSession().$annotations) {
        editor.getSession().$annotations = new Array();
      }

      var myAnno = {
        "column": exn['column'],
        "row": exn['line'] - 1,
        "type": "error",
        "raw": exn['message'],
        "text": exn['message']
      };

      editor.getSession().$annotations.push(myAnno);
      editor.getSession().setAnnotations(editor.getSession().$annotations);
    } // catch(exn)
}

/** get_index
 *  returns a zero-based index derived from active_file's
 *  fancyTree key.
 */
function get_index() {
	return active_file.key - 1;
}

/** update_buffer
 *  Stores the editor's contents into the workspace buffer.
 */
function update_buffer() {

	workspace[get_index()].contents = editor.getValue();
	// Find the approprate file in the workspace
}

/** init_parser
 * Initializes parser module. Parses code on change, either passing or
 * encountering an exception. If an exception is thrown, it is caught in
 * this function and its details are applied to the editor as annotations.
 */
function init_editor_events() {
  // Syntax checking/error reporting
  editor.on("change", function(e) {
  	exec_parser();
  	update_buffer();
  });

}

/** render()
 * renders the red square on the canvas.
 */
function render() {
	var c = document.querySelector('canvas');
	var ctx = c.getContext('2d');
	ctx.fillStyle = '#FF0000';
	ctx.fillRect(0,0,50,50);
}

/** window.onbeforeunload
 * Before leaving the page, trigger a save.
 */
window.onbeforeunload = function() {
	document.querySelector('#save-changes-button').click();
};

/** toggleFullScreen
 *  Work in progress
 */
function toggleFullScreen() {
	var canvas = document.querySelector('#playground');
	// output
	if (canvas.mozRequestFullScreen) {
		if (fullScreen) {
			document.mozCancelFullScreen();
		} else {
			canvas.mozRequestFullScreen();
			$('#output').attr("width",window.outerWidth);
			$('#output').attr("height".window.outerHeight);
			render();
		}

	// Webkit
	} else if (canvas.webkitRequestFullscreen) {
		if (document.webkitIsFullScreen) {
			document.webkitExitFullscreen();
		} else {
			canvas.webkitRequestFullscreen();
			$('#output').attr("width",window.outerWidth);
			$('#output').attr("height",window.outerHeight);
			render();

		}
	}
}

// Triggered when the document enters fullscreen (in webkit)
document.addEventListener("webkitfullscreenchange", function(e) {
	if (document.webkitIsFullScreen) {
		console.log(e);
		$('#output').attr("width",window.outerWidth);
		$('#output').attr("height",window.outerHeight);
		//render();

	}
})

// Trigger fullscreen using ALT+ENTER
document.addEventListener("keydown", function(e) {
	if (e.keyCode == 13 && e.altKey) {
  		toggleFullScreen();
  	}
});<commit_msg>Cleaned up based on jsHint.<commit_after>// Globals
var active_file,
	current_buffer,
	debugData,
	tree,
	lstor,
	workspace,
	worker,
	HOST,
	SOURCE;

init_local_storage();

/** document.ready
 *
 */
$(document).ready(function() {

	init_ace();

	init_canvas();

	init_jquery_ui();

	init_editor_events();

    load_file_tree();

    init_toolbar();

});

/** init_local_storage
 * Sets up localStorage (lstor), creating default workspace if none
 * already exists in lstor. Initilizes workspace buffer object from lstor.
 */
function init_local_storage() {

	// abbreviation for window.localStorage
	lstor = window.localStorage;

	// If no workspace is represented in the lstor, create a default:
	if (lstor.getItem("scales_workspace")) {
		// nothing
	} else {
		lstor.setItem("scales_workspace", "[{\"title\":\"default.scala\",\"key\":\"1\",\"contents\":\"this is the contents of the file\",\"language\":\"scala\",\"dirty\":false},{\"title\":\"resource.scala\",\"key\":\"2\",\"contents\":\"/*This is an example of a second file in your project.*/\",\"language\":\"scala\",\"dirty\":false}]");
	}

	// Populate the workspace buffer from the lstor:
	workspace = JSON.parse(lstor.getItem("scales_workspace"));
}

/** load_file_tree
 * Initializes fancy tree element using the urrent workspace object
 * as its JSON source.
 */
function load_file_tree() {

	// Create the fancytree object:
    $('#tree').fancytree({
		source: workspace,
		debugLevel: 0,
		// When a node is activated (clicked/keyboard):
		activate: function(event, data){
			var node = data.node;

			// Enable the ACE editor:

			// If this is the first file activated this session:
			if (editor.getReadOnly()) {
				editor.setReadOnly(false);

			// Else, the user has just switched from another file
			} else {

			}

             // Set active_file to the newly activated file:
			active_file = node;

			// Load document contents into editor:
			editor.setValue(workspace[get_index()].contents);
		},
		// Apply jQueryUI theme:
		extensions: ["themeroller"]
    });

	// Initialize global variable tree to the fancyTree object:
	tree  = $("#tree").fancytree("getTree");
}

/** init_toolbar
 * Creates event listeners for the icons in the toolbar
 */
function init_toolbar() {

	// New File button
	$('#new-file-button').click( function() {
		// New file
		file_name = prompt("Enter a name for the file:");
		if (file_name) {
            workspace.push({
                "title": file_name,
                "language": "scala",
                "key": tree.count() +1,
                "contents": "",
                "dirty": false
            });
		}

		// Save the workspace to local storage
		$('#save-changes-button').trigger("click");

	});

	// Save Changes button
	// Saves the current workspace buffer into the local storage object
	$('#save-changes-button').click( function() {
		lstor.setItem("scales_workspace", JSON.stringify(workspace));
		console.log("clicked.");
		tree.reload();
	});

	// Zoom out button
	// Decreases editor font size
	$('#zoom-out-button').click( function() {
		editor.setOption('fontSize', editor.getOption('fontSize') - 2);
	});

	// Zoom In button
	// Increases editor font size
	$('#zoom-in-button').click( function() {
		editor.setOption('fontSize', editor.getOption('fontSize') + 2);
	});
	// Editor Options button
	// Shows ace's options menu
	$('#editor-options-button').click( function() {
		editor.execCommand("showSettingsMenu");
	});
	// Build & Run button
	// Executes XHR's to dynamically load and run javascript files
	// created by the server.
	$('#build-run-button').click( function() {
		HOST = "/compile";
		// Save the workspace to local storage
		$('save-changes-button').click();

		// Send the source code to the compiler and execute the result:
		var build_request = $.ajax({
			type: "POST",
			url: HOST,
			data: JSON.stringify(workspace),
			dataType: "json",
			contentType: "application/json",

			// If it compiles, get the scripts it produced:
			success: function (data) {
				// TODO: remove hard-coded file names
				console.log(data);
				$.ajax({
					url: data.url,
					dataType: "script",
					success: function() {
						Foo().main();
					}

				});
			}
		});
	});
}

/** init_ace
 * Initializes the ACE editor.
 */
function init_ace() {
	// Turn the editor div (#editor) into an Ace editor:
	editor = ace.edit('editor');
	editor.setTheme('ace/theme/monokai');
	editor.getSession().setMode('ace/mode/scala');

	// Wrap text based on size of editor panel:
	var valstr = "/* Welcome to the Scales IDE.";
	valstr += "\nTo use this editor, either choose a file from the list on the left\n";
	valstr += "or create a New File using the button at the top.";
	editor.setValue(valstr);
	editor.setOption("wrap", "free");
	editor.setOption('fontSize', 14);
	editor.setReadOnly(true);

	editor.commands.addCommands([{
        name: 'buildAndRun',
        bindKey: {win: 'Ctrl-Enter',  mac: 'Command-Return'},
        exec: function(editor) {
            $('#build-run-button').trigger("click");
        },
        readOnly: true
	}, {
		name: 'zoomIn',
		bindKey: {win: 'Ctrl-Alt-=', mac: 'Command-Alt-='},
		exec: function(editor) {
			$('#zoom-in-button').click();
		},
		readOnly: true
	}, {
		name: 'zoomOut',
		bindKey: {win: 'Ctrl-Alt--', mac: 'Command-Alt--'},
		exec: function(editor) {
			$('#zoom-out-button').click();
		},
		readOnly: true
	}]);
}

/** init_canvas
 * Sets the canvas' html attributes 'width' and 'height' to be the same as
 * its parent container's css attributes for 'width' and 'height'.
 *
 * Changing the canvas' css attributes directly seems to stretch the image.
 */
function init_canvas() {
	$('canvas').attr('width', $('#autodiv').css('width'));
	$('canvas').attr('height', $('#autodiv').css('height'));
	render(); //Redraw canvas
}

/** init_jquery_ui
 * Initializes jQueryUI elements (resizable, draggable, etc.)
 */
function init_jquery_ui() {

	// Make header resizable with a handle on the bottom.
	$('#header').resizable({
		handles: "s",
	});

	// Triggered on header resize: resize other elements to fit:
	// (Magic numbers used to ensure accomodation for resize handles.)
	$('#header').resize( function() {
		$('#panels').css('top', parseInt($(this).css('height')) + 9 + "px");
		$('#autodiv').css("left", $("#resizable").css("width"));
        $('#autodiv').css("right", "0");
		$('#context-list').css('top',
			parseInt($(this).css('height')) + 9 + "px");
		$('canvas').attr('width', $('#autodiv').css('width'));
		$('canvas').attr('height', $('#autodiv').css('height'));
		render(); // Redraw canvas
	});

	// Make context-list resizable with a handle on the right:
	$('#context-list').resizable( {
        handles: "e"
    });

	// Triggered on context-list (project explorer) resize...
	// Automatically resize the panels to the right:
	// (Magic numbers used to ensure accomodation for resize handles.)
	$('#context-list').on("resize", function() {
		$('#panels').css('left',
			parseInt($('#context-list').css('width'))-10 + 'px');
		$('canvas').attr('width', $('#autodiv').css('width'));
		$('canvas').attr('height', $('#autodiv').css('height'));
		render(); // Redraw canvas
    });

	// Set resizable container for Ace editor with handle to right:
	$( "#resizable" ).resizable( {
        handles: "e"
    });

	// Triggered when Ace editor panel is resized:
    $("#resizable").resize( function() {

		// Notify Ace to update its size:
        editor.resize();

		// Automatically resize right panel to fill the
		// remainder of div#panels:
        $('#autodiv').css("left", $("#resizable").css("width"));
        $('#autodiv').css("right", "0");
		$('#current-file').css('right',$('#resizable').css('right'));
		$('canvas').attr('width', $('#autodiv').css('width'));
		$('canvas').attr('height', $('#autodiv').css('height'));
		render(); // Redraw canvas
    });
}

/** exec_parser
 *  Executes the PEG.js parser
 */
function exec_parser() {

    try {
      editor.getSession().clearAnnotations();
      parser.parse(editor.getValue());
    } catch(exn) {
      if (!editor.getSession().$annotations) {
        editor.getSession().$annotations = [];
      }

      var myAnno = {
        "column": exn['column'],
        "row": exn['line'] - 1,
        "type": "error",
        "raw": exn['message'],
        "text": exn['message']
      };

      editor.getSession().$annotations.push(myAnno);
      editor.getSession().setAnnotations(editor.getSession().$annotations);
    } // catch(exn)
}

/** get_index
 *  returns a zero-based index derived from active_file's
 *  fancyTree key.
 */
function get_index() {
	return active_file.key - 1;
}

/** update_buffer
 *  Stores the editor's contents into the workspace buffer.
 */
function update_buffer() {

	workspace[get_index()].contents = editor.getValue();
	// Find the approprate file in the workspace
}

/** init_parser
 * Initializes parser module. Parses code on change, either passing or
 * encountering an exception. If an exception is thrown, it is caught in
 * this function and its details are applied to the editor as annotations.
 */
function init_editor_events() {
  // Syntax checking/error reporting
  editor.on("change", function(e) {
    exec_parser();
    update_buffer();
  });

}

/** render()
 * renders the red square on the canvas.
 */
function render() {
	var c = document.querySelector('canvas');
	var ctx = c.getContext('2d');
	ctx.fillStyle = '#FF0000';
	ctx.fillRect(0,0,50,50);
}

/** window.onbeforeunload
 * Before leaving the page, trigger a save.
 */
window.onbeforeunload = function() {
	document.querySelector('#save-changes-button').click();
};

/** toggleFullScreen
 *  Work in progress
 */
function toggleFullScreen() {
	var canvas = document.querySelector('#playground');
	// output
	if (canvas.mozRequestFullScreen) {
		if (fullScreen) {
			document.mozCancelFullScreen();
		} else {
			canvas.mozRequestFullScreen();
			$('#output').attr("width",window.outerWidth);
			$('#output').attr("height".window.outerHeight);
			render();
		}

	// Webkit
	} else if (canvas.webkitRequestFullscreen) {
		if (document.webkitIsFullScreen) {
			document.webkitExitFullscreen();
		} else {
			canvas.webkitRequestFullscreen();
			$('#output').attr("width",window.outerWidth);
			$('#output').attr("height",window.outerHeight);
			render();

		}
	}
}

// Triggered when the document enters fullscreen (in webkit)
document.addEventListener("webkitfullscreenchange", function(e) {
	if (document.webkitIsFullScreen) {
		console.log(e);
		$('#output').attr("width",window.outerWidth);
		$('#output').attr("height",window.outerHeight);
		//render();

	}
})

// Trigger fullscreen using ALT+ENTER
document.addEventListener("keydown", function(e) {
	if (e.keyCode == 13 && e.altKey) {
        toggleFullScreen();
    }
});
<|endoftext|>


<commit_before>import { filter } from '@ember/object/computed';
import Component from '@ember/component';

export default Component.extend({

  filteredModel: filter('model', function(gist) {
    return gist.get('files').map(function(file) {
      return file.get('fileName');
    }).includes('twiddle.json');
  })
});
<commit_msg>fix missing twiddles in twiddles page<commit_after>import { filter } from '@ember/object/computed';
import Component from '@ember/component';

export default Component.extend({

  filteredModel: filter('model', function(gist) {
    let fileNames = gist.get('files').map(function(file) {
      return file.get('fileName');
    });
    return fileNames.any(fileName => /twiddle\\?.json/.test(fileName));
  })
});
<|endoftext|>


<commit_before>var child = Session.get("child");
var _dep = new Deps.Dependency();
var gameVariable;

Template.childProfile.onRendered(function () {
  // Use the Packery jQuery plugin
  child = Session.get("child");
  _dep.changed();
});

var buildStatsChart = function(title, data, htmlId) {

  $(htmlId).highcharts({

    chart: {
      type: 'spline',
      backgroundColor: null
    },

    title: {
      text: title
    },

    credits: {
      enabled: false
    },

    subtitle: {
      text: 'recent scores'
    },

    legend: {
      enabled: false
    },

    xAxis: {
      lineColor: 'black',
      tickColor: 'black',
      labels: {
        enabled: false
      },
      title: {
        text: 'Time'
      }
    },

    yAxis: {
      max: 105,
      gridLineWidth: 0,
      title: {
        text: 'score'
      },
      labels: {
        enabled: false
      }
    },

    tooltip: {
      formatter: function () {
        return '' + child.name + '' + ' scored ' + this.point.y + '%
at ' + this.point.time;
      }
    },

    plotOptions: {
      spline: {
        lineWidth: 8,
        states: {
          hover: {
            lineWidth: 9
          }
        },
        marker: {
          enabled: false,
          symbol: 'circle',
          radius: 3,
          states: {
            hover: {
              enabled: true
            }
          }
        }
      }
    },

    series: [data]
  });
}

var buildAvgCompareChart = function(title, data, htmlId) {

  $(htmlId).highcharts({

    chart: {
      type: 'column',
      backgroundColor: null
    },

    title: {
      text: title
    },

    credits: {
      enabled: false
    },

    subtitle: {
      text: 'your average vs. other kids at your age'
    },

    legend: {
      align: 'right',
      enabled: true
    },

    xAxis: {
      lineColor: 'black',
      tickColor: 'black',
      labels: {
        enabled: false
      }
    },

    yAxis: {
      max: 105,
      gridLineWidth: 0,
      title: {
        text: 'score'
      },
      labels: {
        enabled: false
      }
    },

    tooltip: {
      formatter: function () {
        return "" + this.series.name + "'s average score  " + this.point.y + "%";
      }
    },

    // plotOptions: {
    //   column: {
    //     pointPadding: 0.2,
    //     borderWidth: 0
    //   }
    // },

    series: data
  });
}

var getScoreAvg = function (database, params) {
  var sum = 0;
  var count = database.find(params).count();
  var gameData = database.find(params);
  gameData.map(function(obj){
    sum += obj.score;
  });

  return Math.floor(sum/count) || "-";
};

/*
 * Call the function to built the chart when the template is rendered
 */
// Template.childProfile.rendered = function() {
//     builtArea();
// }

Template.childProfile.helpers({

  childInfo: function() {
    _dep.depend();
    var childInfo = Children.findOne({_id: child.id});
    return childInfo;
  },

  mathsGameStats: function() {
    _dep.depend();
    return getScoreAvg(MathsGame, {child_id: child.id});
  },

  coloursGameStats: function() {
    _dep.depend();
    return getScoreAvg(ColoursGame, {child_id: child.id});
  },

  shapesGameStats: function() {
    _dep.depend();
    return getScoreAvg(ShapesGame, {child_id: child.id});
  }

});

var getGameData = function(database, params) {
  var gameData = database.find(params, {createdaAt: -1});
  var chartData = gameData.map(function(obj){
    return {time: obj.createdAt, y: obj.score};
  });
  return chartData;
}

Template.childProfile.events({

  "click #play-button-dash": function () {
    Router.go('/' + gameVariable);
  },

  "click #maths-game-chart": function() {
    gameVariable = "mathGame"
    var chartData = getGameData(MathsGame, {child_id: child.id});
    var gameScoreSeries = {
      name: "Maths Game",
      data: chartData
    }
    var childAvg = getScoreAvg(MathsGame, {child_id: child.id});
    var ageAvg = getScoreAvg(MathsGame, {child_age: child.age});
    var avgSeries = [
      {name: child.name, data: [childAvg]},
      {name: child.age + "yr olds", data: [ageAvg]}
    ];

    if (chartData.length > 1) {
      buildStatsChart('Maths Game', gameScoreSeries, '#game-stats-chart');
      buildAvgCompareChart('Maths Game', avgSeries, '#game-avg-comparison');
      buildStatsChart('Maths Game', gameScoreSeries, '#game-stats-chart2');
      buildAvgCompareChart('Maths Game', avgSeries, '#game-avg-comparison2');
    } else {
      $('.game-stats-chart').html("
You haven't played enough, play more!
");
      $('.game-avg-comparison').html('');
    }

  },

  "click #colours-game-chart": function() {
    gameVariable = "colours"
    var chartData = getGameData(ColoursGame, {child_id: child.id});
    var gameScoreSeries = {
      name: "Colours Game",
      data: chartData
    }
    var childAvg = getScoreAvg(ColoursGame, {child_id: child.id});
    var ageAvg = getScoreAvg(ColoursGame, {child_age: child.age});
    var avgSeries = [
      {name: child.name, data: [childAvg]},
      {name: child.age + "yr olds", data: [ageAvg]}
    ];

    if (chartData.length > 1) {
      buildStatsChart('Colours Game', gameScoreSeries, '#game-stats-chart');
      buildAvgCompareChart('Colours Game', avgSeries, '#game-avg-comparison');
      buildStatsChart('Colours Game', gameScoreSeries, '#game-stats-chart2');
      buildAvgCompareChart('Colours Game', avgSeries, '#game-avg-comparison2');
    } else {
      $('.game-stats-chart').html("
You haven't played enough, play more!
");
      $('.game-avg-comparison').html('');
    }

  },

  "click #shapes-game-chart": function() {
    gameVariable = "shapes"
    var chartData = getGameData(ShapesGame, {child_id: child.id});
    var gameScoreSeries = {
      name: "Shapes Game",
      data: chartData
    }
    var childAvg = getScoreAvg(ShapesGame, {child_id: child.id});
    var ageAvg = getScoreAvg(ShapesGame, {child_age: child.age});
    var avgSeries = [
      {name: child.name, data: [childAvg]},
      {name: child.age + "yr olds", data: [ageAvg]}
    ];

    if (chartData.length > 1) {
      buildStatsChart('Shapes Game', gameScoreSeries, '#game-stats-chart');
      buildAvgCompareChart('Shapes Game', avgSeries, '#game-avg-comparison');
      buildStatsChart('Shapes Game', gameScoreSeries, '#game-stats-chart2');
      buildAvgCompareChart('Shapes Game', avgSeries, '#game-avg-comparison2');
    } else {
      $('.game-stats-chart').html("
You haven't played enough, play more!
");
      $('.game-avg-comparison').html('');
    }
  },

  "click .maths-game": function(event, template) {
    Router.go('/mathGame');
  },

  "click .colours-game": function(event, template) {
    Router.go('/colours');
  },

  "click .game-three": function(event, template) {
    Router.go('/game/3');
  },

  "click .game-four": function(event, template) {
    Router.go('/shapes')
  }

});<commit_msg>fixed chart bug when no data to pring 'play more games'<commit_after>
var child = Session.get("child");
var _dep = new Deps.Dependency();
var gameVariable;

Template.childProfile.onRendered(function () {
  // Use the Packery jQuery plugin
  child = Session.get("child");
  _dep.changed();
});

var buildStatsChart = function(title, data, htmlId) {

  $(htmlId).highcharts({

    chart: {
      type: 'spline',
      backgroundColor: null
    },

    title: {
      text: title
    },

    credits: {
      enabled: false
    },

    subtitle: {
      text: 'recent scores'
    },

    legend: {
      enabled: false
    },

    xAxis: {
      lineColor: 'black',
      tickColor: 'black',
      labels: {
        enabled: false
      },
      title: {
        text: 'Time'
      }
    },

    yAxis: {
      max: 105,
      gridLineWidth: 0,
      title: {
        text: 'score'
      },
      labels: {
        enabled: false
      }
    },

    tooltip: {
      formatter: function () {
        return '' + child.name + '' + ' scored ' + this.point.y + '%
at ' + this.point.time;
      }
    },

    plotOptions: {
      spline: {
        lineWidth: 8,
        states: {
          hover: {
            lineWidth: 9
          }
        },
        marker: {
          enabled: false,
          symbol: 'circle',
          radius: 3,
          states: {
            hover: {
              enabled: true
            }
          }
        }
      }
    },

    series: [data]
  });
}

var buildAvgCompareChart = function(title, data, htmlId) {

  $(htmlId).highcharts({

    chart: {
      type: 'column',
      backgroundColor: null
    },

    title: {
      text: title
    },

    credits: {
      enabled: false
    },

    subtitle: {
      text: 'your average vs. other kids at your age'
    },

    legend: {
      align: 'right',
      enabled: true
    },

    xAxis: {
      lineColor: 'black',
      tickColor: 'black',
      labels: {
        enabled: false
      }
    },

    yAxis: {
      max: 105,
      gridLineWidth: 0,
      title: {
        text: 'score'
      },
      labels: {
        enabled: false
      }
    },

    tooltip: {
      formatter: function () {
        return "" + this.series.name + "'s average score  " + this.point.y + "%";
      }
    },

    // plotOptions: {
    //   column: {
    //     pointPadding: 0.2,
    //     borderWidth: 0
    //   }
    // },

    series: data
  });
}

var getScoreAvg = function (database, params) {
  var sum = 0;
  var count = database.find(params).count();
  var gameData = database.find(params);
  gameData.map(function(obj){
    sum += obj.score;
  });

  return Math.floor(sum/count) || "-";
};

/*
 * Call the function to built the chart when the template is rendered
 */
// Template.childProfile.rendered = function() {
//     builtArea();
// }

Template.childProfile.helpers({

  childInfo: function() {
    _dep.depend();
    var childInfo = Children.findOne({_id: child.id});
    return childInfo;
  },

  mathsGameStats: function() {
    _dep.depend();
    return getScoreAvg(MathsGame, {child_id: child.id});
  },

  coloursGameStats: function() {
    _dep.depend();
    return getScoreAvg(ColoursGame, {child_id: child.id});
  },

  shapesGameStats: function() {
    _dep.depend();
    return getScoreAvg(ShapesGame, {child_id: child.id});
  }

});

var getGameData = function(database, params) {
  var gameData = database.find(params, {createdaAt: -1});
  var chartData = gameData.map(function(obj){
    return {time: obj.createdAt, y: obj.score};
  });
  return chartData;
}

Template.childProfile.events({

  "click #play-button-dash": function () {
    Router.go('/' + gameVariable);
  },

  "click #maths-game-chart": function() {
    gameVariable = "mathGame"
    var chartData = getGameData(MathsGame, {child_id: child.id});
    var gameScoreSeries = {
      name: "Maths Game",
      data: chartData
    }
    var childAvg = getScoreAvg(MathsGame, {child_id: child.id});
    var ageAvg = getScoreAvg(MathsGame, {child_age: child.age});
    var avgSeries = [
      {name: child.name, data: [childAvg]},
      {name: child.age + "yr olds", data: [ageAvg]}
    ];

    if (chartData.length > 1) {
      buildStatsChart('Maths Game', gameScoreSeries, '#game-stats-chart');
      buildAvgCompareChart('Maths Game', avgSeries, '#game-avg-comparison');
      buildStatsChart('Maths Game', gameScoreSeries, '#game-stats-chart2');
      buildAvgCompareChart('Maths Game', avgSeries, '#game-avg-comparison2');
    } else {
      $('#game-stats-chart').html("
You haven't played enough, play more!
");
      $('#game-stats-chart2').html("
You haven't played enough, play more!
");
      $('#game-avg-comparison').html('');
      $('#game-avg-comparison2').html('');
    }

  },

  "click #colours-game-chart": function() {
    gameVariable = "colours"
    var chartData = getGameData(ColoursGame, {child_id: child.id});
    var gameScoreSeries = {
      name: "Colours Game",
      data: chartData
    }
    var childAvg = getScoreAvg(ColoursGame, {child_id: child.id});
    var ageAvg = getScoreAvg(ColoursGame, {child_age: child.age});
    var avgSeries = [
      {name: child.name, data: [childAvg]},
      {name: child.age + "yr olds", data: [ageAvg]}
    ];

    if (chartData.length > 1) {
      buildStatsChart('Colours Game', gameScoreSeries, '#game-stats-chart');
      buildAvgCompareChart('Colours Game', avgSeries, '#game-avg-comparison');
      buildStatsChart('Colours Game', gameScoreSeries, '#game-stats-chart2');
      buildAvgCompareChart('Colours Game', avgSeries, '#game-avg-comparison2');
    } else {
      $('#game-stats-chart').html("
You haven't played enough, play more!
");
      $('#game-stats-chart2').html("
You haven't played enough, play more!
");
      $('#game-avg-comparison').html('');
      $('#game-avg-comparison2').html('');
    }

  },

  "click #shapes-game-chart": function() {
    gameVariable = "shapes"
    var chartData = getGameData(ShapesGame, {child_id: child.id});
    var gameScoreSeries = {
      name: "Shapes Game",
      data: chartData
    }
    var childAvg = getScoreAvg(ShapesGame, {child_id: child.id});
    var ageAvg = getScoreAvg(ShapesGame, {child_age: child.age});
    var avgSeries = [
      {name: child.name, data: [childAvg]},
      {name: child.age + "yr olds", data: [ageAvg]}
    ];

    if (chartData.length > 1) {
      buildStatsChart('Shapes Game', gameScoreSeries, '#game-stats-chart');
      buildAvgCompareChart('Shapes Game', avgSeries, '#game-avg-comparison');
      buildStatsChart('Shapes Game', gameScoreSeries, '#game-stats-chart2');
      buildAvgCompareChart('Shapes Game', avgSeries, '#game-avg-comparison2');
    } else {
      $('#game-stats-chart').html("
You haven't played enough, play more!
");
      $('#game-stats-chart2').html("
You haven't played enough, play more!
");
      $('#game-avg-comparison').html('');
      $('#game-avg-comparison2').html('');
    }
  },

  "click .maths-game": function(event, template) {
    Router.go('/mathGame');
  },

  "click .colours-game": function(event, template) {
    Router.go('/colours');
  },

  "click .game-three": function(event, template) {
    Router.go('/game/3');
  },

  "click .game-four": function(event, template) {
    Router.go('/shapes')
  }

});<|endoftext|>