var defaults = ["1/1", "2-1", "3*(3+2)", "5*3", "4+12", "0+16"]; var Card = (function() { var self = Object.create({}, { val: { value: -1, writable: true }, id: { value: -1, writable: true }, index: { value: -1, writable: true }, isMatch: { value: function(card) { if (this.val == card.val) { return true; } return false; } } }); return self; })(); var Game = (function() { var self = Object.create({}, { cards: { value: null, enumarable: true, writable: true }, matches: { value: 0, writable: true }, init: { value: function(count) { if(typeof count !== "number"){ log("Cards count must be an number"); return; } this.cards = new Array(count); for (i = 0; i < this.cards.length / 2; i++) { var card = Object.create(Card, { val: { value: i+1 }, id: { value: i*2 } }); card.index = card.id; var card2 = Object.create(Card, { val: { value: i+1 }, id: { value: card.index+1 } }); card2.index = card2.id; this.cards[card.index] = card; this.cards[card2.index] = card2; } } }, selected: { value: null, writable: true } }); return self; })(); function onTemplateLoadedCallback() { $("select[name=count]").each(function(i, select) { var min = $(select).data("min"); var max = $(select).data("max"); for(var i = min ; i <= max ; i=i+2) { var option = $("