forked from episphere/quest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
237 lines (225 loc) · 11.3 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/[email protected]/css/fontawesome.min.css" integrity="sha384-BY+fdrpOd3gfeRvTSMT+VUZmA728cfF9Z2G42xpaRkUGu2i3DyzpTURDo5A6CaLK" crossorigin="anonymous">
<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">
<script src="replace2.js" type="module"></script>
<script src="buildGrid.js" type="module"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/localforage/1.7.3/localforage.min.js"></script>
<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="navbarSupportedContent" 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">Settings</a>
</li>
<li class="nav-item">
<a class="nav-link" href="https://github.com/episphere/quest" target="_blank">Source</a>
</li>
<li class="nav-item">
<a class="nav-link" href="https://github.com/episphere/quest/wiki" target="_blank">Wiki</a>
</li>
<li class="nav-item">
<a class="nav-link" href="https://github.com/episphere/quest/issues" target="_blank">Issues</a>
</li>
<li class="nav-item">
<a class="nav-link" href="https://gitter.im/episphere/quest" target="_blank">Talk to us</a>
</li>
<li class="nav-item">
<a class="nav-link" data-bs-toggle="offcanvas" href="#cache" role="button" id="viewCache">Cached Responses</a>
</li>
<li class="nav-item">
<a class="nav-link" data-bs-toggle="offcanvas" href="#helpOC" role="button">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" onchange="submitURL()">
<input type="button" aria-label="submit" value="Load" onclick="submitURL()"></input>
</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 aria-label="Save" onclick="saveDoc()">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>
</form>
<div class="border flex-grow-1 p-1">
<h3>Previous Results</h3>
<textarea id="json_input" aria-label="json input" style="width: 100%; height:150px"></textarea>
<div class="col" style="margin-top: 10px;">
<input type="button" id="updater" value="add JSON to memory"/>
<input type="button" id="clearMem" value="Clear Memory"/>
<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">
<span class="me-1 h4">Markup</span>
<div class="d-flex align-items-end">
<span class="me-1 h5">(<a href="#questionnaires/demo.txt" id="demo">Demo</a>)</span>
<label for="buttonFlex" id="fontSpan" class=" me-1 h5">Change Font Size </label>
<button id="increaseSizeButton" aria-label="increaseSize" class="me-1 h4">⊕</button>
<button id="decreaseSizeButton" aria-label="decreaseSize" class="me-1 h4">⊖</button>
</div>
</div>
<textarea class="form-control" id="ta" 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">Cached Data</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="cacheTable"></table>
</div>
</div>
</body>
<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()
console.log('caught click ', event.target)
location.href = event.target.href
location.reload()
})
</script>
<script>
function saveDoc() {
let bb = new Blob([ta.value])
let url = URL.createObjectURL(bb);
let a = document.createElement('a');
a.href = url;
let tb = document.getElementById('tb')
if (tb.value == 0) { 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
location.hash = url
location.reload()
}
</script>
<script>
function onFileSelected(event) {
let file = event.target.files[0]
let reader = new FileReader()
reader.onload = function (event) {
let ta = document.getElementById("ta")
ta.value = event.target.result
ta.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'))
}
let myTree = {};
</script>
<script src="quest.js" type="module"></script>
</html>