-
Notifications
You must be signed in to change notification settings - Fork 62
/
Copy pathcounter.js
49 lines (41 loc) · 900 Bytes
/
counter.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
(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, startValue = 0) {
/** @alias H5P.MemoryGame.Counter# */
var self = this;
var current = startValue;
/**
* @private
*/
self.update = function () {
$container[0].innerText = current;
};
/**
* Get current count.
* @returns {number} Current count.
*/
self.getCount = () => {
return current;
}
/**
* Increment the counter.
*/
self.increment = function () {
current++;
self.update();
};
/**
* Revert counter back to its natural state
*/
self.reset = function () {
current = 0;
self.update();
};
self.update();
};
})(H5P.MemoryGame);