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