Skip to content

Instantly share code, notes, and snippets.

@egonw egonw/aspirin.html
Last active Dec 25, 2015

Embed
What would you like to do?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>OpenPHACTS Jasmine Spec Runner</title>
<script src="lib/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="lib/purl.js"></script>
<!-- include source files here... -->
<script type="text/javascript" src="src/OPS.js"></script>
<script type="text/javascript" src="src/ConceptWikiSearch.js"></script>
<!-- setup -->
<script type="text/javascript">
var prmstr = window.location.search.substr(1);
var prmarr = prmstr.split ("&");
var params = {};
for ( var i = 0; i < prmarr.length; i++) {
var tmparr = prmarr[i].split("=");
params[tmparr[0]] = tmparr[1];
}
var showDetails = function(dataJSON){
data = JSON.parse(unescape(dataJSON));
// document.getElementById("details").innerHTML = JSON.stringify(data);
document.getElementById("details").innerHTML = data._about;
};
</script>
</head>
<body>
<h3>Output</h3>
<!-- p>app_id: <span id="appID"></span>, app_key: <span id="appKey"></span -->
<h3>Search Results</h3>
<p><div id="table"></div></p>
<h3>Compound Details</h3>
<p><div id="details"></div></p>
<h3>JSON reply</h3>
<p><div id="json">Nothing yet</div></p>
<script type="text/javascript">
// document.getElementById("appID").innerHTML = params["app_id"];
// document.getElementById("appKey").innerHTML = params["app_key"];
var searcher = new Openphacts.ConceptWikiSearch("https://beta.openphacts.org", params["app_id"], params["app_key"]);
var callback = function(success, status, response){
document.getElementById("json").innerHTML = JSON.stringify(response);
html = "<table>";
for (var i=0; i<response.length; i++) {
html += "<tr>";
html += "<td>";
dataJSON = JSON.stringify(response[i]);
// dataJSON.replace(/"/g, "'");
html += "Name: <span onClick=\"showDetails('" + escape(dataJSON) + "\')\">" + response[i].prefLabel + "</span>";
html += "</td>";
html += "</tr>";
}
html += "</table>";
document.getElementById("table").innerHTML = html;
};
searcher.byTag('Aspirin', '5', '4', '07a84994-e464-4bbf-812a-a4b96fa3d197', callback);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.