Commits

Anonymous committed bff27b0

now running bib code but with not enough data

Comments (0)

Files changed (3)

 <meta http-equiv="content-type" content="text/html; charset=UTF-8">
 
 	<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
-<script type="text/javascript" src="https://github.com/douglascrockford/JSON-js/raw/master/json.js"></script>
+     <script type="text/javascript" src="https://github.com/douglascrockford/JSON-js/raw/master/json.js"></script>
 	<script type="text/javascript" src="demo_files/loadabbrevs.js"></script>
     <script type="text/javascript; e4x=1" src="demo_files/xmle4x.js"></script> 
 	<script type="text/javascript" src="demo_files/xmldom.js"></script>
 
         <div about="http://dx.doi.org/10.1039/B411699M" typeof="http://purl.org/spar/biro/BibliographicRecord">
             <a name="cite1"></a>
+
             <span property="http://purl.org/dc/terms/title">Experimental data checker: better information for organic chemists</span>
             <br>
             <span rel="http://purl.org/dc/terms/creator">

demo_files/loadcites.js

         aboutObj.author=creators; 
         aboutObj.note = "";
         allRefData[id] = aboutObj;
-        alert(JSON.stringify(allRefData));;
+       
         
 
     /* isPartOf 

demo_files/runcites.js

 }
 
 var CiteInserter = function (name, stub) {
+    //This appears to just find a list of elements into which you want to cite things
 	this.stub = stub;
 	this.nodes = [];
 	this.idx = 0;
+    
 	var spannodes = document.getElementsByTagName("span");
 	for (var pos = 0, len = spannodes.length; pos < len; pos += 1) {
 		var node = spannodes.item(pos);
  */
 var insert = function() {
 
-	var data = ScHTML2_CSL_JSON() ;
-	//for debug :)
-	alert(JSON.stringify(data));
+     data = ScHTML2_CSL_JSON() ;
+	
+	//alert(JSON.stringify(data));
 	
 	var citeproc, output;
 	var sys = new Sys(abbreviations);
 	
 	// Chicago Author-Date
+    //
 	citeproc = new CSL.Engine(sys, chicago_author_date);
-	var citeInserter = new CiteInserter("citation_cad","cad");
+    ctx =  $("body");   
+    citations = ctx.find("a[rel ^= http://purl.org/spar/cito/]"); //TODO - handle citation types properly
+    
+    citations.each(function(_, cit){
+        cit=$(cit);
+        var res = cit.attr("resource");
+        if (res) {
+           var cad = citeproc.appendCitationCluster({
+	                "citationItems": [
+                      {
+		            	"id": res
+		                }
+	            ],
+	                "properties": {
+                    "noteIndex": 1
+	        }
+        });
+        }
+        else {
+            //TODO: Handle external citations - need to call a remote service to get JSON metadata
+        }
+
+    });
+	//var citeInserter = new CiteInserter("citation_cad","cad");
 	
-	var cad1 = citeproc.appendCitationCluster(citationCAD1);
-	citeInserter.insertCite(cad1);
-	var cad2 = citeproc.appendCitationCluster(citationCAD2);
-	citeInserter.insertCite(cad2);
+	//var cad1 = citeproc.appendCitationCluster(citationCAD1);
+	//citeInserter.insertCite(cad1);
+	//var cad2 = citeproc.appendCitationCluster(citationCAD2);
+	//citeInserter.insertCite(cad2);
+
+    
 
 	output = citeproc.makeBibliography();
-	if (output && output.length && output[1].length){
-		output = output[0].bibstart + output[1].join("") + output[0].bibend;
-		pointedStickInnerHtml("chicago_author_date",output);
-	}
+   
+	reflist =  $("*[typeof=http://purl.org/spar/biro/ReferenceList]");
+    reflist = $(reflist);
+    alert(reflist.text());
+    reflist.after(output);
+    reflist.hide();
 
 } ;