-
Notifications
You must be signed in to change notification settings - Fork 3
/
loadState.js
54 lines (40 loc) · 1.68 KB
/
loadState.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
50
51
52
53
54
var loadState = new function () {
var self = this;
var pacManWebModulesLoadedCount = 0;
var scriptsFinished = false;
var assetsFinished = false;
this.__finishedLoading = false;
this.assetLoaded = function (assetName, percentage) {
var p = document.getElementById("progress-bar-assets-percentage");
p.style.width = percentage + "%";
var scriptNameSpan = document.getElementById("progress-assetname");
scriptNameSpan.innerText = assetName;
};
this.scriptLoaded = function (moduleName) {
var p = document.getElementById("progress-bar-scripts-percentage");
pacManWebModulesLoadedCount = pacManWebModulesLoadedCount + 1;
var percentage = (pacManWebModulesLoadedCount / 93) * 100;
console.info(pacManWebModulesLoadedCount);
p.style.width = percentage + "%";
var scriptNameSpan = document.getElementById("progress-scriptname");
scriptNameSpan.innerText = moduleName;
}
this.scriptsFinishedLoading = function() {
scriptsFinished = true;
};
this.waitForFinish = function () {
setTimeout(this.checkFinished);
};
this.checkFinished = function () {
assetsFinished =
document.getElementById("progress-bar-assets-percentage").style.width === "100%";
if (scriptsFinished === false || assetsFinished === false) {
setTimeout(self.checkFinished);
} else {
document.getElementById("loader").hidden = "true";
document.getElementById("controlPanel").style.visibility = "visible";
console.info("setting __finishedLoading!");
self.__finishedLoading = true;
}
};
}