diff --git a/js/script_3.3.js b/js/script_3.3.js
index 2146225..cb53be5 100644
--- a/js/script_3.3.js
+++ b/js/script_3.3.js
@@ -12,8 +12,6 @@ var getJsonQuery;
$(document).ready(function() {
- //$('#multidraggable1').multidraggable();
-
$("#dropAdvanced").on('click', function () {
queryJson.QueryAvanzata = "1";
$("#simpleSearchDiv").removeClass( "d-flex" )
@@ -33,6 +31,7 @@ $(document).ready(function() {
$("#collapseAdvanced").collapse('hide');
});
+/**
$("#copiaTesto").prop("disabled", true);
// Evento: click sul bottone di copia dei risultati testuali
@@ -41,6 +40,8 @@ $(document).ready(function() {
});
$("#copiaQuery").prop("disabled", true);
+ */
+
// Funzioni di gestione del comportamento dei bottoni collapse
$('#collapseLogic').on('hidden.bs.collapse', function (e) {
@@ -66,8 +67,8 @@ $(document).ready(function() {
})
$('.collapse').on('hide.bs.collapse', function (e) {
- if (e.target.id.substr(0,9) == "collapseC") {
- var claIdNum = e.target.id.substr(9);
+ if (e.target.id.substr(0,11) == "collapseCla") {
+ var claIdNum = e.target.id.substr(11);
$("#claCollapse" + claIdNum)[0].removeAttribute("style");
$("#claCollapse" + claIdNum).removeClass( "border-bottom-0" );
$("#claCollapse" + claIdNum).addClass( "border border-lida4" );
@@ -76,8 +77,8 @@ $(document).ready(function() {
})
$('.collapse').on('show.bs.collapse', function (e) {
- if (e.target.id.substr(0,9) == "collapseC") {
- var claIdNum = e.target.id.substr(9);
+ if (e.target.id.substr(0,11) == "collapseCla") {
+ var claIdNum = e.target.id.substr(11);
$("#claCollapse" + claIdNum)[0].setAttribute("style", "background-color: #edf9f3 !important;border-bottom-left-radius: 0;border-bottom-right-radius: 0;");
$("#claCollapse" + claIdNum).removeClass( "border border-lida4" );
$("#claCollapse" + claIdNum).addClass( "border-bottom-0" );
@@ -85,7 +86,7 @@ $(document).ready(function() {
};
})
- // Evento: click sulsullo switch di ricerca avanzata
+ // Evento: click sullo switch di ricerca avanzata
$('#searchToggle').on('change', function() {
if ($(this).prop('checked')) {
queryJson.QueryAvanzata = "1";
@@ -112,20 +113,22 @@ $(document).ready(function() {
handle: ".handle"
});
- // Inizializza selectable0 e definisce le funzioni
- $("#selectable0").selectable({
+ // Inizializza selectable-xX0 e definisce le funzioni
+ $("#selectable-xX0").selectable({
filter: ".sel-canto",
selected: function(event, ui) {
window.context0[ui.selected.id.substring(0,1)][ui.selected.id.substring(2)] = 1;
- var tmpFocusBtn = "#plusBtn" + ui.selected.id.substring(0,1) + "-1"
+ var tmpFocusBtn = "#plusBtn" + ui.selected.id.substring(0,1) + "-xX" + tabID;
$(tmpFocusBtn).focus();
}
});
+/**
// Evento: click sul bottone di copia della query
$("#copiaQuery").on("click", function(){
$('#sparqlquery').copy2clipboard();
});
+ */
// Evento: modifica di un campo clausole
$("form #lemma_forma,#queryText,#opzioni_testo").on('change', function() {
@@ -149,6 +152,7 @@ $(document).ready(function() {
claListLen--;
$("#" + claListItemId)[0].remove();
delete queryJson["Clausola" + claIdNum];
+ delete window["context" + claIdNum];
refreshClaList();
refreshSortables();
});
@@ -243,22 +247,21 @@ $(document).ready(function() {
});
// Evento: click sull'icona di trash del contesto
- $('.trashClaCont').on('click', function() {
- var claIdNum = $(this)[0].id.substring(12);
+ $('#rigaRicerca').on('click', '.trashClaCont', function() {
+ var claIdNum = $(this)[0].id.substring(15);
resetContext(claIdNum);
});
// Evento: click sull'icona di add del contesto
- $('.addClaCont').on('click', function() {
- var claIdNum = $(this).closest('.ui-selectable').attr('id').substr(10);
+ $('#rigaRicerca').on('click', '.addClaCont', function() {
+ var claIdNum = $(this).closest('.ui-selectable').attr('id').substr(13);
var selectedCanti = $(this).closest('.card').find('.ui-selected');
if (selectedCanti.length == 0) {
$(this).closest('.card').find('.ui-selectee').each(function() {
$(this).addClass( "ui-selected" );
- eval('window.context' + claIdNum + '[$(this).attr("id").substring(0,1)][$(this).attr("id").substring(2)] = 1');
+ window["context" + claIdNum][$(this).attr("id").substring(0,1)][$(this).attr("id").substring(2)] = 1;
});
};
- var context = window["context" + claIdNum];
parseContext(claIdNum);
hideContextCanti(claIdNum);
if ($(this).closest('.card').find('span:visible').length == 1) {
@@ -303,29 +306,6 @@ $(document).ready(function() {
e.preventDefault();
});
- // Evento: click sui bottoni Cerca
- /**
-
- $("form #searchcomm,#searchcomm2").on('click', function(e) {
- e.preventDefault();
- var qText = $("form #queryText")[0].value;
- if (qText == "" && logicExprString == "") {
- alert("Inserire un termine di ricerca od una clausola attiva!");
- return false;
- }
- const sparqlGenerator = sparqljs.Generator;
- jsonQuery = buildSQ(queryJson);
- //queryFields = [];
- //for (var i in jsonQuery.variables) {
- // queryFields.push(jsonQuery.variables[i].variable.value);
- //}
- console.log(jsonQuery);
- //execQuery = new sparqlGenerator().stringify(jsonQuery);
- //executeQuery();
- return false;
- });
- */
-
// Evento: click sul checkbox di Ricerca avanzata
$('#cla-TabContent').on('click', '#advanSW', function() {
if ($(this).prop('checked')) {
@@ -337,8 +317,9 @@ $(document).ready(function() {
//resetAdvGui();
}
});
-
- // Evento: click sul checkbox di Definisci contesto
+
+/**
+ // Evento: click sul checkbox di Definisci contesto NON UTILIZZATA
$('#cla-TabContent').on('click', '#contextSW', function() {
if ($(this).prop('checked')) {
$("#contextTableDiv0").attr('style', "display: flex;");
@@ -348,6 +329,7 @@ $(document).ready(function() {
//queryJson.QueryAvanzata = "0";
}
});
+ */
// Evento: click sul bottone di reset semplice
$('#cleanresult').on('click', function() {
@@ -524,24 +506,24 @@ $(document).ready(function() {
var condLIplaceholderPart1 = '
';
- // Variabili funzionali
+ // Variabili e costanti funzionali
var tabID = 0;
var claListLen = 0;
var condListLen = 0;
var logicExprString = ``;
var guiLogicString = ``;
- var execQuery = ``;
- var queryFields = []; // Contiene le intestazioni di colonna della tabella dei risultati
- var contextE = [[],[],[]];
- var jsonContext0 = JSON.stringify(contextE);
- window.context0 = [[],[],[]];
- var canticheList = ["Inferno","Purgatorio","Paradiso"];
+ const cc0 = new Array(34).fill(0);
+ const cc1 = new Array(33).fill(0);
+ const cc2 = new Array(33).fill(0);
+ const contextEmpty = [cc0,cc1,cc2];
+ const canticheList = ["Inferno","Purgatorio","Paradiso"];
var queryJson = JSON.parse('{"EsprLogica":"", "LogicaGui":"", "QueryAvanzata": "0"}');
+ const newGramJsonText = '{"queryText": "", "lemma_forma": "forma", "opzioni_testo": "parola", "TipoClausola": "Grammaticale", "Attiva": "1", "typeGramm0": "all"}';
+ const newSyntJsonText = '{"queryText": "", "lemma_forma": "forma", "opzioni_testo": "parola", "TipoClausola": "Sintattico", "Attiva": "1", "typeSyntax0": ".+", "functionSyntax": ".+"}';
queryJson.LiDaVersion = "1.0";
queryJson.Clausola0 = JSON.parse('{"queryText": "", "lemma_forma": "lemma", "opzioni_testo": "parola", "TipoClausola": "0", "Attiva": "0"}');
- queryJson.Clausola0.contesto = context0;
- queryJson.Clausola1 = JSON.parse('{"queryText": "", "lemma_forma": "lemma", "opzioni_testo": "parola", "TipoClausola": "0", "Attiva": "0"}');
- queryJson.Clausola1.contesto = context0;
+ queryJson.Clausola0.contesto = JSON.stringify(contextEmpty);
+ window.context0 = JSON.parse(JSON.stringify(contextEmpty));
const myEngine = new Comunica.QueryEngine();
const sparqlEndpoint = "https://hdnlab1.isti.cnr.it/fuseki/commediaontosintgra/query";
const jsonReplacer = (key, value) =>
@@ -553,6 +535,7 @@ $(document).ready(function() {
return queryJson;
}
+/**
async function executeQuery(){
$("#loader").show();
bindingsStream = await myEngine.queryBindings(execQuery, { sources: [ { type: 'sparql', value: sparqlEndpoint }, ], });
@@ -618,10 +601,10 @@ $(document).ready(function() {
$("#loader").hide();
};
};
+ */
// Funzione di creazione del tab delle clausole grammaticali
function addGramCla(active,tabID){
- window["context" + tabID] = [[],[],[]]; // ricordarsi il delete
if (active > 0) {
var checkInsert = ' checked="checked"';
} else {
@@ -630,18 +613,20 @@ $(document).ready(function() {
var sortableId = "#sortable0";
var claText = "Categoria grammaticale:
";
addLIitem(sortableId,tabID,claText,checkInsert);
- var clone = document.getElementById("tipogrammaticaleN").cloneNode(true);
- clone.setAttribute("id","cla" + tabID);
- clone.setAttribute("data-claActive", active);
- clone.setAttribute("aria-labelledby","cla" + tabID + "-tab");
- clone.setAttribute("style", "background-color: #edf9f3 !important;");
- //clone.removeAttribute("style");
- $('#claBody' + tabID).append(clone);
+ var claClone = document.getElementById("tipogrammaticaleN").cloneNode(true);
+ claClone.setAttribute("id","cla" + tabID);
+ claClone.setAttribute("data-claActive", active);
+ claClone.setAttribute("aria-labelledby","cla" + tabID + "-tab");
+ claClone.setAttribute("style", "background-color: #edf9f3 !important;");
+ $('#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);
+ queryJson["Clausola" + tabID] = JSON.parse(newGramJsonText);
+ addClaContext(tabID);
}
// Funzione di creazione delle subclausole grammaticali basate sul valore scelto
@@ -679,8 +664,8 @@ $(document).ready(function() {
input2.attr('value', vals[1]);
input1.attr('name', tabPaneId + keys[key]);
input2.attr('name', tabPaneId + keys[key]);
- label1.attr('class', 'custom-control-label form-control-sm custom-control-inline m-0 pl-1');
- label2.attr('class', 'custom-control-label form-control-sm custom-control-inline m-0 pl-1');
+ label1.attr('class', 'custom-control-label form-control-sm custom-control-inline m-0 pl-1 text-muted');
+ label2.attr('class', 'custom-control-label form-control-sm custom-control-inline m-0 pl-1 text-muted');
label1.attr('for', tabPaneId + vals[0].replace(/\s/g, ''));
label2.attr('for', tabPaneId + vals[1].replace(/\s/g, ''));
label1.append(vals[0]);
@@ -713,7 +698,7 @@ $(document).ready(function() {
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 form-control-sm custom-control-inline m-0 pl-1');
+ label1.attr('class', 'custom-control-label form-control-sm custom-control-inline m-0 pl-1 text-muted');
label1.attr('for', tabPaneId + vals[0].replace(/\s/g, ''));
label1.append(vals[0]);
@@ -760,16 +745,18 @@ $(document).ready(function() {
var sortableId = "#sortable0";
var claText = "Tipo sintattico:
";
addLIitem(sortableId,tabID,claText,checkInsert);
- var clone = document.getElementById("tiposintatticoN").cloneNode(true);
- clone.setAttribute("id","cla" + tabID);
- clone.setAttribute("data-claActive",active);
- clone.setAttribute("aria-labelledby","cla" + tabID + "-tab");
- clone.setAttribute("style", "background-color: #edf9f3 !important;");
- //clone.removeAttribute("style");
- $('#claBody' + tabID).append(clone);
+ var claClone = document.getElementById("tiposintatticoN").cloneNode(true);
+ claClone.setAttribute("id","cla" + tabID);
+ claClone.setAttribute("data-claActive",active);
+ claClone.setAttribute("aria-labelledby","cla" + tabID + "-tab");
+ claClone.setAttribute("style", "background-color: #edf9f3 !important;");
+ $('#claBody' + tabID).append(claClone);
$('#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);
+ queryJson["Clausola" + tabID] = JSON.parse(newSyntJsonText);
+ addClaContext(tabID);
}
// Funzione di creazione del tab delle clausole metafore
@@ -785,6 +772,24 @@ $(document).ready(function() {
addLIitem(sortableId,tabID,claText,checkInsert);
}
+ // Funzione di creazione della parte di definizione del contesto delle clausole
+ function addClaContext(tabID){
+ var contClone = document.getElementById("contextTable-xX0").cloneNode(true);
+ contClone.setAttribute("style", "background-color: #edf9f3 !important;");
+ contClone.setAttribute("class","row no-gutters px-2 pt-0 pb-2 border-top border-lida4");
+ contClone = contClone.outerHTML.replace(/xX0/g, "xX" + tabID)
+ $("#contextDiv" + tabID).append($(contClone)[0]);
+ resetContext(tabID);
+ $("#selectable-xX" + tabID).selectable({
+ filter: ".sel-canto",
+ selected: function(event, ui) {
+ window["context" + tabID][ui.selected.id.substring(0,1)][ui.selected.id.substring(2)] = 1;
+ var tmpFocusBtn = "#plusBtn" + ui.selected.id.substring(0,1) + "-xX" + tabID;
+ $(tmpFocusBtn).focus();
+ }
+ });
+ };
+
// Funzione di creazione del LI delle condizioni logiche
function addLogicCond(condtype,sortableId){
condListLen++;
@@ -836,6 +841,7 @@ $(document).ready(function() {
var claActive = 1
};
queryJson.Clausola0 = JSON.parse('{"queryText": "' + qText + '", "lemma_forma": "' + l_f + '", "opzioni_testo": "' + optText + '", "TipoClausola": "0", "Attiva": "' + claActive + '"}');
+ queryJson.Clausola0.contesto = JSON.stringify(window.context0);
var tabsContent = $("#sortable0").find(".claLI");
if ($(tabsContent).length) {
if ($("#li-cla0")[0]) {
@@ -935,6 +941,7 @@ $(document).ready(function() {
addLIitem(sortableId,claIdNum,claText,checkInsert);
};
queryJson["Clausola" + claIdNum] = JSON.parse(jsonTextToParse + '}');
+ queryJson["Clausola" + claIdNum].contesto = JSON.stringify(window["context" + claIdNum]);
};
// Funzione di refresh dei placeholders e attivazione/disattivazione bottoni nelle liste sortable
@@ -1018,7 +1025,6 @@ $(document).ready(function() {
});
logicExprString = parseCond("#sortable0", "AND", 0);
guiLogicString = parseCond("#sortable0", "AND", 1);
- //$("#sparqlquery").val(logicExprString);
queryJson.EsprLogica = logicExprString.split(' ');
queryJson.LogicaGui = guiLogicString.split(' ');
};
@@ -1085,12 +1091,13 @@ $(document).ready(function() {
};
function hideContextCanti(claIdNum) {
- $('#selectable' + claIdNum + " .ui-selected").each(function() {
+ $('#selectable-xX' + claIdNum + " .ui-selected").each(function() {
$(this).attr('style', "display: none;");
$(this).removeClass( "ui-selected" )
});
};
+/**
$.fn.copy2clipboard = function() {
$('div[id^="msgCopiati"]').remove();
this.select();
@@ -1099,6 +1106,7 @@ $(document).ready(function() {
document.getSelection().removeAllRanges();
$(this).after('Copiati nella clipboard
');
};
+ */
function makeUpGui(queryJson) {
//$("#risultatitesto").val(queryJson["LogicaGui"]);
@@ -1222,17 +1230,17 @@ $(document).ready(function() {
};
function resetContext(claIdNum) {
- $('#selectable' + claIdNum + " .ui-selectee").each(function() {
+ $('#selectable-xX' + claIdNum + " .ui-selectee").each(function() {
$(this).attr('style', "line-height: 1.2em");
});
- $('#selectable' + claIdNum + " .ui-selected").removeClass( "ui-selected" )
- $('#selectable' + claIdNum + ' .sel-canti-intro').each(function() {
+ $('#selectable-xX' + claIdNum + " .ui-selected").removeClass( "ui-selected" )
+ $('#selectable-xX' + claIdNum + ' .sel-canti-intro').each(function() {
$(this).text("Seleziona i canti:")
});;
- $("#contextText" + claIdNum).html("Tutta l'opera");
- window["context" + claIdNum] = [[],[],[]];
- eval("queryJson.Clausola" + claIdNum + ".contesto = jsonContext0");
- $('#selectable' + claIdNum + " .show").removeClass("show");
+ $("#contextText-xX" + claIdNum).html("Tutta l'opera");
+ window["context" + claIdNum] = JSON.parse(JSON.stringify(contextEmpty));
+ queryJson["Clausola" + claIdNum].contesto = JSON.stringify(window["context" + claIdNum]);
+ $('#selectable-xX' + claIdNum + " .show").removeClass("show");
};
function resetAdvGui() {
@@ -1242,6 +1250,7 @@ $(document).ready(function() {
$(tabsContent).each(function(){
claIdNum = $(this)[0].id.substring(3);
delete queryJson["Clausola" + claIdNum];
+ delete window["context" + claIdNum];
$(this).remove();
});
};
@@ -1254,7 +1263,7 @@ $(document).ready(function() {
function parseContext(claIdNum) {
var context = window["context" + claIdNum];
var jsonContext = JSON.stringify(context, jsonReplacer);
- eval("queryJson.Clausola" + claIdNum + ".contesto = jsonContext");
+ queryJson["Clausola" + claIdNum].contesto = jsonContext;
var contextStringParts = ["","",""];
var contextString = [];
var rangeHolderS = 0;
@@ -1295,15 +1304,12 @@ $(document).ready(function() {
contextString.push(contextStringParts[i]);
}
if (contextString.toString() != "") {
- $("#contextText" + claIdNum).html(contextString.toString());
+ $("#contextText-xX" + claIdNum).html(contextString.toString());
} else {
- $("#contextText" + claIdNum).html("Tutta l'opera");
+ $("#contextText-xX" + claIdNum).html("Tutta l'opera");
}
- //return contextString.toString();
};
};
-
});
-