index.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. import {funzioneRicerca} from './toExport.js'
  2. import {checkContext, goToSingleContext} from './cercaContesti.js'
  3. import {createNewCC} from './createCooccorrenza.js'
  4. document.querySelector('#lauchSearch').addEventListener('click', funzioneRicerca);
  5. document.querySelector('#lauchSearchContext').addEventListener('click', checkContext);
  6. $(document).on("click", ".singleContext", function (ev) {
  7. var num = this.id;
  8. var parole = 31;
  9. var periodi = 0;
  10. var brani = 0;
  11. goToSingleContext(num, parole, periodi, brani);
  12. });
  13. var occ = 0;
  14. $("#btnGroupAddon").click(function() {
  15. $("#cooccorrenze_options").css("display", "flex");
  16. $("#inner_altro").css("display", "none");
  17. $("#inner_lemmatizzato").css("display", "flex");
  18. if (occ > 8) {
  19. alert("Hai esaurito i parametri a disposizione");
  20. }
  21. else {
  22. occ = occ + 1;
  23. createNewCC(occ);
  24. }
  25. });
  26. $(document).on("click", ".deleteCC", function (ev) {
  27. var deleteID = "occ_" + this.id;
  28. const element = document.getElementById(deleteID);
  29. element.remove();
  30. let numb = document.getElementById("search_form").childElementCount;
  31. if (numb < 2) {
  32. $("#cooccorrenze_options").css("display", "none");
  33. $("#inner_altro").css("display", "flex");
  34. $("#inner_lemmatizzato").css("display", "none");
  35. }
  36. });
  37. $(document).on("change", ".flViewBy", function (ev) {
  38. var check_tipo = this.value;
  39. var parent = this.parentElement.parentElement.parentElement.parentElement.parentElement;
  40. var cc = parent.getElementsByClassName("lemmatizzata");
  41. if (check_tipo == "forma") {
  42. cc[0].disabled = true;
  43. cc[0].checked = false;
  44. }
  45. else if (check_tipo == "lemma"){
  46. cc[0].disabled = false;
  47. }
  48. });
  49. $( "#context-title" ).on( "click", function() {
  50. $( "#additional_info" ).toggle( "slow", function() {
  51. // Animation complete.
  52. });
  53. });
  54. $(document).on("click", ".page-item", function (ev) {
  55. $(".page-item").removeClass("active");
  56. var name = this.id;
  57. this.className = "page-item active";
  58. var num = name.replace("getPage_", "");
  59. var page = "pag_" + num;
  60. $("#" + page).css("display", "block");
  61. $(".page:not(#" + page +")").css("display", "none");
  62. });
  63. $(document).on("click", "#prev", function (ev) {
  64. var el = document.getElementsByClassName("page-item active")[0];
  65. var name = el.id;
  66. var n = name.replace("getPage_", "");
  67. var num = parseInt(n) - 1;
  68. if (num < 0) {
  69. alert("No pages found");
  70. } else {
  71. var page = "pag_" + num;
  72. var getPage = "getPage_" + num;
  73. var elPage = document.getElementById(getPage);
  74. if (elPage !== null) {
  75. $(".page-item").removeClass("active");
  76. elPage.classList.add("active");
  77. $("#" + page).css("display", "block");
  78. $(".page:not(#" + page +")").css("display", "none");
  79. }
  80. }
  81. });
  82. $(document).on("click", "#next", function (ev) {
  83. var el = document.getElementsByClassName("page-item active")[0];
  84. var name = el.id;
  85. var n = name.replace("getPage_", "");
  86. var num = parseInt(n) + 1;
  87. if (num < 0) {
  88. alert("No pages found");
  89. } else {
  90. var page = "pag_" + num;
  91. var getPage = "getPage_" + num;
  92. var elPage = document.getElementById(getPage);
  93. if (elPage !== null) {
  94. $(".page-item").removeClass("active");
  95. elPage.classList.add("active");
  96. $("#" + page).css("display", "block");
  97. $(".page:not(#" + page +")").css("display", "none");
  98. }
  99. }
  100. });
  101. $('#showFilePanel').click(function(event) {
  102. if ($('#single-context-box').hasClass('dismiss')) {
  103. $('#single-context-box').removeClass('dismiss').addClass('selected').show();
  104. $('#showFilePanel').css("display", "none");
  105. $('#closeFilePanel').css("display", "block");
  106. $('.table-responsive').css("width", "60%");
  107. }
  108. event.preventDefault();
  109. });
  110. $('#closeFilePanel').click(function(event) {
  111. if ($('#single-context-box').hasClass('selected')) {
  112. $('#single-context-box').removeClass('selected').addClass('dismiss');
  113. $('#showFilePanel').css("display", "block");
  114. $('#closeFilePanel').css("display", "none");
  115. $('.table-responsive').css("width", "100%");
  116. }
  117. event.preventDefault();
  118. });