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 | function sendSPARQL(){
|
---|
15 | var ep = $("*[name=selectendpoint]").val();
|
---|
16 |
|
---|
17 | if(ep == "input"){
|
---|
18 | ep = $("*[name=inputendpoint]").val();
|
---|
19 | }
|
---|
20 |
|
---|
21 | var query = $("*[name=sparql]").val();
|
---|
22 |
|
---|
23 | query = encodeURIComponent(query);
|
---|
24 |
|
---|
25 | openpage = ep + "?format=text%2Fhtml&query=" + query;
|
---|
26 |
|
---|
27 | window.open(openpage);
|
---|
28 | }
|
---|
29 |
|
---|
30 | function trySample(sparql){
|
---|
31 | var sb = new SPARQLBuilder('sparql');
|
---|
32 | sb.loadSamplePathList();
|
---|
33 |
|
---|
34 | $('#seclass').on('epcomplete', function(){
|
---|
35 | $('#EndPointSelect').val('http://www.ebi.ac.uk/rdf/services/reactome/sparql');
|
---|
36 | sb.changeEndPoint();
|
---|
37 | });
|
---|
38 |
|
---|
39 | $('#seclass').on('secomplete', function(){
|
---|
40 | $('#StartClassSelect').val('http://www.biopax.org/release/biopax-level3.owl#Protein');
|
---|
41 | $('#EndClassSelect').val('http://www.biopax.org/release/biopax-level3.owl#Pathway');
|
---|
42 | });
|
---|
43 | }
|
---|
44 |
|
---|
45 | function sendSPARQL2(){
|
---|
46 | var ep = $("*[name=selectendpoint]").val();
|
---|
47 |
|
---|
48 | if(ep == "input"){
|
---|
49 | ep = $("*[name=inputendpoint]").val();
|
---|
50 | }
|
---|
51 |
|
---|
52 | var query = $("*[name=sparql]").val().replace(/[\n\r]/g,"");
|
---|
53 |
|
---|
54 | //query = encodeURIComponent(query);
|
---|
55 |
|
---|
56 | qr = sendQuery(ep,query);
|
---|
57 |
|
---|
58 | qr.fail(
|
---|
59 | function (xhr, textStatus, thrownError) {
|
---|
60 | alert("Error: A '" + textStatus+ "' occurred.");
|
---|
61 | }
|
---|
62 | );
|
---|
63 | qr.done(
|
---|
64 | function (d) {
|
---|
65 | download_result(d.results.bindings);
|
---|
66 | }
|
---|
67 | );
|
---|
68 | }
|
---|
69 |
|
---|
70 | function download_result(data){
|
---|
71 |
|
---|
72 | if (data instanceof Array) {
|
---|
73 | var result_txt ="";
|
---|
74 |
|
---|
75 | var i=0;
|
---|
76 | for ( var key in data[0]) {
|
---|
77 | if(i>0){result_txt +=",";}
|
---|
78 | result_txt += key;
|
---|
79 | i++;
|
---|
80 | }
|
---|
81 |
|
---|
82 | result_txt += "\n";
|
---|
83 |
|
---|
84 | for (var d = 0; d < data.length; d++) {
|
---|
85 | var i = 0;
|
---|
86 | for ( var key in data[d]) {
|
---|
87 | if(i>0){result_txt +=",";}
|
---|
88 | result_txt += data[d][key].value;
|
---|
89 | i++;
|
---|
90 | }
|
---|
91 | result_txt += '\n';
|
---|
92 | }
|
---|
93 |
|
---|
94 | var blob = new Blob( [result_txt], {type: 'text/plain'} )
|
---|
95 |
|
---|
96 | var link = document.createElement('a')
|
---|
97 | link.href = URL.createObjectURL(blob)
|
---|
98 | link.download = 'result' + '.csv'
|
---|
99 |
|
---|
100 | document.body.appendChild(link) // for Firefox
|
---|
101 | link.click()
|
---|
102 | document.body.removeChild(link) // for Firefox
|
---|
103 | }
|
---|
104 | };
|
---|
105 |
|
---|
106 |
|
---|
107 | -->
|
---|
108 | </script>
|
---|
109 | <link rel="stylesheet" href="./sparqlbuilder.css" type="text/css" />
|
---|
110 | </head>
|
---|
111 | <body>
|
---|
112 | <div id="sbtop"><img src="http://www.sparqlbuilder.org/img/sblogo.png"></div>
|
---|
113 |
|
---|
114 | <div>
|
---|
115 | <form>
|
---|
116 | <input type="button" id="create" value="Start SPARQLBuilder" onclick="new SPARQLBuilder('sparql'); return false;"/>
|
---|
117 | <input type="button" id="create" value="Try with Sample" onclick="trySample('sparql'); return false;" />
|
---|
118 | <br/>
|
---|
119 | <textarea id="sparql" name="sparql" cols="60" rows="10"></textarea><br/>
|
---|
120 | <input type="button" name="sendsparql" value="Send SPARQL" onClick="sendSPARQL()">
|
---|
121 | <input type="button" name="sendsparql" value="Download Result" onClick="sendSPARQL2()"><br/>
|
---|
122 | </form>
|
---|
123 | </div>
|
---|
124 | <div id="searchResult"></div>
|
---|
125 | </body>
|
---|
126 | </html>
|
---|