-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
43 lines (39 loc) · 916 Bytes
/
app.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
var registeredActions = [];
if (typeof App !== 'undefined') {
registeredActions = App;
}
var App = {
/**
* Handle already registered actions.
*
* @param {String} id Element ID
* @param {String} text Text to show
*/
init: function (id, text) {
document.getElementById(id).innerHTML = text;
},
/**
* Implement array's push method to handle push calls.
*
* @param {Array|Function} item Method call. [method_name, args...]
*/
push: function (item) {
if (typeof item === 'function') {
item()
} else {
var functionName = item.shift()
App[functionName].apply(null, item)
}
},
/**
* Handle already registered actions.
*
* @param {Array} array History of calls
*/
_processHistory: function (array) {
for (var i = 0; i < array.length; i++) {
App.push(array[i])
}
}
}
App._processHistory(registeredActions)