From 575a63e503c21a0aeeb1018fefcfc31252d98fdb Mon Sep 17 00:00:00 2001 From: Luca Trupiano Date: Mon, 27 Jun 2022 17:34:31 +0200 Subject: [PATCH] Versione funzionante con condizioni logiche --- index_Luk.html | 761 ++++++++++++++++++++++++++++++++++++++++ index_Luk_logic.html | 771 +++++++++++++++++++++++++++++++++++++++++ js/script_Luk.js | 574 ++++++++++++++++++++++++++++++ js/script_Luk_logic.js | 736 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 2842 insertions(+) create mode 100644 index_Luk.html create mode 100644 index_Luk_logic.html create mode 100644 js/script_Luk.js create mode 100644 js/script_Luk_logic.js diff --git a/index_Luk.html b/index_Luk.html new file mode 100644 index 0000000..d6c33ed --- /dev/null +++ b/index_Luk.html @@ -0,0 +1,761 @@ + + + + + + LiDaDashboard-tab + + + + + + + + + + + + + + +
+

Linking Dante Search, sandbox release

+ "potrai cercare, e non troverai ombra" + (Inf., canto 32, verso 59) +
+
 
+
 
+
 
+
 
+
 
+
+
+ +
+
+
+ + +
+
+
+
+
+ +
+ + +
+ +
+ Applicando le clausole: +
+
+
    +
  • Nessuna clausola aggiunta.
  • +
+
+

+

+ +
+ + +
+
+

+
+
+
+ + +
+
+
+ + +
+
+
+
+ + + + + + + + + + + + + + +
+ + + + + + + + + + +
+
+
+ +
+
+ +
+
+
+
+ + + +
+
+
+
+ +
+
+
+ +
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+
+
+
 
+
 
+
 
+
 
+
 
+
+

+ Info & Copyright + (idem) +

+
+ + + + + + \ No newline at end of file diff --git a/index_Luk_logic.html b/index_Luk_logic.html new file mode 100644 index 0000000..a0692cc --- /dev/null +++ b/index_Luk_logic.html @@ -0,0 +1,771 @@ + + + + + + LiDaDashboard-tab + + + + + + + + + + + + + + +
+

Linking Dante Search, sandbox release

+ "potrai cercare, e non troverai ombra" + (Inf., canto 32, verso 59) +
+
 
+
 
+
 
+
 
+
 
+
+
+ +
+
+
+ + +
+
+
+
+
+ +
+ + +
+ +
+ Applicando le clausole: +
+
+
AND
+
    +
  • Nessuna clausola aggiunta.
  • +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+ +
+
+
+ + +
+
+
+ + +
+
+
+
+ + + + + + + + + + + + + + +
+ + + + + + + + + + +
+
+
+ +
+
+ +
+
+
+
+ + + +
+
+
+
+ +
+
+
+ +
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+
+
+
 
+
 
+
 
+
 
+
 
+
+

+ Info & Copyright + (idem) +

