vivo/utilities/acceptance-tests/testApp/TestSparqlQueryApi.html

75 lines
1.9 KiB
HTML
Raw Normal View History

<!-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
<script src="js/jquery.js"></script>
<script>
function TestSparql() {
self = this;
this.setup = setupButtons;
function setupButtons() {
document.getElementById("submit_button").onclick = function() {
requestWithAcceptHeader(
$("#acceptHeader").val(),
$("#email").val(),
$("#password").val(),
$("#query").val());
}
}
function requestWithAcceptHeader(mimetype, email, password, query) {
var parms = {
type: "POST",
url: "/vivo/api/sparqlQuery",
headers: {Accept: mimetype},
data: {query: query, email: email, password: password},
dataType: "text",
complete: displayResult
};
$.ajax(parms);
}
function displayResult(xhr, status) {
$("#responseCode").text(xhr.status);
$("#mimeType").text(xhr.getResponseHeader("Content-Type"));
$("#responseText").text(xhr.responseText);
}
}
$(document).ready(function() {
new TestSparql().setup();
});
</script>
<h1>Test the SPARQL Query API</h1>
<h3>Request data</h3>
<table>
<tr>
<td>User email</td>
<td><input type="text" size="25" id="email"></td>
</tr>
<tr>
<td>User password</td>
<td><input type="password" size="15" id="password"></td>
</tr>
<tr>
<td>Accept header</td>
<td><input type="text" size="40" id="acceptHeader"></td>
</tr>
<tr>
<td>Query text</td>
<td><textarea cols="60" rows="10" id="query"></textarea></td>
</tr>
<tr>
<td><input type="submit" value="submit the request" id="submit_button"></td>
<td>&nbsp;</td>
</tr>
</table>
<h2>Response data</h2>
<div>Response code is <b><span id="responseCode">000</span></b></div>
<div>MIME type is <b><span id="mimeType">No type</span></b></div>
<div>Text is:</div>
<div><pre id="responseText" style="font-size:small; font-family:monospace">No text</pre></div>