diff --git a/js/script_4.8.js b/js/script_4.8.js
index 17edf4c..c3c1024 100644
--- a/js/script_4.8.js
+++ b/js/script_4.8.js
@@ -314,7 +314,7 @@ $(document).ready(function() {
});
// Evento: modifica di un campo clausole
- $("form #lemma_forma,#queryText,#opzioni_testo").on('change', function() {
+ $("form #lemmaforma_,#queryText,#opzioni_testo").on('change', function() {
if ($(this)[0].id == "queryText") {
var orgSelection = "forma" // $('#lemma_forma option:selected')[0].value
var qText = $(this)[0].value;
@@ -328,22 +328,9 @@ $(document).ready(function() {
$('#cla-TabContent').on('change', '.monMe', function() {
// Nik
var fieldId = $(this)[0].id;
- var claid = 9999;
- if (fieldId.startsWith("query")) {
- $("form #queryText").val($("#" + fieldId).val());
- claid = fieldId.substring(9);
- } else {
- if (fieldId.startsWith("lemma")) {
- $("form #lemma_forma").val($("#" + fieldId).val());
- claid = fieldId.substring(11);
- } else {
- if (fieldId.startsWith("opzioni")) {
- $("form #opzioni_testo").val($("#" + fieldId).val());
- claid = fieldId.substring(13);
- }
- }
- }
- refreshClaList(claid);
+ var ids = fieldId.split('_');
+ var claType = $("#" + fieldId+":parent").attr('data-claType');
+ refreshClaList(ids[1],claType);
});
// Evento: click sull'icona rimuovi clausola
@@ -357,7 +344,7 @@ $(document).ready(function() {
thisIs.remove();
delete queryJson["Clausola" + claIdNum];
delete window["context" + claIdNum];
- refreshClaList();
+ refreshClaList(claIdNum);
refreshSortables();
});
});
@@ -381,13 +368,15 @@ $(document).ready(function() {
tabID++;
addGramCla("#sortable0", 1, tabID, 1,1);
$('#collapseLogic').attr('style', "display: d-flex;");
- $("#unitaRicerca").prop('disabled',true);
+ $("#unitaRicerca").prop('disabled',true);
+ refreshClaList(tabID);
});
$('#btnAddOr').on('click', function() {
tabID++;
addGramCla("#sortable0", 1, tabID, 1,2);
$('#collapseLogic').attr('style', "display: d-flex;");
- $("#unitaRicerca").prop('disabled',true);
+ $("#unitaRicerca").prop('disabled',true);
+ refreshClaList(tabID);
});
// Evento: clausola spostata nella lista
$('#sortable0').sortable({
@@ -445,7 +434,7 @@ $(document).ready(function() {
$('#rigaRicerca').on('click', '.trashClaCont', function() {
var claIdNum = $(this)[0].id.substring(15);
resetContext(claIdNum);
- refreshClaList();
+ refreshClaList(tabID);
});
// Evento: click sull'icona di add del contesto
@@ -463,7 +452,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();
+ refreshClaList(claIdNum);
});
// Evento: click sull'icona di save local
@@ -506,8 +495,10 @@ $(document).ready(function() {
$("#grammtypesN").on('change', function(e) {
var selectedValue = $(this).val();
var tabPaneId = ($(this).closest('.tab-pane').attr("id"));
- var id = tabPaneId.replace("tipogrammaticale","cla");
+ var id = tabPaneId.replace("tipogrammaticale_","cla");
addCatgramSubcla(id, selectedValue);
+ //id = id.substr(3);
+ //refreshClaList(id);
});
// Evento: Submit form
$("form").submit(function(e) {
@@ -795,7 +786,7 @@ $(document).ready(function() {
var checkInsert = '';
};
- var claText = ""; //Categoria grammaticale:
";
+ var claText = ""; // "Categoria grammaticale:
";
addLIitem(sortableId, tabID, claText, checkInsert, toExpand, cond);
var claClone = $("#grammaticaEsintassi").clone(true);
claClone.attr("id", "cla" + tabID);
@@ -803,13 +794,15 @@ $(document).ready(function() {
claClone.attr("aria-labelledby", "cla" + tabID + "-tab");
claClone.attr("style", "");
$('#claBody' + tabID).append(claClone);
- // se non cambio l'id della select react non rileva l'evento onchange:
- $('#cla' + tabID + " #grammtypesN").attr("id", "grammtypes" + tabID);
- $('#cla' + tabID + " #lemma_formaN").attr("id", "lemma_forma" + tabID);
- $('#cla' + tabID + " #queryTextN").attr("id", "queryText" + tabID);
- $('#cla' + tabID + " #opzioni_testoN").attr("id", "opzioni_testo" + tabID);
- $('#cla' + tabID + " #contextDivN").attr("id", "contextDiv" + tabID);
- $('#cla' + tabID + " #tipogrammaticaleN").attr("id","tipogrammaticale" + tabID);
+ $('#cla' + tabID + " #grammtypesN").attr("id", "grammtypes_" + tabID);
+ $('#cla' + tabID + " #lemma_formaINIT").attr("id", "lemmaforma_" + tabID);
+ $('#cla' + tabID + " #queryTextINIT").attr("id", "queryText_" + tabID);
+ $('#cla' + tabID + " #opzioni_testoINIT").attr("id", "opzionitesto_" + tabID);
+ $('#cla' + tabID + " #contextDivN").attr("id", "contextDiv_" + tabID);
+ $('#cla' + tabID + " #tipogrammaticaleN").attr("id","tipogrammaticale_" + tabID);
+ $('#cla' + tabID + " #tiposintatticoN").attr("id","tiposintattico_" + tabID);
+ $('#cla' + tabID + " #synttypes").attr("id","synttypes_" + tabID);
+ $('#cla' + tabID + " #syntfunc").attr("id","syntfunc_" + tabID);
$("#contextDiv0").attr('style', "display: none");
addClaContext(tabID);
@@ -935,7 +928,7 @@ $(document).ready(function() {
contClone = contClone.replace(/sel-canto/g, "sel-canto suxess");
- $("#contextDiv" + tabID).append($(contClone)[0]);
+ $("#contextDiv_" + tabID).append($(contClone)[0]);
resetContext(tabID);
$("#selectable-xX" + tabID).selectable({
filter: ".sel-canto",
@@ -1004,23 +997,11 @@ $(document).ready(function() {
};
// Funzione di refresh della lista clausole nella tab principale e del json della query
- function refreshClaList(editCard = 9999) {
- var l_f = $("#lemma_formaINIT").val();
- var qText = $("#queryTextINIT").val();
- var optText = $("#opzioni_testoINIT").val();
- /*var l_f = "";
- var qText = "";
- var optText = "";
- var unitaDiRicerca = $("#unitaRicerca")[0].options[$("#unitaRicerca")[0].selectedIndex].value;
- if (unitaDiRicerca == "lemma" || unitaDiRicerca == "forma") {
- l_f = unitaDiRicerca;
- qText = $("#queryTextUnita")[0].value;
- optText = $("#opzioni_testoUnita")[0].value;
- } else {
- l_f = $("#lemma_formaINIT")[0].options[$("#lemma_formaINIT")[0].selectedIndex].value;
- qText = $("#queryTextINIT")[0].value;
- optText = $("#opzioni_testoINIT")[0].value;
- }*/
+ function refreshClaList(editCard = 9999, claType) {
+
+ var l_f = $("#lemmaforma_"+editCard).val();
+ var qText = $("#queryText_"+editCard).val();
+ var optText = $("#opzionitesto_"+editCard).val();
if (qText == "") { //disattivo clausola 0 se il testo e' vuoto
var claActive = 0
@@ -1037,7 +1018,7 @@ $(document).ready(function() {
};
$(tabsContent).each(function() {
var claIdNum = $(this).attr('id').substr(6);
- updateClaListItem(claIdNum, "#sortable0", editCard);
+ updateClaListItem(claIdNum, "#sortable0",claType);
});
} else {
if (claListLen == 0 && condListLen == 0) {
@@ -1057,93 +1038,72 @@ $(document).ready(function() {
}
// Funzione di creazione del LI nella lista delle clausole nel tab principale, aggiunta della clausola nel JSON
- function updateClaListItem(claIdNum, sortableId, editCard) {
+ function updateClaListItem(claIdNum, sortableId, type) {
var claText = '';
var termText = '';
var checkInsert = '';
var claId = "cla" + claIdNum;
var claListItemId = "li-cla" + claIdNum;
- var claType = $("#" + claId).attr('data-claType');
+ var claType = type;//$("#" + claId).attr('data-claType');
var claActive = $("#" + claId).attr('data-claActive');
- var tabsContentLenght = ($("#sortable0").find(".claLI").length);
if (claActive > 0) {
checkInsert = ' checked="checked"';
};
-
- var l_f = "";
- var l_f_t = "";
- var qText = "";
- var optText = "";
- var optText_t = "";
- var articolo = "Il ";
- //Nik verificare in cao di modifica delle clausola
- //var unitaDiRicerca = $("#unitaRicerca")[0].options[$("#unitaRicerca")[0].selectedIndex].value;
- if (editCard == 9999) {
-
- l_f = $("#lemma_formaINIT").val();
- l_f_t = $("#lemma_formaINIT").text();
- qText = $("#queryTextINIT").val();
- optText = $("#opzioni_testoINIT").val();
- optText_t = $("#opzioni_testoINIT").text();
- } else {
- l_f = $("#lemma_forma" + editCard)[0].options[$("#lemma_forma" + editCard)[0].selectedIndex].value;
- l_f_t = $("#lemma_forma" + editCard)[0].options[$("#lemma_forma" + editCard)[0].selectedIndex].text;
- qText = $("#queryText" + editCard)[0].value;
- optText = $("#opzioni_testo" + editCard)[0].value;
- optText_t = $("#opzioni_testo" + editCard)[0].options[$("#opzioni_testo" + editCard)[0].selectedIndex].text;
-
- }
+ var l_f = $("#lemmaforma_"+claIdNum).val();
+ var l_f_t = $("#lemmaforma_"+claIdNum+" option:selected").text();
+ var qText = $("#queryText_"+claIdNum).val();
+ var optText = $("#opzionitesto_"+claIdNum).val();
+ var optText_t = $("#opzionitesto_"+claIdNum+" option:selected").text();
+
if (qText != "") {
- termText = l_f_t + ' ' + qText + ' ' + optText_t + '.
';
+ termText = l_f_t + ' ' + qText + ' ' + optText_t + '.';
};
var jsonTextToParse = '{"queryText": "' + qText + '", "lemma_forma": "' + l_f + '", "opzioni_testo": "' + optText + '", "TipoClausola": "' + claType + '", "Attiva": "' + claActive + '"';
-
-
- switch (claType) {
- case "Grammaticale":
- var gramSelect = $("#" + claId).find(".catgram");
- 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() {
- var claSubParType = $(this)[0].type;
- if (claSubParType == "fieldset" && $(this).find(":checked").length) {
- var claSubParName = $(this).find(":checked")[0].name;
- if (claSubParName.startsWith(claId)) {
- claSubParName = claSubParName.replace(claId, '');
- }
- 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;
- jsonTextToParse = jsonTextToParse + ', "' + $(this)[0].name + '": "' + $(this)[0].options[$(this)[0].selectedIndex].value + '"';
- };
- });
- claText = claText + '.
Contesto: ' + contextText;
- break;
- case "Sintattico":
- var syntSelect = $("#" + claId).find("#synttypes");
- var funcSelect = $("#" + claId).find("#syntfunc");
- 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 = $("#" + claListItemId + " .clatext").text();
- checkInsert = ' disabled';
- var jsonTextToParse = '{"queryText": "", "lemma_forma": "", "opzioni_testo": "", "TipoClausola": "' + claType + '", "Attiva": "' + claActive + '"';
- };
- // nik controllare in quale caso si verifica "else"
- if ($("#" + claListItemId)[0]) {
- if (claListItemId == "li-cla" + tabsContentLenght && editCard == 9999) {
- $("#" + claListItemId + " .clatext").replaceWith('' + claText + '');
- } else {
- $("#" + "li-cla" + editCard + " .clatext").replaceWith('' + claText + '');
-
+ var gramSelect = $("#" + claId).find(".catgram");
+ var contextText = $("#contextText-xX" + claIdNum).text();
+ if (gramSelect[0].selectedIndex > 0){
+ if(termText !=""){
+ termText += "
";
}
+ claText = termText + "Categoria grammaticale: " + gramSelect[0].options[gramSelect[0].selectedIndex].text;
+ }else{
+ claText = termText;
+ }
+ jsonTextToParse = jsonTextToParse + ', "' + gramSelect.attr('name') + '": "' + gramSelect[0].options[gramSelect[0].selectedIndex].value + '"';
+ var claSubParList = $("#" + claId).children(".dettaglifiltri").find("select, fieldset");
+ claSubParList.each(function() {
+ var claSubParType = $(this)[0].type;
+ if (claSubParType == "fieldset" && $(this).find(":checked").length) {
+ var claSubParName = $(this).find(":checked")[0].name;
+ if (claSubParName.startsWith(claId)) {
+ claSubParName = claSubParName.replace(claId, '');
+ }
+ 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;
+ jsonTextToParse = jsonTextToParse + ', "' + $(this)[0].name + '": "' + $(this)[0].options[$(this)[0].selectedIndex].value + '"';
+ };
+ });
+
+ var syntSelect = $("#synttypes_"+claIdNum).find(":selected").text();
+ var funcSelect = $("#syntfunc_"+claIdNum).find(":selected").text();
+
+ if(!syntSelect.startsWith("\n\t")){
+ claText = claText+"
Tipo sintattico: " + syntSelect;
+ } else {
+ if (!funcSelect.startsWith("Livello di subordinazione")) {
+ claText = claText + "
Qualsiasi tipo sintattico: ";
+ }
+ }
+ if(!funcSelect.startsWith("Livello di subordinazione")){
+ claText = claText+"
Livello di subordinazione: " + funcSelect;
+ }
+ claText = claText + '.
Contesto: ' + contextText;
+ if ($("#" + claListItemId)[0]) {
+ $("#" + claListItemId + " .clatext").replaceWith('' + claText + '');
} else {
addLIitem(sortableId, claIdNum, claText, checkInsert, 0);
};
@@ -1354,8 +1314,8 @@ $(document).ready(function() {
};
// Rigenerazione Clausola0:
if (queryJson["Clausola0"].Attiva) {
- $("#queryText").val(queryJson["Clausola0"].queryText);
- $("#opzioni_testo").val(queryJson["Clausola0"].opzioni_testo);
+ $("#queryText_").val(queryJson["Clausola0"].queryText);
+ $("#opzionitesto_").val(queryJson["Clausola0"].opzioni_testo);
var qText = queryJson["Clausola0"].queryText;
if (qText !== null && qText !== '') { qText = ' "' + qText + '"'; }
setLemmaForma(qText, queryJson["Clausola0"].lemma_forma);
@@ -1411,13 +1371,13 @@ $(document).ready(function() {
$("#lemma_formaINIT").val(queryJson["Clausola" + itm].lemma_forma);
$("#queryTexINIT").val(queryJson["Clausola" + itm].queryText);
$("#opzioni_testoINIT").val(queryJson["Clausola" + itm].opzioni_testo);
- $("#lemma_forma" + tabID).val(queryJson["Clausola" + itm].lemma_forma);
- $("#queryText" + tabID).val(queryJson["Clausola" + itm].queryText);
- $("#opzioni_testo" + tabID).val(queryJson["Clausola" + itm].opzioni_testo);
+ $("#lemmaforma_" + tabID).val(queryJson["Clausola" + itm].lemma_forma);
+ $("#queryText_" + tabID).val(queryJson["Clausola" + itm].queryText);
+ $("#opzionitesto_" + tabID).val(queryJson["Clausola" + itm].opzioni_testo);
if (selectedValue != "all") {
- $("#grammtypes" + tabID).val(selectedValue);
+ $("#grammtypes_" + tabID).val(selectedValue);
addCatgramSubcla("cla" + tabID, selectedValue);
var ks = Object.keys(queryJson["Clausola" + itm]);
for (var j = 6; j < ks.length - 1; j++) {
@@ -1438,50 +1398,28 @@ $(document).ready(function() {
window["context" + tabID] = JSON.parse(queryJson["Clausola" + itm].contesto);
parseContext(tabID);
break;
- case "Sintattico":
- addSyntCla($(this)[1], active, tabID, 0);
- $("#lemma_formaINIT").val(queryJson["Clausola" + itm].lemma_forma);
- $("#queryTextINIT").val(queryJson["Clausola" + itm].queryText);
- $("#opzioni_testoINIT").val(queryJson["Clausola" + itm].opzioni_testo);
- $("#lemma_forma" + tabID).val(queryJson["Clausola" + itm].lemma_forma);
- $("#queryText" + tabID).val(queryJson["Clausola" + itm].queryText);
- $("#opzioni_testo" + tabID).val(queryJson["Clausola" + itm].opzioni_testo);
-
-
- if (queryJson["Clausola" + itm].typeSyntax0 != ".+") {
- $("#cla" + tabID + " #synttypes").val(queryJson["Clausola" + itm].typeSyntax0);
- }
- if (queryJson["Clausola" + itm].functionSyntax != ".+") {
- $("#cla" + tabID + " #syntfunc").val(queryJson["Clausola" + itm].functionSyntax);
- }
- window["context" + tabID] = JSON.parse(queryJson["Clausola" + itm].contesto);
- parseContext(tabID);
- break;
- case "Metafora":
- addMetaCla($(this)[1], active, tabID, 0);
- break;
default:
};
};
});
- refreshClaList();
+ refreshClaList(tabID);
refreshSortables();
};
function resetSimpleGui() {
- $('#queryText').val("");
+ $('#queryText_').val("");
setLemmaForma("", "forma");
- $('#opzioni_testo').val("parola");
+ $('#opzionitesto_').val("parola");
resetContext(0);
};
function setLemmaForma(qText, newSelection) {
var newOptions = { ['La forma' + qText]: 'forma', ['Il lemma' + qText]: 'lemma', ['Il testo' + qText]: 'testo' };
- $("#lemma_forma").empty();
+ $("#lemmaforma_").empty();
$.each(newOptions, function(key, value) {
- $("#lemma_forma").append($("").attr("value", value).text(key));
+ $("#lemmaforma_").append($("").attr("value", value).text(key));
});
- $("#lemma_forma").val(newSelection);
+ $("#lemmaforma_").val(newSelection);
};
function resetContext(claIdNum) {