Menu

Techniques
how to use DOACC data in your own application / web site.

Using DOACC with Javascript

Modal presentation example

See the source for details. Jquery fetches the graph, rdflib parses it, picks out all the alts that use BLAKE for a PoW hashing algo, retrieves other facts about the coin, sets the lot in a table and presents via a modal popup.

Loading DOACC data.

How the lists of facts are generated using mashlib.js

The listing is rendered by the mashlib.js library in the browser, working on the AJAX-retrieved DOACC RDF graph. The approach is fairly standard and straightforward. The example below lists all the different protection schemes used.

var RDF = $rdf.Namespace("http://www.w3.org/1999/02/22-rdf-syntax-ns#") var SKOS = $rdf.Namespace("http://www.w3.org/2004/02/skos/core#") var DOACC = $rdf.Namespace("http://purl.org/net/bel-epa/doacc#") var listout = function() { var op = '<div class="ui segment"><ul>'; var rel = DOACC('ProtectionScheme'); var res = g.each(null, RDF('type'), rel); var n = res.length; for (i = 0; i < n; i++) { ps = res[i]; pv = ps.value; // var rels = g.each(ps, null, null); op += '<li><a href="' + pv + '"> ' + pv.slice(pv.indexOf('#') + 1, pv.length) + '</a> - '; op += '<i>' + g.any(ps, SKOS('prefLabel')) + '</i>, ' + g.any(ps, RDFS('comment')) + '</li>'; }; op += '</ul></div>'; $("#results").html(op) }; var g = $rdf.graph(); var docURI = "https://DOACC.github.io/altcoin.n3"; var fetch = $rdf.fetcher(g); fetch.nowOrWhenFetched(docURI, undefined, function(ok, body, xhr) { // @@ check ok listout() });