2015-10-19 11:17:38 +02:00
|
|
|
(function (MemoryGame) {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Keeps track of the number of cards that has been turned
|
|
|
|
*
|
|
|
|
* @class H5P.MemoryGame.Counter
|
|
|
|
* @param {H5P.jQuery} $container
|
|
|
|
*/
|
|
|
|
MemoryGame.Counter = function ($container) {
|
2017-02-13 14:42:34 +01:00
|
|
|
/** @alias H5P.MemoryGame.Counter# */
|
2015-10-19 11:17:38 +02:00
|
|
|
var self = this;
|
|
|
|
|
|
|
|
var current = 0;
|
|
|
|
|
2017-02-13 14:42:34 +01:00
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
var update = function () {
|
|
|
|
$container[0].innerText = current;
|
|
|
|
};
|
|
|
|
|
2015-10-19 11:17:38 +02:00
|
|
|
/**
|
|
|
|
* Increment the counter.
|
|
|
|
*/
|
|
|
|
self.increment = function () {
|
|
|
|
current++;
|
2017-02-13 14:42:34 +01:00
|
|
|
update();
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Revert counter back to its natural state
|
|
|
|
*/
|
|
|
|
self.reset = function () {
|
|
|
|
current = 0;
|
|
|
|
update();
|
2015-10-19 11:17:38 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
})(H5P.MemoryGame);
|