1 | <html>
|
---|
2 | <head>
|
---|
3 | <!--
|
---|
4 | <script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
|
---|
5 | <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
|
---|
6 | -->
|
---|
7 | <script src="./jquery-1.11.1.min.js"></script>
|
---|
8 | <script src="./d3.v3.min.js" charset="utf-8"></script>
|
---|
9 | <script src="./sparqlbuilder.js"></script>
|
---|
10 | <script type="text/javascript" src="http://uedayou.net/SPARQLTimeliner/js_sparql/sparql.js" charset="UTF-8"></script>
|
---|
11 | <!-- script src="./sb-test.js"></script -->
|
---|
12 | <script>
|
---|
13 | <!--
|
---|
14 |
|
---|
15 | var ep;
|
---|
16 | var st;
|
---|
17 | var en;
|
---|
18 |
|
---|
19 | $(window).load(function() {
|
---|
20 | var param = getParameter();
|
---|
21 | ep = param['ep'];
|
---|
22 | st = param['st'];
|
---|
23 | en = param['en'];
|
---|
24 |
|
---|
25 | if(ep!=undefined && st!=undefined && en!=undefined){
|
---|
26 | if(ep!="" && st!="" && en!=""){
|
---|
27 | openSPARQLBuilder(ep,st,en);
|
---|
28 | }
|
---|
29 | }
|
---|
30 | });
|
---|
31 |
|
---|
32 | function startSPARQLBuilder(){
|
---|
33 | /* if(ep!=undefined && st!=undefined && en!=undefined){
|
---|
34 | if(ep!="" && st!="" && en!=""){
|
---|
35 | openSPARQLBuilder(ep,st,en);
|
---|
36 | }
|
---|
37 | }
|
---|
38 | else{*/
|
---|
39 | var sb = new SPARQLBuilder('sparql');
|
---|
40 | sb.loadSamplePathList();
|
---|
41 | return false;
|
---|
42 | //}
|
---|
43 | }
|
---|
44 |
|
---|
45 | function sendSPARQL(){
|
---|
46 | ep = $("*[name=selectendpoint]").val();
|
---|
47 |
|
---|
48 | if(ep == "input"){
|
---|
49 | ep = $("*[name=inputendpoint]").val();
|
---|
50 | }
|
---|
51 |
|
---|
52 | var query = $("*[name=sparql]").val();
|
---|
53 |
|
---|
54 | query = encodeURIComponent(query);
|
---|
55 |
|
---|
56 | openpage = ep + "?format=text%2Fhtml&query=" + query;
|
---|
57 |
|
---|
58 | window.open(openpage);
|
---|
59 | }
|
---|
60 |
|
---|
61 | function trySample(sparql){
|
---|
62 | openSPARQLBuilder('http://www.ebi.ac.uk/rdf/services/reactome/sparql',
|
---|
63 | 'http://www.biopax.org/release/biopax-level3.owl#Protein',
|
---|
64 | 'http://www.biopax.org/release/biopax-level3.owl#Pathway');
|
---|
65 | /*
|
---|
66 | var sb = new SPARQLBuilder('sparql');
|
---|
67 | sb.loadSamplePathList('http://www.ebi.ac.uk/rdf/services/reactome/sparql'));
|
---|
68 |
|
---|
69 | $('#seclass').on('epcomplete', function(){
|
---|
70 | $('#EndPointSelect').val('http://www.ebi.ac.uk/rdf/services/reactome/sparql');
|
---|
71 | sb.changeEndPoint();
|
---|
72 | });
|
---|
73 |
|
---|
74 | $('#seclass').on('secomplete', function(){
|
---|
75 | $('#StartClassSelect').val('http://www.biopax.org/release/biopax-level3.owl#Protein');
|
---|
76 | $('#EndClassSelect').val('http://www.biopax.org/release/biopax-level3.owl#Pathway');
|
---|
77 | });*/
|
---|
78 | }
|
---|
79 |
|
---|
80 | function openSPARQLBuilder(ep,st,en){
|
---|
81 | var sb = new SPARQLBuilder('sparql');
|
---|
82 | sb.loadSamplePathList();
|
---|
83 |
|
---|
84 | $('#seclass').on('epcomplete', function(){
|
---|
85 | $('#EndPointSelect').val(ep);
|
---|
86 | sb.changeEndPoint();
|
---|
87 | });
|
---|
88 |
|
---|
89 | $('#seclass').on('secomplete', function(){
|
---|
90 | $('#StartClassSelect').val(st);
|
---|
91 | $('#EndClassSelect').val(en);
|
---|
92 | });
|
---|
93 | }
|
---|
94 |
|
---|
95 |
|
---|
96 | function sendSPARQL2(){
|
---|
97 | var ep = $("*[name=selectendpoint]").val();
|
---|
98 |
|
---|
99 | if(ep == "input"){
|
---|
100 | ep = $("*[name=inputendpoint]").val();
|
---|
101 | }
|
---|
102 |
|
---|
103 | var query = $("*[name=sparql]").val().replace(/[\n\r]/g,"");
|
---|
104 |
|
---|
105 | //query = encodeURIComponent(query);
|
---|
106 |
|
---|
107 | qr = sendQuery(ep,query);
|
---|
108 |
|
---|
109 | qr.fail(
|
---|
110 | function (xhr, textStatus, thrownError) {
|
---|
111 | alert("Error: A '" + textStatus+ "' occurred.");
|
---|
112 | }
|
---|
113 | );
|
---|
114 | qr.done(
|
---|
115 | function (d) {
|
---|
116 | download_result(d.results.bindings);
|
---|
117 | }
|
---|
118 | );
|
---|
119 | }
|
---|
120 |
|
---|
121 | function download_result(data){
|
---|
122 |
|
---|
123 | if (data instanceof Array) {
|
---|
124 | var result_txt ="";
|
---|
125 |
|
---|
126 | var i=0;
|
---|
127 | for ( var key in data[0]) {
|
---|
128 | if(i>0){result_txt +=",";}
|
---|
129 | result_txt += key;
|
---|
130 | i++;
|
---|
131 | }
|
---|
132 |
|
---|
133 | result_txt += "\n";
|
---|
134 |
|
---|
135 | for (var d = 0; d < data.length; d++) {
|
---|
136 | var i = 0;
|
---|
137 | for ( var key in data[d]) {
|
---|
138 | if(i>0){result_txt +=",";}
|
---|
139 | result_txt += data[d][key].value;
|
---|
140 | i++;
|
---|
141 | }
|
---|
142 | result_txt += '\n';
|
---|
143 | }
|
---|
144 |
|
---|
145 | var blob = new Blob( [result_txt], {type: 'text/plain'} )
|
---|
146 |
|
---|
147 | var link = document.createElement('a')
|
---|
148 | link.href = URL.createObjectURL(blob)
|
---|
149 | link.download = 'result' + '.csv'
|
---|
150 |
|
---|
151 | document.body.appendChild(link) // for Firefox
|
---|
152 | link.click()
|
---|
153 | document.body.removeChild(link) // for Firefox
|
---|
154 | }
|
---|
155 | };
|
---|
156 |
|
---|
157 | function getParameter()
|
---|
158 | {
|
---|
159 | var result = {};
|
---|
160 | if( 1 < window.location.search.length )
|
---|
161 | {
|
---|
162 | var query = window.location.search.substring( 1 );
|
---|
163 | var parameters = query.split( '&' );
|
---|
164 |
|
---|
165 | for( var i = 0; i < parameters.length; i++ )
|
---|
166 | {
|
---|
167 | var element = parameters[ i ].split( '=' );
|
---|
168 | var paramName = decodeURIComponent( element[ 0 ] );
|
---|
169 | var paramValue = decodeURIComponent( element[ 1 ] );
|
---|
170 | result[ paramName ] = paramValue;
|
---|
171 | }
|
---|
172 | }
|
---|
173 | return result;
|
---|
174 | }
|
---|
175 |
|
---|
176 | -->
|
---|
177 | </script>
|
---|
178 | <link rel="stylesheet" href="./sparqlbuilder.css" type="text/css" />
|
---|
179 | </head>
|
---|
180 | <body>
|
---|
181 | <div id="sbtop"><img src="http://www.sparqlbuilder.org/img/sblogo.png"></div>
|
---|
182 |
|
---|
183 | <div>
|
---|
184 | <form>
|
---|
185 | <input type="button" id="create" value="Start SPARQLBuilder" onclick="startSPARQLBuilder()"/>
|
---|
186 | <!--<input type="button" id="create" value="Start SPARQLBuilder" onclick="new SPARQLBuilder('sparql'); return false;"/> -->
|
---|
187 | <input type="button" id="create" value="Try with Sample" onclick="trySample('sparql'); return false;" />
|
---|
188 | <br/>
|
---|
189 | <textarea id="sparql" name="sparql" cols="60" rows="10"></textarea><br/>
|
---|
190 | <input type="button" name="sendsparql" value="Send SPARQL" onClick="sendSPARQL()">
|
---|
191 | <input type="button" name="sendsparql" value="Download Result" onClick="sendSPARQL2()"><br/>
|
---|
192 | </form>
|
---|
193 | </div>
|
---|
194 | <div id="searchResult"></div>
|
---|
195 | </body>
|
---|
196 | </html>
|
---|