+
+ + + + + + \ No newline at end of file diff --git a/js/script_Luk.js b/js/script_Luk.js new file mode 100644 index 0000000..5c6fde3 --- /dev/null +++ b/js/script_Luk.js @@ -0,0 +1,574 @@ +/** + * + */ + +$(document).ready(function() { + + $( "#sortable1" ).sortable(); + + // Evento: click sull'area di anvigazione delle tab + $('#tab-list').on('click', refreshClaList); + + // Evento: click sull'icona check dentro il tab della clausola + $('#cla-TabContent').on('click', '.return2Query', function() { + var tabFirst = $('#tab-list a:first'); + refreshClaList(); + tabFirst.tab('show'); + }); + + // Evento: click sull'icona rimuovi dentro il tab della clausola + $('#cla-TabContent').on('click', '.removeClaInTab', function() { + var tabIDVal = "#" + $(this).parent('div').parent().attr('id'); + removedTabOrder = $(tabIDVal).attr('data-claOrder'); + var liID = tabIDVal +"-tab"; + claListLen--; + $(liID).parent().remove(); + $(tabIDVal).remove(); + var tabFirst = $('#tab-list a:first'); + refreshTabList(); + refreshClaList(); + tabFirst.tab('show'); + }); + + // Evento: click sull'icona rimuovi dentro la lista delle clausole + $('#cla-TabContent').on('click', '.removeClaInList', function() { + var tabIDHandle = $(this).closest('li').attr('id'); + var tabIDVal = "#" + tabIDHandle.substring(2); + removedTabOrder = $(tabIDVal).attr('data-claOrder'); + var liID = tabIDVal + "-tab"; + claListLen--; + $(liID).parent().remove(); + $(tabIDVal).remove(); + var tabFirst = $('#tab-list a:first'); + refreshTabList(); + refreshClaList(); + tabFirst.tab('show'); + }); + + // Evento: click sull'icona modifica dentro la lista delle clausole + $('#cla-TabContent').on('click', '.editCla', function() { + var tabIDHandle = $(this).closest('li').attr('id'); + var liID = "#" + tabIDHandle.substring(2) + "-tab"; + var tabTarget = $('#tab-list ' + liID); + tabTarget.tab('show'); + }); + + // Evento: click sulla lista di clausole nel dropbox "Aggiungi clausola di tipo:" + $('.btn-group a').on('click', function() { + var addClaN = $(this).attr('id'); + switch (addClaN) { + case "Grammaticale": + tabID++; + var clone = document.getElementById("tipogrammaticaleN").cloneNode(true); + clone.setAttribute("id","cla" + tabID); + clone.setAttribute("data-claOrder",claListLen); + clone.setAttribute("aria-labelledby","cla" + tabID + "-tab"); + clone.removeAttribute("style"); + $('#cla-TabContent').append(clone); + // se non cambio l'id della select react non rileva l'evento onchange: + $('#cla' + tabID + " #grammtypes").attr("id","grammtypes" + tabID); + claListLen++; + $('#tab-list').append($('')); + $('#cla' + tabID + '-tab').tab('show'); + break; + case "Sintattico": + tabID++; + var clone = document.getElementById("tiposintatticoN").cloneNode(true); + clone.setAttribute("id","cla" + tabID); + clone.setAttribute("data-claOrder",claListLen); + clone.setAttribute("aria-labelledby","cla" + tabID + "-tab"); + clone.removeAttribute("style"); + $('#cla-TabContent').append(clone); + claListLen++; + $('#tab-list').append($('')); + $('#cla' + tabID + '-tab').tab('show'); + break; + case "Metafore": + tabID++; + $('#cla-TabContent').append($('
' + iconCheckAndClose + '
Clausola Metafore - non ancora implementata
')); + claListLen++; + $('#tab-list').append($('')); + $('#cla' + tabID + '-tab').tab('show'); + break; + case "Dialoghi": + tabID++; + $('#cla-TabContent').append($('
' + iconCheckAndClose + '
Clausola Dialoghi - non ancora implementata
')); + claListLen++; + $('#tab-list').append($('')); + $('#cla' + tabID + '-tab').tab('show'); + break; + case "Struttura": + tabID++; + $('#cla-TabContent').append($('
' + iconCheckAndClose + '
Clausola Struttura testo - non ancora implementata
')); + claListLen++; + $('#tab-list').append($('')); + $('#cla' + tabID + '-tab').tab('show'); + break; + default: + }; + }); + + // Evento: clausola spostata nella lista + $('#sortable1').sortable({ + opacity: 0.6, + cursor: 'move', + update: function(event, ui) { + var orderLI = $(this).sortable('toArray'); + $.each(orderLI, function(index, tabIDHandle){ + tabIDSet = "#" + tabIDHandle.substring(2); + $(tabIDSet).attr("data-claOrder", index); + }); + } + }); + + // Evento: click sul checkbox di attivazione delle clausole + $('#cla-TabContent').on('click', '.claAct', function() { + var tabIDHandle = $(this).closest('li').attr('id'); + var tabIDVal = "#" + tabIDHandle.substring(2); + if ($(this).prop('checked')) { + $(tabIDVal).attr("data-claActive", 1); + $(this).closest('li').find('.clatext').fadeTo( "slow", 1 ); + } else { + $(tabIDVal).attr("data-claActive", 0); + $(this).closest('li').find('.clatext').fadeTo( "slow", 0.6 ); + } + }); + + // Evento: click sull'icona di refresh dei radio button + $('#cla-TabContent').on('click', '.radioRefresh', function() { + fSet = $(this).siblings('fieldset'); + if (fSet.find(":checked").length) { + radioChecked = fSet.find(":checked")[0]; + radioChecked.checked = false; + }; + }); + + // Evento: SCELTA CATEGORIA GRAMMATICALE + $('#cla-TabContent').on('change', 'select.catgram', function(e) { + e.preventDefault(); + + var tabPaneId = ($(this).closest('.tab-pane').attr("id")); + var dettagliBox = $(this).parent().parent().siblings(".dettaglifiltri"); + + dettagliBox.html(""); + containerid = 'dettaglio_' + $(this).parent().parent().parent().attr("id") + + if (Object.keys(categorie).includes($(this).val())) { + var filtro = categorie[$(this).val()] + var keys = Object.keys(categorieJson[filtro]) + for (key in keys) { + var vals = categorieJson[filtro][keys[key]] + switch (vals.length) { + case 2: + var element = $('
'); + element.attr('class', ' d-flex flex-nowrap pr-2 mb-1 col-8 form-group form-control justify-content-between'); + var rbfieldset = $('
'), + flexdiv1 = $('
'), + flexdiv2 = $('
'), + input1 = $(''), + input2 = $(''), + label1 = $('
'; + + // Variabili funzionali + var tabID = 0; + var claListLen = 0; + var removedTabOrder = -1; + + // Funzione di refresh della lista delle tab delle clausole + function refreshTabList(){ + var tabs=$("#tab-list li:not(:first)"); + var len=0; + $(tabs).each(function(){ + len++; + var claType = $(this).find('a').attr("data-claType"); + switch (claType) { + case "Grammaticale": + textClassType = "text-lida8"; + break; + case "Sintattico": + textClassType = "text-lida9"; + break; + case "Metafore": + textClassType = "text-lida3"; + break; + case "Dialoghi": + textClassType = "text-lida4"; + break; + case "Struttura": + textClassType = "text-lida5"; + break; + default: + textClassType = "text-lida8"; + }; + $(this).find('a').html('' + iconFilter + '  ' + len + ': ' + claType + '  '); + $(this).find('a').attr("data-claType", claType) + }); + } + + // Funzione di refresh della lista clausole nella tab query + function refreshClaList(){ + var tabsC=$("#cla-TabContent").find(".tab-pane:not(:first)"); + var clausoleText = ""; + var len=0; + if ($(tabsC).length) { + var LItextArray = new Array($(tabsC).length); + $(tabsC).each(function(){ + len++; + checkInsert = '"'; + tabIDHandle = "H-" + $(this).attr('id'); + claType = $(this).attr('data-claType'); + claOrder = $(this).attr('data-claOrder'); + claActive = $(this).attr('data-claActive'); + if (claActive > 0) { + checkInsert = '" checked="checked"'; + }; + // se una clausola è stata rimossa aggiorno il 'data-claOrder' di quelle successive nella lista, + // altrimenti l'array ha elementi undefined: + if (removedTabOrder > -1 && claOrder > removedTabOrder) { + claOrder--; + $(this).attr('data-claOrder',claOrder); + }; + switch (claType) { + case "Grammaticale": + graSelect = $(this).find(".catgram"); + graText = graSelect[0].options[graSelect[0].selectedIndex].text; + claText = len + ". Categoria grammaticale: " + graText + '
'; + claSubParList = $(this).children(".dettaglifiltri").find("select, fieldset"); + claSubParList.each(function(){ + claSubParType = $(this)[0].type; + if (claSubParType == "fieldset" && $(this).find(":checked").length) { + //claSubParValue = $(this).find(":checked")[0].value; + claSubParId = $(this).find(":checked")[0].id; + claSubParText = $(this).find("[for='" + claSubParId + "']")[0].innerText; + claText = claText + claSubParText + "; "; + }; + if (claSubParType == "select-one") { + //claSubParValue = $(this)[0].value; + claSubParText = $(this)[0].options[$(this)[0].selectedIndex].text; + //claText = claText + $(this)[0].title + ": " + claSubParText + "; " + claText = claText + claSubParText + "; " + }; + }); + break; + case "Sintattico": + syntSelect = $(this).find("#synttypes"); + syntText = syntSelect[0].options[syntSelect[0].selectedIndex].text; + funcSelect = $(this).find("#syntfunc"); + funcText = funcSelect[0].options[funcSelect[0].selectedIndex].text; + claText = len + ". Tipo sintattico: " + syntText + ';
Livello di subordinazione: ' + funcText + break; + default: + claText = len + ". " + $(this).text(); + checkInsert = '" disabled'; + }; + LItextArray[claOrder] = LIpart1 + tabIDHandle + LIpart2 + claText + LIpart3 + len + checkInsert + LIpart4 + len + LIpart5; + }); + $.each(LItextArray, function(index, LItext){ + clausoleText = clausoleText + LItextArray[index]; + }); + } else { + clausoleText = emptyClaList; + tabID = 0; + claListLen = 0; + }; + $('#sortable1').html(clausoleText); + $('#sortable1 li').each(function(){ + if (! $(this).find(".claAct").prop('checked')) { + $(this).find('.clatext').css({ opacity: 0.6 }); + }; + }); + removedTabOrder = -1; + } + + + function cloneClaSint(clone,tabID){ + var original = document.getElementById("tiposintatticoX"); + clone = original.cloneNode(true); + clone.setAttribute("id","tiposintattico" + tabID); + } +}); + + diff --git a/js/script_Luk_logic.js b/js/script_Luk_logic.js new file mode 100644 index 0000000..87dce3a --- /dev/null +++ b/js/script_Luk_logic.js @@ -0,0 +1,736 @@ +/** + * + */ + +$(document).ready(function() { + + $( "#sortable0" ).sortable({ + items: "> li", + handle: ".handle" + }); + + // Evento: click sull'area di anvigazione delle tab + $('#tab-list').on('click', function() { + refreshClaList(); + refreshSortables(); + }); + + // Evento: click sull'icona check dentro il tab della clausola + $('#cla-TabContent').on('click', '.return2Query', function() { + var tabFirst = $('#tab-list a:first'); + refreshClaList(); + tabFirst.tab('show'); + }); + + // Evento: click sull'icona rimuovi clausola dentro il tab della clausola + $('#cla-TabContent').on('click', '.removeClaInTab', function() { + var tabPanelId = "#" + $(this).parent('div').parent().attr('id'); + var claListItemID = "H-" + $(this).parent('div').parent().attr('id'); + var tabLiId = tabPanelId + "-tab"; + claListLen--; + $(tabLiId).parent().remove(); + $(tabPanelId).remove(); + if ($("#" + claListItemID)[0]){ + $("#" + claListItemID)[0].remove(); + }; + var tabFirst = $('#tab-list a:first'); + refreshTabList(); + refreshClaList(); + refreshSortables(); + tabFirst.tab('show'); + }); + + // Evento: click sull'icona rimuovi clausola dentro la lista delle clausole + $('#cla-TabContent').on('click', '.removeClaInList', function() { + var claListItemID = $(this).closest('li').attr('id'); + var tabPanelId = "#" + claListItemID.substring(2); + var tabLiId = tabPanelId + "-tab"; + claListLen--; + $(tabLiId).parent().remove(); + $(tabPanelId).remove(); + $("#" + claListItemID)[0].remove(); + var tabFirst = $('#tab-list a:first'); + refreshTabList(); + refreshClaList(); + refreshSortables(); + tabFirst.tab('show'); + }); + + // Evento: click sull'icona rimuovi condizione dentro la lista delle clausole + $('#sortable0').on('click', '.removeCond', function() { + $(this).closest('ul').parent().remove(); + condListLen--; + refreshSortables(); + refreshConnectWith(); + if (claListLen == 0 && condListLen == 0) { + $('#sortable0').html(emptyClaList); + } + }); + + // Evento: click sull'icona modifica dentro la lista delle clausole + $('#cla-TabContent').on('click', '.editCla', function() { + var claListItemID = $(this).closest('li').attr('id'); + var tabLiId = "#" + claListItemID.substring(2) + "-tab"; + var tabTarget = $('#tab-list ' + tabLiId); + tabTarget.tab('show'); + }); + + // Evento: click sulla lista di clausole nel dropbox "Aggiungi clausola di tipo:" o "aggiungi condizione logica:" + $('.btn-group a').on('click', function() { + var addClaN = $(this).attr('id'); + switch (addClaN) { + case "Grammaticale": + tabID++; + var clone = document.getElementById("tipogrammaticaleN").cloneNode(true); + clone.setAttribute("id","cla" + tabID); + clone.setAttribute("aria-labelledby","cla" + tabID + "-tab"); + clone.removeAttribute("style"); + $('#cla-TabContent').append(clone); + // se non cambio l'id della select react non rileva l'evento onchange: + $('#cla' + tabID + " #grammtypes").attr("id","grammtypes" + tabID); + claListLen++; + $('#tab-list').append($('')); + $('#cla' + tabID + '-tab').tab('show'); + break; + case "Sintattico": + tabID++; + var clone = document.getElementById("tiposintatticoN").cloneNode(true); + clone.setAttribute("id","cla" + tabID); + clone.setAttribute("aria-labelledby","cla" + tabID + "-tab"); + clone.removeAttribute("style"); + $('#cla-TabContent').append(clone); + claListLen++; + $('#tab-list').append($('')); + $('#cla' + tabID + '-tab').tab('show'); + break; + case "Metafore": + tabID++; + $('#cla-TabContent').append($('
' + iconCheckAndClose + '
Clausola Metafore - non ancora implementata
')); + claListLen++; + $('#tab-list').append($('')); + $('#cla' + tabID + '-tab').tab('show'); + break; + case "Dialoghi": + tabID++; + $('#cla-TabContent').append($('
' + iconCheckAndClose + '
Clausola Dialoghi - non ancora implementata
')); + claListLen++; + $('#tab-list').append($('')); + $('#cla' + tabID + '-tab').tab('show'); + break; + case "Struttura": + tabID++; + $('#cla-TabContent').append($('
' + iconCheckAndClose + '
Clausola Struttura testo - non ancora implementata
')); + claListLen++; + $('#tab-list').append($('')); + $('#cla' + tabID + '-tab').tab('show'); + break; + case "andCond": + condListLen++; + LItext = condLIpart1 + condListLen + condLIpart2and + condListLen + condLIpart3and + condListLen + condLIpart4; + if ($("#H-cla0")[0]) { + $("#H-cla0")[0].remove(); + }; + $("#sortable0").append(LItext); + $("#sortable" + condListLen).sortable(); + $("#sortable" + condListLen).sortable( "option", "appendTo", document.body ); + $("#sortable" + condListLen).sortable({ + items: "> li", + handle: ".handle", + opacity: 0.6, + cursor: 'move', + update: function() {refreshSortables();} + }); + refreshConnectWith(); + break; + case "orCond": + condListLen++; + LItext = condLIpart1 + condListLen + condLIpart2or + condListLen + condLIpart3or + condListLen + condLIpart4; + if ($("#H-cla0")[0]) { + $("#H-cla0")[0].remove(); + }; + $("#sortable0").append(LItext); + $("#sortable" + condListLen).sortable(); + $("#sortable" + condListLen).sortable( "option", "appendTo", document.body ); + $("#sortable" + condListLen).sortable({ + items: "> li", + handle: ".handle", + opacity: 0.6, + cursor: 'move', + update: function() {refreshSortables();} + }); + refreshConnectWith(); + break; + default: + }; + }); + + // Evento: clausola spostata nella lista principale + $('#sortable0').sortable({ + opacity: 0.6, + cursor: 'move', + update: function() { + refreshSortables(); + } + }); + + // Evento: click sul checkbox di attivazione delle clausole + $('#cla-TabContent').on('click', '.claAct', function() { + var claListItemID = $(this).closest('li').attr('id'); + var tabPanelId = "#" + claListItemID.substring(2); + if ($(this).prop('checked')) { + $(tabPanelId).attr("data-claActive", 1); + $(this).closest('li').find('.clatext').fadeTo( "slow", 1 ); + } else { + $(tabPanelId).attr("data-claActive", 0); + $(this).closest('li').find('.clatext').fadeTo( "slow", 0.6 ); + } + refreshSortables(); + }); + + // Evento: click sull'icona di refresh dei radio button + $('#cla-TabContent').on('click', '.radioRefresh', function() { + fSet = $(this).siblings('fieldset'); + if (fSet.find(":checked").length) { + radioChecked = fSet.find(":checked")[0]; + radioChecked.checked = false; + }; + }); + + // Evento: SCELTA CATEGORIA GRAMMATICALE + $('#cla-TabContent').on('change', 'select.catgram', function(e) { + e.preventDefault(); + + var tabPaneId = ($(this).closest('.tab-pane').attr("id")); + var dettagliBox = $(this).parent().parent().siblings(".dettaglifiltri"); + + dettagliBox.html(""); + containerid = 'dettaglio_' + $(this).parent().parent().parent().attr("id") + + if (Object.keys(categorie).includes($(this).val())) { + var filtro = categorie[$(this).val()] + var keys = Object.keys(categorieJson[filtro]) + for (key in keys) { + var vals = categorieJson[filtro][keys[key]] + switch (vals.length) { + case 2: + var element = $('
'); + element.attr('class', ' d-flex flex-nowrap pr-2 mb-1 col-8 form-group form-control justify-content-between'); + var rbfieldset = $('
'); + flexdiv1 = $('
'); + flexdiv2 = $('
'); + input1 = $(''); + input2 = $(''); + label1 = $('
'; + + var condLIplaceholderText1 = 'Trascina qui almeno 1 clausola o condizione'; + var condLIplaceholderText2 = 'Trascina qui almeno 2 clausole o condizioni'; + var condLIplaceholderText1d = 'Trascina qui almeno 1 clausola o condizione, oppure attiva le clausole inattive'; + var condLIplaceholderText2d = 'Trascina qui almeno 2 clausole o condizioni, oppure attiva le clausole inattive'; + var condLIplaceholderPart1 = '
  • '; + var condLIpart1 = '
    • AND
      ' + iconCloseCond + '
      ' + condLIplaceholderPart1; + var condLIpart2or = '" class="condLIor p-1 m-1 list-group-item align-items-center border text-muted bg-lida11">
        OR
        ' + iconCloseCond + '
        ' + condLIplaceholderPart1; + var condLIpart4 = condLIplaceholderPart2 + condLIplaceholderText2 + '
      '; + + + // Variabili funzionali + var tabID = 0; + var claListLen = 0; + var condListLen = 0; + + // Funzione di refresh della lista delle tab delle clausole + function refreshTabList(){ + var tabs=$("#tab-list li:not(:first)"); + var len=0; + $(tabs).each(function(){ + len++; + var claType = $(this).find('a').attr("data-claType"); + switch (claType) { + case "Grammaticale": + textClassType = "text-lida8"; + break; + case "Sintattico": + textClassType = "text-lida9"; + break; + case "Metafore": + textClassType = "text-lida3"; + break; + case "Dialoghi": + textClassType = "text-lida4"; + break; + case "Struttura": + textClassType = "text-lida5"; + break; + default: + textClassType = "text-lida8"; + }; + $(this).find('a').html('' + iconFilter + '  ' + len + ': ' + claType + '  '); + $(this).find('a').attr("data-claType", claType) + }); + } + + // Funzione di refresh della lista clausole nella tab principale + function refreshClaList(){ + var tabsC=$("#cla-TabContent").find(".tab-pane:not(:first)"); + var clausoleText = ""; + var len=0; + if ($(tabsC).length) { + $(tabsC).each(function(){ + if ($("#H-cla0")[0]) { + $("#H-cla0")[0].remove(); + }; + len++; + checkInsert = '"'; + claListItemID = "H-" + $(this).attr('id'); + claType = $(this).attr('data-claType'); + claActive = $(this).attr('data-claActive'); + if (claActive > 0) { + checkInsert = '" checked="checked"'; + }; + switch (claType) { + case "Grammaticale": + graSelect = $(this).find(".catgram"); + graText = graSelect[0].options[graSelect[0].selectedIndex].text; + claText = len + ". Categoria grammaticale: " + graText + '
      '; + claSubParList = $(this).children(".dettaglifiltri").find("select, fieldset"); + claSubParList.each(function(){ + claSubParType = $(this)[0].type; + if (claSubParType == "fieldset" && $(this).find(":checked").length) { + claSubParId = $(this).find(":checked")[0].id; + claSubParText = $(this).find("[for='" + claSubParId + "']")[0].innerText; + claText = claText + claSubParText + "; "; + }; + if (claSubParType == "select-one") { + claSubParText = $(this)[0].options[$(this)[0].selectedIndex].text; + claText = claText + claSubParText + "; " + }; + }); + break; + case "Sintattico": + syntSelect = $(this).find("#synttypes"); + syntText = syntSelect[0].options[syntSelect[0].selectedIndex].text; + funcSelect = $(this).find("#syntfunc"); + funcText = funcSelect[0].options[funcSelect[0].selectedIndex].text; + claText = len + ". Tipo sintattico: " + syntText + ';
      Livello di subordinazione: ' + funcText + break; + default: + claText = len + ". " + $(this).text(); + checkInsert = '" disabled'; + }; + LItext = claLIpart1 + claListItemID + claLIpart2 + claText + claLIpart3 + len + checkInsert + claLIpart4 + len + claLIpart5; + if ($("#" + claListItemID)[0]) { + $("#" + claListItemID).replaceWith(LItext); + } else { + $("#sortable0").append(LItext); + }; + }); + } else { + if (claListLen == 0 && condListLen == 0) { + $('#sortable0').html(emptyClaList); + } + tabID = 0; + }; + } + + // Funzione di refresh dei placeholders e attivazione/disattivazione bottoni nelle liste sortable + function refreshSortables(){ + $(".ui-sortable:not(:first)").each(function() { + sortableID = $(this)[0].id; + placeholderID = "#placeholderSort" + sortableID.slice(-1); + iconSpan = $(this).find(".iconClClass")[0]; + iconDiv = $(iconSpan).parent()[0]; + activeUL = $(this).children("li").children("ul").length; + activeLI = 0; + inactiveLI = 0; + $(this).children("li .claLI").each(function() { + if ($(this).find("input")[0].checked){ + activeLI++; + $(this).find('.clatext').css({ opacity: 1 }); + }; + if ($(this).find("input")[0].checked == false){ + inactiveLI++; + $(this).find('.clatext').css({ opacity: 0.6 }); + }; + }); + switch (activeLI + activeUL) { + case 0: + if ($(placeholderID).length) { + if (inactiveLI > 0){ + $(placeholderID).text(condLIplaceholderText2d); + } else { + $(placeholderID).text(condLIplaceholderText2); + }; + } else { + if (inactiveLI > 0){ + condLIplaceholder = condLIplaceholderPart1 + sortableID.slice(-1) + condLIplaceholderPart2 + condLIplaceholderText2d + ''; + } else { + condLIplaceholder = condLIplaceholderPart1 + sortableID.slice(-1) + condLIplaceholderPart2 + condLIplaceholderText2 + ''; + } + $("#" + sortableID).append(condLIplaceholder); + }; + if (inactiveLI == 0){ + $(iconSpan).attr("class","iconClClass removeCond"); + $(iconDiv).attr("class","p-0 mr-1 text-right text-primary"); + }; + break; + case 1: + if ($(placeholderID).length) { + if (inactiveLI > 0){ + $(placeholderID).text(condLIplaceholderText1d); + } else { + $(placeholderID).text(condLIplaceholderText1); + }; + } else { + if (inactiveLI > 0){ + condLIplaceholder = condLIplaceholderPart1 + sortableID.slice(-1) + condLIplaceholderPart2 + condLIplaceholderText1d + ''; + } else { + condLIplaceholder = condLIplaceholderPart1 + sortableID.slice(-1) + condLIplaceholderPart2 + condLIplaceholderText1 + ''; + } + $("#" + sortableID).append(condLIplaceholder); + }; + $(iconSpan).attr("class","iconClClass NOremoveCond"); + $(iconDiv).attr("class","p-0 mr-1 text-right text-muted"); + break; + case 2: + if ($(placeholderID).length) { + $(placeholderID).remove(); + }; + break; + default: + if ($(placeholderID).length) { + $(placeholderID).remove(); + }; + }; + }); + $("#risultati").val(parseCond("#sortable0", "AND")); + }; + + // Funzione di refresh dei collegamenti tra elementi sortable + function refreshConnectWith(){ + for (var i=0; i <= condListLen; i++) { + cw = ""; + for (var j=0; j <= condListLen; j++) { + if (i != j) { + cw = cw + "#sortable" + j + ", "; + }; + $( "#sortable" + i ).sortable( "option", "connectWith", cw.slice(0, -2) ); + }; + }; + }; + + function parseCond(sortableList, condType){ + var condText = ""; + var items = $(sortableList).children("li") + var itemsText = []; + $(items).each(function() { + if ($(this).hasClass("condLIand")) { + var andID = "#" + $(this).children("ul").attr("id"); + var andText = parseCond(andID, "AND"); + if (andText.length){ + itemsText.push(andText); + }; + }; + if ($(this).hasClass("condLIor")) { + var orID = "#" + $(this).children("ul").attr("id"); + var orText = parseCond(orID, "OR"); + if (orText.length){ + itemsText.push(orText); + }; + }; + if ($(this).hasClass("claLI")) { + if ($(this).find("input")[0].checked == true){ + var claText = $(this).find(".clatext").text().substr(0,2); + itemsText.push(claText); + }; + }; + }); + var len = itemsText.length; + switch (len) { + case 0: + break; + case 1: + condText += itemsText[0]; + break; + default: + condText = "( "; + for (let i = 0; i < (len - 1); i++) { + condText += itemsText[i] + " " + condType + " "; + } + condText += itemsText[len - 1] + " )" + }; + return condText; + }; + +}); + +