object.js 31 KB

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