-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
165 lines (151 loc) · 6.98 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
<html>
<meta charset="UTF-8"/>
<title>d3sparql.js</title>
<link rel="stylesheet" type="text/css" href="$app-root/resources/css/bootstrap.min.css"/>
<link rel="stylesheet" href="relationships.css"/>
<link rel="stylesheet" href="$app-root/modules/d3xquery/pygment_trac.css"/>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"/>
<script type="text/javascript" src="http://d3js.org/d3.v3.js"/>
<script src="d3sparql.js"/>
<script src="sankey.js"/>
<script>
$(document).ready(function () {
/* Populate relationsip menu */
populateRelationships();
/* Subimt form */
$("#query").on('click', function(e){
e.preventDefault();
var $form = $("#RDF"),
url = $form.attr('action'),
type = $("#type option:selected").val();
if (type === "JSON" || type === "XML") {
/* If JSON/XML submit the form with the appropriate/requested format */
$("#format").val(type);
$('form').submit();
} else {
/* Otherwise send to d3 visualization, set format to json. */
$("#format").val('json');
$.get(url, $form.serialize(), function(data) {
d3sparql.graphType(data, type);
/*console.log(data);*/
}).fail( function(jqXHR, textStatus, errorThrown) {
console.log(textStatus);
});
}
});
});
/* Toggle textarea */
function toggle() {
d3sparql.toggle()
}
/* Function to populate relationships */
function populateRelationships(){
<![CDATA[
var $form = $("#RDF")
$.get('list-relationships.xql', function(data) {
var options = "";
var data = data.option
// Loop over our returned result set and build our options
$.each(data, function(k, v){
options += '<option label="' + v.label + '">' + v.value + '</option>';
});
$("#relationship").append(options);
}).fail( function(jqXHR, textStatus, errorThrown) {
console.log(textStatus);
});
]]>
};
</script>
<style>
.bundle-node {
font: 300 11px "Helvetica Neue", Helvetica, Arial, sans-serif;
fill: #bbb;
}
.bundle-node:hover {
fill: #000;
}
.bundle-link {
stroke: steelblue;
stroke-opacity: .4;
fill: none;
pointer-events: none;
}
.bundle-node:hover,
.bundle-node--source,
.bundle-node--target {
font-weight: 700;
}
.bundle-node--source {
fill: #ff7f0e;
}
.bundle-node--target {
fill: #1F77B4;
}
.bundle-link--source,
.bundle-link--target {
stroke-opacity: 1;
stroke-width: 2px;
}
.bundle-link--source {
stroke: #ff7f0e;
}
.bundle-link--target {
stroke: #1F77B4;
}
</style>
<body>
<div>
<h1>Build a Query</h1>
<form class="form-inline" id="RDF" action="relationships.xql">
<div class="input-append">
<div class="form-group" style="display:block; width:80%">
<label for="id">Entity ID: </label>
<input type="text" name="id" id="id" size="50" placeholder="ex: http://syriaca.org/person/51"/>
<hint style="font-size:small;font-style:italic;"> *Use to get relationships for specific TEI entity . </hint>
<br/>
</div>
<!--
<div class="form-group" style="display:block; width:80%">
<label for="id">Record ID: </label>
<input type="text" name="recordID" id="recordID" size="50" placeholder="ex: http://syriaca.org/person/51"/>
<hint style="font-size:small;font-style:italic;"> * Use to get all the relationships in a specified TEI record. </hint>
<br/>
</div>
-->
<div class="form-group">
<label for="relationship">Relationship Type: </label>
<select id="relationship" name="relationship">
<option> --- Select relationship --- </option>
</select>
<label for="type">Visualization Type: </label>
<select id="type" name="type">
<option id="Tabel">Table</option>
<option id="barchart">Bar Chart</option>
<option id="piechart">Pie Chart</option>
<option id="Force">Force</option>
<!--<option id="Bundle">Bundle</option>-->
<option id="Sankey">Sankey</option>
<!--
<option id="RoundTree">Round Tree</option>
<option id="CirclePack">Circle Pack</option>
-->
<option id="Bubble">Bubble</option>
<option id="xml">XML</option>
<option id="json">JSON</option>
</select>
<input type="hidden" name="format" id="format" value="json"/>
<input type="hidden" name="collection" id="collection" value="/db/apps/srophe-data/data/spear"/>
<button class="btn btn-default" type="button" id="query">Query</button>
<!--
<button class="btn btn-default" type="button" id="hide" onclick="toggle()">
<span class="glyphicon glyphicon-chevron-up" aria-hidden="true"/>
</button>
-->
</div>
</div>
</form>
</div>
<h2>Query Results</h2>
<div id="result"/>
</body>
</html>