-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkeys.html
712 lines (616 loc) · 19.9 KB
/
keys.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
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
<head>
<title>這是一個台灣蛙類(無尾目)的互動式檢索工具</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style>
.key_choices:hover, .filter_values:hover{
background-color:chartreuse;
cursor: pointer;
}
.key_choices_idontknow:hover {
background-color:crimson;
cursor: pointer;
}
.has_value {
background-color:yellow;
}
#key_choices_area {
position: absolute;
width: 24%;
left: 1%;
}
#res_species {
position: absolute;
width: 48%;
left: 26%;
}
#submit_onmyownVal {
cursor: pointer;
}
#keyVal {
position: absolute;
width: 24%;
left: 75%;
top: 30px;
}
.no_species_img_grid {
width:100%;
}
.species_img_grid {
width:90%;
}
</style>
</head>
<script src="http://code.jquery.com/jquery-1.11.0.js"></script>
<script src="http://isotope.metafizzy.co/jquery.isotope.min.js"></script>
<br/>
<table>
<tr>
<td><div id='previous_choice' style='cursor:pointer'><u>前一個特徵</u></div></td>
<td><div id='char_name'></div></td>
<td><div id='next_choice' style='cursor:pointer'><u>下一個特徵</u></div></td>
</tr>
</table>
<div id="key_choices_area"></div>
<div id="res_species"></div>
<div id="keyVal"></div>
<script>
// Initialize
$('#res_species').isotope({
// options
itemSelector : '.species_grid',
layoutMode : 'fitRows'
});
$(document).delegate('.onmyownInput', 'keydown', function() {
document.getElementById('onmyownRadio').checked = true;
$('#submit_onmyownVal').css('background-color', 'red');
})
$(document).delegate('.key_choices', 'click', function () {
document.getElementById('distinctValueRadio').checked = true;
foo(this.id);
runKeys('=');
});
$(document).delegate('.filter_values', 'click', function () {
var ffss = 5566;
var frags = this.id.split("_");
indexOfKey = frags[1];
runKeys('=');
});
var idontknowOp;
$(document).delegate('.key_choices_idontknow', 'click', function () {
idontknowOp = '=';
document.getElementById('distinctValueRadio').checked = true;
foo(this.id);
runKeys(idontknowOp);
});
var isotopeSpecies = null;
function isEmpty(obj) {
// null and undefined are "empty"
if (obj == null) return true;
// Assume if it has a length property with a non-zero value
// that that property is correct.
if (obj.length > 0) return false;
if (obj.length === 0) return true;
// Otherwise, does it have any properties of its own?
// Note that this doesn't handle
// toString and valueOf enumeration bugs in IE < 9
for (var key in obj) {
if (hasOwnProperty.call(obj, key)) return false;
}
return true;
}
function foo (rVal) {
if (isEmpty(rVal)) {
var r = document.getElementsByName('char_radio');
for (i=0; i<r.length; i++) {
if (r[i].checked) {
rVal = r[i].value;
var vFrags = rVal.split('_')
selectedKey[vFrags[0]] = vFrags[1];
/* 好像沒P用了這三行
if ((vFrags[1] == 'idontknow')||(vFrags[1] == 'onmyown')) {
continue;
}
*/
}
}
}
var q = getFilterQuery(rVal);
if (q != "") {
var toShow = query(null, q);
var snames = [];
for (i=0; i<toShow.length; i++) {
var uri = toShow[i].s.value;
var uriFrags = uri.split(/[\#\/]/);
var namecode = uriFrags.pop();
var imgSetURL = "http://api.taibif.tw/catalogue/images/taieol/" + namecode;
var imgObjs = [];
$.ajax(imgSetURL, {
async: false,
cache: false,
success: function (data, txtStatus, jqXHR) {
imgObjs = data;
},
dataType: 'json'
});
var imgAuthor = "麥舘碩";
var imgLicense = "CC-0";
if (imgObjs[0] != undefined) {
var imgURL = imgObjs[0].url;
imgAuthor = imgObjs[0].author;
imgLicense = "CC-" + imgObjs[0].license;
var imgHtml = "<img src='"+imgURL+"' alt='"+toShow[i].sname.value+"' title='"+toShow[i].sname.value+"' class='species_img_grid'/>";
}
else {
var imgHtml = "<img src='nopic.jpg' alt='沒有圖片, 等你貢獻^.<' title='沒有圖片, 等你貢獻^.<' class='no_species_img_grid'/>";
}
imgHtml = "<div class='species_grid'><a target='_blank' href='http://taibnet.sinica.edu.tw/chi/taibnet_species_detail.php?name_code="+namecode+"'>"+toShow[i].sname.value+"</a>"
+"-<a target='_blank' href='http://taibif.tw/lod/resource/Species/"+namecode+"'>LOD</a>"
+ "<div>" + imgHtml + "</div><span>"+imgAuthor+"</span> <span>"+imgLicense+"</span>"
+"</div>";
snames.push(imgHtml);
}
if (snames.length < 1) {
var imgHtml = "<img src='noresult.jpg' alt='沒有了' title='沒有了' class='species_img_grid'/>";
imgHtml = "<div class='species_grid'><span>沒有了</span><div>" + imgHtml + "</div></div>";
snames.push(imgHtml);
}
$('#res_species').html(snames.join("\n"));
}
else {
$('#res_species').html('');
}
$('#res_species').isotope('destroy');
$('#res_species').isotope({
// options
itemSelector : '.species_grid',
// layoutMode : 'cellsByRow'
// layoutMode : 'masonry'
}).isotope( 'reLayout');
}
$(document).delegate('#submit_onmyownVal', 'click', function (e) {
foo();
runKeys('+');
});
$('#next_choice').click(function (e) {
foo();
runKeys('+');
});
$('#previous_choice').click(function (e) {
foo();
runKeys('-');
});
var keys = [];
//+ Jonas Raoni Soares Silva
//@ http://jsfromhell.com/array/shuffle [v1.0]
function shuffle(o){ //v1.0
for(var j, x, i = o.length; i; j = Math.floor(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);
return o;
};
function query (ep, q) {
var b = [];
if ((ep == null)||(ep == '')||(ep == undefined)) {
ep = "http://ecowlim.tfri.gov.tw/sparql/query";
}
$.ajax(ep, {
async: false,
cache: false,
data: {query: q, format: 'json'},
success: function (data, txtStatus, jqXHR) {
b = data.results.bindings;
},
dataType: 'json'
});
var ffss = 5566;
return b;
}
var prefixSet = "prefix : <http://lod.tw/rdf/taicol.n3#> "
+"prefix tsp: <http://taibif.tw/lod/resource/Species/> "
+"prefix spv: <http://taibif.tw/lod/resource/vocab/> "
+"prefix dbp: <http://dbpedia.org/resource/> "
+"prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> "
+"prefix xsd: <http://www.w3.org/2001/XMLSchema#>";
var selectAllFromTpl = "select distinct * "
+"from <http://lod.tw/trashmai/frogs.n3> "
+"{ "
+" ::placeholder:: "
+"} ";
var selectSFromTpl = "select distinct ?s ?sname "
+"from <http://lod.tw/trashmai/frogs.n3> "
+"{ "
+" ::placeholder:: "
+"} ";
var subqs = {};
var filterVal = {};
function getFilterQuery(rVal) {
// rVal means value from input typed "radio"
var subqFilterString = "";
if (getFilterQuery.q == undefined) {
getFilterQuery.q = "";
}
if (isEmpty(rVal)) return getFilterQuery.q;
var vFrags = rVal.split('_');
var iok = vFrags[0];
if ((vFrags[1] == 'idontcare')||(vFrags[1] == 'exists')) {
return getFilterQuery.q;
}
if (vFrags[1] == 'idontknow') {
// return getFilterQuery.q;
if (subqs[iok] != undefined) {
delete subqs[iok];
delete filterVal[iok];
keyChars[iok] = "<div class='filter_values' id='fv_"+iok+"'>"+keys[iok].char+":</div>";
}
else {
idontknowOp = '+';
}
subq = "";
if (isEmpty(subqs)) {
subqFilterString = "";
getFilterQuery.q = "";
return getFilterQuery.q;
}
}
else {
if (vFrags[1] == 'onmyown') {
var f = filterVar[iok][0];
}
else {
var f = filterVar[iok][vFrags[1]];
}
switch (f.type) {
case "http://lod.tw/rdf/taicol.n3#RangeValueDescription":
if (vFrags[1] == 'onmyown') {
var dlmt = document.getElementsByName(iok+'_onmyownValue')[0].value.match(/[^\d.]+/);
var omoFrags = document.getElementsByName(iok+'_onmyownValue')[0].value.split(dlmt);
f.from = omoFrags[0];
f.to = omoFrags[1];
if (f.to == undefined) {
f.to = f.from;
}
f.literalUnit = document.getElementsByName(iok+'_onmyownUnit')[0].value;
f.literalValue = "與" + f.from + "~" + f.to + ((f.literalUnit == undefined)?"":f.literalUnit) + "有重疊";
}
var subq = "{ "
+"?s rdfs:label ?sname. "
+"?s :hasDescription ?d"+iok+". "
+"?d"+iok+" :character ?char"+iok+". "
+"?d"+iok+" a ?type"+iok+". "
+"?d"+iok+" :from ?from"+iok+". "
+"?d"+iok+" :to ?to"+iok+". "
+"optional { "
+" ?d"+iok+" :literalUnit ?literalUnit"+iok+". "
+"} "
+"optional { "
+" ?d"+iok+" :majorFrom ?majorFrom"+iok+". "
+" ?d"+iok+" :majorTo ?majorTo"+iok+". "
+"} "
+"optional { "
+" ?d"+iok+" :restriction ?r"+iok+". "
+"} "
+"filter (?char"+iok+"='"+f.char+"') "
+"filter (xsd:float(?from"+iok+") <= "+f.to+") "
+"filter (xsd:float(?to"+iok+") >= "+f.from+") "
+((f.literalUnit=='')?"":("filter (?literalUnit"+iok+" = '"+f.literalUnit+"') "))
+"filter (str(?type"+iok+") = '"+f.type+"') "
+"}\n";
break;
case "http://lod.tw/rdf/taicol.n3#SimpleValueDescription":
case "http://lod.tw/rdf/taicol.n3#LiteralValueDescription":
if (vFrags[1] == 'onmyown') {
f.value = document.getElementsByName(iok+'_onmyownValue')[0].value;
f.literalUnit = document.getElementsByName(iok+'_onmyownUnit')[0].value;
f.literalValue = document.getElementsByName(iok+'_onmyownValue')[0].value + ((f.literalUnit == undefined)?"":f.literalUnit);
}
var subq = "{ "
+"?s rdfs:label ?sname. "
+"?s :hasDescription ?d"+iok+". "
+"?d"+iok+" :character ?char"+iok+". "
+"?d"+iok+" a ?type"+iok+". "
+"?d"+iok+" :value ?value"+iok+". "
+"optional { "
+" ?d"+iok+" :literalUnit ?literalUnit"+iok+". "
+"} "
+"optional { "
+" ?d"+iok+" :majorFrom ?majorFrom"+iok+". "
+" ?d"+iok+" :majorTo ?majorTo"+iok+". "
+"} "
+"optional { "
+" ?d"+iok+" :restriction ?r"+iok+". "
+"} "
+"filter (?char"+iok+"='"+f.char+"') "
+"filter (?value"+iok+"='"+f.value+"')"
+((f.literalUnit=='')?"":("filter (?literalUnit"+iok+" = '"+f.literalUnit+"') "))
+"filter (str(?type"+iok+") = '"+f.type+"') "
+"}\n";
break;
default:
subq = "";
break;
}
}
if (subq != "") {
filterVal[iok] = f;
subqs[iok] = subq;
}
$.each (subqs, function (i, v) {
subqFilterString += v + "\n";
});
getFilterQuery.q = prefixSet + selectSFromTpl.replace(/\:\:placeholder\:\:/, subqFilterString);
return getFilterQuery.q;
}
function getQueryByKey(iok) {
var subqFilterString = "";
key = keys[iok];
switch (key.type) {
case "http://lod.tw/rdf/taicol.n3#RangeValueDescription":
var subq = "{ "
+"?s :hasDescription ?d. "
+"?d :character ?char. "
+"?d a ?type. "
+"?d :from ?from. "
+"?d :to ?to. "
+"optional { "
+" ?d :literalUnit ?literalUnit. "
+"} "
+"optional { "
+" ?d :majorFrom ?majorFrom. "
+" ?d :majorTo ?majorTo. "
+"} "
+"optional { "
+" ?d :restriction ?r. "
+"} "
+"filter (?char='"+key.char+"') "
+"filter (str(?type) = '"+key.type+"') "
+"}\n";
break;
case "http://lod.tw/rdf/taicol.n3#SimpleValueDescription":
case "http://lod.tw/rdf/taicol.n3#LiteralValueDescription":
var subq = "{ "
+"?s :hasDescription ?d. "
+"?d :character ?char. "
+"?d a ?type. "
+"?d :value ?value. "
+"optional { "
+" ?d :literalUnit ?literalUnit. "
+"} "
+"optional { "
+" ?d :majorFrom ?majorFrom. "
+" ?d :majorTo ?majorTo. "
+"} "
+"optional { "
+" ?d :restriction ?r. "
+"} "
+"filter (?char='"+key.char+"') "
+"filter (str(?type) = '"+key.type+"') "
+"}\n";
break;
default:
subq = "";
break;
}
$.each (subqs, function (i, v) {
subqFilterString += v + "\n";
});
var q = prefixSet + selectAllFromTpl.replace(/\:\:placeholder\:\:/, subq);
/* 這是聯動式檢索選項, 若要使用此功能
// "runKeys" 函式中註名的部分也要一起 uncomment .
var q = prefixSet + selectAllFromTpl.replace(/\:\:placeholder\:\:/, subq + subqFilterString);
//*/
return q;
}
var filterVar = {};
var selectedKey = {};
function renderChoices (toShow) {
var s = [];
var mergedChoices = [];
for (i=0; i<toShow.length; i++) {
if (toShow[i].type != undefined)
switch (toShow[i].type.value) {
case "http://lod.tw/rdf/taicol.n3#SimpleValueDescription" :
case "http://lod.tw/rdf/taicol.n3#LiteralValueDescription" :
if (s.indexOf(toShow[i].s.value) == -1) {
var indexOfS = s.push(toShow[i].s.value);
indexOfS = indexOfS - 1;
}
else {
var indexOfS = s.indexOf(toShow[i].s.value);
}
if (mergedChoices[indexOfS] == undefined) {
mergedChoices[indexOfS] = {
s: toShow[i].s.value,
char: toShow[i].char.value,
value: toShow[i].value.value,
literalValue: toShow[i].value.value + ((toShow[i].literalUnit == undefined)?"":toShow[i].literalUnit.value),
literalUnit: ((toShow[i].literalUnit == undefined)?"":toShow[i].literalUnit.value),
type: toShow[i].type.value
};
}
break;
case "http://lod.tw/rdf/taicol.n3#RangeValueDescription":
if (s.indexOf(toShow[i].s.value) == -1) {
var indexOfS = s.push(toShow[i].s.value);
indexOfS = indexOfS - 1;
}
else {
var indexOfS = s.indexOf(toShow[i].s.value);
}
if (mergedChoices[indexOfS] == undefined) {
mergedChoices[indexOfS] = {
s: toShow[i].s.value,
char: toShow[i].char.value,
from: toShow[i].from.value,
to: toShow[i].to.value,
literalValue: "與" + toShow[i].from.value + "~" + toShow[i].to.value + ((toShow[i].literalUnit == undefined)?"":toShow[i].literalUnit.value) + "有重疊",
literalUnit: ((toShow[i].literalUnit == undefined)?"":toShow[i].literalUnit.value),
type: toShow[i].type.value
};
}
else {
if (parseFloat(mergedChoices[indexOfS].from) > parseFloat(toShow[i].from.value)) {
mergedChoices[indexOfS].from = toShow[i].from.value;
mergedChoices[indexOfS].literalValue = "與" + mergedChoices[indexOfS].from + "~" + mergedChoices[indexOfS].to + mergedChoices[indexOfS].literalUnit + "有重疊";
}
if (parseFloat(mergedChoices[indexOfS].to) < parseFloat(toShow[i].to.value)) {
mergedChoices[indexOfS].to = toShow[i].to.value;
mergedChoices[indexOfS].literalValue = "與" + mergedChoices[indexOfS].from + "~" + mergedChoices[indexOfS].to + mergedChoices[indexOfS].literalUnit + "有重疊";
}
}
break;
}
}
document.getElementById('char_name').innerHTML = "<h2>"+keys[indexOfKey].char+"</h2>";
var choices_html = "<input type='radio' id='distinctValueRadio' name='char_radio' value='"+indexOfKey+"_exists'/>從現有資料中選一個值";
var charExists = [];
var charExistsKeepIndex = [];
for (i=0; i<mergedChoices.length; i++) {
if (filterVar[indexOfKey] == undefined) {
filterVar[indexOfKey] = {};
}
filterVar[indexOfKey][i] = mergedChoices[i];
if (selectedKey[indexOfKey] == i) {
var checkedString = 'checked';
}
else {
var checkedString = '';
}
// var keyTxt = mergedChoices[i].char + ":" + mergedChoices[i].literalValue;
var keyTxt = mergedChoices[i].literalValue;
if (charExists.indexOf(keyTxt) == -1) {
charExists.push(keyTxt);
}
charExistsKeepIndex.push(keyTxt);
}
if (charExists.length < 1) {
choices_html += '<div class="key_choices" id="'+indexOfKey+'_idontcare">這個特徵好像還沒處理好ㄆㄆ</div>';
}
else {
charExists.sort();
for (i=0; i<charExists.length; i++) {
choices_html += "<div class='key_choices' id='"+indexOfKey+"_"+charExistsKeepIndex.indexOf(charExists[i])+"'>" + charExists[i] + "</div>";
}
}
choices_html += "<div class='key_choices_idontknow' id='"+indexOfKey+"_idontknow'>我不知道</div>";
if (mergedChoices[0] != undefined) {
choices_html += "<input id='onmyownRadio' type='radio' name='char_radio' value='"+indexOfKey+"_onmyown'/>我要自己輸入 <span id='submit_onmyownVal'><u>填好送出</u></span><br/>數值<input class='onmyownInput' name='"+indexOfKey+"_onmyownValue'/><br/>單位<input class='onmyownInput' name='"+indexOfKey+"_onmyownUnit' value='"+mergedChoices[0].literalUnit+"'/>";
}
$('#key_choices_area').html(choices_html);
}
var keyChars = {};
function renderFilters() {
var html = "";
$.each(filterVal, function(i, f) {
var fDiv = "<div class='filter_values has_value' id='fv_"+i+"'>"+f.char+": <b>"+f.literalValue+"</b></div>";
keyChars[i] = fDiv;
});
$.each(keyChars, function(i, div) {
html = html + div + "\n";
});
$('#keyVal').html(html);
}
var restKeys = null;
var indexOfKey = 0;
function runKeys(op) {
if (op=='=') {
}
else if (op=='+') {
if (parseInt(indexOfKey) + 1 > keys.length - 1) {
alert("到底了!!");
}
else {
indexOfKey = parseInt(indexOfKey) + 1;
}
}
else if (op=='-') {
if (parseInt(indexOfKey) - 1 < 0) {
alert("到頭了!!");
}
else {
indexOfKey = parseInt(indexOfKey) - 1;
}
}
var q = getQueryByKey(indexOfKey);
var toShow = query(null, q); // set to null to use default value
/*
// 聯動式檢索選項請 uncomment 以下部分
if (!isEmpty(toShow)) {
if (!isEmpty(toShow[0].char)) {
renderChoices(toShow);
}
else {
if (op != '=') {
if ((indexOfKey - 1 < 0)||(indexOfKey + 1 > keys.length - 1)) {
if (op == '-') {
alert("到頭了!!");
op = '+';
}
else if (op == '+') {
alert("到底了!!");
op = '-';
}
}
runKeys(op);
}
else {
runKeys('+');
}
}
}
else {
if (op != '=') {
if ((indexOfKey - 1 < 0)||(indexOfKey + 1 > keys.length - 1)) {
if (op == '-') {
alert("到頭了!!");
op = '+';
}
else if (op == '+') {
alert("到底了!!");
op = '-';
}
}
runKeys(op);
}
else {
runKeys('+');
}
}
*/
// 聯動式檢索選項請 comment 下一行
renderChoices(toShow);
renderFilters();
}
function getKeys() {
var q = "prefix : <http://lod.tw/rdf/taicol.n3#> ";
q += "prefix tsp: <http://taibif.tw/lod/resource/Species/> ";
q += "prefix spv: <http://taibif.tw/lod/resource/vocab/> ";
q += "prefix dbp: <http://dbpedia.org/resource/> ";
q += "prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> ";
q += "select distinct ?char ?type ";
q += "from <http://lod.tw/trashmai/frogs.n3> ";
q += "{ ";
q += " ?s :hasDescription [ ";
q += " :character ?char; ";
q += " a ?type; ";
q += " ];. ";
q += "} ";
$.post("http://ecowlim.tfri.gov.tw/sparql/query", {query : q, format: 'json'}, function(data, getKeysStatus, getKeysXhr) {
var ffss = 5566;
var tmpKeys = [];
data.results.bindings.forEach(function (b) {
var descriptionKey = {char: b.char.value, type: b.type.value};
tmpKeys.push(descriptionKey);
});
keys = shuffle(tmpKeys);
$.each(keys, function(i, k) {
var kDiv = "<div class='filter_values' id='fv_"+i+"'>"+k.char+":</div>";
keyChars[i] = kDiv;
});
var html = "";
$.each(keyChars, function(i, div) {
html = html + div + "\n";
});
$('#keyVal').html(html);
runKeys('=');
}, 'json');
}
getKeys();
</script>