Aggiunti bottoni carica/salva e menu' Unita' di ricerca

This commit is contained in:
Luca Trupiano 2023-01-20 15:15:24 +01:00
parent 3a02f19983
commit c51c98d8c3
2 changed files with 63 additions and 30 deletions

View File

@ -386,25 +386,29 @@
<button class="btn btn-sm btn-outline-lida4 bg-light mr-2" type="button"
id='cleanresult' aria-expanded="false"
aria-controls="collapseExample"><span class="text-muted">Reset</span></button>
<button class="btn btn-sm btn-outline-lida4 bg-light mr-2" type="button" id="showOptions"
<button class="btn btn-sm btn-outline-lida4 bg-light" type="button" id="showOptions"
data-toggle="collapse" data-target="#collapseOptions"
aria-expanded="false" aria-controls="collapseExample">
<span class="text-muted">Opzioni</span></button>
</div>
</div>
<div class="col-9 justify-content-end px-0"
<div class="col-12 justify-content-end px-0"
id="advancedSearchDiv" style="display: none">
<div class="btn-group" role="group" aria-label="Bottoni Ricerca Avanzata">
<button class="btn btn-sm btn-lida4 mr-2" type="submit"
<div class="btn-group d-sm-inline flex-nowrap p-0" role="group" aria-label="Bottoni Ricerca Avanzata">
<button class="btn btn-sm btn-lida4 mr-1" type="submit"
id='searchcomm2'><ion-icon name="search"></ion-icon></button>
<button class="btn btn-sm btn-outline-lida4 bg-light mr-2" type="button"
<button class="btn btn-sm btn-outline-lida4 bg-light mr-1" type="button"
id='cleanresult2' aria-expanded="false"
aria-controls="collapseExample"><span class="text-muted">Reset</span></button>
<button class="btn btn-sm btn-outline-lida4 bg-light mr-2" id="showLogic"
data-toggle="collapse" data-target="#collapseLogic"
aria-expanded="true" aria-controls="collapseLogic"><span class="font-weight-bold text-muted">Nascondi</span></button>
</div>
<div class="text-right pl-3 pt-1 d-sm-inline flex-nowrap align-text-bottom">
<span class="border border-lida4 rounded bg-light p-1 mb-1 align-text-bottom"><ion-icon name="save-outline"></ion-icon> <ion-icon name="folder-open-outline"></ion-icon>
<ion-icon name="cloud-upload-outline"></ion-icon> <ion-icon name="cloud-download-outline"></ion-icon></span>
</div>
</div>
</div>
@ -445,7 +449,7 @@
<h6 class="mb-0">
<div class="row no-gutters justify-content-between">
<div class="col-auto flex-fill align-self-center text-muted">
<button class="btn btn-sm btn-outline-lida4 bg-light btn-link border rounded py-0 my-1" id="cantica1-xX0"
<button class="btn btn-sm btn-outline-lida4 bg-light btn-link border rounded py-0 my-1 ml-1" id="cantica1-xX0"
data-toggle="collapse" data-target="#collapseCa1-xX0"
aria-expanded="true" aria-controls="collapseCa1-xX0"><span class="small text-lida4">Inferno</span></button>
</div>
@ -536,7 +540,7 @@
<h6 class="mb-0">
<div class="row no-gutters justify-content-between">
<div class="col-auto flex-fill align-self-center text-muted">
<button class="btn btn-sm btn-outline-lida4 bg-light btn-link border rounded py-0 my-1" id="cantica2-xX0"
<button class="btn btn-sm btn-outline-lida4 bg-light btn-link border rounded py-0 my-1 ml-1" id="cantica2-xX0"
data-toggle="collapse" data-target="#collapseCa2-xX0"
aria-expanded="true" aria-controls="collapseCa2-xX0"><span class="small text-lida4">Purgatorio</span></button>
</div>
@ -624,7 +628,7 @@
<h6 class="mb-0">
<div class="row no-gutters justify-content-between">
<div class="col-auto flex-fill align-self-center text-muted">
<button class="btn btn-sm btn-outline-lida4 bg-light btn-link border rounded py-0 my-1" id="cantica3-xX0"
<button class="btn btn-sm btn-outline-lida4 bg-light btn-link border rounded py-0 my-1 ml-1" id="cantica3-xX0"
data-toggle="collapse" data-target="#collapseCa3-xX0"
aria-expanded="true" aria-controls="collapseCa3-xX0"><span class="small text-lida4">Paradiso</span></button>
</div>
@ -739,7 +743,26 @@
<div class="col-12 p-0">
<div id="accordionSearch">
<div class="row card d-flex justify-content-end m-0">
<div class="row card d-flex justify-content-end bg-lida10 m-0">
<div class="col-7 justify-content-between d-sm-inline bg-lida10 px-2 pt-2 pb-0">
<div class="input-group input-group-sm px-1 pt-1">
<div class="input-group-prepend">
<label class="input-group-text border-right-0 border-lida4 pr-0"><ion-icon name="receipt-outline"></ion-icon></label>
<label class="input-group-text text-muted border-left-0 border-lida4" for="unitaRicerca">Unità di ricerca:</label>
</div>
<select class="custom-select text-muted bg-light border border-lida4 btn-outline-lida4 " id="unitaRicerca">
<option value="verso">Verso</option>
<option value="discorso">Discorso</option>
<option value="periodo">Periodo</option>
<option value="frase">Frase</option>
<option value="metafora">Metafora</option>
<option value="sintagma">Sintagma</option>
<option value="lemma">Lemma</option>
<option value="forme">Forma</option>
</select>
</div>
</div>
<div class="col-12 justify-content-between d-sm-inline bg-lida10 p-2">
<div class="col-12 p-0 pl-2">
<span class="small text-muted align-bottom pr-2">Aggiungi clausole o condizioni logiche: </span>

