object.js 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934
  1. // Raccatto i parametri dall'URL -- mi aspetto un parametro di nome 'link'!
  2. thisUrlParams = {};
  3. window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
  4. thisUrlParams[key] = value;
  5. });
  6. console.log('URL get params: ', thisUrlParams);
  7. // Funzioni per eseguire le queries
  8. function prepareQueryURL(query){
  9. sparqlEndpoint = 'http://dev.restore.ovi.cnr.it:8890/sparql/';
  10. sparqlUrlParams = '?default-graph-uri=&query=' + encodeURIComponent(query) + '&output=json&callback=?';
  11. return sparqlEndpoint + sparqlUrlParams;
  12. }
  13. function doJsonQuery(query){
  14. queryURL = prepareQueryURL(query);
  15. response = $.ajax({//OGGETTO
  16. url: queryURL,
  17. dataType: "json",
  18. success: function (data){},
  19. error: function (e) {}
  20. });
  21. return response;
  22. }
  23. // Funzioni per raccattare + stringhificare l'output
  24. queryStringOutput = "";
  25. function stringifyResponse(val){
  26. resultArray = val['results']['bindings'];
  27. out = "";
  28. for(i = 0; i < resultArray.length; i++){
  29. out = out + JSON.stringify(resultArray[i])
  30. }
  31. queryStringOutput = (queryStringOutput + out).replace("}{",",");
  32. }
  33. prefixes = "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \
  34. PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \
  35. PREFIX crm: <http://www.cidoc-crm.org/cidoc-crm/> \
  36. PREFIX owl: <http://www.w3.org/2002/07/owl#> \
  37. PREFIX schema: <http://schema.org/> \
  38. PREFIX foaf: <http://xmlns.com/foaf/0.1/> \
  39. PREFIX person: <http://www.w3.org/ns/person#>"
  40. queryInfo = prefixes + " SELECT DISTINCT ?g AS ?graph ?uri ?label ?dimension ?consistency ?id ?sigla_registro (group_concat(distinct ?dimension ; separator='<br />') as ?dimensions) ?material (group_concat(distinct ?time_span ;separator='-') as ?time_span) ?location ?uri_owner ?owner ?note \
  41. WHERE { \
  42. VALUES ?uri {<" + thisUrlParams.link + ">} \
  43. GRAPH ?g { ?uri rdfs:label ?label } \
  44. OPTIONAL {?uri crm:P1_is_identified_by ?uri_id . \
  45. ?uri_id rdfs:label ?id ; \
  46. crm:P2_has_type 'Segnatura' .} \
  47. OPTIONAL { ?uri crm:P43_has_dimension ?uri_consistency . \
  48. ?uri_consistency crm:P2_has_type 'Consistenza carte' ; \
  49. rdfs:label ?consistency } \
  50. OPTIONAL { ?uri crm:P43_has_dimension ?uri_dimension . \
  51. ?uri_dimension crm:P2_has_type 'Dimensioni' ; \
  52. rdfs:label ?dimension } \
  53. OPTIONAL { ?uri crm:P139_has_alternative_form ?uri_registro . \
  54. ?uri_registro rdfs:label ?sigla_registro; \
  55. crm:P2_has_type 'Sigla registro' . } \
  56. OPTIONAL { ?uri crm:P45_consist_of ?uri_material . \
  57. ?uri_material rdfs:label ?material } \
  58. OPTIONAL { ?uri crm:P52_has_current_owner ?uri_owner . \
  59. ?uri_owner rdfs:label ?owner . } \
  60. OPTIONAL { ?uri crm:P54_has_current_permanent_location ?location } \
  61. OPTIONAL { ?uri crm:P3_has_note ?uri_note . \
  62. ?uri_note rdfs:label ?note } \
  63. OPTIONAL { ?uri crm:P92i_was_brought_into_existence_by ?creation . \
  64. ?creation crm:P4_has_time-span ?uri_time_span . \
  65. ?uri_time_span rdfs:label ?time_span . } \
  66. } "
  67. queryContent = prefixes + " SELECT DISTINCT ?g AS ?graph ?uri ?titolo ?tipo (group_concat(distinct ?ref ; separator='<br />') as ?ref) \
  68. WHERE { \
  69. VALUES ?object {<" + thisUrlParams.link + ">} \
  70. ?object crm:P128_carries ?uri . \
  71. ?uri rdf:type crm:E73_Information_Object . \
  72. GRAPH ?g { ?uri rdfs:label ?label } \
  73. OPTIONAL {?uri crm:P1_is_identified_by ?uri_titolo . \
  74. ?uri_titolo rdfs:label ?titolo ; \
  75. rdf:type crm:E35_Title . } \
  76. OPTIONAL { ?uri crm:P2_has_type ?uri_tipo . \
  77. ?uri_tipo rdfs:label ?tipo . } \
  78. OPTIONAL { ?uri crm:P67_refers_to ?uri_ref . \
  79. ?uri_ref rdfs:label ?ref . } \
  80. FILTER NOT EXISTS {GRAPH <http://dev.restore.ovi.cnr.it:8890/ovi/datini> { ?uri rdfs:label ?label }}. \
  81. }"
  82. queryOviLetter = prefixes + " SELECT DISTINCT ?otherId ?InfObj \
  83. WHERE { \
  84. VALUES ?uri {<" + thisUrlParams.link + ">} \
  85. ?uri crm:P1_is_identified_by ?uri_id . \
  86. ?uri_id crm:P2_has_type 'Segnatura' ; \
  87. crm:P139_has_alternative_form ?other_id . \
  88. ?other_id crm:P2_has_type ?uri_type ; \
  89. rdfs:label ?otherId . \
  90. ?uri_type rdfs:label 'Segnatura OVI' . \
  91. OPTIONAL { ?uri crm:P128_carries ?InfObj . \
  92. GRAPH <http://dev.restore.ovi.cnr.it:8890/ovi/datini> {?InfObj rdf:type crm:E73_Information_Object } } \
  93. } "
  94. queryPersone = prefixes + " SELECT DISTINCT ?uri_person ?name ?p_type ?note \
  95. WHERE { \
  96. VALUES ?uri {<" + thisUrlParams.link + ">} \
  97. {?uri crm:P46_is_composed_of ?card . \
  98. ?card crm:P2_has_type 'Scheda anagrafica' . \
  99. ?document crm:P141_assigned ?card ; \
  100. crm:P67_refers_to ?uri_person . \
  101. ?uri_person foaf:name ?name ; \
  102. crm:P2_has_type ?person_type . \
  103. ?person_type rdfs:label ?p_type . \
  104. } UNION { \
  105. ?document crm:P141_assigned ?uri ; \
  106. crm:P67_refers_to ?uri_person . \
  107. ?uri_person foaf:name ?name ; \
  108. crm:P2_has_type ?person_type . \
  109. ?person_type rdfs:label ?p_type . \
  110. } UNION { \
  111. ?uri crm:P92i_was_brought_into_existence_by ?creation . \
  112. ?creation crm:P67_refers_to ?uri_person . \
  113. ?uri_person foaf:name ?name ; \
  114. crm:P67.1_type ?person_type . \
  115. OPTIONAL {?uri_person crm:P3_has_note ?note } \
  116. ?person_type rdfs:label ?p_type . \
  117. } \
  118. }"
  119. queryAssocDocs = prefixes + " SELECT DISTINCT ?card ?doc_type ?name_card \
  120. WHERE { \
  121. VALUES ?uri {<" + thisUrlParams.link + ">} \
  122. ?uri crm:P46_is_composed_of ?card . \
  123. ?card rdfs:label ?name_card . \
  124. OPTIONAL {?card crm:P2_has_type ?doc_type } \
  125. OPTIONAL {?document crm:P141_assigned ?card ; \
  126. crm:P67_refers_to ?uri_person . \
  127. ?uri_person foaf:name ?name ; \
  128. crm:P2_has_type ?person_type . \
  129. ?person_type rdfs:label ?type . \
  130. } \
  131. }"
  132. queryContrassegni = prefixes + " SELECT DISTINCT ?uri_contrassegno ?contrassegno \
  133. WHERE {VALUES ?uri {<" + thisUrlParams.link + ">} \
  134. ?uri crm:P46_is_composed_of ?uri_paper . \
  135. ?uri_documentation crm:P141_assigned ?uri_paper ; \
  136. crm:P140_assigned_attribute_to ?uri_contrassegno . \
  137. ?uri_contrassegno rdfs:label ?contrassegno . \
  138. }"
  139. queryEventiGettatelli = prefixes + " SELECT DISTINCT ?uri_obj ?object ?name_event ?event_type ?uri_person ?label ?role ?time_span ?uri_place ?place \
  140. WHERE {VALUES ?uri {<" + thisUrlParams.link + ">} \
  141. ?uri crm:P46_is_composed_of ?uri_paper . \
  142. {?uri_paper crm:P128_carries ?uri_doc } \
  143. UNION \
  144. {?uri crm:P128_carries ?uri_doc } \
  145. ?uri_doc crm:P70_documents ?event ; \
  146. rdfs:label ?document . \
  147. ?uri_obj crm:P128_carries ?uri_doc . \
  148. ?uri_doc rdfs:label ?object . \
  149. ?event rdfs:label ?name_event . \
  150. ?event crm:P2_has_type ?uri_event_type . \
  151. ?uri_event_type rdfs:label ?event_type . \
  152. ?event crm:P01_has_domain ?domain . \
  153. ?domain crm:P02_has_range ?uri_person ; \
  154. crm:P14.1_in_the_role_of ?uri_role . \
  155. ?uri_role rdfs:label ?role . \
  156. ?uri_person rdfs:label ?label . \
  157. OPTIONAL {?event crm:P4_has_time-span ?uri_time_span . \
  158. ?uri_time_span rdfs:label ?time_span . } \
  159. OPTIONAL {?event crm:P7_took_place_at ?uri_location . \
  160. ?uri_place owl:sameAs ?uri_location ; \
  161. crm:P168_place_is_defined_by ?coords; \
  162. rdfs:label ?place . } \
  163. }"
  164. queryURL = prepareQueryURL(queryInfo);
  165. queryINF = prepareQueryURL(queryContent);
  166. queryOVI = prepareQueryURL(queryOviLetter);
  167. queryPERS = prepareQueryURL(queryPersone);
  168. queryDOC = prepareQueryURL(queryAssocDocs);
  169. queryCON = prepareQueryURL(queryContrassegni);
  170. queryEV = prepareQueryURL(queryEventiGettatelli);
  171. response = $.ajax({
  172. url: queryURL,
  173. dataType: "json",
  174. success: function (data){
  175. handle_objectData(data);
  176. },
  177. error: function (e) {}
  178. });
  179. response_info = $.ajax({
  180. url: queryINF,
  181. dataType: "json",
  182. success: function (data){
  183. handle_objectInfo(data);
  184. },
  185. error: function (e) {}
  186. });
  187. response_info = $.ajax({
  188. url: queryOVI,
  189. dataType: "json",
  190. success: function (data){
  191. handle_oviLetter(data);
  192. },
  193. error: function (e) {}
  194. });
  195. response_people = $.ajax({
  196. url: queryPERS,
  197. dataType: "json",
  198. success: function (data){
  199. handle_citedPeople(data);
  200. },
  201. error: function (e) {}
  202. });
  203. response_contrassegni = $.ajax({
  204. url: queryCON,
  205. dataType: "json",
  206. success: function (data){
  207. handle_contrassegni(data);
  208. },
  209. error: function (e) {}
  210. });
  211. response_eventi = $.ajax({
  212. url: queryEV,
  213. dataType: "json",
  214. success: function (data){
  215. handle_eventiGettatelli(data);
  216. },
  217. error: function (e) {}
  218. });
  219. function handle_objectData(json) {
  220. console.log(json['results']['bindings']);
  221. $.each(
  222. json['results']['bindings'],
  223. function (index, value) {
  224. var graph = value['graph']['value'];
  225. var label = value['label']['value'];
  226. var uri = value['uri']['value'];
  227. var identifier = "";
  228. var dimensions = "";
  229. var consistence = "";
  230. var materials = "";
  231. var description = "";
  232. var button_ext = "";
  233. var button_owner = "";
  234. var current_owner = "";
  235. var uri_owner = "";
  236. var dates = "";
  237. var dataset = get_graph_name(graph);
  238. if (value.hasOwnProperty('id')) {
  239. $("#ID").css("display", "flex");
  240. identifier = value['id']['value'];
  241. }
  242. if (value.hasOwnProperty('dimension')) {
  243. $("#dimensione").css("display", "flex");
  244. dimensions = value['dimensions']['value'];
  245. }
  246. if (value.hasOwnProperty('consistency')) {
  247. $("#consistenza").css("display", "flex");
  248. consistence = value['consistency']['value'];
  249. }
  250. if (value.hasOwnProperty('condition')) {
  251. $("#STCC").css("display", "flex");
  252. condition = value['condition']['value'];
  253. }
  254. if (value.hasOwnProperty('material')) {
  255. $("#materia").css("display", "flex");
  256. materials = value['material']['value'];
  257. }
  258. if (value.hasOwnProperty('uri_owner')) {
  259. $("#current_owner").css("display", "flex");
  260. current_owner = value['owner']['value'];
  261. uri_owner = value['uri_owner']['value'];
  262. }
  263. if (value.hasOwnProperty('time_span')) {
  264. if (value['time_span']['value'] != ""){
  265. $("#time_span_object").css("display", "flex");
  266. dates = value['time_span']['value'];
  267. }
  268. }
  269. if (value.hasOwnProperty('note')) {
  270. $("#notes").css("display", "flex");
  271. description = value['note']['value'];
  272. }
  273. if (identifier != "") {
  274. button_ext = '<button class="btn btn-default" type="button" onclick="schedaASPO(\'' + uri + '\')"> \
  275. <i class="fa fa-link" aria-hidden="true"> <p class="btn-text">Link</p></i></button>';
  276. }
  277. if (owner != "") {
  278. button_owner = '<button class="btn btn-default" type="button" onclick="schedaASPO(\'' + uri_owner + '\')"> \
  279. <i class="fa fa-link" aria-hidden="true"> <p class="btn-text">Link</p></i></button>';
  280. }
  281. var Buttons = '<button class="btn btn-default" type="button" onclick="schedaASPO(\'' + uri + '\')"> \
  282. <i class="fas fa-external-link-alt" aria-hidden="true"></i></button> \
  283. <button type="button" value="object" id="' + uri + '" class="cit btn btn-default" alt="scheda" title="Citazione"><i class="fa fa-quote-right"></i></button> \
  284. <button type="button" value="object" id="' + uri + '" class="hyp btn btn-default" alt="scheda" title="Hyperlink"><i class="fa fa-link"></i></button> \
  285. <a href="http://dev.restore.ovi.cnr.it/lodlive/?' + uri + '" target="_blank"><button type="button" class="btn btn-default info" alt="LOD" title="LodLive"><i class="fa fa-share-alt"></i></button></a></div></div>';
  286. document.getElementById("grafo").innerHTML = dataset;
  287. document.getElementById("nome_oggetto").innerHTML = label;
  288. document.getElementById("identifier").innerHTML = identifier;
  289. document.getElementById("btn_identifier").innerHTML = button_ext;
  290. document.getElementById("nota").innerHTML = description;
  291. document.getElementById("dimensions").innerHTML = dimensions;
  292. document.getElementById("materials").innerHTML = materials;
  293. document.getElementById("consistence").innerHTML = consistence;
  294. document.getElementById("owner").innerHTML = current_owner;
  295. document.getElementById("btn_owner").innerHTML = button_owner;
  296. document.getElementById("timeSpan").innerHTML = dates;
  297. document.getElementById("link_buttons").innerHTML = Buttons;
  298. });
  299. }
  300. function get_graph_name(graph) {
  301. var dataset = "Scheda Oggetto";
  302. if (graph == "http://dev.restore.ovi.cnr.it:8890/aspo/ospedale") {
  303. dataset = dataset + " / Ospedale";
  304. } else if (graph == "http://dev.restore.ovi.cnr.it:8890/aspo/datini") {
  305. dataset = dataset + " / Datini";
  306. } else if (graph == "http://dev.restore.ovi.cnr.it:8890/aspo/marcovaldi") {
  307. dataset = dataset + " / Marcovaldi";
  308. } else if (graph == "http://dev.restore.ovi.cnr.it:8890/aspo/gettatelli") {
  309. dataset = dataset + " / Gettatelli";
  310. } else {
  311. dataset = dataset;
  312. }
  313. return dataset;
  314. }
  315. function handle_objectInfo(json) {
  316. console.log(json['results']['bindings']);
  317. $.each(
  318. json['results']['bindings'],
  319. function (index, value) {
  320. var title = "";
  321. var type = "";
  322. var subject = "";
  323. if (value.hasOwnProperty('titolo')) {
  324. $("#titolo").css("display", "flex");
  325. title = value['titolo']['value'];
  326. }
  327. if (value.hasOwnProperty('tipo')) {
  328. $("#tipo").css("display", "flex");
  329. type = value['tipo']['value'];
  330. }
  331. if (value.hasOwnProperty('ref')) {
  332. if (value['ref']['value'] != "") {
  333. $("#argomento").css("display", "flex");
  334. subject = value['ref']['value'];
  335. }
  336. }
  337. document.getElementById("title").innerHTML = title;
  338. document.getElementById("type").innerHTML = type;
  339. document.getElementById("subject").innerHTML = subject;
  340. });
  341. }
  342. function handle_oviLetter(json) {
  343. console.log(json['results']['bindings']);
  344. $.each(
  345. json['results']['bindings'],
  346. function (index, value) {
  347. var other_id = "";
  348. var uri = "";
  349. var button_letter = "";
  350. if (value.hasOwnProperty('otherId')) {
  351. $("#IDbis").css("display", "flex");
  352. other_id = value['otherId']['value'];
  353. }
  354. if (value.hasOwnProperty('InfObj')) {
  355. uri = value['InfObj']['value'];
  356. }
  357. if (uri != "") {
  358. button_letter = '<button type="button" id="' + uri +
  359. '" class="lettera btn btn-default" alt="lettera"><i class="fa fa-envelope"></i><p class="btn-text">Scheda Lettera</p></button>';
  360. }
  361. document.getElementById("other_identifier").innerHTML = other_id;
  362. document.getElementById("btn_other_identifier").innerHTML = button_letter;
  363. });
  364. }
  365. /*
  366. function handle_citedPeople(json) {
  367. console.log(json);
  368. var Relazioni = "";
  369. const myArray = []
  370. $.each(
  371. json['results']['bindings'],
  372. function (index, value) {
  373. var uri_person = value['uri_person']['value'];
  374. var name = value['name']['value'];
  375. var tipo = "";
  376. var nota = "";
  377. if (value.hasOwnProperty('p_type')) {
  378. tipo = value['p_type']['value'];
  379. }
  380. if (value.hasOwnProperty('note')) {
  381. nota = "<br /><span class='nota_menzione'><i>" + value['note']['value'] + "</i></span>";
  382. }
  383. var string = name + nota;
  384. myArray.push([tipo, string, uri_person, nota]);
  385. });
  386. if (myArray.length == 0) {
  387. $("#placeholder_people").css("display", "none");
  388. }
  389. const checkRel = [];
  390. for (var i=0; i<myArray.length; i++) {
  391. var key = myArray[i][0];
  392. checkRel.push(key);
  393. }
  394. var params = [];
  395. $.each(checkRel, function(i, el){
  396. if($.inArray(el, params) === -1) params.push(el);
  397. });
  398. for (var i=0; i<params.length; i++) {
  399. var par = params[i];
  400. var par_id = par.replaceAll(" ", "_");
  401. var rel = createDivRelazione(par, par_id);
  402. Relazioni = Relazioni + rel;
  403. }
  404. $(Relazioni).insertAfter( "#placeholder_people" );
  405. for (var j=0; j<params.length; j++) {
  406. var el = params[j];
  407. var par = el.replaceAll(" ", "_");
  408. var Colums = "";
  409. for (var i=0; i<myArray.length; i++) {
  410. var text = myArray[i][1];
  411. var link = myArray[i][2];
  412. var declaration = ""
  413. if (myArray[i][3] != "") {
  414. declaration = "myMargin";
  415. }
  416. var rel = myArray[i][0].replaceAll(" ", "_");
  417. if (par == rel) {
  418. var col = createColRelazione(text, link, "persona", "fa fa-user", "Scheda Persona", declaration);
  419. Colums = Colums + col;
  420. }
  421. }
  422. document.getElementById(par).innerHTML = Colums;
  423. }
  424. }
  425. function handle_associatedDocuments(json) {
  426. console.log(json);
  427. var Sezioni = "";
  428. const myArray = []
  429. $.each(
  430. json['results']['bindings'],
  431. function (index, value) {
  432. var uri = value['card']['value'];
  433. var name = value['name_card']['value'];
  434. var tipo = "";
  435. if (value.hasOwnProperty('doc_type')) {
  436. tipo = value['doc_type']['value'];
  437. }
  438. myArray.push([tipo, name, uri]);
  439. });
  440. if (myArray.length == 0) {
  441. $("#placeholder_documents").css("display", "none");
  442. }
  443. const checkRel = [];
  444. for (var i=0; i<myArray.length; i++) {
  445. var key = myArray[i][0];
  446. checkRel.push(key);
  447. }
  448. var params = [];
  449. $.each(checkRel, function(i, el){
  450. if($.inArray(el, params) === -1) params.push(el);
  451. });
  452. for (var i=0; i<params.length; i++) {
  453. var par = params[i];
  454. var par_id = par.replaceAll(" ", "_");
  455. var rel = createDivRelazione(par, par_id);
  456. Sezioni = Sezioni + rel;
  457. }
  458. $(Sezioni).insertAfter( "#placeholder_documents" );
  459. for (var j=0; j<params.length; j++) {
  460. var el = params[j];
  461. var par = el.replaceAll(" ", "_");
  462. var Colums = "";
  463. for (var i=0; i<myArray.length; i++) {
  464. var text = myArray[i][1];
  465. var link = myArray[i][2];
  466. var rel = myArray[i][0].replaceAll(" ", "_");
  467. if (par == rel) {
  468. var col = createColRelazione(text, link, "object", "fa fa-book", "Scheda Oggetto", "");
  469. Colums = Colums + col;
  470. }
  471. }
  472. document.getElementById(par).innerHTML = Colums;
  473. }
  474. }
  475. function handle_associatedDocuments(json) {
  476. console.log(json);
  477. const docs = [];
  478. $.each(
  479. json['results']['bindings'],
  480. function (index, value) {
  481. var uri = value['card']['value'];
  482. var label = value['name_card']['value'];
  483. var tipo = "";
  484. if (value.hasOwnProperty('doc_type')) {
  485. tipo = value['doc_type']['value'];
  486. }
  487. docs.push([uri, label, tipo]);
  488. });
  489. var Docs = "";
  490. for (var i=0; i<docs.length; i++) {
  491. var object = '<div class="col-8"><p><span id="' + docs[i][0] + '" class="title_doc object">'+ docs[i][1] + '</span>';
  492. if (docs[i][2] != "") {
  493. object = object + "<br />Documento: " + docs[i][2];
  494. }
  495. object = object + '</p></div>';
  496. var object_button = '<button type="button" id="' + docs[i][0] +
  497. '" class="object btn btn-default" alt="oggetto" title="' + docs[i][1] +
  498. '"><i class="fa fa-book"></i><p class="btn-text">Scheda Oggetto</p></button>';
  499. Docs += '<div class="row res">'+ object +
  500. '<div class="col d-flex align-items-start justify-content-end">' + object_button +
  501. '<button type="button" value="object" id="' + docs[i][0] + '" class="cit btn btn-default" alt="scheda" title="Info"><i class="fa fa-quote-right"></i><p class="btn-text">Citazione</p></button>' +
  502. '<button type="button" value="object" id="' + docs[i][0] + '" class="hyp btn btn-default" alt="scheda" title="Info"><i class="fa fa-link"></i><p class="btn-text">Hyperlink</p></button>' +
  503. '<a href="http://dev.restore.ovi.cnr.it/lodlive/?' + docs[i][0] + '" target="_blank"><button type="button" class="btn btn-default info" alt="LOD"><i class="fa fa-share-alt"></i><p class="btn-text">Lod</p></button></a></div></div>';
  504. }
  505. document.getElementById("n_sec").innerHTML = docs.length;
  506. document.getElementById("section_documents").innerHTML = Docs;
  507. if (docs.length==0) {
  508. var messaggio = "<p class='no-results'>Nessun risultato trovato</p>";
  509. document.getElementById("section_documents").innerHTML = messaggio;
  510. }
  511. }*/
  512. function handle_citedPeople(json) {
  513. console.log(json);
  514. const people = [];
  515. $.each(
  516. json['results']['bindings'],
  517. function (index, value) {
  518. var uri = value['uri_person']['value'];
  519. var name = value['name']['value'];
  520. var tipo = "";
  521. var nota = "";
  522. if (value.hasOwnProperty('p_type')) {
  523. tipo = value['p_type']['value'];
  524. }
  525. if (value.hasOwnProperty('note')) {
  526. nota = value['note']['value'];
  527. }
  528. people.push([uri, name, tipo, nota]);
  529. });
  530. var Person = "";
  531. for (var i=0; i<people.length; i++) {
  532. var object = '<div class="col-8"><p><span id="' + people[i][0] + '" class="title_doc persona">'+ people[i][1] + '</span>';
  533. if (people[i][2] != "") {
  534. object = object + "<br />Ruolo: " + people[i][2];
  535. }
  536. if (people[i][3] != "") {
  537. object = object + "<br />Nota: " + people[i][3];
  538. }
  539. object = object + '</p></div>';
  540. Person += '<div class="row res">' + object +
  541. '<div class="col d-flex align-items-start justify-content-end"><button type="button" id="' + people[i][0] + '" class="persona btn btn-default" alt="persona" title="' +
  542. people[i][1] + '"><i class="fa fa-user"></i><p class="btn-text">Scheda Persona</p></button>' +
  543. '<button type="button" value="Persona" id="' + people[i][0] + '" class="cit btn btn-default" alt="scheda" title="Info"><i class="fa fa-quote-right"></i><p class="btn-text">Citazione</p></button>' +
  544. '<button value="Persona" type="button" id="' + people[i][0] + '" class="hyp btn btn-default" alt="scheda" title="Info"><i class="fa fa-link"></i><p class="btn-text">Hyperlink</p></button>' +
  545. '<a href="http://dev.restore.ovi.cnr.it/lodlive/?' + people[i][0] + '" target="_blank"><button type="button" class="btn btn-default info" alt="LOD"><i class="fa fa-share-alt"></i><p class="btn-text">Lod</p></button></a></div></div>';
  546. }
  547. document.getElementById("n_pp").innerHTML = people.length;
  548. document.getElementById("cited_people").innerHTML = Person;
  549. if (people.length==0) {
  550. var messaggio = "<p class='no-results'>Nessun risultato trovato</p>";
  551. document.getElementById("cited_people").innerHTML = messaggio;
  552. }
  553. }
  554. function handle_contrassegni(json) {
  555. console.log(json);
  556. const cons = [];
  557. $.each(
  558. json['results']['bindings'],
  559. function (index, value) {
  560. var uri = value['uri_contrassegno']['value'];
  561. var label = value['contrassegno']['value'];
  562. cons.push([uri, label]);
  563. });
  564. var Marks = "";
  565. for (var i=0; i<cons.length; i++) {
  566. var object = '<div class="col-8"><p><span id="' + cons[i][0] + '" class="title_doc object">'+ cons[i][1] + '</span></p></div>';
  567. var object_button = '<button type="button" id="' + cons[i][0] +
  568. '" class="object btn btn-default" alt="oggetto" title="' + cons[i][1] +
  569. '"><i class="fa fa-book"></i><p class="btn-text">Scheda Oggetto</p></button>';
  570. Marks += '<div class="row res">'+ object +
  571. '<div class="col d-flex align-items-start justify-content-end">' + object_button +
  572. '<button type="button" value="object" id="' + cons[i][0] + '" class="cit btn btn-default" alt="scheda" title="Info"><i class="fa fa-quote-right"></i><p class="btn-text">Citazione</p></button>' +
  573. '<button type="button" value="object" id="' + cons[i][0] + '" class="hyp btn btn-default" alt="scheda" title="Info"><i class="fa fa-link"></i><p class="btn-text">Hyperlink</p></button>' +
  574. '<a href="http://dev.restore.ovi.cnr.it/lodlive/?' + cons[i][0] + '" target="_blank"><button type="button" class="btn btn-default info" alt="LOD"><i class="fa fa-share-alt"></i><p class="btn-text">Lod</p></button></a></div></div>';
  575. }
  576. document.getElementById("n_sec").innerHTML = cons.length;
  577. document.getElementById("section_documents").innerHTML = Marks;
  578. if (cons.length==0) {
  579. var messaggio = "<p class='no-results'>Nessun risultato trovato</p>";
  580. document.getElementById("section_documents").innerHTML = messaggio;
  581. }
  582. }
  583. function handle_eventiGettatelli(json) {
  584. console.log(json);
  585. const evGett = [];
  586. $.each(
  587. json['results']['bindings'],
  588. function (index, value) {
  589. var uri = value['uri_obj']['value'];
  590. var label = value['object']['value'];
  591. var name_event = value['name_event']['value'];
  592. var event_type = value['event_type']['value'];
  593. var uri_person = value['uri_person']['value'];
  594. var person = value['label']['value'];
  595. var role = value['role']['value'];
  596. var time_span = "";
  597. var uri_place = "";
  598. var place = "";
  599. if (value.hasOwnProperty('time_span')) {
  600. time_span = value['time_span']['value'];
  601. }
  602. if (value.hasOwnProperty('uri_place')) {
  603. uri_place = value['uri_place']['value'];
  604. }
  605. if (value.hasOwnProperty('place')) {
  606. place = value['place']['value'];
  607. }
  608. evGett.push([name_event, uri_person, person, role, time_span, uri_place, place]);
  609. });
  610. var thead =
  611. '<div class="col-4">Evento registrato</div>' +
  612. '<div class="col-2">Persona</div>' +
  613. '<div class="col-2">Ruolo</div>' +
  614. '<div class="col-2">Data</div>' +
  615. '<div class="col-2">Luogo</div>';
  616. var EventsTable = "";
  617. for (var i=0; i<evGett.length; i++) {
  618. EventsTable += '<div class="row res">' +
  619. '<div class="col-4">' + evGett[i][0] + '</div>' +
  620. '<div id="' + evGett[i][1] + '" class="col-2 persona">' + evGett[i][2] + '</div>' +
  621. '<div class="col-2">' + evGett[i][3] + '</div>' +
  622. '<div class="col-2">' + evGett[i][4] + '</div>' +
  623. '<div id="' + evGett[i][5] + '" class="col-2 luogo">' + evGett[i][6] + '</div>' +
  624. '</div>';
  625. }
  626. if (events.length != 0) {
  627. document.getElementById("thead_ev").innerHTML = thead;
  628. document.getElementById("section_events").innerHTML = EventsTable;
  629. } else {
  630. document.getElementById("section_events").innerHTML = "Nessun evento trovato";
  631. }
  632. }
  633. function createDivRelazione(type, id){
  634. htmlCode = '\
  635. <div class="row mb-2"> \
  636. <div class="col-sm-4"> \
  637. <span class="label"><RELATIONSHIP></span> \
  638. </div> \
  639. <div class="col record_box" id="<ID_RELATIONSHIP>"></div> \
  640. </div> \
  641. '.replace("<RELATIONSHIP>", type).replace("<ID_RELATIONSHIP>", id);
  642. return htmlCode;
  643. }
  644. function createColRelazione(text, link, tipo, fa, tab, decl) {
  645. htmlCode = '\
  646. <div class="row"> \
  647. <div class="col <CLASS>"><NAME></div> \
  648. <div class="col-auto"> \
  649. <button class="<TIPO> btn btn-default" type="button" id="<URI>">\
  650. <i class="<BUTTON>" aria-hidden="true">\
  651. <p class="btn-text"><TAB></p>\
  652. </i>\
  653. </button>\</div> \
  654. </div>\
  655. '.replace("<NAME>", text).replace("<URI>", link).replace("<TIPO>", tipo).replace("<BUTTON>", fa).replace("<TAB>", tab).replace("<CLASS>", decl);
  656. return htmlCode;
  657. }
  658. $(document).on("click", ".lettera", function (ev) {
  659. var link = this.id;
  660. //alert(nome_autore);
  661. //$('#myModal').text("");
  662. window.open("lettera.html?link="+this.id);
  663. });
  664. $(document).on("click", ".luogo", function (ev) {
  665. var link = this.id;
  666. //alert(nome_autore);
  667. //$('#myModal').text("");
  668. window.open("Luogo.html?link="+this.id);
  669. });
  670. $(document).on("click", ".persona", function (ev) {
  671. var link = this.id;
  672. //alert(nome_autore);
  673. //$('#myModal').text("");
  674. window.open("Persona.html?link="+this.id);
  675. });
  676. $(document).on("click", ".object", function (ev) {
  677. var link = this.id;
  678. //alert(nome_autore);
  679. //$('#myModal').text("");
  680. window.open("object.html?link="+this.id);
  681. });
  682. $(document).on("click", ".hyp", function (ev) {
  683. var baseurl = window.location.origin+window.location.pathname;
  684. let slash = baseurl.lastIndexOf("/");
  685. var type = $(this).val() + '.html';
  686. var link = this.id;
  687. var url = baseurl.substr(0, slash+1) + type + "?link="+link;
  688. var link = this.id;
  689. $("#myModal").empty();
  690. $("#myModal").css("display", "block");
  691. $('#myModal').append("<div class='modal-content'><div class='modal-close'><span class='close'>&times;</span></div><div id='myInput'>" +
  692. url + "</div><button id='copy_btn' class='btn btn-theme-primary btn-md' onclick='myFunction()'>Copia</button>");
  693. });
  694. $(document).on("click", ".cit", function (ev) {
  695. var author ="RESTORE. smart access to digital heritage and memory"
  696. var year = new Date().getFullYear()
  697. var today = new Date();
  698. var dd = String(today.getDate()).padStart(2, '0');
  699. var mm = String(today.getMonth() + 1).padStart(2, '0'); //January is 0!
  700. var yyyy = today.getFullYear();
  701. today = dd + '/' + mm + '/' + yyyy;
  702. var baseurl = window.location.origin+window.location.pathname;
  703. let slash = baseurl.lastIndexOf("/");
  704. var type = $(this).val() + '.html';
  705. var link = this.id;
  706. var url = baseurl.substr(0, slash+1) + type + "?link="+link;
  707. //alert(nome_autore);
  708. //$('#myModal').text("");
  709. $("#myModal").empty();
  710. $("#myModal").css("display", "block");
  711. $('#myModal').append("<div class='modal-content'><div class='modal-close'><span class='close'>&times;</span></div><div id='myInput'>" +
  712. author + " " + year + ", accesso effettuato: " + today + ", &lt;" + url + "&gt;</div><button id='copy_btn' class='btn btn-theme-primary btn-md' onclick='myFunction()'>Copia</button>");
  713. });
  714. function schedaASPO(info){
  715. window.open(info);
  716. }
  717. $(document).on("click", ".close", function (ev) {
  718. var link = this.id;
  719. //alert(nome_autore);
  720. //$('#myModal').text("");
  721. $("#myModal").css("display", "none");
  722. });
  723. $(document).on("click", ".back", function (ev) {
  724. $("#myTab").css("display", "none");
  725. });
  726. function copyToClipboard(text) {
  727. var sampleTextarea = document.createElement("textarea");
  728. document.body.appendChild(sampleTextarea);
  729. sampleTextarea.value = text; //save main text in it
  730. sampleTextarea.select(); //select textarea contenrs
  731. document.execCommand("copy");
  732. document.body.removeChild(sampleTextarea);
  733. }
  734. function myFunction(){
  735. var copy = document.getElementById("myInput");
  736. copyText = copy.textContent;
  737. copyToClipboard(copyText);
  738. //copyToClipboard(copyText.value);
  739. }