object.js 32 KB

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