cercaContesti.js 1.8 KB

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