-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontent.js
149 lines (143 loc) · 4.12 KB
/
content.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
let stages = [{
"id": "stage-1-0",
"name": "Description",
"brief": "Description",
"valid": true
}, {
"id": "stage-1-1",
"name": "Document",
"brief": "Document",
"valid": true
}];
let survey = {
"name": "Survey Example",
"id": "Designed-Survey-ID-00001",
"version": "0",
"time": (new Date()).getTime(),
"text": "Change the Answer to see Real-Time Survey Update!",
"data": [{
"name": "Multi Choice Question Example",
"id": "T-0-Q-1",
"type": "multi",
"text": "What question type are you looking for?",
"must": false,
"page": 1,
"data": {
"selection": [{
"id": "0",
"text": "Open Text"
}, {
"id": "1",
"text": "Checkbox"
}, {
"id": "2",
"text": "Upload File"
}]
}
}, {
"name": "Open Text Question Example",
"id": "T-0-Q-2",
"type": "open",
"condition": {
"id": "T-0-Q-1",
"data": "0"
},
"text": "Any feedback?",
"must": false,
"page": 1,
"data": {
"text": "Write your feedback here!"
}
}, {
"name": "Checkbox Question Example",
"id": "T-0-Q-3",
"type": "checkbox",
"condition": {
"id": "T-0-Q-1",
"data": "1"
},
"text": "Question description...",
"must": false,
"page": 1,
"data": {
"selection": [{
"id": "0",
"text": "Test Option 1"
}, {
"id": "1",
"text": "Test Option 2"
}]
}
}, {
"name": "Upload Question Example",
"id": "T-0-Q-4",
"type": "upload",
"condition": {
"id": "T-0-Q-1",
"data": "2"
},
"text": "Question description...",
"must": false,
"page": 1,
"data": {
"multiple": true
}
}]
};
function setDescription(content){
let report = getReport4Survey(survey);
// layout
let tmp1 = document.createElement('div');
tmp1.className = "w3-row";
let tmp2 = document.createElement('div');
tmp2.className = "w3-half";
tmp2.id = "survey";
tmp1.appendChild(tmp2);
let tmp3 = document.createElement('div');
tmp3.className = "w3-half w3-padding";
tmp3.style.height = "100%";
let tmp4 = document.createElement('div');
tmp4.innerHTML = "Real-Time Survey Update Demonstration!";
tmp3.appendChild(tmp4);
let tmp5 = document.createElement('textarea');
tmp5.className = "w3-margin w3-padding";
tmp5.style.height = "100%";
tmp5.style.width = "100%";
tmp5.style.fontFamily = "Courier New";
tmp5.innerHTML = JSON.stringify(report, null, 4);
tmp3.appendChild(tmp5);
tmp1.appendChild(tmp3);
content.appendChild(tmp1);
// draw
drawSurvey(survey, report);
showPage(survey, report, CURRENTPAGE);
// change context
tmp2.onchange = function(){
let tmpReport = finalizeReport(survey, report);
tmp5.innerHTML = JSON.stringify(tmpReport, null, 4);
}
}
function setDocument(content){
let tmp1 = document.createElement('div');
loadFile("README.md", (mdstr) => {
tmp1.innerHTML = window.markdownit().render(mdstr);
});
let tmp2 = document.createElement('h2');
tmp2.innerHTML = "Links";
let tmp3 = document.createElement('a');
tmp3.innerHTML = " - Github Link";
tmp3.href = "https://github.com/TakoAI/TakoQ";
let tmp4 = document.createElement('a');
tmp4.innerHTML = " - Website Link";
tmp4.href = "https://takoai.github.io/TakoQ";
content.appendChild(tmp1);
content.appendChild(document.createElement("p"));
content.appendChild(tmp2);
content.appendChild(document.createElement("p"));
content.appendChild(tmp3);
content.appendChild(document.createElement("p"));
content.appendChild(tmp4);
}
let functions = [setDescription, setDocument];
setProgress(stages, 0, "TakoQ", functions);
setContent(stages, 0, functions);