-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsparql-editor.html
406 lines (364 loc) · 13 KB
/
sparql-editor.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
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
<!-- Public Domain : do what thou wilt -->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>SPARQL Editor</title>
<link rel="stylesheet" type="text/css" href="common.css" />
<link rel="stylesheet" type="text/css" href="meniu.css" />
<style type="text/css">
table{
border:2
}
.button {
width:150px;
}
</style>
<script type="text/javascript">
//<![CDATA[
var editArea;
function init(){
editArea = document.getElementById('editArea');
}
function insertText(editField, insertText) {
// IE
if (document.selection) {
editField.focus();
selected = document.selection.createRange();
selected.text = insertText;
return;
}
// MOZ
var length = editField.value.length;
var start = editField.selectionStart;
var end = editField.selectionEnd;
if ((start != 0) && (end != length)) {
var before = editField.value.substring(0, start);
var after = editField.value.substring(end, length);
editField.value = before + insertText + after;
} else {
editField.value += insertText;
}
}
function insert(text){
insertText(editArea, text + "\n");
}
function insertAtTop(editField, insertText) {
// IE - to do
if (document.selection) {
insertText(editField, insertText);
}
// MOZ
editField.value = insertText+editField.value;
}
function insertAtStart(insertText) {
insertAtTop(editArea, insertText + "\n");
}
// might not work with IE
function inset(editField, insetString) {
var start = editField.selectionStart;
var end = editField.selectionEnd;
for(var c=start;c<end;c++){
var length = editField.value.length;
var before = editField.value.substring(0, c);
var after = editField.value.substring(c, length);
if(editField.value.substring(c-1, c) == "\n") {
editField.value = before + insetString + after;
end = end+insetString.length;
}
}
}
function commentOut(editField) {
inset(editField, "#");
}
function comment(){
commentOut(editArea);
}
function indentArea(editField){
inset(editField, " ");
}
function indent(){
indentArea(editArea);
}
// might not work with IE
function makeOptional(editField) {
var length = editField.value.length;
var start = editField.selectionStart;
var end = editField.selectionEnd;
var before = editField.value.substring(0, start);
var after = editField.value.substring(end, length);
var selection = editField.value.substring(start, end);
editField.value = before + "\nOPTIONAL\n{\n" + selection + "\n}\n"+after;
}
// quick and dirty - wipes all # in selected region
function unCommentRegion(editField) {
var length = editField.value.length;
var start = editField.selectionStart;
var end = editField.selectionEnd;
for(var c=start;c<end;c++){
var before = editField.value.substring(0, c-1);
var after = editField.value.substring(c, length);
if(editField.value.substring(c-1, c) == "#") {
editField.value = before + after;
}
}
}
function unComment(){
unCommentRegion(editArea);
}
function clearArea(editField){
editField.value = "";
}
function clearAll(){
clearArea(editArea);
}
function optional(){
makeOptional(editArea);
}
// Styling on mouse events - needs fixing
function mouseOver(ctrl){
// ctrl.style.borderColor = '#000000';
// ctrl.style.backgroundColor = '#BBBBBB';
}
function mouseOut(ctrl){
// ctrl.style.borderColor = '#ccc';
// ctrl.style.backgroundColor = '#CCCCCC';
}
function mouseDown(ctrl){
// ctrl.style.backgroundColor = '#8492B5';
}
function mouseUp(ctrl){
// ctrl.style.backgroundColor = '#B5BED6';
}
function activate(field) {
field.disabled=false;
if(document.styleSheets)field.style.visibility = 'visible';
field.focus(); }
function last_choice(selection) {
return selection.selectedIndex==selection.length - 1; }
function process_choice(selection,textfield) {
if(last_choice(selection)) {
activate(textfield); }
else {
textfield.disabled = true;
if(document.styleSheets)textfield.style.visibility = 'hidden';
textfield.value = ''; }}
function valid(endpoint,txt) {
if(txt.value == '') {
if(last_choice(endpoint)) {
alert('You need to type your choice into the text box');
return false; }
else {
return true; }}
else {
if(!last_choice(endpoint)) {
alert('Incompatible selection');
return false; }
else {
return true; }}}
function check_choice() {
if(!last_choice(document.theForm.endpoint)) {
document.theForm.choicetext.blur();
alert('Please check your endpoint selection first');
document.theForm.endpoint.focus(); }}
// ]]>
</script>
</head>
<body onload="init()">
<div id="meniu">
<a href="index.php">Home</a>
<a href="sparql-editor.html">Query editor</a>
</div>
<div id="hr"></div>
<div class="moreindent">
<form method="get" action="query.php" enctype="application/x-www-form-urlencoded" id="theForm" name="theForm" onsubmit="return valid(this.endpoint,this.choicetext)">
<table>
<tr>
<td>
<input type="submit" value="Run SPARQL Query" />
</td>
<td>
<select name="insertTemplate"
onchange="insert(this.options[this.selectedIndex].value)">
<option value="">-- Template --</option>
<option value="SELECT DISTINCT ?s ?p ?o
WHERE
{
?s ?p ?o .
}">Select</option>
<option value="CONSTRUCT
{
?s ?p ?o .
}
WHERE
{
?s ?p ?o .
}">Construct</option>
<option value="ASK
WHERE
{
?s ?p ?o .
}">Ask</option>
<option value="To be decided...">Describe</option>
</select>
</td>
<td>
<select name="insertPrefix"
onchange="insertAtStart(this.options[this.selectedIndex].value)">
<option value="">-- Prefixes --</option>
<option value="PREFIX cc: <http://web.resource.org/cc/>
">CC</option>
<option value="PREFIX dataview: <http://www.w3.org/2003/g/data-view#>
">DATAVIEW</option>
<option value="PREFIX dc: <http://purl.org/dc/elements/1.1/>
">DC</option>
<option value="PREFIX dcterms: <http://purl.org/dc/terms/>
">DCTERMS</option>
<option value="PREFIX foaf: <http://xmlns.com/foaf/0.1/>
">FOAF</option>
<option value="PREFIX owl: <http://www.w3.org/2002/07/owl#>
">OWL</option>
<option value="PREFIX prj: <http://purl.org/stuff/project/>
">PRJ</option>
<option value="PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
">RDF</option>
<option value="PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
">RDFS</option>
<option value="PREFIX rev: <http://www.purl.org/stuff/rev#>
">REV</option>
<option value="PREFIX rss: <http://purl.org/rss/1.0/>
">RSS</option>
<option value="PREFIX sioc: <http://rdfs.org/sioc/ns#>
">SIOC</option>
<option value="PREFIX sioct: <http://rdfs.org/sioc/types#>
">SIOCT</option>
<option value="PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
">SKOS</option>
<option value="PREFIX tag: <http://www.holygoat.co.uk/owl/redwood/0.1/tags/>
">TAG</option>
<option value="PREFIX vs: <http://www.w3.org/2003/06/sw-vocab-status/ns#>
">VS</option>
<option value="PREFIX wot: <http://xmlns.com/wot/0.1/>
">WOT</option>
<option value="PREFIX xhtml: <http://www.w3.org/1999/xhtml>
">XHTML</option>
<option value="PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
">XSD</option>
</select>
</td>
</tr>
</table>
<table>
<tr>
<td>
<textarea id="editArea" name="query" cols="60" rows="25">
</textarea>
</td>
<td style="width:120">
<input type="button" class="button"
value="Comment Region" onclick="comment()"
onmouseover="mouseOver(this)" onmouseout="mouseOut(this)"
onmousedown="mouseDown(this)" onmouseup="mouseUp(this)" />
<input type="button" class="button"
value="Uncomment Region" onclick="unComment()"
onmouseover="mouseOver(this)" onmouseout="mouseOut(this)"
onmousedown="mouseDown(this)" onmouseup="mouseUp(this)" />
<input type="button" class="button"
value="Make Optional" onclick="optional()"
onmouseover="mouseOver(this)" onmouseout="mouseOut(this)"
onmousedown="mouseDown(this)" onmouseup="mouseUp(this)" />
<input type="button" class="button"
value="Indent Region" onclick="indent()"
onmouseover="mouseOver(this)" onmouseout="mouseOut(this)"
onmousedown="mouseDown(this)" onmouseup="mouseUp(this)" />
<input type="button" class="button"
value="BASE" onclick="insert('BASE <http://example.org/base>')"
onmouseover="mouseOver(this)" onmouseout="mouseOut(this)"
onmousedown="mouseDown(this)" onmouseup="mouseUp(this)" />
<input type="button" class="button"
value="FROM" onclick="insert('FROM <http://example.org/from>')"
onmouseover="mouseOver(this)" onmouseout="mouseOut(this)"
onmousedown="mouseDown(this)" onmouseup="mouseUp(this)" />
<input type="button" class="button"
value="FROM NAMED" onclick="insert('FROM NAMED <http://example.org/named>')"
onmouseover="mouseOver(this)" onmouseout="mouseOut(this)"
onmousedown="mouseDown(this)" onmouseup="mouseUp(this)" />
<input type="button" class="button"
value="UNION" onclick="insert('UNION')"
onmouseover="mouseOver(this)" onmouseout="mouseOut(this)"
onmousedown="mouseDown(this)" onmouseup="mouseUp(this)" />
<input type="button" class="button"
value="GRAPH" onclick="insert('GRAPH')"
onmouseover="mouseOver(this)" onmouseout="mouseOut(this)"
onmousedown="mouseDown(this)" onmouseup="mouseUp(this)" />
<input type="button" class="button"
value="ORDER BY" onclick="insert('ORDER BY')"
onmouseover="mouseOver(this)" onmouseout="mouseOut(this)"
onmousedown="mouseDown(this)" onmouseup="mouseUp(this)" />
<input type="button" class="button"
value="ORDER BY ASC()" onclick="insert('ORDER BY ASC(?x)')"
onmouseover="mouseOver(this)" onmouseout="mouseOut(this)"
onmousedown="mouseDown(this)" onmouseup="mouseUp(this)" />
<input type="button" class="button"
value="ORDER BY DESC()" onclick="insert('ORDER BY DESC(?x)')"
onmouseover="mouseOver(this)" onmouseout="mouseOut(this)"
onmousedown="mouseDown(this)" onmouseup="mouseUp(this)" />
<input type="button" class="button"
value="LIMIT" onclick="insert('LIMIT 10')"
onmouseover="mouseOver(this)" onmouseout="mouseOut(this)"
onmousedown="mouseDown(this)" onmouseup="mouseUp(this)" />
<input type="button" class="button"
value="OFFSET" onclick="insert('OFFSET 10')"
onmouseover="mouseOver(this)" onmouseout="mouseOut(this)"
onmousedown="mouseDown(this)" onmouseup="mouseUp(this)" />
<input type="button" class="button"
value="Simple Filter" onclick="insert('FILTER ( ?x < 3 ) .')"
onmouseover="mouseOver(this)" onmouseout="mouseOut(this)"
onmousedown="mouseDown(this)" onmouseup="mouseUp(this)" />
<input type="button" class="button"
value="Regex Filter" onclick="insert('FILTER regex( str(?name), "Jane", "i" ) .')"
onmouseover="mouseOver(this)" onmouseout="mouseOut(this)"
onmousedown="mouseDown(this)" onmouseup="mouseUp(this)" />
<input type="button" class="button"
value="Bound Filter" onclick="insert('FILTER ( bound(?x) ) .')"
onmouseover="mouseOver(this)" onmouseout="mouseOut(this)"
onmousedown="mouseDown(this)" onmouseup="mouseUp(this)" />
<input type="button" class="button"
value="Date Filter" onclick="insert('FILTER ( ?date > "2005-01-01T00:00:00Z"^^xsd:dateTime ) .')"
onmouseover="mouseOver(this)" onmouseout="mouseOut(this)"
onmousedown="mouseDown(this)" onmouseup="mouseUp(this)" />
<input type="button" class="button"
value="Clear All" onclick="clearAll()"
onmouseover="mouseOver(this)" onmouseout="mouseOut(this)"
onmousedown="mouseDown(this)" onmouseup="mouseUp(this)" />
</td>
</tr>
</table>
<p><strong>SPARQL endpoint:</strong>
<br/>
<select name="endpoint" onchange="process_choice(this,document.theForm.choicetext)">
<option value="http://api.talis.com/stores/mhahnel-dev1/services/sparql">mhahnel endpoint</option>
</select>
</p>
</form>
</div>
<div id="bottom">
<img src="opendata.png" alt="opendata" />
<img src="http://i.creativecommons.org/p/zero/1.0/80x15.png" style="border-style: none;" alt="CC0" />
<p xmlns:dct="http://purl.org/dc/terms/" xmlns:vcard="http://www.w3.org/2001/vcard-rdf/3.0#">
<a rel="license"
href="http://creativecommons.org/publicdomain/zero/1.0/">
</a>
<br />
To the extent possible under law,
<a rel="dct:publisher"
href="http://www.science3point0.com/opendata/">
<span property="dct:title">Science3.0</span></a>
has waived all copyright and related or neighboring rights to
<span property="dct:title">CC0 RDF Hosting For Scientists</span>.
This work is published from:
<span property="vcard:Country" datatype="dct:ISO3166"
content="GB" about="http://www.science3point0.com/opendata/">
United Kingdom</span>.
</p>
</div>
</body>
</html>