-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
293 lines (280 loc) · 13.1 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
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>DDI-CDI Sample generator</title>
<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-9ndCyUaIbzAi2FUVXJi0CjmCapSmO7SnpJef0486qhLnuZ2cdeRhO02iuK6FUUVM" crossorigin="anonymous">
<link rel="icon" href="resources/ddi-cdi-sample-generator.svg">
<script src="js/lib/utils.js"></script>
<script src="js/lib/formatters/ddi-cdi-json-ld.js"></script>
<script src="js/lib/formatters/ddi-l-xml.js"></script>
<script src="js/lib/formatters/ddi-c-xml.js"></script>
<style>
textarea{
font-family: monospace;
}
.checkbox-xl input{
margin-top: .1rem;
width: 2rem;
height: 2rem;
}
form .codeCheckLabel{
margin-left:0px;
}
@media (min-width: 768px) {
form .row .notFirst{
display:none;
}
form hr {
display: none;
}
}
</style>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/styles/default.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/highlight.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/languages/xml.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/languages/json.min.js"></script>
</head>
<body>
<div id="app" class="container">
<!-- top toolbar -->
<nav class="row navbar navbar-expand-lg bg-body-tertiary">
<div class="container-fluid">
<a class="navbar-brand" href="#">
<img src="resources/ddi-cdi-sample-generator.svg" alt="DDI-CDI sample generator" height="24">
</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse"
data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent"
aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item">
<button @click="openCsv()" type="button" class="btn btn-light" title="open csv or tsv file">📂 open csv</button>
</li>
<li class="nav-item">
<button type="button" class="btn btn-light" data-bs-toggle="modal" data-bs-target="#aboutModal" title="about this app">ℹ️ about</button>
</li>
</ul>
</div>
</div>
</nav>
<!-- startup message -->
<div v-if="input.fileName == null" class="alert alert-primary d-flex align-items-center gap-2" role="alert">
<div>
<strong><span>ℹ️</span>DDI-CDI Sample Generator</strong><br/>
Open a csv/tsv data file of load one of the examples.<br/>
<br />
<strong>🗃️ example csv:s</strong>
<span v-for="e in examples">
<a @click="loadExample(e)" class="dropdown-item" href="#"><span>📄</span><span v-html="e.fileName"></span></a>
</span>
</div>
</div>
<!-- About Modal -->
<div class="modal modal-dialog-scrollable fade" id="aboutModal" tabindex="-2" aria-labelledby="aboutModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title fs-5" id="aboutModallLabel">ℹ️ About ddi-cdi spample generator</h1>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<img src="resources/ddi-cdi-sample-generator.svg" class="mx-auto d-block" alt="DDI-CDI sample generator" height="64">
<p>
This webbapp is for demonstration purposes only and is intended to show
implementers how to use ddi-cdi by an interactive example with documentation of
csv/tsv-files on a variable level.
</p>
<p>
Dont use this tool to document your data.
</p>
<h5>Created by</h5>
<p>
<ul>
<li>
Olof Olsson, SND
<a href="https://orcid.org/0000-0002-7365-0691">
<img alt="ORCID logo" src="https://info.orcid.org/wp-content/uploads/2019/11/orcid_16x16.png" width="16" height="16" />
</a>
</li>
<li>
Oliver Hopt, GESIS
<a href="https://orcid.org/0000-0002-3848-574X">
<img alt="ORCID logo" src="https://info.orcid.org/wp-content/uploads/2019/11/orcid_16x16.png" width="16" height="16" />
</a>
</li>
</ul>
</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#aboutModal">Close</button>
</div>
</div>
</div>
</div>
<!-- Code List Modal -->
<div class="modal modal-dialog-scrollable fade" id="codeListModal" tabindex="-1" aria-labelledby="codeListModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div v-if="codeListVariableIndex != null" class="modal-content">
<div class="modal-header">
<h1 class="modal-title fs-5" id="codeListModalLabel">📦Code list <span v-html="input.columns[codeListVariableIndex].name" class="badge bg-secondary"></span></h1>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<form class="mb-4">
<div class="row" v-for="(code, index) in input.columns[codeListVariableIndex].codeList">
<div class="col-md-4">
<label class="form-label" :class="{notFirst: (index > 0)}">Code</label>
<input v-model="code.notation" type="text" class="form-control" disabled>
</div>
<div class="col-md-8">
<label class="form-label" :class="{notFirst: (index > 0)}">Name</label>
<input v-model="code.prefLabel" type="text" class="form-control">
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#codeListModal">Close</button>
</div>
</div>
</div>
</div>
<!-- Instance Variable list -->
<div class="row" v-if="input.fileName != null">
<form class="mb-4">
<div class="row mb-2" v-for="(column, index) in input.columns">
<div class="col-md-1">
<label class="form-label" :class="{notFirst: (index > 0)}">Position</label>
<input v-model="column.position" type="text" class="form-control" disabled>
</div>
<div class="col-md-2">
<label class="form-label" :class="{notFirst: (index > 0)}">Name</label>
<input v-model="column.name" type="text" class="form-control">
</div>
<div class="col-md-4">
<label class="form-label" :class="{notFirst: (index > 0)}">Label</label>
<input v-model="column.displayLabel" type="text" class="form-control">
</div>
<div class="col-md-2">
<label class="form-label" :class="{notFirst: (index > 0)}">Role</label>
<select v-model="column.role" class="form-select" aria-label="Default select example">
<option v-for="colRole in cv.colRoles" :value="colRole.id">{{ colRole.id }}</option>
</select>
</div>
<div class="col-md-2">
<label class="form-label" :class="{notFirst: (index > 0)}">Type</label>
<select v-model="column.hasIntendedDataType" class="form-select"
aria-label="Default select example">
<option v-for="colType in cv.colTypes" :value="colType.id">{{ colType.label }}</option>
</select>
</div>
<div class="col-md-1">
<label class="form-label row codeCheckLabel" :class="{notFirst: (index > 0)}">Coded</label>
<div class="btn-group" role="group" aria-label="coded variable">
<input v-model="column.coded" @change="column.createCodeList()" type="checkbox" class="btn-check" :id="'coded-'+column.id" autocomplete="off">
<label class="btn btn-outline-secondary" :for="'coded-'+column.id">
<span v-if="!column.coded">☐</span>
<span v-if="column.coded">☒</span>
</label>
<button v-if="column.coded" @click="codeListVariableIndex=index" data-bs-toggle="modal" data-bs-target="#codeListModal" type="button" class="btn btn-outline-secondary">✏️</button>
</div>
</div>
<hr class="mt-4" />
</div>
</form>
</div>
<!-- output in tabs -->
<div class="row" v-if="input.fileName != null">
<div class="col">
<ul class="nav nav-tabs" id="myTab" role="tablist">
<li class="nav-item" role="presentation">
<button class="nav-link" id="home-tab" data-bs-toggle="tab" data-bs-target="#csv" type="button" role="tab" aria-controls="home-tab-pane" aria-selected="false">📄 csv</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link active" id="profile-tab" data-bs-toggle="tab" data-bs-target="#cdi" type="button" role="tab" aria-controls="profile-tab-pane" aria-selected="true">⚗️ ddi-cdi (json-ld)</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="profile-tab" data-bs-toggle="tab" data-bs-target="#ddil" type="button" role="tab" aria-controls="profile-tab-pane" aria-selected="false"><> ddi-l (xml)</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="profile-tab" data-bs-toggle="tab" data-bs-target="#ddic" type="button" role="tab" aria-controls="profile-tab-pane" aria-selected="false"><> ddi-c (xml)</button>
</li>
</ul>
<div class="tab-content" id="myTabContent">
<div class="tab-pane fade" id="csv" role="tabpanel" aria-labelledby="home-tab" tabindex="0">
<div class="card">
<div class="card-header">
<div class="d-grid gap-2 d-md-flex justify-content-md-start">
<button v-html="input.fileName" class="btn btn-light me-md-2" type="button" disabled></button>
<button @click="copyToClipboard(input.raw)" class="btn btn-light" type="button" title="copy csv to clipboard">📋 copy</button>
</div>
</div>
<div class="card-body">
<div class="form-floating mb-3">
<pre><code v-html="input.raw" class="language-csv"></code></pre>
</div>
</div>
</div>
</div>
<div class="tab-pane fade show active" id="cdi" role="tabpanel" aria-labelledby="profile-tab" tabindex="0">
<div class="card">
<div class="card-header">
<div class="d-grid gap-2 d-md-flex justify-content-md-start">
<button v-html="input.fileNameWithoutExtension + '.jsonld'" class="btn btn-light me-md-2" type="button" disabled></button>
<button @click="saveFile(output.cdi, 'application/ld+json', input.fileNameWithoutExtension + '.jsonld')" class="btn btn-light me-md-2" type="button" title="save ddi-cdi">💾 save</button>
<button @click="copyToClipboard(output.cdi)" class="btn btn-light" type="button" title="copy ddi-cdi to clipboard">📋 copy</button>
</div>
</div>
<div class="card-body">
<div class="form-floating mb-3">
<pre><code v-html="outputFormated.cdi" class="language-json"></code></pre>
</div>
</div>
</div>
</div>
<div class="tab-pane fade" id="ddil" role="tabpanel" aria-labelledby="profile-tab" tabindex="0">
<div class="card">
<div class="card-header">
<div class="d-grid gap-2 d-md-flex justify-content-md-start">
<button v-html="input.fileNameWithoutExtension + '.ddi-l.xml'" class="btn btn-light me-md-2" type="button" disabled></button>
<button @click="saveFile(output.ddiL, 'application/xml', input.fileNameWithoutExtension + '.ddi-l.xml')" class="btn btn-light me-md-2" type="button">💾</button>
<button @click="copyToClipboard(output.ddiL)" class="btn btn-light" type="button" title="copy to clipboard">📋</button>
</div>
</div>
<div class="card-body">
<div class="form-floating mb-3">
<pre><code v-html="outputFormated.ddiL" class="language-xml"></code></pre>
</div>
</div>
</div>
</div>
<div class="tab-pane fade" id="ddic" role="tabpanel" aria-labelledby="profile-tab" tabindex="0">
<div class="card">
<div class="card-header">
<div class="d-grid gap-2 d-md-flex justify-content-md-start">
<button v-html="input.fileNameWithoutExtension + '.ddi-c.xml'" class="btn btn-light me-md-2" type="button" disabled></button>
<button @click="saveFile(output.ddiC, 'application/xml', input.fileNameWithoutExtension + '.ddi-c.xml')" class="btn btn-light me-md-2" type="button">💾</button>
<button @click="copyToClipboard(output.ddiC)" class="btn btn-light" type="button" title="copy to clipboard">📋</button>
</div>
</div>
<div class="card-body">
<div class="form-floating mb-3">
<pre><code v-html="outputFormated.ddiC" class="language-xml"></code></pre>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL" crossorigin="anonymous"></script>
<script src="js/app.js"></script>
</body>
</html>