-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrender-check_list.js
58 lines (46 loc) · 1.57 KB
/
render-check_list.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
// Writes parsed check lists based on 'Checkboxes' form elements to the output document. (field-check_list)
function constructCheckListOptions(parsedCheck, dataObject)
{
var filledText = dataObject.filledItem;
var emptyText = dataObject.unfilledItem;
var optionIndex = 0;
var currentOption = "";
var currentChosen = false;
var currentSelectStart = -1;
var currentSelectEnd = -1;
var currentBold = [];
// Loops list options.
for (optionIndex = 0; optionIndex < parsedCheck.checkboxList.length; optionIndex = optionIndex + 1)
{
// Reads option and whether it has been ticked.
currentOption = parsedCheck.checkboxList[optionIndex];
currentChosen = parsedCheck.chosenItems.includes(optionIndex);
currentSelectStart = -1;
currentSelectEnd = -1;
currentSymbolLocation = [];
dataObject.textString += "\r";
// Begin symbol text.
currentSelectStart = dataObject.textString.length - 1;
if (currentChosen === true)
{
dataObject.textString += filledText;
}
else
{
dataObject.textString += emptyText;
}
// End symbol text.
currentSelectEnd = dataObject.textString.length - 1;
// Save symbol location.
currentSymbolLocation = [currentSelectStart, currentSelectEnd];
dataObject.symbolArray.push(currentSymbolLocation);
// Writes answer text.
dataObject.textString += "\t";
dataObject.textString += currentOption;
// Marks symbol text as bold if applicable.
if (dataObject.boldSelection === true)
{
dataObject.boldArray.push(currentSymbolLocation);
}
}
}