cambiata notazione espressione logica nel json + WIP carica query

This commit is contained in:
Luca Trupiano 2022-10-06 13:26:18 +02:00
parent ab27b68ad7
commit e147920973
1 changed files with 189 additions and 160 deletions

View File

@ -108,23 +108,23 @@ $(document).ready(function() {
var addClaN = $(this).attr('id'); var addClaN = $(this).attr('id');
switch (addClaN) { switch (addClaN) {
case "Grammaticale": case "Grammaticale":
addGramCla(); addGramCla(1);
$('#cla' + tabID + '-tab').tab('show'); $('#cla' + tabID + '-tab').tab('show');
break; break;
case "Sintattico": case "Sintattico":
addSyntCla(); addSyntCla(1);
$('#cla' + tabID + '-tab').tab('show'); $('#cla' + tabID + '-tab').tab('show');
break; break;
case "Metafore": case "Metafore":
addMetaCla(); addMetaCla(0);
$('#cla' + tabID + '-tab').tab('show'); $('#cla' + tabID + '-tab').tab('show');
break; break;
case "Dialoghi": case "Dialoghi":
addDialCla(); addDialCla(0);
$('#cla' + tabID + '-tab').tab('show'); $('#cla' + tabID + '-tab').tab('show');
break; break;
case "Struttura": case "Struttura":
addStruCla(); addStruCla(0);
$('#cla' + tabID + '-tab').tab('show'); $('#cla' + tabID + '-tab').tab('show');
break; break;
case "andCond": case "andCond":
@ -163,7 +163,7 @@ $(document).ready(function() {
}); });
// Evento: click sull'icona di refresh dei radio button // Evento: click sull'icona di refresh dei radio button
$('#cla-TabContent').on('click', '.radioRefresh', function() { $('#cla-TabContent').on('click', '.radioReset', function() {
fSet = $(this).siblings('fieldset'); fSet = $(this).siblings('fieldset');
if (fSet.find(":checked").length) { if (fSet.find(":checked").length) {
radioChecked = fSet.find(":checked")[0]; radioChecked = fSet.find(":checked")[0];
@ -199,112 +199,9 @@ $(document).ready(function() {
// Evento: SCELTA CATEGORIA GRAMMATICALE // Evento: SCELTA CATEGORIA GRAMMATICALE
$('#cla-TabContent').on('change', 'select.catgram', function(e) { $('#cla-TabContent').on('change', 'select.catgram', function(e) {
e.preventDefault(); e.preventDefault();
var tabPaneId = ($(this).closest('.tab-pane').attr("id")); var tabPaneId = ($(this).closest('.tab-pane').attr("id"));
var dettagliBox = $(this).parent().parent().siblings(".dettaglifiltri"); var selectedValue = $(this).val();
addCatgramSubcla(tabPaneId,selectedValue);
dettagliBox.html("");
var 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 (var key in keys) {
var vals = categorieJson[filtro][keys[key]]
switch (vals.length) {
case 2:
var element = $('<div />');
element.attr('class', ' d-flex flex-nowrap pr-2 mb-1 col-8 form-group form-control justify-content-between');
var rbfieldset = $('<fieldset />');
var flexdiv1 = $('<div />');
var flexdiv2 = $('<div />');
var input1 = $('<input />');
var input2 = $('<input />');
var label1 = $('<label />');
var label2 = $('<label />');
rbfieldset.attr('id', tabPaneId + keys[key]);
rbfieldset.attr('class', 'bn');
flexdiv1.attr('class', 'custom-control custom-radio custom-control-inline');
flexdiv2.attr('class', 'custom-control custom-radio custom-control-inline');
input1.attr('class', 'custom-control-input');
input2.attr('class', 'custom-control-input');
input1.attr('type', 'radio');
input2.attr('type', 'radio');
input1.attr('id', tabPaneId + vals[0]);
input2.attr('id', tabPaneId + vals[1]);
input1.attr('value', vals[0]);
input2.attr('value', vals[1]);
input1.attr('name', tabPaneId + keys[key]);
input2.attr('name', tabPaneId + keys[key]);
label1.attr('class', 'custom-control-label');
label2.attr('class', 'custom-control-label');
label1.attr('for', tabPaneId + vals[0]);
label2.attr('for', tabPaneId + vals[1]);
label1.append(vals[0]);
label2.append(vals[1]);
input1.appendTo(flexdiv1);
input2.appendTo(flexdiv2);
label1.appendTo(flexdiv1);
label2.appendTo(flexdiv2);
flexdiv1.appendTo(rbfieldset);
flexdiv2.appendTo(rbfieldset);
rbfieldset.appendTo(element);
var iconR = $(iconReset);
iconR.appendTo(element);
element.attr('style', 'display:block');
element.appendTo(dettagliBox);
break;
case 1:
var element = $('<div />');
element.attr('class', ' d-flex flex-nowrap mb-1 col-4 form-group form-control');
var rbfieldset = $('<fieldset />');
flexdiv1 = $('<div />');
input1 = $('<input />');
label1 = $('<label />');
rbfieldset.attr('id', tabPaneId + keys[key]);
rbfieldset.attr('class', 'bn');
flexdiv1.attr('class', 'custom-control custom-checkbox custom-control-inline');
input1.attr('class', 'custom-control-input');
input1.attr('type', 'checkbox');
input1.attr('id', tabPaneId + vals[0].replace(/\s/g, ''));
input1.attr('value', vals[0]);
input1.attr('name', keys[key]);
label1.attr('class', 'custom-control-label');
label1.attr('for', tabPaneId + vals[0].replace(/\s/g, ''));
label1.append(vals[0]);
input1.appendTo(flexdiv1);
label1.appendTo(flexdiv1);
flexdiv1.appendTo(rbfieldset);
rbfieldset.appendTo(element);
element.attr('style', 'display:block');
element.appendTo(dettagliBox);
break;
default:
var element = $('<div />');
element.attr('class', ' col-8 form-group px-0 pb-1 m-0');
var select = $('<select class="form-control custom-select"/>');
select.attr('id', tabPaneId + keys[key]);
select.attr('title', keys[key]);
select.attr('name', keys[key]);
for (var val in vals) {
var seloption = $('<option />');
seloption.attr('value', vals[val]);
seloption.append(vals[val]);
seloption.appendTo(select);
}
select.appendTo(element);
element.attr('style', 'display:block');
element.appendTo(dettagliBox);
}
}
}
if (element) {
element.attr('style', "display: block;");
element.appendTo(dettagliBox);
};
}); });
// Evento: Submit form // Evento: Submit form
@ -319,11 +216,7 @@ $(document).ready(function() {
jsonQuery = buildSQ(queryJson); jsonQuery = buildSQ(queryJson);
queryFields = []; queryFields = [];
for (var i in jsonQuery.variables) { for (var i in jsonQuery.variables) {
//if (jsonQuery.variables[i].value) {
//queryFields.push(jsonQuery.variables[i].value);
//} else {
queryFields.push(jsonQuery.variables[i].variable.value); queryFields.push(jsonQuery.variables[i].variable.value);
//}
} }
execQuery = new sparqlGenerator().stringify(jsonQuery); execQuery = new sparqlGenerator().stringify(jsonQuery);
executeQuery(); executeQuery();
@ -485,7 +378,7 @@ $(document).ready(function() {
var iconClose = '<ion-icon name="close-circle"></ion-icon>'; var iconClose = '<ion-icon name="close-circle"></ion-icon>';
var iconCheck = '<ion-icon name="checkmark-circle"></ion-icon>'; var iconCheck = '<ion-icon name="checkmark-circle"></ion-icon>';
var iconFilter = '<ion-icon name="filter-circle"></ion-icon>'; var iconFilter = '<ion-icon name="filter-circle"></ion-icon>';
var iconReset = '<div class="text-right text-primary radioRefresh"><ion-icon name="refresh-circle"></ion-icon></div>'; var iconReset = '<div class="text-right text-primary radioReset"><ion-icon name="refresh-circle"></ion-icon></div>';
var iconCloseCond = '<div class="p-0 mr-1 text-right text-primary"><span class="iconClClass removeCond">' + iconClose + '</span></div>'; var iconCloseCond = '<div class="p-0 mr-1 text-right text-primary"><span class="iconClClass removeCond">' + iconClose + '</span></div>';
var iconCheckAndClose = '<div class="p-0 m-1 text-right text-primary"><span class="return2Query">' + iconCheck + '</span>&nbsp;&nbsp;<span class="removeClaInTab">' + iconClose + '</span></div>'; var iconCheckAndClose = '<div class="p-0 m-1 text-right text-primary"><span class="return2Query">' + iconCheck + '</span>&nbsp;&nbsp;<span class="removeClaInTab">' + iconClose + '</span></div>';
var emptyClaList = '<li id="H-cla0" class="list-group-item align-items-center ui-state-default ui-state-disabled border text-muted bg-white ui-state-disabled-opacity-06">Nessuna clausola aggiunta.</li>'; var emptyClaList = '<li id="H-cla0" class="list-group-item align-items-center ui-state-default ui-state-disabled border text-muted bg-white ui-state-disabled-opacity-06">Nessuna clausola aggiunta.</li>';
@ -528,7 +421,6 @@ $(document).ready(function() {
const myEngine = new Comunica.QueryEngine(); const myEngine = new Comunica.QueryEngine();
const sparqlEndpoint = "https://hdnlab1.isti.cnr.it/fuseki/commediaontosintgra/query"; const sparqlEndpoint = "https://hdnlab1.isti.cnr.it/fuseki/commediaontosintgra/query";
const sparqlEndpoint2 = "https://hdnlab1.isti.cnr.it/fuseki/commedia-wip/query";
// Fine variabili // Fine variabili
@ -538,7 +430,6 @@ $(document).ready(function() {
bindingsStream = await myEngine.queryBindings(execQuery, { sources: [ { type: 'sparql', value: sparqlEndpoint }, ], }); bindingsStream = await myEngine.queryBindings(execQuery, { sources: [ { type: 'sparql', value: sparqlEndpoint }, ], });
$("#sparqlquery").val(execQuery); $("#sparqlquery").val(execQuery);
$("#copiaQuery").prop("disabled", false); $("#copiaQuery").prop("disabled", false);
var resultTablePart1a = '<table id="resultTable" class="table table-striped table-bordered responsive nowrap"><thead><tr>';
var resultTablePart1 = '<table id="resultTable" class="table table-striped table-bordered"><thead><tr>'; var resultTablePart1 = '<table id="resultTable" class="table table-striped table-bordered"><thead><tr>';
var resultTablePart2 = '<th scope="col">#</th>'; var resultTablePart2 = '<th scope="col">#</th>';
var resultTablePart3 = '</tr></thead><tbody>'; var resultTablePart3 = '</tr></thead><tbody>';
@ -590,10 +481,11 @@ $(document).ready(function() {
}; };
// Funzione di creazione del tab delle clausole grammaticali // Funzione di creazione del tab delle clausole grammaticali
function addGramCla(){ function addGramCla(active){
tabID++; tabID++;
var clone = document.getElementById("tipogrammaticaleN").cloneNode(true); var clone = document.getElementById("tipogrammaticaleN").cloneNode(true);
clone.setAttribute("id","cla" + tabID); clone.setAttribute("id","cla" + tabID);
clone.setAttribute("data-claActive",active);
clone.setAttribute("aria-labelledby","cla" + tabID + "-tab"); clone.setAttribute("aria-labelledby","cla" + tabID + "-tab");
clone.removeAttribute("style"); clone.removeAttribute("style");
$('#cla-TabContent').append(clone); $('#cla-TabContent').append(clone);
@ -603,11 +495,118 @@ $(document).ready(function() {
$('#tab-list').append($('<li class="nav-item" role="presentation"><a class="nav-link" id="cla' + tabID + '-tab" data-toggle="tab" href="#cla' + tabID + '" role="tab" aria-controls="cla' + tabID + '" aria-selected="false" data-claType="Grammaticale"><span class="small font-weight-bold text-lida8">' + iconFilter + '&nbsp;&nbsp;' + claListLen + '. Grammaticale</span></a></li>')); $('#tab-list').append($('<li class="nav-item" role="presentation"><a class="nav-link" id="cla' + tabID + '-tab" data-toggle="tab" href="#cla' + tabID + '" role="tab" aria-controls="cla' + tabID + '" aria-selected="false" data-claType="Grammaticale"><span class="small font-weight-bold text-lida8">' + iconFilter + '&nbsp;&nbsp;' + claListLen + '. Grammaticale</span></a></li>'));
} }
// Funzione di creazione delle subclausole grammaticali basate sul valore scelto
function addCatgramSubcla(tabPaneId,selectedValue){
var dettagliBox = $("#" + tabPaneId + " .dettaglifiltri");
//var dettagliBox = $(this).parent().parent().siblings(".dettaglifiltri");
dettagliBox.html("");
if (Object.keys(categorie).includes(selectedValue)) {
var filtro = categorie[selectedValue]
var keys = Object.keys(categorieJson[filtro])
for (var key in keys) {
var vals = categorieJson[filtro][keys[key]]
switch (vals.length) {
case 2:
var element = $('<div />');
element.attr('class', ' d-flex flex-nowrap pr-2 mb-1 col-8 form-group form-control justify-content-between');
var rbfieldset = $('<fieldset />');
var flexdiv1 = $('<div />');
var flexdiv2 = $('<div />');
var input1 = $('<input />');
var input2 = $('<input />');
var label1 = $('<label />');
var label2 = $('<label />');
rbfieldset.attr('id', tabPaneId + keys[key]);
rbfieldset.attr('class', 'bn');
flexdiv1.attr('class', 'custom-control custom-radio custom-control-inline');
flexdiv2.attr('class', 'custom-control custom-radio custom-control-inline');
input1.attr('class', 'custom-control-input');
input2.attr('class', 'custom-control-input');
input1.attr('type', 'radio');
input2.attr('type', 'radio');
input1.attr('id', tabPaneId + vals[0]);
input2.attr('id', tabPaneId + vals[1]);
input1.attr('value', vals[0]);
input2.attr('value', vals[1]);
input1.attr('name', tabPaneId + keys[key]);
input2.attr('name', tabPaneId + keys[key]);
label1.attr('class', 'custom-control-label');
label2.attr('class', 'custom-control-label');
label1.attr('for', tabPaneId + vals[0]);
label2.attr('for', tabPaneId + vals[1]);
label1.append(vals[0]);
label2.append(vals[1]);
input1.appendTo(flexdiv1);
input2.appendTo(flexdiv2);
label1.appendTo(flexdiv1);
label2.appendTo(flexdiv2);
flexdiv1.appendTo(rbfieldset);
flexdiv2.appendTo(rbfieldset);
rbfieldset.appendTo(element);
var iconR = $(iconReset);
iconR.appendTo(element);
element.attr('style', 'display:block');
element.appendTo(dettagliBox);
break;
case 1:
var element = $('<div />');
element.attr('class', ' d-flex flex-nowrap mb-1 col-4 form-group form-control');
var rbfieldset = $('<fieldset />');
flexdiv1 = $('<div />');
input1 = $('<input />');
label1 = $('<label />');
rbfieldset.attr('id', tabPaneId + keys[key]);
rbfieldset.attr('class', 'bn');
flexdiv1.attr('class', 'custom-control custom-checkbox custom-control-inline');
input1.attr('class', 'custom-control-input');
input1.attr('type', 'checkbox');
input1.attr('id', tabPaneId + vals[0].replace(/\s/g, ''));
input1.attr('value', vals[0]);
input1.attr('name', keys[key]);
label1.attr('class', 'custom-control-label');
label1.attr('for', tabPaneId + vals[0].replace(/\s/g, ''));
label1.append(vals[0]);
input1.appendTo(flexdiv1);
label1.appendTo(flexdiv1);
flexdiv1.appendTo(rbfieldset);
rbfieldset.appendTo(element);
element.attr('style', 'display:block');
element.appendTo(dettagliBox);
break;
default:
var element = $('<div />');
element.attr('class', ' col-8 form-group px-0 pb-1 m-0');
var select = $('<select class="form-control custom-select"/>');
select.attr('id', tabPaneId + keys[key]);
select.attr('title', keys[key]);
select.attr('name', keys[key]);
for (var val in vals) {
var seloption = $('<option />');
seloption.attr('value', vals[val]);
seloption.append(vals[val]);
seloption.appendTo(select);
}
select.appendTo(element);
element.attr('style', 'display:block');
element.appendTo(dettagliBox);
}
}
}
if (element) {
element.attr('style', "display: block;");
element.appendTo(dettagliBox);
};
}
// Funzione di creazione del tab delle clausole sintattiche // Funzione di creazione del tab delle clausole sintattiche
function addSyntCla(){ function addSyntCla(active){
tabID++; tabID++;
var clone = document.getElementById("tiposintatticoN").cloneNode(true); var clone = document.getElementById("tiposintatticoN").cloneNode(true);
clone.setAttribute("id","cla" + tabID); clone.setAttribute("id","cla" + tabID);
clone.setAttribute("data-claActive",active);
clone.setAttribute("aria-labelledby","cla" + tabID + "-tab"); clone.setAttribute("aria-labelledby","cla" + tabID + "-tab");
clone.removeAttribute("style"); clone.removeAttribute("style");
$('#cla-TabContent').append(clone); $('#cla-TabContent').append(clone);
@ -616,25 +615,25 @@ $(document).ready(function() {
} }
// Funzione di creazione del tab delle clausole metafore // Funzione di creazione del tab delle clausole metafore
function addMetaCla(){ function addMetaCla(active){
tabID++; tabID++;
$('#cla-TabContent').append($('<div class="tab-pane fade p-2 bg-white" data-claActive="0" id="cla' + tabID + '" role="tabpanel" aria-labelledby="cla' + tabID + '-tab" data-claType="Metafore">' + iconCheckAndClose + '<div class="text-muted form-group px-1 pb-1">Clausola <span class="text-lida3">Metafore</span> - non ancora implementata</div></div>')); $('#cla-TabContent').append($('<div class="tab-pane fade p-2 bg-white" data-claActive="' + active + '" id="cla' + tabID + '" role="tabpanel" aria-labelledby="cla' + tabID + '-tab" data-claType="Metafore">' + iconCheckAndClose + '<div class="text-muted form-group px-1 pb-1">Clausola <span class="text-lida3">Metafore</span> - non ancora implementata</div></div>'));
claListLen++; claListLen++;
$('#tab-list').append($('<li class="nav-item" role="presentation"><a class="nav-link" id="cla' + tabID + '-tab" data-toggle="tab" href="#cla' + tabID + '" role="tab" aria-controls="cla' + tabID + '" aria-selected="false" data-claType="Metafore"><span class="small font-weight-bold text-lida3">' + iconFilter + '&nbsp;&nbsp;' + claListLen + '. Metafore</span></a></li>')); $('#tab-list').append($('<li class="nav-item" role="presentation"><a class="nav-link" id="cla' + tabID + '-tab" data-toggle="tab" href="#cla' + tabID + '" role="tab" aria-controls="cla' + tabID + '" aria-selected="false" data-claType="Metafore"><span class="small font-weight-bold text-lida3">' + iconFilter + '&nbsp;&nbsp;' + claListLen + '. Metafore</span></a></li>'));
} }
// Funzione di creazione del tab delle clausole dialoghi // Funzione di creazione del tab delle clausole dialoghi
function addDialCla(){ function addDialCla(active){
tabID++; tabID++;
$('#cla-TabContent').append($('<div class="tab-pane fade p-2 bg-white" data-claActive="0" id="cla' + tabID + '" role="tabpanel" aria-labelledby="cla' + tabID + '-tab" data-claType="Dialoghi">' + iconCheckAndClose + '<div class="text-muted form-group px-1 pb-1">Clausola <span class="text-lida4">Dialoghi</span> - non ancora implementata</div></div>')); $('#cla-TabContent').append($('<div class="tab-pane fade p-2 bg-white" data-claActive="' + active + '" id="cla' + tabID + '" role="tabpanel" aria-labelledby="cla' + tabID + '-tab" data-claType="Dialoghi">' + iconCheckAndClose + '<div class="text-muted form-group px-1 pb-1">Clausola <span class="text-lida4">Dialoghi</span> - non ancora implementata</div></div>'));
claListLen++; claListLen++;
$('#tab-list').append($('<li class="nav-item" role="presentation"><a class="nav-link" id="cla' + tabID + '-tab" data-toggle="tab" href="#cla' + tabID + '" role="tab" aria-controls="cla' + tabID + '" aria-selected="false" data-claType="Dialoghi"><span class="small font-weight-bold text-lida4">' + iconFilter + '&nbsp;&nbsp;' + claListLen + '. Dialoghi</span></a></li>')); $('#tab-list').append($('<li class="nav-item" role="presentation"><a class="nav-link" id="cla' + tabID + '-tab" data-toggle="tab" href="#cla' + tabID + '" role="tab" aria-controls="cla' + tabID + '" aria-selected="false" data-claType="Dialoghi"><span class="small font-weight-bold text-lida4">' + iconFilter + '&nbsp;&nbsp;' + claListLen + '. Dialoghi</span></a></li>'));
} }
// Funzione di creazione del tab delle clausole struttura // Funzione di creazione del tab delle clausole struttura
function addStruCla(){ function addStruCla(active){
tabID++; tabID++;
$('#cla-TabContent').append($('<div class="tab-pane fade p-2 bg-white" data-claActive="0" id="cla' + tabID + '" role="tabpanel" aria-labelledby="cla' + tabID + '-tab" data-claType="Struttura">' + iconCheckAndClose + '<div class="text-muted form-group px-1 pb-1">Clausola <span class="text-lida5">Struttura testo</span> - non ancora implementata</div></div>')); $('#cla-TabContent').append($('<div class="tab-pane fade p-2 bg-white" data-claActive="' + active + '" id="cla' + tabID + '" role="tabpanel" aria-labelledby="cla' + tabID + '-tab" data-claType="Struttura">' + iconCheckAndClose + '<div class="text-muted form-group px-1 pb-1">Clausola <span class="text-lida5">Struttura testo</span> - non ancora implementata</div></div>'));
claListLen++; claListLen++;
$('#tab-list').append($('<li class="nav-item" role="presentation"><a class="nav-link" id="cla' + tabID + '-tab" data-toggle="tab" href="#cla' + tabID + '" role="tab" aria-controls="cla' + tabID + '" aria-selected="false" data-claType="Struttura"><span class="small font-weight-bold text-lida5">' + iconFilter + '&nbsp;&nbsp;' + claListLen + '. Struttura</span></a></li>')); $('#tab-list').append($('<li class="nav-item" role="presentation"><a class="nav-link" id="cla' + tabID + '-tab" data-toggle="tab" href="#cla' + tabID + '" role="tab" aria-controls="cla' + tabID + '" aria-selected="false" data-claType="Struttura"><span class="small font-weight-bold text-lida5">' + iconFilter + '&nbsp;&nbsp;' + claListLen + '. Struttura</span></a></li>'));
} }
@ -703,12 +702,11 @@ $(document).ready(function() {
var claActive = 1 var claActive = 1
}; };
var l_f = $("form #lemma_forma")[0].options[$("form #lemma_forma")[0].selectedIndex].value; var l_f = $("form #lemma_forma")[0].options[$("form #lemma_forma")[0].selectedIndex].value;
var tabsC=$("#cla-TabContent").find(".tab-pane:not(:first)"); var tabsContent=$("#cla-TabContent").find(".tab-pane:not(:first)");
var clausoleText = "";
var len=0; var len=0;
queryJson.Clausola0 = JSON.parse('{"queryText": "' + qText + '", "lemma_forma": "' + l_f + '", "TipoClausola": "0", "Attiva": "' + claActive + '"}'); queryJson.Clausola0 = JSON.parse('{"queryText": "' + qText + '", "lemma_forma": "' + l_f + '", "TipoClausola": "0", "Attiva": "' + claActive + '"}');
if ($(tabsC).length) { if ($(tabsContent).length) {
$(tabsC).each(function(){ $(tabsContent).each(function(){
if ($("#H-cla0")[0]) { if ($("#H-cla0")[0]) {
$("#H-cla0")[0].remove(); $("#H-cla0")[0].remove();
}; };
@ -776,6 +774,14 @@ $(document).ready(function() {
// Funzione di refresh dei placeholders e attivazione/disattivazione bottoni nelle liste sortable // Funzione di refresh dei placeholders e attivazione/disattivazione bottoni nelle liste sortable
function refreshSortables(){ function refreshSortables(){
$("#sortable0").children(".claLI").each(function() {
if ($(this).find("input")[0].checked){
$(this).find('.clatext').css({ opacity: 1 });
};
if ($(this).find("input")[0].checked == false){
$(this).find('.clatext').css({ opacity: 0.6 });
};
});
$(".ui-sortable:not(:first)").each(function() { $(".ui-sortable:not(:first)").each(function() {
var sortableID = $(this)[0].id; var sortableID = $(this)[0].id;
var placeholderID = "#placeholderSort" + sortableID.slice(-1); var placeholderID = "#placeholderSort" + sortableID.slice(-1);
@ -866,7 +872,7 @@ $(document).ready(function() {
// Funzione di parsing delle clausole e delle condizioni logiche // Funzione di parsing delle clausole e delle condizioni logiche
function parseCond(sortableList, condType){ function parseCond(sortableList, condType){
var condText = ""; var condText = "";
var items = $(sortableList).children("li") var items = $(sortableList).children("li");
var itemsText = []; var itemsText = [];
$(items).each(function() { $(items).each(function() {
if ($(this).hasClass("condLIand")) { if ($(this).hasClass("condLIand")) {
@ -899,11 +905,11 @@ $(document).ready(function() {
condText += itemsText[0]; condText += itemsText[0];
break; break;
default: default:
condText = "( "; condText = "( " + condType + " ";
for (let i = 0; i < (len - 1); i++) { for (let i = 0; i < len; i++) {
condText += itemsText[i] + " " + condType + " "; condText += itemsText[i] + " ";
} }
condText += itemsText[len - 1] + " )" condText += ")";
}; };
return condText; return condText;
}; };
@ -918,12 +924,28 @@ $(document).ready(function() {
}; };
function makeUpGui(queryJson) { function makeUpGui(queryJson) {
// 1. verifica json legit // 1. verifica json legit --> TO DO
// 2. pulire interfaccia // 2. pulire interfaccia --> OK
// 3. contare clausole, ricrearle in ordine e popolarle // 3. contare clausole, ricrearle in ordine e popolarle
// 4. ricreare condizioni logiche // 4. ricreare condizioni logiche --> OK
// 5. ricreare albero logico // 5. ricreare albero logico
// 6. ??? // 6. ???
// -------------------
// 2:
var tabsContent=$("#cla-TabContent").find(".tab-pane:not(:first)");
var tabs=$("#tab-list li:not(:first)");
if ($(tabsContent).length) {
$(tabsContent).each(function(){
$(this).remove();
});
$(tabs).each(function(){
$(this).remove();
});
};
claListLen = 0;
condListLen = 0;
$('#sortable0').html(emptyClaList);
// 3:
var logicExpr = queryJson.EsprLogica; var logicExpr = queryJson.EsprLogica;
var clauCount = 0; var clauCount = 0;
var clau2Make = ""; var clau2Make = "";
@ -932,59 +954,66 @@ $(document).ready(function() {
//console.log("- " + logicExpr[i]); //console.log("- " + logicExpr[i]);
switch (logicExpr[i]) { switch (logicExpr[i]) {
case "(": case "(":
console.log("("); //console.log("(");
break; break;
case ")": case ")":
console.log(")"); //console.log(")");
break; break;
case "OR": case "OR":
console.log("OR"); //console.log("OR");
addLogicCond("OR");
refreshConnectWith();
break; break;
case "AND": case "AND":
console.log("AND"); //console.log("AND");
addLogicCond("AND");
refreshConnectWith();
break; break;
default: default:
clauCount++ clauCount++
}; };
}; };
console.log(clauCount + " clausole:");
for (var i=1; i <= clauCount; i++) { for (var i=1; i <= clauCount; i++) {
clau2Make = queryJson["Clausola" + i].TipoClausola; clau2Make = queryJson["Clausola" + i].TipoClausola;
console.log(clau2Make); active = queryJson["Clausola" + i].Attiva
switch (clau2Make) { switch (clau2Make) {
case "Grammaticale": case "Grammaticale":
addGramCla(); selectedValue = queryJson["Clausola" + i].typeGramm0;
//$('#cla' + tabID + '-tab').tab('show'); addGramCla(active);
break; if (selectedValue != "all") {
console.log(tabID + " " + selectedValue);
console.log($("#cla" + tabID + " .catgram"));
$("#cla" + tabID + " .catgram").val(selectedValue);
addCatgramSubcla("cla" + tabID,selectedValue)
// aggiungere altri valori
}
break;
case "Sintattico": case "Sintattico":
addSyntCla(); addSyntCla(active);
//$('#cla' + tabID + '-tab').tab('show');
break; break;
case "Metafore": case "Metafore":
addMetaCla(); addMetaCla(active);
//$('#cla' + tabID + '-tab').tab('show');
break; break;
case "Dialoghi": case "Dialoghi":
addDialCla(); addDialCla(active);
//$('#cla' + tabID + '-tab').tab('show');
break; break;
case "Struttura": case "Struttura":
addStruCla(); addStruCla(active);
//$('#cla' + tabID + '-tab').tab('show');
break; break;
case "andCond": /* case "andCond":
addLogicCond("AND") addLogicCond("AND");
refreshConnectWith(); refreshConnectWith();
break; break;
case "orCond": case "orCond":
addLogicCond("OR") addLogicCond("OR");
refreshConnectWith(); refreshConnectWith();
break; break; */
default: default:
}; };
}; };
refreshTabList(); refreshTabList();
refreshClaList(); refreshClaList();
refreshSortables();
}; };
}); });