forked from episphere/quest
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
273 lines (257 loc) · 13.5 KB
/
index.html
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
<!-- Font Awesome -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/[email protected]/css/fontawesome.min.css" integrity="sha384-BY+fdrpOd3gfeRvTSMT+VUZmA728cfF9Z2G42xpaRkUGu2i3DyzpTURDo5A6CaLK" crossorigin="anonymous">
<!-- Custom CSS -->
<link id="pagestyle" href="Default.css" rel="stylesheet" type="text/css">
<link id="pagelogic" href="Default.css" rel="stylesheet" type="text/css">
<link href="Quest.css" rel="stylesheet" type="text/css">
<title>Quest</title>
</head>
<body class="w-100">
<nav id="questNavbar" class="navbar navbar-expand-sm quest-bg-gradient" data-bs-theme="dark">
<div class="container-fluid">
<a class="navbar-brand text-baskerville" href="#">Quest</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#questNavContent" aria-controls="questNavContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="questNavContent">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" data-bs-toggle="offcanvas" href="#settings"
aria-controls="settings">Settings</a>
</li>
<li class="nav-item">
<a class="nav-link" href="https://github.com/episphere/quest-dev" target="_blank"
rel="noopener noreferrer">Source</a>
</li>
<li class="nav-item">
<a class="nav-link" href="https://github.com/episphere/quest/wiki" target="_blank"
rel="noopener noreferrer">Wiki</a>
</li>
<li class="nav-item">
<a class="nav-link" href="https://github.com/episphere/quest-dev/issues" target="_blank"
rel="noopener noreferrer">Issues</a>
</li>
<li class="nav-item">
<a class="nav-link" href="https://gitter.im/episphere/quest" target="_blank"
rel="noopener noreferrer">Talk to us</a>
</li>
<li class="nav-item">
<a class="nav-link" data-bs-toggle="offcanvas" href="#cache" role="button"
id="viewCurrentResponses" aria-controls="cache">View Current Responses</a>
</li>
<li class="nav-item">
<a class="nav-link" id="Reference" href="https://doi.org/10.1186/s12911-023-02338-6"
target="_blank" rel="noopener noreferrer">Paper</a>
</li>
<li class="nav-item">
<a class="nav-link" data-bs-toggle="offcanvas" href="#helpOC" role="button"
aria-controls="helpOC">Help</a>
</li>
</ul>
</div>
</div>
</nav>
<div class="container-fluid" id="tool">
<div class="offcanvas offcanvas-start" tabindex="-1" id="settings" aria-labelledby="settingLabel">
<div class="offcanvas-header">
<h5 class="offcanvas-title" id="settingLabel">Settings</h5>
<button type="button" class="btn-close" data-bs-dismiss="offcanvas" aria-label="Close"></button>
</div>
<div class="offcanvas-body">
<div class="d-flex flex-wrap">
<form class="form border flex-grow-1 p-1 d-flex flex-column">
<h3>Questionnaire Options</h3>
<div>
<label for="url" class="form-label">Module URL</label>
<div class="input-group mb-3">
<input id="url" class="form-control" aria-label="url">
<button type="button" class="btn btn-outline-secondary" id="loadURLBtn" aria-label="Load URL">Load</button>
</div>
<label for="tb" class="form-label">Save Module</label>
<div class="input-group mb-3">
<input id="tb" class="form-control" aria-label="File Name" style="margin-top: 10px;">
<button type="button" class="btn">.txt</button>
<button type="button" class="btn btn-outline-secondary" id="saveBtn" aria-label="Save">Save</button>
</div>
</div>
<div>
<label class="form-check form-switch mt-2">
Use Styling
<input class="form-check-input" type="checkbox" role="switch" id="styling" data-sheet-on="Style1.css" data-sheet-off="Default.css">
</label>
</div>
<div>
<label class="form-check form-switch mt-2">
Activate Logic
<input class="form-check-input" type="checkbox" role="switch" id="logic" data-sheet-on="ActiveLogic.css" data-sheet-off="Default.css">
</label>
</div>
<div>
<label class="form-check form-switch mt-2">
Hide Markup
<input class="form-check-input" type="checkbox" role="switch" id="hide-markup">
</label>
</div>
<div>
<label for="langSelect">Language:</label>
<div class="input-group mb-3">
<select id="langSelect" class="form-select" aria-label="quest-locale">
<option value="en" selected>en-US</option>
<option value="es">en-MX</option>
</select>
</div>
</div>
</form>
<div class="border flex-grow-1 p-1">
<h3>Previous Results</h3>
<textarea id="jsonInput" aria-label="json input" style="width: 100%; height:150px"></textarea>
<div class="col" style="margin-top: 10px;">
<button type="button" id="updater" class="btn btn-outline-secondary">Add JSON to
Memory</button>
<button type="button" id="clearMem" class="btn btn-outline-danger">Clear Memory</button>
<div id="loadDisplay"></div>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-12 col-md-6" id="markup">
<div class="d-flex flex-wrap justify-content-between align-items-end">
<span class="me-1 h4">Markup</span>
<div class="d-flex align-items-center">
<span class="me-1 h5">(<a
href="https://raw.githubusercontent.com/episphere/quest/main/questionnaires/demo.txt"
id="demo">Demo</a>)</span>
<label for="fontSpan" id="fontSpan" class="me-1 h5">Change Font Size</label>
<button type="button" id="increaseSizeButton" aria-label="Increase Font Size"
class="btn btn-sm btn-outline-primary me-1">+</button>
<button type="button" id="decreaseSizeButton" aria-label="Decrease Font Size"
class="btn btn-sm btn-outline-primary">-</button>
</div>
</div>
<textarea class="form-control" id="markupTextArea" placeholder="type, paste, or upload questionnaire markup"></textarea>
</div>
<div class="col-12 col-md-6">
<h4 id="renderText" style="color: navy;">Rendering</h4>
<div id="rendering"></div>
</div>
</div>
</div>
<div id="helpOC" class="offcanvas offcanvas-end" tabindex="-1" aria-labelledby="helpOCLabel">
<div class="offcanvas-header">
<h5 class="offcanvas-title" id="helpOCLabel">Help</h5>
<button type="button" class="btn-close" data-bs-dismiss="offcanvas" aria-label="Close"></button>
</div>
<div class="offcanvas-body">
<div class="card">
<div class="card-body">
<h5 class="card-title">How do I load a module from a URL?</h5>
<p class="card-text">
The questionnaire module load/save features were hidden to save space on the screen.
Click "settings" in the menu and type the URL in the <i>Module URL</i> box.
</p>
</div>
</div>
</div>
</div>
<div id="cache" class="offcanvas offcanvas-end" tabindex="-1" aria-labelledby="cacheLabel">
<div class="offcanvas-header">
<h5 class="offcanvas-title" id="cacheLabel">Current Responses</h5>
<button type="button" class="btn-close" data-bs-dismiss="offcanvas" aria-label="Close"></button>
</div>
<div class="offcanvas-body">
<table class="table table-striped" id="currentResponsesTable"></table>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL"
crossorigin="anonymous" defer></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/localforage/1.10.0/localforage.min.js" defer></script>
<script src="main.js" type="module"></script>
<script src="buildGrid.js" type="module"></script>
<script src="quest.js" type="module"></script>
<script>
function changeStyle(sheet) {
document.getElementById("pagestyle").setAttribute("href", sheet)
}
function changeLogic(sheet) {
document.getElementById("pagelogic").setAttribute("href", sheet)
}
</script>
<script>
function goToLink() {
let a = document.createElement('a')
a.href = "https://github.com/episphere/quest/upload/master/questionnaires"
a.target = "_blank"
a.click()
}
document.getElementById("demo").addEventListener("click", (event) => {
event.preventDefault();
const demoUrl = document.getElementById("demo").href;
let newUrl = new URL(window.location.href);
newUrl.searchParams.set('url', demoUrl);
window.location.href = newUrl.toString();
})
</script>
<script>
function saveDoc() {
let bb = new Blob([markupTextArea.value])
let url = URL.createObjectURL(bb);
let a = document.createElement('a');
a.href = url;
let tb = document.getElementById('tb')
if (!tb.value?.trim()) { tb.value = "demo" }
a.download = tb.value;
a.click() // then download it automatically
return a
}
</script>
<script>
function submitURL() {
let url = document.getElementById("url").value
let newUrl = new URL(window.location.href);
newUrl.searchParams.set('url', url);
window.location.href = newUrl.toString();
}
</script>
<script>
function onFileSelected(event) {
let file = event.target.files[0]
let reader = new FileReader()
reader.onload = function (event) {
let markupTextArea = document.getElementById("markupTextArea")
markupTextArea.value = event.target.result
markupTextArea.onkeyup()
}
reader.readAsText(file)
}
</script>
<script>
let searchParams = new URLSearchParams(location.search)
if (location.hash.split('&').includes('run') || searchParams.has('run')) {
document.getElementById('logic').checked=true;
changeLogic("ActiveLogic.css");
document.getElementById('questNavbar').style.display = 'none';
document.getElementById('markup').style.display = 'none';
document.getElementById('renderText').style.display = 'none';
}
let styleRegex = /^style=([^&\s]+)/
let styleIndx = location.hash.split("&").findIndex((x) => styleRegex.exec(x))
if (styleIndx > -1) {
let styleSheet = location.hash.split("&")[styleIndx].match(styleRegex)[1]
console.log(styleSheet)
changeStyle(styleSheet)
} else if (searchParams.has('style')) {
changeStyle(searchParams.get('style'))
}
</script>
</body>
</html>