source: gs2-extensions/afrepo/trunk/src/src/html/sparql.php@ 27745

Last change on this file since 27745 was 27745, checked in by davidb, 11 years ago

Javascript code to load an AJAX call to the Sparql-endpoint into a textarea

File size: 4.2 KB
RevLine 
[27679]1<?php
2 require_once "setup.php";
3 $base = parse_url($repo->getURIPrefix());
4 $basepath = $base["path"];
5?>
6<!DOCTYPE HTML>
7<html>
8 <head>
9 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
10
11 <link rel="stylesheet" href="css/core-style.css" type="text/css" media="screen" />
12
13
14 <title>SALAMI SPARQL Endpoint</title>
[27693]15
16 <script src="js/jquery-1.10.1.js" > </script>
17
18 <script>
19
20
21 function onSubmit() {
22
23 $.ajax({
[27745]24 type: "GET",
25
[27693]26 beforeSend: function (request) {
27 //request.setRequestHeader("Authority", authorizationToken);
[27745]28 //request.setRequestHeader("origin", "http://nema.lis.illinois.edu");
29 },
30
31 url: "<?php echo $repo->getSparqlEndpoint();?>",
32 data: { "query": $('#rdf-query').val(), "output": $('#rdf-output').val() },
33 //processData: false,
34
35 /*
36 xhrFields: {
37 withCredentials: true
[27693]38 },
[27745]39 crossDomain: true,
40 */
[27693]41
[27745]42 // accepts: "text/plain",
43 //converters: {},
44 dataType: "text",
45
[27693]46 success: function(msg) {
[27745]47 //var $msg = $(msg);
48 //alert("msg = " +msg);
49
50 //$('#rdf-results').val(msg.documentElement.outerHTML);
51 $('#rdf-results').val(msg);
52 },
53
54
55 error: function(err) {
56 alert(err.toString());
57 if (err.status == 200) {
58 ParseResult(err);
59 }
60 else { alert('Error:' + err.responseText + ' Status: ' + err.status); }
61 }
62
[27693]63 });
64
65 return false;
66
67 }
68
69
70 </script>
71
[27679]72 </head>
73
74 <body>
75 <div id="container">
76
77 <div id="header">
78 <h1>The SALAMI SPARQL Endpoint</h1>
79 </div>
80
81 <div id="navigation">
82 <ul>
[27693]83 <li><a href="index.php">Home</a></li>
84 <li class="selected"><a href="#">SPARQL</a></li>
[27679]85 <li><a href="contact.php">Contact</a></li>
86 </ul>
87 </div>
88
89 <div id="content-container">
90
91 <div id="content">
92
[27693]93 <p>
94 RDF Query:
95 </p>
[27679]96
[27693]97<!--
98 action="<?php echo htmlspecialchars($repo->getSparqlEndpoint()); ?>" method="post"
99-->
[27679]100
[27693]101 <form onsubmit="return onSubmit()">
102
103 <textarea name="query" id="rdf-query"
104 style="width: 97%; margin-left: 10px; margin-right: 20px;" rows="8">
105PREFIX rdf: &lt;http://www.w3.org/1999/02/22-rdf-syntax-ns#&gt;
106PREFIX rdfs: &lt;http://www.w3.org/2000/01/rdf-schema#&gt;
107
[27679]108SELECT * WHERE {
109 ?s ?p ?o
110} LIMIT 10
[27693]111 </textarea>
112 <br/>
[27679]113
[27693]114 <span style="margin: 5px 20px 5px 20px;">
115 Output type:
[27745]116 <select name="output" id="rdf-output">
[27693]117 <option>xml</option>
118 <option>json</option>
119 <option>text</option>
120 </select>
121 </span>
[27679]122
[27693]123 <span style="margin: 5px 20px 5px 20px;">
124 Maximum results returned:
125 <select name="soft-limit">
126 <option>10</option>
127 <option>100</option>
128 <option>1000</option>
129 </select>
130 </span>
[27679]131
[27693]132 <span style="margin: 5px 40px 5px 40px;">
133 <input type="submit" value="Execute">
134 </span>
[27679]135
[27693]136 <span style="margin: 5px 40px 5px 40px;">
137 <input type="reset">
138 </span>
139
140
[27679]141 </form>
142
143
[27693]144 <p>
145 RDF Results:
146 </p>
147 <textarea id="rdf-results"
148 style="width: 97%; margin-left: 10px; margin-right: 20px;" rows="8">
149 </textarea>
150
151 <p>
152 The <code>Accept</code> header you send is taken into account.
153 Various types of RDF are available, plus an HTML representation and
154 potentially the audio data (use <code>audio/*</code> to accept any
155 format of audio).
156 </p>
157
158
159 <p>
160 The machine-interfacable Sparql endpoint, which operates without
161 a limit on the number of tripples returned, is available at
162 <code><?php echo htmlspecialchars($repo->getSparqlEndpoint()); ?></code>.
163 </p>
164
165
166</div>
167
168
169 <div id="footer" style="border-top: 8px groove #7ECDF3;">
170 <table cellpadding="0px" cellspacing="0px" width="100%">
171 <tbody>
172 <tr style="background: white;">
173 <td align="center">
174 <a href="http://www.sshrc-crsh.gc.ca/Default.aspx">
175 <img width="400px" src="images/sshrc_logo.jpeg">
176 </a>
177 </td>
178 <td align="center">
179 <a href="http://www.nsf.gov/index.jsp">
180 <img width="100px" src="images/nsf_logo.jpeg">
181 </a>
182 </td>
183 <td align="center">
184 <a href="http://www.jisc.ac.uk/">
185 <img height="100px" src="images//jisc_logo.jpeg">
186 </a>
187 </td>
188 </tr>
189 </tbody>
190 </table>
191
192 </div>
193
194 </div>
[27679]195 </body>
196</html>
Note: See TracBrowser for help on using the repository browser.