From 3a02f1998306e6601c023dfea44b2015d23ea25b Mon Sep 17 00:00:00 2001 From: Luca Trupiano Date: Thu, 19 Jan 2023 17:52:07 +0100 Subject: [PATCH] Aggiustamenti minori nella gestione del contesto --- js/script_3.3.js | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/js/script_3.3.js b/js/script_3.3.js index cb53be5..ab7101c 100644 --- a/js/script_3.3.js +++ b/js/script_3.3.js @@ -1,5 +1,6 @@ /** - * + *unita' di ricerca: +verso discorso periodo frase metafora sintagma lemma forma */ /* necessari per il bundle: @@ -250,6 +251,7 @@ $(document).ready(function() { $('#rigaRicerca').on('click', '.trashClaCont', function() { var claIdNum = $(this)[0].id.substring(15); resetContext(claIdNum); + refreshClaList(); }); // Evento: click sull'icona di add del contesto @@ -267,6 +269,7 @@ $(document).ready(function() { if ($(this).closest('.card').find('span:visible').length == 1) { $(this).closest('.card').find('div .sel-canti-intro').text("Selezionati tutti i canti."); }; + refreshClaList(); }); // Evento: click sull'icona di save local @@ -892,8 +895,8 @@ $(document).ready(function() { }; var jsonTextToParse = '{"queryText": "' + qText + '", "lemma_forma": "' + l_f + '", "opzioni_testo": "' + optText + '", "TipoClausola": "' + claType + '", "Attiva": "' + claActive + '"'; var gramSelect = $("#" + claId).find(".catgram"); - //claText = claGuiNum + ". " + termText + "Categoria grammaticale: " + gramSelect[0].options[gramSelect[0].selectedIndex].text + ';
'; - claText = termText + "Categoria grammaticale: " + gramSelect[0].options[gramSelect[0].selectedIndex].text + ';
'; + var contextText = $("#contextText-xX" + claIdNum).text(); + claText = termText + "Categoria grammaticale: " + gramSelect[0].options[gramSelect[0].selectedIndex].text; jsonTextToParse = jsonTextToParse + ', "' + gramSelect.attr('name') + '": "' + gramSelect[0].options[gramSelect[0].selectedIndex].value + '"'; var claSubParList = $("#" + claId).children(".dettaglifiltri").find("select, fieldset"); claSubParList.each(function(){ @@ -903,14 +906,15 @@ $(document).ready(function() { if (claSubParName.startsWith(claId)) { claSubParName = claSubParName.replace(claId,''); } - claText = claText + $(this).find(":checked")[0].defaultValue + "; "; + claText = claText + "; " + $(this).find(":checked")[0].defaultValue; jsonTextToParse = jsonTextToParse + ', "' + claSubParName + '": "' + $(this).find(":checked")[0].value + '"'; }; if (claSubParType == "select-one" && $(this)[0].selectedIndex != 0) { - claText = claText + $(this)[0].options[$(this)[0].selectedIndex].text + "; "; + claText = claText + "; " + $(this)[0].options[$(this)[0].selectedIndex].text; jsonTextToParse = jsonTextToParse + ', "' + $(this)[0].name + '": "' + $(this)[0].options[$(this)[0].selectedIndex].value + '"'; }; }); + claText = claText + '.
Contesto: ' + contextText; break; case "Sintattico": var l_f = $("form #lemma_forma" + claIdNum)[0].options[$("form #lemma_forma" + claIdNum)[0].selectedIndex].value; @@ -924,13 +928,11 @@ $(document).ready(function() { var jsonTextToParse = '{"queryText": "' + qText + '", "lemma_forma": "' + l_f + '", "opzioni_testo": "' + optText + '", "TipoClausola": "' + claType + '", "Attiva": "' + claActive + '"'; var syntSelect = $("#" + claId).find("#synttypes"); var funcSelect = $("#" + claId).find("#syntfunc"); - //claText = claGuiNum + ". " + termText + "Tipo sintattico: " + syntSelect[0].options[syntSelect[0].selectedIndex].text + ';
Livello di subordinazione: ' + funcSelect[0].options[funcSelect[0].selectedIndex].text; - claText = termText + "Tipo sintattico: " + syntSelect[0].options[syntSelect[0].selectedIndex].text + ';
Livello di subordinazione: ' + funcSelect[0].options[funcSelect[0].selectedIndex].text; + var contextText = $("#contextText-xX" + claIdNum).text(); + claText = termText + "Tipo sintattico: " + syntSelect[0].options[syntSelect[0].selectedIndex].text + ';
Livello di subordinazione: ' + funcSelect[0].options[funcSelect[0].selectedIndex].text + '.
Contesto: ' + contextText; jsonTextToParse = jsonTextToParse + ', "' + syntSelect.attr('name') + '": "' + syntSelect[0].options[syntSelect[0].selectedIndex].value + '", "' + funcSelect.attr('name') + '": "' + funcSelect[0].options[funcSelect[0].selectedIndex].value + '"'; break; default: - //claText = claGuiNum + ". " + $("#" + claId).text(); - //claText = $("#" + claId).text(); claText = $("#" + claListItemId + " .clatext").text(); checkInsert = ' disabled'; var jsonTextToParse = '{"queryText": "", "lemma_forma": "", "opzioni_testo": "", "TipoClausola": "' + claType + '", "Attiva": "' + claActive + '"'; @@ -1269,6 +1271,7 @@ $(document).ready(function() { var rangeHolderS = 0; var rangeHolderE = -1; var lastElem = ""; + var totCan = 0; for (var i=0; i < 3; i++) { for (var j=0; j <= context[i].length; j++) { if (context[i][j] == 1) { @@ -1278,6 +1281,7 @@ $(document).ready(function() { rangeHolderS = j; rangeHolderE = j; }; + totCan++; } else { if (rangeHolderE >= 0) { if ( rangeHolderS == rangeHolderE) { @@ -1303,10 +1307,10 @@ $(document).ready(function() { contextStringParts[i] = contextStringParts[i] + "]" contextString.push(contextStringParts[i]); } - if (contextString.toString() != "") { + if ((contextString.toString() != "") && (totCan < 100)) { $("#contextText-xX" + claIdNum).html(contextString.toString()); } else { - $("#contextText-xX" + claIdNum).html("Tutta l'opera"); + resetContext(claIdNum) } }; };