Changeset 31645 for other-projects
- Timestamp:
- 2017-05-04T14:43:27+12:00 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
other-projects/hathitrust/wcsa/extracted-features-solr/trunk/web-portal/index.js
r31624 r31645 32 32 33 33 function add_titles(json_data) { 34 var itemURLs = []; 35 34 36 $.each( json_data, function( htid_with_prefix, htid_val ) { 35 37 var htid = htid_with_prefix.replace(/^htid:/,""); … … 40 42 console.log(htid + ", title = " + metadata.titles[0]); 41 43 }); 44 45 $.each(htid_val.items, function( item_index, item_val ) { 46 if (item_val.htid == htid) { 47 var itemURL = item_val.itemURL; 48 itemURL = itemURL.replace(/^https:/,"http:"); 49 50 var ws_span = '<span style="display: none;"><br>[Workset: <span name="'+itemURL+'"></span>]</span>'; 51 $("[name='"+htid+"']").each(function() {$(this).append(ws_span)}); 52 console.log("itemURL = " + itemURL); 53 itemURLs.push(itemURL); 54 } 55 }); 42 56 }); 43 } 57 58 workset_enrich_results(itemURLs); 59 60 } 61 62 function add_worksets(json_data) { 63 64 //console.log("****" + JSON.stringify(json_data)); 65 $.each( json_data["@graph"], function( ws_index, ws_val ) { 66 var workset_title = ws_val["http://purl.org/dc/terms/title"][0]["@value"]; 67 68 var gathers = ws_val["http://www.europeana.eu/schemas/edm/gathers"] 69 70 $.each(gathers, function(gather_index,gather_val) { 71 var item_url = gather_val["@id"]; 72 73 $("[name='"+item_url+"']").each(function() { 74 $(this).parent().show(); 75 // if ($(this).find("span").length>1) { 76 if ($(this).children().size()>=1) { 77 $(this).append("; "); 78 } 79 80 $(this).append("<span>" + workset_title + "</span>") 81 }); 82 }); 83 }); 84 85 } 86 44 87 45 88 function show_new_results(delta) … … 118 161 119 162 163 function workset_enrich_results(itemURLs) 164 { 165 // prefix dcterms: <http://purl.org/dc/terms/> 166 // prefix edm: <http://www.europeana.eu/schemas/edm/> 167 // prefix htrc: <http://wcsa.htrc.illinois.edu/> 168 // prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> 169 // prefix xsd: <http://www.w3.org/2001/XMLSchema#> 170 171 // CONSTRUCT { 172 // ?wsid 173 // rdf:type htrc:Workset ; 174 // dcterms:title ?title ; 175 // dcterms:creator ?cre ; 176 // dcterms:created ?dat ; 177 // edm:gathers ?gar.} 178 179 // where { 180 // ?wsid 181 // rdf:type htrc:Workset ; 182 // dcterms:title ?title ; 183 // dcterms:creator ?cre ; 184 // dcterms:created ?dat ; 185 // edm:gathers ?gar 186 187 // FILTER ( ?gar = <http://hdl.handle.net/2027/uc2.ark:/13960/t4fn12212> || ?gar = <http://hdl.handle.net/2027/uva.x030825627> ) 188 // } 189 190 var prefixes = ""; 191 prefixes += "prefix dcterms: <http://purl.org/dc/terms/>\n"; 192 prefixes += "prefix edm: <http://www.europeana.eu/schemas/edm/>\n"; 193 prefixes += "prefix htrc: <http://wcsa.htrc.illinois.edu/>\n"; 194 prefixes += "prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n"; 195 prefixes += "prefix xsd: <http://www.w3.org/2001/XMLSchema#>\n"; 196 197 var graph_body = ""; 198 graph_body += " ?wsid\n"; 199 graph_body += " rdf:type htrc:Workset ;\n"; 200 graph_body += " dcterms:title ?title ;\n"; 201 graph_body += " dcterms:creator ?cre ;\n"; 202 graph_body += " dcterms:created ?dat ;\n"; 203 graph_body += " edm:gathers ?gar .\n"; 204 205 var filter_array = []; 206 var item_urls_len = itemURLs.length; 207 for (var hi=0; hi<item_urls_len; hi++) { 208 var htid = itemURLs[hi]; 209 filter_array.push("?gar = " + "<"+htid+">"); 210 } 211 var filter = " FILTER ( " + filter_array.join(" || ") + " ) "; 212 213 var construct = "CONSTRUCT {\n" + graph_body + "}\n"; 214 var where = "WHERE {\n" + graph_body + filter + "}\n"; 215 216 var sparql_query = prefixes + construct + where; 217 //console.log("*** sparql query = " + sparql_query); 218 219 // http://acbres224.ischool.illinois.edu:8890/sparql?default-graph-uri=&query 220 // &format=application/x-json+ld&timeout=0&debug=on 221 222 var sparql_url = "http://acbres224.ischool.illinois.edu:8890/sparql"; 223 var sparql_data = { "default-graph-uri": "", 224 "format": "application/x-json+ld", 225 "timeout": 0, 226 "debug": "on" }; 227 sparql_data.query = sparql_query; 228 229 $.ajax({ 230 type: "POST", 231 url: sparql_url, 232 data: sparql_data, 233 dataType: 'jsonp', 234 jsonpCallback: "add_worksets" 235 }); 236 237 238 239 } 120 240 121 241 function show_results(jsonData) { … … 202 322 var htids_str = htids.join("|",htids); 203 323 var cat_url = "http://catalog.hathitrust.org/api/volumes/brief/json/" + htids_str; 204 $.ajax({ 205 url: cat_url, 206 dataType: 'jsonp', 207 jsonpCallback: "add_titles" 208 }); 324 $.ajax({ 325 url: cat_url, 326 dataType: 'jsonp', 327 jsonpCallback: "add_titles" 328 }); 329 330 209 331 } 210 332
Note:
See TracChangeset
for help on using the changeset viewer.