Public Domain Calculators

In addition to being run as a standalone program, the public domain calculators provide an API that can be easily integrated into a website.


Here is an example on how to do it by means of simple javascript code:

<!DOCTYPE html>




<meta charset=”utf-8″ />

<title>Public Domain Works example</title>


<script src=”//ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js”></script>


<script type=”text/javascript”>

jQuery(document).ready(function($) {

// Function that specifies how to display the results:


 var showresult = function(data) {




       var result = ‘<div id=”result”>’;


      for ( var i in data ) {


/* data is an array that contains the following information:

   “output” : questions, answers and assumptions for every node in the decision tree

   “errors”  : all errors raised along the process

   “work”    : the JSON description of the work being processed */


result +=  i + ‘: ‘ + JSON.stringify( data[i] ).replace( /\\n/g, ‘<br>’ ).replace( /\\”/g, ” );



       result += ‘</div>’;




// Function that specifies what to do once the query has been submitted:


   var pdw = function(event) {


var url = ‘http://publicdomainworks.net/api/pd?jurisdiction=’ + $(‘#jurisdiction’).val()   // relevant jurisdiction


//  if the metadata has been passed as POST (in JSON format)

+ ‘&work=’ + JSON.stringify(work);


// if the metadata is provided through a filename (in JSON or RDF format)

+ ‘&work=’ + ‘http://bnb.bibsoup.net/bibsoup/bnb/GB9407119.json’;

+ ‘&work=’ + ‘https://raw.github.com/okfn/pdcalc/master/pd/’ + $(‘#work’).val() + ‘.rdf’;



           type: “get”,

           url: url,

           dataType: ‘jsonp’,

           success: showresult,

           error: showresult




   $(‘#submit’).bind(‘click’, pdw);










jurisdiction: <select name=”jurisdiction” id=”jurisdiction”>








metadata file: <select name=”work” id=”work”>







<p><input type=”submit” name=”submit” value=”submit” id=”submit” /></p>




Leave a Reply

Your email address will not be published. Required fields are marked *