/
timer.ui.js
73 lines (51 loc) · 2.48 KB
/
timer.ui.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
==========================================================================
* Created by tim on 6/12/18.
==========================================================================
timer.ui in plugins
Author: Tim Erickson
Copyright (c) 2018 by The Concord Consortium, Inc. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==========================================================================
*/
timer.ui = {
initialize : function() {
this.update();
},
update : function() {
this.makeDataButtons();
const newSetButton = document.getElementById("newSetButton");
const statusDiv = document.getElementById("status");
const wholeTimerDiv = document.getElementById("wholeTimer");
const editorDiv = document.getElementById("editMode");
const editorTextBox = document.getElementById("timerConfigurationTextBox");
let tCaseOrCasesWord = (timer.sequenceNumber - 1) === 1 ? " case " : " cases "
let theStatus = timer.waiting
? "Waiting for the first data in set " + (timer.state.setNumber + 1)
: "You have " + (timer.sequenceNumber - 1) + tCaseOrCasesWord + " in set " + timer.state.setNumber;
newSetButton.style.visibility = timer.waiting ? "hidden" : "visible";
statusDiv.innerHTML = theStatus;
wholeTimerDiv.style.display = timer.timerMode ? "block" : "none";
editorDiv.style.display = timer.timerMode ? "none" : "block";
editorTextBox.value = timer.state.configurationText;
},
makeDataButtons : function() {
const buttonTextArray = timer.state.configurationText.split(",");
let buttonsHTMLArray = [];
buttonTextArray.forEach( name => {
const thisButton =
"<button class = 'do' " +
`onclick='timer.doDataButton("${name}")'>${name}</button>`;
buttonsHTMLArray.push(thisButton);
});
document.getElementById("dataButtonDiv").innerHTML = buttonsHTMLArray.join(' ');
}
};