customPages.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. var params = thisUrlParams.params;
  2. const pp = params.split("%");
  3. var tipo = pp[0];
  4. var val = pp[1];
  5. console.log([tipo, val]);
  6. prefixes = queryManager['prefixes']['all'];
  7. if ((tipo == "gettatelli") && (val == "contrassegni")) {
  8. queryGettatelli = prefixes + (queryManager['queryCustom']['queryTipo']).replaceAll('{TYPE}', 'Contrassegno');
  9. console.log(queryGettatelli);
  10. doJsonQuery(queryGettatelli).done(function(r) { handle_contrassegni(r); });
  11. }
  12. else if (tipo == "occupazione") {
  13. queryOccupazione = prefixes + (queryManager['queryCustom']['queryOccupazione']).replaceAll('{WORD}', val);
  14. console.log(queryOccupazione);
  15. doJsonQuery(queryOccupazione).done(function(r) { handle_occupation(r, val); });
  16. }
  17. else if (tipo == "opere") {
  18. var grafo = "";
  19. if (val == "Martini") {
  20. grafo = "http://dev.restore.ovi.cnr.it:8890/mpp/martini";
  21. }
  22. else if (val == "Ospedale") {
  23. grafo = "http://dev.restore.ovi.cnr.it:8890/mpp/ospedale";
  24. }
  25. else {
  26. grafo = "http://dev.restore.ovi.cnr.it:8890/mpp/datini";
  27. }
  28. queryOpere = prefixes + (queryManager['queryCustom']['queryOpereGrafo']).replaceAll('{GRAPH}', grafo);
  29. console.log(queryOpere);
  30. doJsonQuery(queryOpere).done(function(r) { handle_artwork(r, val); });
  31. }
  32. else {
  33. alert("Nessun parametro");
  34. }
  35. function handle_contrassegni(json){
  36. console.log(json);
  37. thead = '<div class="row def_res"> \
  38. <div class="col">Contrassegni</div> \
  39. <div class="col-3">Esplora</div> \
  40. </div>';
  41. var ContrassegniTable = thead;
  42. $.each(
  43. json['results']['bindings'],
  44. function (index, value) {
  45. var uri = value['subject']['value'];
  46. var label = value['label']['value'];
  47. var uri_ct = value['uri_contrassegno']['value'];
  48. ContrassegniTable += '<div class="row res"> \
  49. <div class="col object link" id="' + uri + '">' + label + '</div> \
  50. <div class="col-3"><button title="Apri risorsa originale" class="btn btn-default" type="button" onclick="schedaASPO(\'' + uri_ct + '\')"> \
  51. <i class="fas fa-external-link-alt" aria-hidden="true"></i><p class="btn-text">Link</p></button> \
  52. <button type="button" id="' + uri +
  53. '" class="object btn btn-default" alt="oggetto" title="' + label +
  54. '"><i class="fa fa-book"></i><p class="btn-text">Oggetto</p></button></div></div>' ;
  55. });
  56. document.getElementById("results_table").innerHTML = ContrassegniTable;
  57. document.getElementById("results_title").innerHTML = "Contrassegni";
  58. }
  59. function handle_occupation(json, occ) {
  60. thead = '<div class="row def_res"> \
  61. <div class="col">Persona</div> \
  62. <div class="col-3">Esplora</div> \
  63. </div>';
  64. var PeopleTable = thead;
  65. $.each(
  66. json['results']['bindings'],
  67. function (index, value) {
  68. var uri = value['subject']['value'];
  69. var name = value['name']['value'];
  70. var givenName = "";
  71. var familyName = "";
  72. var patronymic = "";
  73. var provenienza = "";
  74. var occupation = "";
  75. var stringName = "";
  76. if(value.hasOwnProperty('givenName')) {
  77. givenName = value['givenName']['value'];
  78. }
  79. if(value.hasOwnProperty('familyName')) {
  80. familyName = value['familyName']['value'];
  81. }
  82. if(value.hasOwnProperty('patronymic')) {
  83. patronymic = value['patronymic']['value'];
  84. }
  85. if(value.hasOwnProperty('provenienza')) {
  86. provenienza = value['provenienza']['value'];
  87. }
  88. if(value.hasOwnProperty('occupation')) {
  89. occupation = value['occupation']['value'];
  90. }
  91. if ((givenName != "") && (familyName != "")) {
  92. stringName = givenName + " " + patronymic + " " + familyName + " " + provenienza;
  93. } else {
  94. stringName = name;
  95. }
  96. stringName = titleCase(stringName);
  97. PeopleTable += '<div class="row res"> \
  98. <div class="col persona link" id="' + uri + '">' + stringName + '</div> \
  99. <div class="col-3"> \
  100. <button type="button" id="' + uri +
  101. '" class="persona btn btn-default" alt="oggetto" title="' + stringName +
  102. '"><i class="fa fa-user"></i><p class="btn-text">Persona</p></button></div></div>' ;
  103. });
  104. document.getElementById("results_table").innerHTML = PeopleTable;
  105. document.getElementById("results_title").innerHTML = titleCase(occ);
  106. }
  107. function handle_artwork(json, gg) {
  108. thead = '<div class="row def_res"> \
  109. <div class="col">Opera</div> \
  110. <div class="col">Esplora</div> \
  111. </div>';
  112. var ArtworkTable = thead;
  113. $.each(
  114. json['results']['bindings'],
  115. function (index, value) {
  116. var uri = value['subject']['value'];
  117. var label = value['label']['value'];
  118. ArtworkTable += '<div class="row res"> \
  119. <div class="col artwork" id="' + uri + '">' + label + '</div> \
  120. <div class="col"><button title="Apri risorsa originale" class="btn btn-default" type="button" onclick="schedaASPO(\'' + uri + '\')"> \
  121. <i class="fas fa-external-link-alt" aria-hidden="true"></i><p class="btn-text">Link</p></button> \
  122. <button type="button" id="' + uri +
  123. '" class="artwork btn btn-default" alt="oggetto" title="' + label +
  124. '"><i class="fas fa-paint-brush"></i><p class="btn-text">Opera</p></button></div></div>' ;
  125. });
  126. document.getElementById("results_table").innerHTML = ArtworkTable;
  127. document.getElementById("results_title").innerHTML = "Collezione " + gg;
  128. }