object.js 33 KB

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