Skip to content

Instantly share code, notes, and snippets.

@seralf
Forked from LaurensRietveld/README.md
Created June 27, 2014 16:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seralf/f7dc9abe213b804a0dfd to your computer and use it in GitHub Desktop.
Save seralf/f7dc9abe213b804a0dfd to your computer and use it in GitHub Desktop.
var yasqe = YASQE(document.getElementById("yasqe"), {
sparql: {
showQueryButton: true
}
});
var yasr = YASR(document.getElementById("yasr"), {
//this way, the URLs in the results are prettified using the defined prefixes in the query
getUsedPrefixes: yasqe.getPrefixesFromQuery
});
/**
* Set some of the hooks to link YASR and YASQE
*/
yasqe.options.sparql.handlers.success = function(data, textStatus, xhr) {
yasr.setResponse({response: data, contentType: xhr.getResponseHeader("Content-Type")});
};
yasqe.options.sparql.handlers.error = function(xhr, textStatus, errorThrown) {
var exceptionMsg = textStatus + " (response status code " + xhr.status + ")";
if (errorThrown && errorThrown.length) exceptionMsg += ": " + errorThrown;
yasr.setResponse({exception: exceptionMsg});
};
<!DOCTYPE html>
<html lang="en">
<!--Make sure to store YASR and YASQE css/js files in the current working dir! (these are not included in this gist)-->
<head>
<meta charset="utf-8">
<title>Glueing YASQE and YASR</title>
<link href="yasqe.min.css" rel="stylesheet" type="text/css" />
<link href="yasr.min.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="yasqe"></div>
<div id="yasr"></div>
<script src="yasqe.min.js"></script>
<script src="yasr.min.js"></script>
<script src="glue.js"></script>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment