-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgress.js
54 lines (47 loc) · 1.11 KB
/
Progress.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
export default class Progress {
constructor() {
this.message = '';
this.phase = 'none';
this.download = {
errors: [],
remaining: 0,
currentWord: '',
};
this.layout = {
iteration: 0
};
this.working = true
}
startDownload() {
this.phase = 'download';
}
startLayout() {
this.message = 'Finished download. Constructing layout...';
this.phase = 'layout';
}
setLayoutCompletion(layoutCompletion) {
if (this.phase === 'layout') {
this.message = `Finished download. Constructing layout ${layoutCompletion}%...`;
}
}
updateLayout(remaining, nextWord) {
this.download.currentWord = nextWord;
this.download.remaining = remaining;
this.message = `Remaining: ${remaining}. Downloading ${nextWord}`;
}
done() {
this.working = false;
}
downloadError(message) {
this.download.errors.push(message);
}
reset() {
this.phase = 'none',
this.download.errors = [];
this.download.remaining = 0;
this.download.currentWord = '';
this.layout.iteration = 0;
this.message = '';
this.working = true;
}
}