OA.js 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. var link = thisUrlParams.link;
  2. prefixes = queryManager['prefixes']['all'];
  3. queryURL = prefixes + (queryManager['querySchedaOpera']['queryInfo']).replace('{URI}', link);
  4. doJsonQuery(queryURL).done(function(data) { handle_OAdata(data); });
  5. queryPro = prefixes + (queryManager['querySchedaOpera']['queryProduction']).replace('{URI}', link);
  6. doJsonQuery(queryPro).done(function(data) { handle_Production(data); });
  7. function handle_OAdata(json) {
  8. console.log(json['results']['bindings']);
  9. $.each(
  10. json['results']['bindings'],
  11. function (index, value) {
  12. var graph = value['graph']['value'];
  13. var label = value['label']['value'];
  14. var uri = value['uri']['value'];
  15. var title = "";
  16. var type = "";
  17. var current_owner = "";
  18. var current_location = "";
  19. var subject = "";
  20. var dimensions = "";
  21. var materials = "";
  22. var condition = "";
  23. var note = "";
  24. var identifier = "";
  25. var unit = "";
  26. var dataset = get_dataset_name(graph);
  27. if (value.hasOwnProperty('title')) {
  28. $("#SGTT").css("display", "flex");
  29. title = value['title']['value'];
  30. }
  31. if (value.hasOwnProperty('identifier')) {
  32. $("#NCT").css("display", "flex");
  33. identifier = value['identifier']['value'];
  34. }
  35. if (value.hasOwnProperty('type')) {
  36. $("#OGTD").css("display", "flex");
  37. type = "<div class='d-flex'><div class='mr-3'><a href='" + value['uriType']['value'] + "'>" +
  38. value['type']['value'] + "</a></div></div>";
  39. }
  40. if (value.hasOwnProperty('current_owner')) {
  41. $("#LDCN").css("display", "flex");
  42. current_owner = "<div class='d-flex'><div class='mr-3'><a href='" + value['uriOwner']['value'] + "'>" +
  43. value['current_owner']['value'] + "</a></div></div>";
  44. }
  45. if (value.hasOwnProperty('current_location')) {
  46. $("#LDCS").css("display", "flex");
  47. current_location = value['current_location']['value'];
  48. }
  49. if (value.hasOwnProperty('unit')) {
  50. unit = value['unit']['value'];
  51. }
  52. if (value.hasOwnProperty('subject')) {
  53. $("#SGTI").css("display", "flex");
  54. subject = value['subject']['value'];
  55. }
  56. if (value.hasOwnProperty('dimensions')) {
  57. if (value['dimensions']['value'] != "") {
  58. $("#MIS").css("display", "flex");
  59. dimensions = value['dimensions']['value'];
  60. }
  61. }
  62. if (value.hasOwnProperty('condition')) {
  63. $("#STCC").css("display", "flex");
  64. condition = value['condition']['value'];
  65. }
  66. if (value.hasOwnProperty('note')) {
  67. $("#NSC").css("display", "flex");
  68. note = value['note']['value'];
  69. }
  70. if (value.hasOwnProperty('Materials')) {
  71. if (value['Materials']['value'] != "") {
  72. $("#MTC").css("display", "flex");
  73. mm = value['Materials']['value'];
  74. mat = mm.split("<br />");
  75. for (i in mat) {
  76. slice = mat[i].split("; ");
  77. /*materials += "<a href='" + slice[0] + "'>" + slice[1] + "</a><br />";*/
  78. materials += "<div class='d-flex'><div class='mr-3'><a href='" + slice[0] + "'>" +
  79. slice[1] + "</a></div>";
  80. }
  81. }
  82. }
  83. var Buttons = '<button title="Apri risorsa originale" class="btn btn-default" type="button" onclick="schedaASPO(\'' + uri + '\')"> \
  84. <i class="fas fa-external-link-alt" aria-hidden="true"></i></button> \
  85. <button title="Citazione" type="button" value="artwork" id="' + uri + '" class="cit btn btn-default" alt="scheda" title="Citazione"><i class="fa fa-quote-right"></i></button> \
  86. <button title="Permalink" type="button" value="artwork" id="' + uri + '" class="hyp btn btn-default" alt="scheda" title="Hyperlink"><i class="fa fa-link"></i></button> \
  87. <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>';
  88. document.getElementById("grafo").innerHTML = dataset;
  89. document.getElementById("nome_oggetto").innerHTML = label;
  90. document.getElementById("identifier").innerHTML = identifier;
  91. document.getElementById("type").innerHTML = type;
  92. document.getElementById("owner").innerHTML = current_owner;
  93. document.getElementById("subject").innerHTML = subject;
  94. document.getElementById("dimensions").innerHTML = dimensions + unit;
  95. document.getElementById("materials").innerHTML = materials;
  96. document.getElementById("condition").innerHTML = condition;
  97. document.getElementById("description").innerHTML = note;
  98. document.getElementById("link_buttons").innerHTML = Buttons;
  99. });
  100. }
  101. function get_dataset_name(graph) {
  102. var string = "Scheda Opera d'Arte";
  103. if (graph == "http://dev.restore.ovi.cnr.it:8890/mpp/martini") {
  104. string = string + " / Collezione Martini";
  105. }
  106. else if (graph == "http://dev.restore.ovi.cnr.it:8890/mpp/ospedale") {
  107. string = string + " / Collezione Ospedale";
  108. }
  109. else if (graph == "http://dev.restore.ovi.cnr.it:8890/mpp/datini") {
  110. string = string + " / Collezione Datini";
  111. }
  112. else {
  113. string = string;
  114. }
  115. return (string);
  116. }
  117. function handle_Production(json) {
  118. console.log(json['results']['bindings']);
  119. $.each(
  120. json['results']['bindings'],
  121. function (index, value) {
  122. var partecipants = "";
  123. var teche = "";
  124. var time = "";
  125. var client = "";
  126. var artist = "";
  127. var artist_name = "";
  128. if (value.hasOwnProperty('techniques')) {
  129. if (value['techniques']['value'] != "") {
  130. $("#MTC").css("display", "flex");
  131. tt = value['techniques']['value'];
  132. tec = tt.split("<br />");
  133. for (i in tec) {
  134. slice = tec[i].split("; ");
  135. /*teche += "<a href='" + slice[0] + "'>" + slice[1] + "</a><br />";*/
  136. teche += "<div class='d-flex'><div class='mr-3'><a href='" + slice[0] + "'>" +
  137. slice[1] + "</a></div>";
  138. }
  139. }
  140. }
  141. if (value.hasOwnProperty('Partecipants')) {
  142. pp = value['Partecipants']['value'];
  143. people = pp.split("<br />");
  144. for (i in people) {
  145. slice = people[i].split("; ");
  146. if (slice[2] == "Committente") {
  147. $("#CMM").css("display", "flex");
  148. client += slice[1];
  149. } else {
  150. $("#AUT").css("display", "flex");
  151. artist_name += slice[1];
  152. artist += "<div class='d-flex'><div class='mr-3'><a href='" + slice[0] + "'>" +
  153. slice[1] + "</a></div><div class='d-flex ml-auto'><div class='persona btn-icon' style='cursor:pointer' id='" +
  154. slice[0] + "'><i class='fa fa-user'></i><p class='btn-text'>SCHEDA<br />PERSONA</p></div></div></div></div>";
  155. }
  156. }
  157. }
  158. if (value.hasOwnProperty('time')) {
  159. time = value['time']['value'];
  160. }
  161. document.getElementById("technique").innerHTML = teche;
  162. document.getElementById("time").innerHTML = time;
  163. document.getElementById("artist").innerHTML = artist;
  164. document.getElementById("client").innerHTML = client;
  165. });
  166. }