cercaContesti.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import {arrayResponse} from './processData.js'
  2. import {queryDTO, getData} from './toExport.js'
  3. import {processOccData, processSingleContext} from './processData.js'
  4. import {flask_be_address} from './config.js'
  5. export function checkContext() {
  6. $("#lauchSearchContext").css("display", "none");
  7. let resulTable = document.getElementById("result");
  8. const checkBoxes = resulTable.querySelectorAll('input[type="checkbox"]');
  9. let arrayContesti = [];
  10. var selected = [];
  11. $('#result input:checked').each(function() {
  12. //selected.push($(this).attr('id'));
  13. var checkNum = $(this).attr('id');
  14. selected.push(checkNum);
  15. });
  16. for (var i=0; i<arrayResponse.length; i++) {
  17. for (var j=0; j<selected.length; j++) {
  18. if (arrayResponse[i]["cod"] == selected[j]) {
  19. arrayResponse[i]["selected"] = true;
  20. arrayContesti.push(arrayResponse[i]);
  21. }
  22. }
  23. }
  24. queryDTO["listResults"] = arrayContesti;
  25. console.log(queryDTO);
  26. $("#result").html("");
  27. $("#loader").css("display", "block");
  28. getData('/get_context', queryDTO)
  29. // After request finishes, process response data
  30. .done(response => processOccData(response))
  31. .fail(err => {
  32. console.log(err);
  33. $("#loader").css("display", "none");
  34. alert('Something went wrong!');
  35. });
  36. // .always(response => console.log(response));
  37. }
  38. export function goToSingleContext(num, parole, periodi, brani) {
  39. let params = {"indice": num, "parole": parole, "periodi": periodi, "brani": brani};
  40. let queryGSC = {
  41. elem: arrayResponse[num],
  42. params: params
  43. }
  44. getData('/get_single_context', queryGSC)
  45. // After request finishes, process response data
  46. .done(response => processSingleContext(response))
  47. .fail(err => {
  48. console.log(err);
  49. $("#loader").css("display", "none");
  50. alert('Something went wrong!');
  51. });
  52. }