Commits

ptsefton  committed 73569bf

data working sort of

  • Participants
  • Parent commits e359a48

Comments (0)

Files changed (3)

File article.html

 <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="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>
 	<script type="text/javascript" src="demo_files/loadcites.js"></script>
 	<script type="text/javascript" src="demo_files/runcites.js"></script>
 
+
+
 <title>Article Demo</title>
 </head>
 
 
 
  
-    <div id="biblography" property="http://purl.org/spar/biro/ReferenceList">
+    <div id="biblography" typeof="http://purl.org/spar/biro/ReferenceList">
 
-        <div about="http://dx.doi.org/10.1039/B411699M" rel="http://purl.org/spar/biro/BibliographicRecord">
+        <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>
     <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
 
 </div>
-</body></html>
+</body></html>

File demo_files/loadcites.js

  * or the [AGPLv3] License.”
  */
 
-var data = new Object() ;
 
-var ScHTML2_CSL_JSON = function () {
 
-	var bib = $("[rel='http://purl.org/spar/biro/BibliographicRecord']") ;
-	
-	bib.each(function() {
+var ScHTML2_CSL_JSON = function (ctx) {
 
-		var doi = this.getAttribute("about") ;
-		
-		var recordTemplate = {
-			"id": doi,
-			"doi": doi,
-			"title":"Anhydrous proton conduction at 150&nbsp;&#x000B0;C in a crystalline metal&#x02013;organic framework",
-			"author": [
-				{
-					"family": "D'Arcus",
-					"given": "Bruce",
-					"static-ordering": false
-				}
-			],
-	        "note":"The apostrophe in Bruce's name appears in proper typeset form.",
-			"publisher": "Routledge",
-	        "publisher-place": "New York",
-			"issued": {
-				"date-parts":[
-					[2006]
-				]
-			},
-			"type": "book"
-		 };
+   // ctx = jQuery context in which to search, if not given will search the whole document
+    var allRefData={}; // A Javascript object (JSON) var refList;
 
-		data[doi] = recordTemplate ;
-	  });
+    ctx =  $("body");
 
-} ;
+    
+    refList=ctx.find("div[typeof= http://purl.org/spar/biro/BibliographicRecord]"); 
+    refList.each(function(_, e){ // iterate over the list
+
+        var aboutObj={}, tmp; 
+        var id, title, creators=[], isPartOf={}; e=$(e); 
+        id=e.attr("about"); 
+        aboutObj.id=id; 
+        // title 
+        title=e.find("span[property= http://purl.org/dc/terms/title]:first").text(); 
+        aboutObj.title=title; 
+        //creators 
+        tmp=e.find("span[rel= http://purl.org/dc/terms/creator] span[property= http://xmlns.com/foaf/0.1/name]"); 
+        tmp.each(function(_, e){
+                //TODO: work out how to handle names with and without parts
+                var name, url; 
+                e=$(e); 
+                name=e.text(); 
+                url=e.parent("span[resource]").attr("resource"); 
+                creators.push   ({literal:name, url:url});});
+    
+  
+        aboutObj.author=creators; 
+        aboutObj.note = "";
+        allRefData[id] = aboutObj;
+        alert(JSON.stringify(allRefData));;
+        
+
+    /* isPartOf 
+    tmp=e.find("span[rel= http://purl.org/dc/terms/isPartOf]"); 
+    isPartOf.title=tmp.find("span[property= http://purl.org/dc/terms/title]").attr("content");                        isPartOf.shortTitle=tmp.find("span[property= http://purl.org/ontology/bibo/shortTitle]").text(); aboutObj.isPartOf=isPartOf; // date aboutObj.date=e.find("span[property= http://purl.org/dc/terms/date]").text(); // volume aboutObj.volue=e.find("span[property= http://purl.org/ontology/bibo/volume]").text(); // issue aboutObj.issue=e.find("span[property= http://purl.org/ontology/bibo/issue]").text(); // pageStart & pageEnd aboutObj.pageStart=e.find("span[property= http://purl.org/ontology/bibo/pageStart]").text(); aboutObj.pageEnd=e.find("span[property= http://purl.org/ontology/bibo/pageEnd]").text(); // doi tmp=e.find("span[property= http://purl.org/ontology/bibo/doi]"); aboutObj.doi={url:tmp.attr("href"), text:tmp.text()}; // jsObj[id]=aboutObj;
+  */
+
+}); 
+return allRefData;
+}
+
+
+var data = ScHTML2_CSL_JSON() ;
+
+

File demo_files/runcites.js

  */
 var insert = function() {
 
-	ScHTML2_CSL_JSON() ;
+	var data = ScHTML2_CSL_JSON() ;
 	//for debug :)
-	//alert(data.toString());
+	alert(JSON.stringify(data));
 	
 	var citeproc, output;
 	var sys = new Sys(abbreviations);