View File

@ -130,7 +130,11 @@ $(document).ready(function() {
$('#sparqlquery').copy2clipboard();
});
*/
$("#unitaRicerca").on('change', function() {
queryJson.unitaRicerca = $("#unitaRicerca")[0].options[$("#unitaRicerca")[0].selectedIndex].value;
});
// Evento: modifica di un campo clausole
$("form #lemma_forma,#queryText,#opzioni_testo").on('change', function() {
if ($(this)[0].id == "queryText"){
@ -273,7 +277,7 @@ $(document).ready(function() {
});
// Evento: click sull'icona di save local
$('#cla-TabContent').on('click', 'ion-icon[name="save-outline"]', function() {
$('#advancedSearchDiv').on('click', 'ion-icon[name="save-outline"]', function() {
var fileA = document.createElement("a");
fileA.href = window.URL.createObjectURL(new Blob([JSON.stringify(queryJson)], {type: "text/plain;charset=utf-8"}));
fileA.download = "LiDaQuery.txt";
@ -282,7 +286,7 @@ $(document).ready(function() {
});
// Evento: click sull'icona di load local
$('#cla-TabContent').on('click', 'ion-icon[name="folder-open-outline"]', function() {
$('#advancedSearchDiv').on('click', 'ion-icon[name="folder-open-outline"]', function() {
$('#apriFile').click();
});
@ -497,17 +501,20 @@ $(document).ready(function() {
// Variabili testuali per compattezza
var iconReset = '<div class="text-right text-lida4 radioReset"><ion-icon name="refresh-circle"></ion-icon></div>';
var iconCloseCond = '<div class="p-0 mr-3 mt-0 text-right text-lida4"><span class="iconClClass removeCond"><ion-icon name="close-circle"></ion-icon></span></div>';
var emptyClaList = '<li id="li-cla0" class="list-group-item align-items-center my-1 ui-state-default ui-state-disabled border text-muted bg-white ui-state-disabled-opacity-06 small">Nessuna clausola aggiunta.</li>';
var defaultCond = '<div id="cla-defaultCond" class="col-12 px-0 pb-1 small font-weight-bold text-muted">Clausole e condizioni in AND di default</div>';
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 = '<li id="placeholderSort';
var condLIplaceholderPart2 = '" class="mx-0 my-1 p-1 pl-3 list-group-item align-items-center border text-muted small bg-light ui-state-disabled ui-state-disabled-opacity-06">';
const iconReset = '<div class="text-right text-lida4 radioReset"><ion-icon name="refresh-circle"></ion-icon></div>';
const iconCloseCond = '<div class="p-0 mr-3 mt-0 text-right text-lida4"><span class="iconClClass removeCond"><ion-icon name="close-circle"></ion-icon></span></div>';
const emptyClaList = '<li id="li-cla0" class="list-group-item align-items-center my-1 ui-state-default ui-state-disabled border text-muted bg-white ui-state-disabled-opacity-06 small">Nessuna clausola aggiunta.</li>';
const defaultCond = '<div id="cla-defaultCond" class="col-12 px-0 pb-1 small font-weight-bold text-muted">Clausole e condizioni in AND di default</div>';
const canticheList = ["Inferno","Purgatorio","Paradiso"];
const cla0JsonText = '{"queryText": "", "lemma_forma": "lemma", "opzioni_testo": "parola", "TipoClausola": "0", "Attiva": "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": ".+"}';
const condLIplaceholderText1 = 'Trascina qui almeno 1 clausola o condizione';
const condLIplaceholderText2 = 'Trascina qui almeno 2 clausole o condizioni';
const condLIplaceholderText1d = 'Trascina qui almeno 1 clausola o condizione, oppure attiva le clausole inattive';
const condLIplaceholderText2d = 'Trascina qui almeno 2 clausole o condizioni, oppure attiva le clausole inattive';
const condLIplaceholderPart1 = '<li id="placeholderSort';
const condLIplaceholderPart2 = '" class="mx-0 my-1 p-1 pl-3 list-group-item align-items-center border text-muted small bg-light ui-state-disabled ui-state-disabled-opacity-06">';
// Variabili e costanti funzionali
var tabID = 0;
@ -519,16 +526,14 @@ $(document).ready(function() {
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.unitaRicerca = "verso";
queryJson.Clausola0 = JSON.parse(cla0JsonText);
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 myEngine = new Comunica.QueryEngine();
//const sparqlEndpoint = "https://hdnlab1.isti.cnr.it/fuseki/commediaontosintgra/query";
const jsonReplacer = (key, value) =>
typeof value === 'undefined' ? 0 : value;
@ -826,11 +831,14 @@ $(document).ready(function() {
function addLIitem(sortableId,tabID,claText,checkInsert){
claListLen++;
var cloneLI = document.getElementById("li-claxX1Xx").cloneNode(true);
cloneLI.removeAttribute("style");
cloneLI.setAttribute("style", "opacity: 0.1;");
cloneLI = cloneLI.outerHTML.replace(/xX1Xx/g, tabID)
cloneLI = cloneLI.replace(/xX2Xx/g, claText)
cloneLI = cloneLI.replace(/xX3Xx"/g, tabID + '" ' + checkInsert)
$(sortableId).append($(cloneLI)[0]);
$("#claCollapse" + tabID).focus();
$("#claCollapse" + tabID).trigger("click");
$("#li-cla" + tabID).fadeTo(1000,1);
};
// Funzione di refresh della lista clausole nella tab principale e del json della query
@ -845,6 +853,7 @@ $(document).ready(function() {
};
queryJson.Clausola0 = JSON.parse('{"queryText": "' + qText + '", "lemma_forma": "' + l_f + '", "opzioni_testo": "' + optText + '", "TipoClausola": "0", "Attiva": "' + claActive + '"}');
queryJson.Clausola0.contesto = JSON.stringify(window.context0);
queryJson.unitaRicerca = $("#unitaRicerca")[0].options[$("#unitaRicerca")[0].selectedIndex].value;
var tabsContent = $("#sortable0").find(".claLI");
if ($(tabsContent).length) {
if ($("#li-cla0")[0]) {
@ -1116,6 +1125,7 @@ $(document).ready(function() {
// -------------------
// Pulizia ricerca avanzata:
resetAdvGui();
console.log(queryJson);
// Imposta checkbox:
if (queryJson["QueryAvanzata"] == 1) {
$("#cla-Advanced").attr('style', "display: block;");