2023-01-12 17:09:58 +01:00
/ * *
*
* /
/ * n e c e s s a r i p e r i l b u n d l e :
import "./jquery-global.js" ;
require ( "../node_modules/jquery-ui-dist/jquery-ui.js" ) ;
require ( "../node_modules/bootstrap/dist/js/bootstrap.bundle.min.js" ) ;
* /
var getJsonQuery ;
$ ( document ) . ready ( function ( ) {
$ ( "#dropAdvanced" ) . on ( 'click' , function ( ) {
queryJson . QueryAvanzata = "1" ;
$ ( "#simpleSearchDiv" ) . removeClass ( "d-flex" )
$ ( "#simpleSearchDiv" ) . attr ( 'style' , "display: none;" ) ;
$ ( "#collapseOptions" ) . collapse ( 'hide' ) ;
$ ( "#collapseAdvanced" ) . collapse ( 'show' ) ;
$ ( "#advancedSearchDiv" ) . addClass ( "d-flex" )
$ ( "#advancedSearchDiv" ) . attr ( 'style' , "display: flex;" ) ;
} ) ;
$ ( "#dropSimple" ) . on ( 'click' , function ( ) {
queryJson . QueryAvanzata = "0" ;
$ ( "#advancedSearchDiv" ) . removeClass ( "d-flex" )
$ ( "#advancedSearchDiv" ) . attr ( 'style' , "display: none;" ) ;
$ ( "#simpleSearchDiv" ) . addClass ( "d-flex" )
$ ( "#simpleSearchDiv" ) . attr ( 'style' , "display: flex;" ) ;
$ ( "#collapseAdvanced" ) . collapse ( 'hide' ) ;
} ) ;
2023-01-18 18:59:45 +01:00
/ * *
2023-01-12 17:09:58 +01:00
$ ( "#copiaTesto" ) . prop ( "disabled" , true ) ;
// Evento: click sul bottone di copia dei risultati testuali
$ ( "#copiaTesto" ) . on ( "click" , function ( ) {
$ ( "#risultatitesto" ) . copy2clipboard ( ) ;
} ) ;
$ ( "#copiaQuery" ) . prop ( "disabled" , true ) ;
2023-01-18 18:59:45 +01:00
* /
2023-01-12 17:09:58 +01:00
// Funzioni di gestione del comportamento dei bottoni collapse
$ ( '#collapseLogic' ) . on ( 'hidden.bs.collapse' , function ( e ) {
if ( e . target . id == "collapseLogic" ) {
$ ( "#showLogic" ) . html ( '<span class="text-muted">Mostra</span>' ) ;
$ ( "#collapseAdvanced" ) . collapse ( 'hide' ) ;
} ;
} )
$ ( '#collapseLogic' ) . on ( 'shown.bs.collapse' , function ( ) {
$ ( "#showLogic" ) . html ( '<span class="font-weight-bold text-muted">Nascondi</span>' ) ;
$ ( "#collapseAdvanced" ) . collapse ( 'show' ) ;
} )
$ ( '#collapseOptions' ) . on ( 'hidden.bs.collapse' , function ( e ) {
if ( e . target . id == "collapseOptions" ) {
$ ( "#showOptions" ) . html ( '<span class="text-muted">Opzioni</span>' ) ;
} ;
} )
$ ( '#collapseOptions' ) . on ( 'shown.bs.collapse' , function ( ) {
$ ( "#showOptions" ) . html ( '<span class="font-weight-bold text-muted">Opzioni</span>' ) ;
} )
$ ( '.collapse' ) . on ( 'hide.bs.collapse' , function ( e ) {
2023-01-18 18:59:45 +01:00
if ( e . target . id . substr ( 0 , 11 ) == "collapseCla" ) {
var claIdNum = e . target . id . substr ( 11 ) ;
2023-01-12 17:09:58 +01:00
$ ( "#claCollapse" + claIdNum ) [ 0 ] . removeAttribute ( "style" ) ;
$ ( "#claCollapse" + claIdNum ) . removeClass ( "border-bottom-0" ) ;
$ ( "#claCollapse" + claIdNum ) . addClass ( "border border-lida4" ) ;
e . stopPropagation ( ) ;
} ;
} )
$ ( '.collapse' ) . on ( 'show.bs.collapse' , function ( e ) {
2023-01-18 18:59:45 +01:00
if ( e . target . id . substr ( 0 , 11 ) == "collapseCla" ) {
var claIdNum = e . target . id . substr ( 11 ) ;
2023-01-12 17:09:58 +01:00
$ ( "#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" ) ;
e . stopPropagation ( ) ;
} ;
} )
2023-01-18 18:59:45 +01:00
// Evento: click sullo switch di ricerca avanzata
2023-01-12 17:09:58 +01:00
$ ( '#searchToggle' ) . on ( 'change' , function ( ) {
if ( $ ( this ) . prop ( 'checked' ) ) {
queryJson . QueryAvanzata = "1" ;
$ ( "#simpleSearchDiv" ) . removeClass ( "d-flex" )
$ ( "#simpleSearchDiv" ) . attr ( 'style' , "display: none;" ) ;
$ ( "#collapseOptions" ) . collapse ( 'hide' ) ;
$ ( "#advancedSearchDiv" ) . addClass ( "d-flex" )
$ ( "#advancedSearchDiv" ) . attr ( 'style' , "display: flex;" ) ;
$ ( "#collapseAdvanced" ) . collapse ( 'show' ) ;
$ ( "#collapseLogic" ) . collapse ( 'show' ) ;
} else {
queryJson . QueryAvanzata = "0" ;
$ ( "#collapseAdvanced" ) . collapse ( 'hide' ) ;
$ ( "#advancedSearchDiv" ) . removeClass ( "d-flex" )
$ ( "#advancedSearchDiv" ) . attr ( 'style' , "display: none;" ) ;
$ ( "#simpleSearchDiv" ) . addClass ( "d-flex" )
$ ( "#simpleSearchDiv" ) . attr ( 'style' , "display: flex;" ) ;
} ;
} ) ;
// Inizializza sortable
$ ( "#sortable0" ) . sortable ( {
items : "> li" ,
handle : ".handle"
} ) ;
2023-01-18 18:59:45 +01:00
// Inizializza selectable-xX0 e definisce le funzioni
$ ( "#selectable-xX0" ) . selectable ( {
2023-01-12 17:09:58 +01:00
filter : ".sel-canto" ,
selected : function ( event , ui ) {
window . context0 [ ui . selected . id . substring ( 0 , 1 ) ] [ ui . selected . id . substring ( 2 ) ] = 1 ;
2023-01-18 18:59:45 +01:00
var tmpFocusBtn = "#plusBtn" + ui . selected . id . substring ( 0 , 1 ) + "-xX" + tabID ;
2023-01-12 17:09:58 +01:00
$ ( tmpFocusBtn ) . focus ( ) ;
}
} ) ;
2023-01-18 18:59:45 +01:00
/ * *
2023-01-12 17:09:58 +01:00
// Evento: click sul bottone di copia della query
$ ( "#copiaQuery" ) . on ( "click" , function ( ) {
$ ( '#sparqlquery' ) . copy2clipboard ( ) ;
} ) ;
2023-01-18 18:59:45 +01:00
* /
2023-01-12 17:09:58 +01:00
// Evento: modifica di un campo clausole
$ ( "form #lemma_forma,#queryText,#opzioni_testo" ) . on ( 'change' , function ( ) {
2023-01-13 16:49:40 +01:00
if ( $ ( this ) [ 0 ] . id == "queryText" ) {
var orgSelection = $ ( '#lemma_forma option:selected' ) [ 0 ] . value
var qText = $ ( this ) [ 0 ] . value ;
if ( qText !== null && qText !== '' ) { qText = ' "' + qText + '"' ; }
setLemmaForma ( qText , orgSelection ) ;
} ;
2023-01-12 17:09:58 +01:00
refreshClaList ( ) ;
} ) ;
$ ( '#cla-TabContent' ) . on ( 'change' , '.monMe' , function ( ) {
refreshClaList ( ) ;
} ) ;
// Evento: click sull'icona rimuovi clausola
$ ( '#cla-TabContent' ) . on ( 'click' , '.removeCla' , function ( ) {
var claListItemId = $ ( this ) . closest ( 'li' ) . attr ( 'id' ) ;
var claIdNum = claListItemId . substr ( 6 ) ;
claListLen -- ;
$ ( "#" + claListItemId ) [ 0 ] . remove ( ) ;
delete queryJson [ "Clausola" + claIdNum ] ;
2023-01-18 18:59:45 +01:00
delete window [ "context" + claIdNum ] ;
2023-01-12 17:09:58 +01:00
refreshClaList ( ) ;
refreshSortables ( ) ;
} ) ;
// Evento: click sull'icona rimuovi condizione
$ ( '#sortable0' ) . on ( 'click' , '.removeCond' , function ( ) {
$ ( this ) . closest ( 'ul' ) . parent ( ) . remove ( ) ;
condListLen -- ;
refreshClaList ( ) ;
refreshSortables ( ) ;
refreshConnectWith ( ) ;
if ( claListLen == 0 && condListLen == 0 ) {
$ ( '#sortable0' ) . html ( emptyClaList ) ;
}
} ) ;
// Evento: click sulla lista di clausole nel dropbox "Aggiungi clausola di tipo:" o "aggiungi condizione logica:"
$ ( '.addCCbtn' ) . on ( 'click' , function ( ) {
var addCC = $ ( this ) . attr ( 'id' ) ;
switch ( addCC ) {
case "btnAddCla1" :
tabID ++ ;
addGramCla ( 1 , tabID ) ;
break ;
case "btnAddCla2" :
tabID ++ ;
addSyntCla ( 1 , tabID ) ;
break ;
case "btnAddCla3" :
tabID ++ ;
addMetaCla ( 0 , tabID ) ;
break ;
case "btnAddCond" :
addLogicCond ( "OR" , "#sortable0" ) ;
break ;
default :
} ;
refreshClaList ( ) ;
refreshSortables ( ) ;
} ) ;
// Evento: clausola spostata nella lista
$ ( '#sortable0' ) . sortable ( {
opacity : 0.6 ,
cursor : 'move' ,
update : function ( ) {
refreshClaList ( ) ;
refreshSortables ( ) ;
}
} ) ;
// Evento: cambiato il tipo della condizione logica
$ ( '#cla-TabContent' ) . on ( 'change' , '.condType' , function ( ) {
var condtype = $ ( this ) . val ( ) ;
var condId = $ ( this ) . attr ( 'id' ) . substring ( 12 ) ;
if ( condtype == "AND" ) {
$ ( "#cond" + condId ) . removeClass ( "condLI-OR bg-lida11" )
2023-01-13 16:49:40 +01:00
$ ( "#cond" + condId ) . addClass ( "condLI-AND bg-lida10g" )
2023-01-12 17:09:58 +01:00
$ ( this ) . removeClass ( "bg-lida11" )
2023-01-13 16:49:40 +01:00
$ ( this ) . addClass ( "bg-lida10g" )
2023-01-12 17:09:58 +01:00
} else {
2023-01-13 16:49:40 +01:00
$ ( "#cond" + condId ) . removeClass ( "condLI-AND bg-lida10g" )
2023-01-12 17:09:58 +01:00
$ ( "#cond" + condId ) . addClass ( "condLI-OR bg-lida11" )
2023-01-13 16:49:40 +01:00
$ ( this ) . removeClass ( "bg-lida10g" )
2023-01-12 17:09:58 +01:00
$ ( this ) . addClass ( "bg-lida11" )
} ;
refreshClaList ( ) ;
} ) ;
// Evento: click sul bottone di edit delle clausole
$ ( '#cla-TabContent' ) . on ( 'click' , '.claAct' , function ( ) {
var claListItemId = $ ( this ) . closest ( 'li' ) . attr ( 'id' ) ;
var tabPanelId = "#" + claListItemId . substring ( 3 ) ;
if ( $ ( this ) . prop ( 'checked' ) ) {
$ ( tabPanelId ) . attr ( "data-claActive" , 1 ) ;
$ ( this ) . closest ( 'li' ) . find ( '.clatext' ) . fadeTo ( "slow" , 1 ) ;
} else {
$ ( tabPanelId ) . attr ( "data-claActive" , 0 ) ;
$ ( this ) . closest ( 'li' ) . find ( '.clatext' ) . fadeTo ( "slow" , 0.6 ) ;
}
refreshSortables ( ) ;
} ) ;
// Evento: click sull'icona di refresh dei radio button
$ ( '#cla-TabContent' ) . on ( 'click' , '.radioReset' , function ( ) {
fSet = $ ( this ) . siblings ( 'fieldset' ) ;
if ( fSet . find ( ":checked" ) . length ) {
radioChecked = fSet . find ( ":checked" ) [ 0 ] ;
radioChecked . checked = false ;
} ;
refreshClaList ( ) ;
} ) ;
// Evento: click sull'icona di trash del contesto
2023-01-18 18:59:45 +01:00
$ ( '#rigaRicerca' ) . on ( 'click' , '.trashClaCont' , function ( ) {
var claIdNum = $ ( this ) [ 0 ] . id . substring ( 15 ) ;
2023-01-13 16:49:40 +01:00
resetContext ( claIdNum ) ;
2023-01-12 17:09:58 +01:00
} ) ;
// Evento: click sull'icona di add del contesto
2023-01-18 18:59:45 +01:00
$ ( '#rigaRicerca' ) . on ( 'click' , '.addClaCont' , function ( ) {
var claIdNum = $ ( this ) . closest ( '.ui-selectable' ) . attr ( 'id' ) . substr ( 13 ) ;
2023-01-12 17:09:58 +01:00
var selectedCanti = $ ( this ) . closest ( '.card' ) . find ( '.ui-selected' ) ;
if ( selectedCanti . length == 0 ) {
$ ( this ) . closest ( '.card' ) . find ( '.ui-selectee' ) . each ( function ( ) {
$ ( this ) . addClass ( "ui-selected" ) ;
2023-01-18 18:59:45 +01:00
window [ "context" + claIdNum ] [ $ ( this ) . attr ( "id" ) . substring ( 0 , 1 ) ] [ $ ( this ) . attr ( "id" ) . substring ( 2 ) ] = 1 ;
2023-01-12 17:09:58 +01:00
} ) ;
} ;
parseContext ( claIdNum ) ;
hideContextCanti ( claIdNum ) ;
if ( $ ( this ) . closest ( '.card' ) . find ( 'span:visible' ) . length == 1 ) {
$ ( this ) . closest ( '.card' ) . find ( 'div .sel-canti-intro' ) . text ( "Selezionati tutti i canti." ) ;
} ;
} ) ;
// Evento: click sull'icona di save local
$ ( '#cla-TabContent' ) . 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" ;
fileA . click ( ) ;
fileA . remove ( ) ;
} ) ;
// Evento: click sull'icona di load local
$ ( '#cla-TabContent' ) . on ( 'click' , 'ion-icon[name="folder-open-outline"]' , function ( ) {
$ ( '#apriFile' ) . click ( ) ;
} ) ;
$ ( "#apriFile" ) . on ( 'change' , function ( ) {
var file = $ ( this ) . prop ( 'files' ) [ 0 ] ;
var reader = new FileReader ( ) ;
reader . onload = function ( data ) {
queryJson = JSON . parse ( data . target . result )
makeUpGui ( queryJson ) ;
} ;
if ( file ) { reader . readAsText ( file ) ; }
} ) ;
// Evento: SCELTA CATEGORIA GRAMMATICALE
$ ( '#cla-TabContent' ) . on ( 'change' , 'select.catgram' , function ( e ) {
e . preventDefault ( ) ;
var tabPaneId = ( $ ( this ) . closest ( '.tab-pane' ) . attr ( "id" ) ) ;
var selectedValue = $ ( this ) . val ( ) ;
addCatgramSubcla ( tabPaneId , selectedValue ) ;
} ) ;
// Evento: Submit form
$ ( "form" ) . submit ( function ( e ) {
e . preventDefault ( ) ;
} ) ;
// Evento: click sul checkbox di Ricerca avanzata
$ ( '#cla-TabContent' ) . on ( 'click' , '#advanSW' , function ( ) {
if ( $ ( this ) . prop ( 'checked' ) ) {
$ ( "#cla-Advanced" ) . attr ( 'style' , "display: block;" ) ;
queryJson . QueryAvanzata = "1" ;
} else {
$ ( "#cla-Advanced" ) . attr ( 'style' , "display: none;" ) ;
queryJson . QueryAvanzata = "0" ;
//resetAdvGui();
}
} ) ;
2023-01-18 18:59:45 +01:00
/ * *
// Evento: click sul checkbox di Definisci contesto NON UTILIZZATA
2023-01-12 17:09:58 +01:00
$ ( '#cla-TabContent' ) . on ( 'click' , '#contextSW' , function ( ) {
if ( $ ( this ) . prop ( 'checked' ) ) {
$ ( "#contextTableDiv0" ) . attr ( 'style' , "display: flex;" ) ;
//queryJson.QueryAvanzata = "1";
} else {
$ ( "#contextTableDiv0" ) . attr ( 'style' , "display: none;" ) ;
//queryJson.QueryAvanzata = "0";
}
} ) ;
2023-01-18 18:59:45 +01:00
* /
2023-01-12 17:09:58 +01:00
2023-01-13 16:49:40 +01:00
// Evento: click sul bottone di reset semplice
$ ( '#cleanresult' ) . on ( 'click' , function ( ) {
resetResult ( ) ;
resetSimpleGui ( ) ;
refreshClaList ( ) ;
} ) ;
2023-01-12 17:09:58 +01:00
// Evento: click sul bottone di reset azanzata
$ ( '#cleanresult2' ) . on ( 'click' , function ( ) {
2023-01-13 16:49:40 +01:00
resetResult ( ) ;
2023-01-12 17:09:58 +01:00
resetAdvGui ( ) ;
refreshClaList ( ) ;
} ) ;
2023-01-13 16:49:40 +01:00
2023-01-12 17:09:58 +01:00
// Variabili JSON per i filtri
var verboJson = {
"filtriverbo" : {
"Diatesi" : [ "Attivo" , "Passivo" ] ,
"Transitivita" : [ "Transitivo" , "Intransitivo" ] ,
"Genere" : [ "Femminile" , "Maschile" ] ,
"Numero" : [ "Singolare" , "Plurale" ] ,
"Pers" : [ "Impersonale" ] ,
"Rifl" : [ "Riflessivo" ] ,
"Coniugazione" : [ "Qualsiasi coniugazione" , "Prima coniugazione" , "Seconda coniugazione" , "Terza coniugazione" , "Essere coniugazione" , "Avere coniugazione" ] ,
"Tempi" : [ "Qualsiasi tempo verbale" , "Indicativo presente" , "Indicativo passato prossimo" , "Indicativo imperfetto" , "Indicativo passato remoto" ,
"Indicativo trapassato prossimo" , "Indicativo trapassato remoto" , "Indicativo futuro semplice" , "Indicativo futuro anteriore" , "Congiuntivo presente" ,
"Congiuntivo imperfetto" , "Congiuntivo passato" , "Congiuntivo trapassato" , "Condizionale presente" , "Condizionale passato" , "Imperativo presente" ,
"Infinito presente" , "Infinito passato" , "Participio presente" , "Participio passato" , "Gerundio presente" , "Gerundio passato" ] ,
"Persona" : [ "Qualsiasi persona" , "1ª persona singolare" , "2ª persona singolare" , "3ª persona singolare" , "1ª persona plurale" , "2ª persona plurale" , "3ª persona plurale" ] ,
"Funzione" : [ "Tutte le funzioni" , "Aggettivo" , "Sostantivo maschile" , "Sostantivo femminile" ] ,
"Declinazione" : [ "Tutte le declinazioni" , "Prima declinazione" , "Seconda declinazione" , "Terza declinazione" ] ,
}
}
var sostantivoJson = {
"filtrisostantivo" : {
"Numero" : [ "Singolare" , "Plurale" ] ,
"Genere_lemma" : [ "Lemma femminile" , "Lemma maschile" ] ,
"Genere_forma" : [ "Forma femminile" , "Forma maschile" ] ,
"riflpers" : [ "In locuzione" ] ,
"Declinazione_sostantivo" : [ "Tutte le declinazioni" , "Prima declinazione" , "Seconda declinazione" , "Terza declinazione" ] ,
}
}
var aggettivoJson = {
"filtriaggettivo" : {
"Classe" : [ "1ª" , "2ª" ] ,
"Genere" : [ "Femminile" , "Maschile" ] ,
"Numero" : [ "Singolare" , "Plurale" ] ,
"Con_oggetto_indiretto" : [ "Con oggetto indiretto" ] ,
"Tipo_aggettivo" : [ "Qualsiasi tipo aggettivo" , "Qualificativo" , "Indefinito" , "Interrogativo" , "Esclamativo" , "Numerale" , "Dimostrativo" , "Relativo" , "Possessivo" , "In locuzione" ] ,
"Grado" : [ "Qualsiasi grado" , "Comparativo di maggioranza" , "Comparativo di minoranza" , "Comparativo di uguaglianza" , "Superlativo relativo" , "Superlativo assoluto" ] ,
"Tipo_di_Complemento" : [ "Qualsiasi tipo di Complemento" , "Introdotto da A" , "Introdotto da CON" , "Introdotto da CONTRO" , "Introdotto da DA" , "Introdotto da DI" , "Introdotto da IN" ,
"Introdotto da PER" , "Introdotto da SU" , "Introdotto da TRA" , "Introdotto da VERSO" , "Introdotto da SOPRA" ,
"Introdotto da SOTTO" , "Introdotto da DINANZI" , "Introdotto da prep." , "Oggetto ind." , "Ogg. indi. + compl. con DI" , "Ogg. ind. pronom." ] ,
"Tipo_di_frase" : [ "Qualsiasi tipo di frase" , "Con infinito retto da A" , "Con infinito retto da DA" , "Con infinito retto da DI" , "Con infinito retto da PER" ,
"Con infinito retto da SE" , "Con subordinata all'indic." , "Con subordinata al cong." , "In locuzione imp.+infinito" ,
"In locuzione imp.+che+indic." , "In locuzione imp.+che+cong." , "In locuzione imp.+se+indic." , "In locuzione imp.+se+cong." ,
"In locuzione imp.+come+indic." , "In locuzione imp.+quando+indic." , "In locuzione imp.+perché+cong." , "In locuzione imp.+a+infinito" ]
}
}
var pronomeJson = {
"filtripronome" : {
"Genere" : [ "Femminile" , "Maschile" ] ,
"Numero" : [ "Singolare" , "Plurale" ] ,
"Classe_Persona" : [ "Qualsiasi Classe Persona" , "1ª" , "2ª" , "3ª" ] ,
"Tipo" : [ "Qualsiasi tipo" , "Personale" , "Riflessivo" , "Interrogativo" , "Esclamativo" , "Dimostrativo" , "Relativo" , "Possessivo" ] ,
"Forma_Personali_Riflessivi" : [ "Qualsiasi forma (Personali-Riflessivi)" , "Libero" , "Libero in Composizione" , "Proclitico" , "Enclitico" ] ,
"Funzione_Personali" : [ "Qualsiasi funzione (Personali)" , "Libero - soggetto" , "Libero - soggetto impersonale" , "Libero - complemento" , "Libero - rafforzativo" ,
"Clitico - accusativo" , "Clitico - dativo" , "Clitico - partitivo" ] ,
"Tipo_Riflessivi" : [ "Qualsiasi tipo (Riflessivi)" , "Proprio" , "Lessicalizzato" , "Impersonale" , "Passivo" , "Reciproco" ]
}
}
var articoloJson = {
"filtriarticolo" : {
"Genere" : [ "Femminile" , "Maschile" ] ,
"Numero" : [ "Singolare" , "Plurale" ] ,
"Tipo" : [ "Determinativo" , "Indeterminativo" ]
}
}
var avverbioJson = {
"filtriavverbio" : {
"Tipo" : [ "Qualsiasi tipo" , "Al comparativo di maggioranza" , "Al comparativo di minoranza" ,
"Al superlativo assoluto" , "Al superlativo relativo" ,
"In Locuzione" , "In Locuzione separato" , "Proclitico" , "Enclitico" ]
}
}
var preposizioneJson = {
"filtripreposizione" : {
"Tipo_I" : [ "Propria" , "Impropria" ] ,
"Tipo_preposizione" : [ "Qualsiasi tipo preposizione" , "Semplice" , "Articolata" , "In locuzione" , "In locuzione separata" ] ,
"Sintassi" : [ "Qualsiasi sintassi" , "Soggettiva" , "Oggettiva" , "Dichiarativa" , "Completiva obliqua" , "Finale" ,
"Causale" , "Concessiva" , "Consecutiva" , "Temporale" , "Modale" , "Eccettuativa" , "Esclusiva" ,
"Limitativa" , "Comparativa" , "Avversativa" ] ,
"Complemento_(I)" : [ "Qualsiasi complemento (I)" , "Di stato in luogo" , "Di moto a luogo" , "Di moto da luogo" , "Di moto per luogo" ,
"Di luogo" , "Predicativo del soggetto" , "Predicativo dell'oggetto" , "Di distanza" ,
"Di tempo determinato" , "Di tempo continuato" , "Di tempo" , "Di termine" , "Di vantaggio" ,
"Di svantaggio" , "Di specificazione" , "Di modo" , "Di mezzo" , "Di compagnia" ,
"Di unione" , "Di allontanamento-separazione" , "Di materia" ] ,
"Complemento_(II)" : [ "Qualsiasi complemento (II)" , "Di limitazione" , "Di qualità" , "Di causa" , "Di agente" , "Di causa efficiente" , "Di fine o scopo" ,
"Di paragone" , "Di argomento" , "Distributivo" , "Di sostituzione" , "Di estensione" , "Di rapporto" ,
"Di esclusione" , "Di peso" , "Di quantità" , "Di colpa" , "Di denominazione" , "partitivo" ,
"Di abbondanza-privazione" , "Di origine-provenienza" , "Concessivo" , "Di effetto" , "Di pena" ,
"Simmetrico" , "Indiretto esperiente" , "Indiretto dativo" , "Indiretto oggetto" , "Indiretto possessore" ,
"Indiretto benefattivo" ]
}
}
var congiunzioneJson = {
"filtricongiunzione" : {
"Coo_sub" : [ "Coordinativa" , "Subordinativa" ] ,
"Tipo" : [ "Qualsiasi tipo" , "Semplice" , "Composta" , "Locuzione" , "Locuzione separata" ] ,
"Coord_tipo" : [ "Qualsiasi coord. tipo" , "Copulativa" , "Disgiuntiva" , "Avversativa" , "Esplicativa" , "Conclusiva" , "Correlativa" ] ,
"Subord_tipo" : [ "Qualsiasi subord. tipo" , "Soggettiva" , "Oggettiva" , "Dichiarativa" , "Completiva obliqua" , "Interrogativa" ,
"Finali" , "Causali" , "Concessiva" , "Consecutiva" , "Temporale" , "Modale" ,
"Eccettuativa" , "Comparativa" , "Condizionale" , "Esclusiva" , "Limitativa" ]
}
}
var onomasticacitazioneJson = {
"filtrionomastica" : {
"Tipo" : [ "Qualsiasi tipo" , "Nome proprio" , "Nome proprio separato" , "Titolo" ]
} ,
"filtricitazione" : {
"Tipo" : [ "Qualsiasi tipo" , "Latina" , "Provenzale" , "Francese" , "Spagnola" , "Ebraica" , "Greca" ]
}
}
var categorie = {
"verbovolgare" : "filtriverbo" ,
"sostantivovolgare" : "filtrisostantivo" ,
"pronomevolgare" : "filtripronome" ,
"aggettivovolgare" : "filtriaggettivo" ,
"articolovolgare" : "filtriarticolo" ,
"avverbiovolgare" : "filtriavverbio" ,
"preposizionevolgare" : "filtripreposizione" ,
"congiunzionevolgare" : "filtricongiunzione" ,
"onomasticavolgare" : "filtrionomastica" ,
"citazionevolgare" : "filtricitazione"
}
var catGrammsenzaspec = [ 'all' , 'interiezionevolgare' ]
var subordinazioneJson = {
"subordinazione" : {
"livello" : [ "Qualsiasi livello di subordinazione" , "principale" , "coordinata a una principale" , "subordinata di I grado" ,
"subordinata di II grado" , "subordinata di III grado" , "subordinata di IV grado" , "subordinata di V grado" ,
"subordinata di VI grado" , "subordinata di VII grado" , "coordinata a una subordinata di I grado" ,
"coordinata a una subordinata di II grado" , "coordinata a una subordinata di III grado" ,
"coordinata a una subordinata di IV grado" , "coordinata a una subordinata di V grado" , "pseudo-coordinata" ,
"parentetica" , "coordinata a una parentetica" ]
}
}
var categorieJson = $ . extend ( { } , verboJson , sostantivoJson , pronomeJson , aggettivoJson , articoloJson , avverbioJson , preposizioneJson , congiunzioneJson , onomasticacitazioneJson ) ;
// Variabili testuali per compattezza
var iconReset = '<div class="text-right text-lida4 radioReset"><ion-icon name="refresh-circle"></ion-icon></div>' ;
2023-01-13 16:49:40 +01:00
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>' ;
2023-01-12 17:09:58 +01:00
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">' ;
2023-01-18 18:59:45 +01:00
// Variabili e costanti funzionali
2023-01-12 17:09:58 +01:00
var tabID = 0 ;
var claListLen = 0 ;
var condListLen = 0 ;
var logicExprString = ` ` ;
var guiLogicString = ` ` ;
2023-01-18 18:59:45 +01:00
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" ] ;
2023-01-12 17:09:58 +01:00
var queryJson = JSON . parse ( '{"EsprLogica":"", "LogicaGui":"", "QueryAvanzata": "0"}' ) ;
2023-01-18 18:59:45 +01:00
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": ".+"}' ;
2023-01-12 17:09:58 +01:00
queryJson . LiDaVersion = "1.0" ;
queryJson . Clausola0 = JSON . parse ( '{"queryText": "", "lemma_forma": "lemma", "opzioni_testo": "parola", "TipoClausola": "0", "Attiva": "0"}' ) ;
2023-01-18 18:59:45 +01:00
queryJson . Clausola0 . contesto = JSON . stringify ( contextEmpty ) ;
window . context0 = JSON . parse ( JSON . stringify ( contextEmpty ) ) ;
2023-01-12 17:09:58 +01:00
const myEngine = new Comunica . QueryEngine ( ) ;
const sparqlEndpoint = "https://hdnlab1.isti.cnr.it/fuseki/commediaontosintgra/query" ;
const jsonReplacer = ( key , value ) =>
typeof value === 'undefined' ? 0 : value ;
// Fine variabili
getJsonQuery = function ( ) {
return queryJson ;
}
2023-01-18 18:59:45 +01:00
/ * *
2023-01-12 17:09:58 +01:00
async function executeQuery ( ) {
$ ( "#loader" ) . show ( ) ;
bindingsStream = await myEngine . queryBindings ( execQuery , { sources : [ { type : 'sparql' , value : sparqlEndpoint } , ] , } ) ;
$ ( "#sparqlquery" ) . val ( execQuery ) ;
$ ( "#copiaQuery" ) . prop ( "disabled" , false ) ;
var resultTablePart1 = '<table id="resultTable" class="table table-striped table-bordered"><thead><tr>' ;
var resultTablePart2 = '<th scope="col">#</th>' ;
var resultTablePart3 = '</tr></thead><tbody>' ;
var resultTablePart4 = '' ;
var resultTablePart5 = '</tbody></table>' ;
var resultTable = '' ;
var latestVerso = '' ;
var latestResult = '' ;
var rowNum = 1 ;
for ( var i = 0 ; i < queryFields . length ; i ++ ) {
resultTablePart2 = resultTablePart2 + '<th scope="col">' + queryFields [ i ] + '</th>' ;
} ;
var resultTable = resultTablePart1 + resultTablePart2 + resultTablePart3 ;
$ ( '#resultsId1' ) . empty ( ) ;
$ ( '#resultsId1' ) . addClass ( "small pb-2" )
$ ( "#risultatitesto" ) . empty ( ) ;
try {
bindingsStream . on ( 'data' , ( binding ) => {
//console.log(binding.toString()); // Quick way to print bindings for testing
//console.log(binding.has('sub')); // Will be true
latestVerso = binding . get ( 'Verso' ) . value
latestResult = rowNum + '. "' + latestVerso . replace ( binding . get ( 'Forma' ) . value , '*' + binding . get ( 'Forma' ) . value + '*' ) + '" (' + binding . get ( 'Cantica' ) . value + ', ' + binding . get ( 'Canto' ) . value + ', Verso ' + binding . get ( 'NumeroVerso' ) . value + ')\n' ;
$ ( "#risultatitesto" ) . append ( latestResult ) ;
resultTablePart4 = '<tr><th scope="row" class="text-muted">' + rowNum ++ + '</th>' ;
for ( var i = 0 ; i < queryFields . length ; i ++ ) {
if ( binding . get ( queryFields [ i ] ) != null ) {
val = binding . get ( queryFields [ i ] ) . value
} else {
val = "na"
}
resultTablePart4 = resultTablePart4 + '<td class="text-muted">' + val + "</td>" ;
} ;
resultTable = resultTable + resultTablePart4 + '</tr>' ;
$ ( "#loader" ) . hide ( ) ;
} ) ;
bindingsStream . on ( 'end' , ( ) => {
$ ( "#loader" ) . hide ( ) ;
resultTable = resultTable + resultTablePart5 ;
$ ( "#resultsId1" ) . append ( resultTable ) ;
$ ( "#copiaTesto" ) . prop ( "disabled" , false ) ;
$ ( '#resultTable' ) . DataTable ( {
colReorder : true ,
language : {
url : 'dataTables.it-IT.json'
} ,
//dom: 'Blfrtip',
dom : "<'row'<'col-sm-12 col-md-6'l><'col-sm-6 col-md-3'f><'col-sm-6 col-md-3 text-right'B>>" + "<'row'<'col-sm-12'tr>>" + "<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>" ,
buttons : [ 'copy' , 'excel' , 'print' ]
} ) ;
setTimeout ( function ( ) {
buttonDiv = $ ( "#resultsId1" ) . find ( ".buttons-copy" ) ;
$ ( '<label class="input-group-text"><ion-icon name="copy"></ion-icon></label>' ) . insertBefore ( buttonDiv ) ;
} , 300 ) ;
} ) ;
}
catch ( err ) {
console . log ( err . message ) ;
$ ( "#loader" ) . hide ( ) ;
} ;
} ;
2023-01-18 18:59:45 +01:00
* /
2023-01-12 17:09:58 +01:00
// Funzione di creazione del tab delle clausole grammaticali
function addGramCla ( active , tabID ) {
if ( active > 0 ) {
var checkInsert = ' checked="checked"' ;
} else {
var checkInsert = '' ;
} ;
var sortableId = "#sortable0" ;
var claText = "Categoria grammaticale: <br>" ;
addLIitem ( sortableId , tabID , claText , checkInsert ) ;
2023-01-18 18:59:45 +01:00
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 ) ;
2023-01-12 17:09:58 +01:00
// 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 ) ;
2023-01-18 18:59:45 +01:00
$ ( '#cla' + tabID + " #contextDivN" ) . attr ( "id" , "contextDiv" + tabID ) ;
queryJson [ "Clausola" + tabID ] = JSON . parse ( newGramJsonText ) ;
addClaContext ( tabID ) ;
2023-01-12 17:09:58 +01:00
}
// Funzione di creazione delle subclausole grammaticali basate sul valore scelto
function addCatgramSubcla ( tabPaneId , selectedValue ) {
var dettagliBox = $ ( "#" + tabPaneId + " .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 />' ) ;
2023-01-13 16:49:40 +01:00
element . attr ( 'class' , ' d-flex flex-sm-nowrap pr-2 py-1 mb-1 form-group form-control justify-content-between bg-light' ) ;
2023-01-12 17:09:58 +01:00
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 ] . replace ( /\s/g , '' ) ) ;
rbfieldset . attr ( 'class' , 'custom-control-inline monMe' ) ;
flexdiv1 . attr ( 'class' , 'custom-control custom-radio custom-control-inline m-0 pb-0' ) ;
flexdiv2 . attr ( 'class' , 'custom-control custom-radio custom-control-inline m-0 pb-0' ) ;
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 ] . replace ( /\s/g , '' ) ) ;
input2 . attr ( 'id' , tabPaneId + vals [ 1 ] . replace ( /\s/g , '' ) ) ;
input1 . attr ( 'value' , vals [ 0 ] ) ;
input2 . attr ( 'value' , vals [ 1 ] ) ;
input1 . attr ( 'name' , tabPaneId + keys [ key ] ) ;
input2 . attr ( 'name' , tabPaneId + keys [ key ] ) ;
2023-01-18 18:59:45 +01:00
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' ) ;
2023-01-12 17:09:58 +01:00
label1 . attr ( 'for' , tabPaneId + vals [ 0 ] . replace ( /\s/g , '' ) ) ;
label2 . attr ( 'for' , tabPaneId + vals [ 1 ] . replace ( /\s/g , '' ) ) ;
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 />' ) ;
2023-01-13 16:49:40 +01:00
element . attr ( 'class' , ' d-flex flex-sm-nowrap pr-2 py-1 mb-1 form-group form-control bg-light' ) ;
2023-01-12 17:09:58 +01:00
var rbfieldset = $ ( '<fieldset />' ) ;
flexdiv1 = $ ( '<div />' ) ;
input1 = $ ( '<input />' ) ;
label1 = $ ( '<label />' ) ;
rbfieldset . attr ( 'id' , tabPaneId + keys [ key ] . replace ( /\s/g , '' ) ) ;
rbfieldset . attr ( 'class' , 'custom-control-inline monMe' ) ;
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 ] ) ;
2023-01-18 18:59:45 +01:00
label1 . attr ( 'class' , 'custom-control-label form-control-sm custom-control-inline m-0 pl-1 text-muted' ) ;
2023-01-12 17:09:58 +01:00
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' , ' form-group px-0 pb-1 m-0' ) ;
var select = $ ( '<select class="form-control custom-select-sm monMe bg-light text-muted border btn-outline-lida4"/>' ) ;
select . attr ( 'id' , tabPaneId + keys [ key ] . replace ( /\s/g , '' ) ) ;
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 ) ;
refreshClaList ( ) ;
} ;
}
// Funzione di creazione del tab delle clausole sintattiche
function addSyntCla ( active , tabID ) {
if ( active > 0 ) {
var checkInsert = ' checked="checked"' ;
} else {
var checkInsert = '' ;
} ;
var sortableId = "#sortable0" ;
var claText = "Tipo sintattico: <br>" ;
addLIitem ( sortableId , tabID , claText , checkInsert ) ;
2023-01-18 18:59:45 +01:00
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 ) ;
2023-01-12 17:09:58 +01:00
$ ( '#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 ) ;
2023-01-18 18:59:45 +01:00
$ ( '#cla' + tabID + " #contextDivN" ) . attr ( "id" , "contextDiv" + tabID ) ;
queryJson [ "Clausola" + tabID ] = JSON . parse ( newSyntJsonText ) ;
addClaContext ( tabID ) ;
2023-01-12 17:09:58 +01:00
}
// Funzione di creazione del tab delle clausole metafore
function addMetaCla ( active , tabID ) {
var checkInsert = ' disabled' ;
//if (active > 0) {
// var checkInsert = '" checked="checked"';
//} else {
// var checkInsert = '"';
//};
var sortableId = "#sortable0" ;
var claText = "Clausola Metafore - non ancora implementata" ;
addLIitem ( sortableId , tabID , claText , checkInsert ) ;
}
2023-01-18 18:59:45 +01:00
// 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 ( ) ;
}
} ) ;
} ;
2023-01-12 17:09:58 +01:00
// Funzione di creazione del LI delle condizioni logiche
function addLogicCond ( condtype , sortableId ) {
condListLen ++ ;
var cloneLI = document . getElementById ( "condxX4Xx" ) . cloneNode ( true ) ;
cloneLI . removeAttribute ( "style" ) ;
cloneLI = cloneLI . outerHTML . replace ( /xX4Xx/g , condListLen )
cloneLI = cloneLI . replace ( /xX5Xx/g , condtype )
if ( condtype == "AND" ) {
2023-01-13 16:49:40 +01:00
cloneLI = cloneLI . replace ( /xX6Xx/g , "lida10g" )
2023-01-12 17:09:58 +01:00
} else {
cloneLI = cloneLI . replace ( /xX6Xx/g , "lida11" )
}
if ( $ ( "#li-cla0" ) [ 0 ] ) {
$ ( "#li-cla0" ) [ 0 ] . remove ( ) ;
} ;
$ ( sortableId ) . append ( $ ( cloneLI ) [ 0 ] ) ;
$ ( "#andOrSelect-" + condListLen ) . val ( condtype ) ;
$ ( "#sortable" + condListLen ) . sortable ( ) ;
$ ( "#sortable" + condListLen ) . sortable ( "option" , "appendTo" , document . body ) ;
$ ( "#sortable" + condListLen ) . sortable ( {
items : "> li" ,
handle : ".handle" ,
opacity : 0.6 ,
cursor : 'move' ,
update : function ( ) { refreshSortables ( ) ; }
} ) ;
refreshConnectWith ( ) ;
}
// Funzione di creazione del LI di una clausola nella lista sortable
function addLIitem ( sortableId , tabID , claText , checkInsert ) {
claListLen ++ ;
var cloneLI = document . getElementById ( "li-claxX1Xx" ) . cloneNode ( true ) ;
cloneLI . removeAttribute ( "style" ) ;
cloneLI = cloneLI . outerHTML . replace ( /xX1Xx/g , tabID )
cloneLI = cloneLI . replace ( /xX2Xx/g , claText )
cloneLI = cloneLI . replace ( /xX3Xx"/g , tabID + '" ' + checkInsert )
$ ( sortableId ) . append ( $ ( cloneLI ) [ 0 ] ) ;
} ;
// Funzione di refresh della lista clausole nella tab principale e del json della query
function refreshClaList ( ) {
var l _f = $ ( "form #lemma_forma" ) [ 0 ] . options [ $ ( "form #lemma_forma" ) [ 0 ] . selectedIndex ] . value ;
var qText = $ ( "form #queryText" ) [ 0 ] . value ;
var optText = $ ( "form #opzioni_testo" ) [ 0 ] . value ;
if ( qText == "" ) { //disattivo clausola 0 se il testo e' vuoto
var claActive = 0
} else {
var claActive = 1
} ;
queryJson . Clausola0 = JSON . parse ( '{"queryText": "' + qText + '", "lemma_forma": "' + l _f + '", "opzioni_testo": "' + optText + '", "TipoClausola": "0", "Attiva": "' + claActive + '"}' ) ;
2023-01-18 18:59:45 +01:00
queryJson . Clausola0 . contesto = JSON . stringify ( window . context0 ) ;
2023-01-12 17:09:58 +01:00
var tabsContent = $ ( "#sortable0" ) . find ( ".claLI" ) ;
if ( $ ( tabsContent ) . length ) {
if ( $ ( "#li-cla0" ) [ 0 ] ) {
$ ( "#li-cla0" ) [ 0 ] . remove ( ) ;
} ;
$ ( tabsContent ) . each ( function ( ) {
var claIdNum = $ ( this ) . attr ( 'id' ) . substr ( 6 ) ;
updateClaListItem ( claIdNum , "#sortable0" ) ;
} ) ;
} else {
if ( claListLen == 0 && condListLen == 0 ) {
$ ( '#sortable0' ) . html ( emptyClaList ) ;
queryJson . EsprLogica = "" ;
queryJson . LogicaGui = "" ;
}
tabID = 0 ;
} ;
if ( $ ( '#sortable0' ) . children ( "li" ) . length <= 1 ) {
$ ( "#cla-defaultCond" ) . remove ( ) ;
} else {
if ( $ ( '#cla-defaultCond' ) . length == 0 ) {
$ ( "#cla-list-row" ) . prepend ( $ ( defaultCond ) ) ;
}
} ;
}
// Funzione di creazione del LI nella lista delle clausole nel tab principale, aggiunta della clausola nel JSON
function updateClaListItem ( claIdNum , sortableId ) {
var claText = '' ;
var termText = '' ;
var checkInsert = '' ;
var claId = "cla" + claIdNum ;
var claListItemId = "li-cla" + claIdNum ;
var claType = $ ( "#" + claId ) . attr ( 'data-claType' ) ;
var claActive = $ ( "#" + claId ) . attr ( 'data-claActive' ) ;
if ( claActive > 0 ) {
checkInsert = ' checked="checked"' ;
} ;
switch ( claType ) {
case "Grammaticale" :
var l _f = $ ( "form #lemma_forma" + claIdNum ) [ 0 ] . options [ $ ( "form #lemma_forma" + claIdNum ) [ 0 ] . selectedIndex ] . value ;
var l _f _t = $ ( "form #lemma_forma" + claIdNum ) [ 0 ] . options [ $ ( "form #lemma_forma" + claIdNum ) [ 0 ] . selectedIndex ] . text ;
var qText = $ ( "form #queryText" + claIdNum ) [ 0 ] . value ;
var optText = $ ( "form #opzioni_testo" + claIdNum ) [ 0 ] . value ;
var optText _t = $ ( "form #opzioni_testo" + claIdNum ) [ 0 ] . options [ $ ( "form #opzioni_testo" + claIdNum ) [ 0 ] . selectedIndex ] . text ;
if ( qText != "" ) {
termText = l _f _t + ' <span class="text-dark font-weight-bold">' + qText + '</span> ' + optText _t + '.<br>' ;
} ;
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 + ';<br>';
claText = termText + "Categoria grammaticale: " + gramSelect [ 0 ] . options [ gramSelect [ 0 ] . selectedIndex ] . text + ';<br>' ;
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 + '"' ;
} ;
} ) ;
break ;
case "Sintattico" :
var l _f = $ ( "form #lemma_forma" + claIdNum ) [ 0 ] . options [ $ ( "form #lemma_forma" + claIdNum ) [ 0 ] . selectedIndex ] . value ;
var l _f _t = $ ( "form #lemma_forma" + claIdNum ) [ 0 ] . options [ $ ( "form #lemma_forma" + claIdNum ) [ 0 ] . selectedIndex ] . text ;
var qText = $ ( "form #queryText" + claIdNum ) [ 0 ] . value ;
var optText = $ ( "form #opzioni_testo" + claIdNum ) [ 0 ] . value ;
var optText _t = $ ( "form #opzioni_testo" + claIdNum ) [ 0 ] . options [ $ ( "form #opzioni_testo" + claIdNum ) [ 0 ] . selectedIndex ] . text ;
if ( qText != "" ) {
termText = l _f _t + ' <span class="text-dark font-weight-bold">' + qText + '</span> ' + optText _t + '.<br>' ;
} ;
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 + ';<div class="col-md-12"></div>Livello di subordinazione: ' + funcSelect[0].options[funcSelect[0].selectedIndex].text;
claText = termText + "Tipo sintattico: " + syntSelect [ 0 ] . options [ syntSelect [ 0 ] . selectedIndex ] . text + ';<div class="col-md-12"></div>Livello di subordinazione: ' + funcSelect [ 0 ] . options [ funcSelect [ 0 ] . selectedIndex ] . text ;
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 + '"' ;
} ;
if ( $ ( "#" + claListItemId ) [ 0 ] ) {
$ ( "#" + claListItemId + " .clatext" ) . replaceWith ( '<span class="small clatext">' + claText + '</span>' ) ;
} else {
addLIitem ( sortableId , claIdNum , claText , checkInsert ) ;
} ;
queryJson [ "Clausola" + claIdNum ] = JSON . parse ( jsonTextToParse + '}' ) ;
2023-01-18 18:59:45 +01:00
queryJson [ "Clausola" + claIdNum ] . contesto = JSON . stringify ( window [ "context" + claIdNum ] ) ;
2023-01-12 17:09:58 +01:00
} ;
// Funzione di refresh dei placeholders e attivazione/disattivazione bottoni nelle liste sortable
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 } ) ;
} ;
} ) ;
$ ( "#cla-TabContent .ui-sortable:not(:first)" ) . each ( function ( ) {
var sortableID = $ ( this ) [ 0 ] . id ;
var placeholderID = "#placeholderSort" + sortableID . slice ( - 1 ) ;
var iconSpan = $ ( this ) . find ( ".iconClClass" ) [ 0 ] ;
var iconDiv = $ ( iconSpan ) . parent ( ) [ 0 ] ;
var activeUL = $ ( this ) . children ( "li" ) . children ( "ul" ) . length ;
var activeLI = 0 ;
var inactiveLI = 0 ;
var condLIplaceholder = "" ;
$ ( this ) . children ( "li .claLI" ) . each ( function ( ) {
if ( $ ( this ) . find ( "input" ) [ 0 ] . checked ) {
activeLI ++ ;
$ ( this ) . find ( '.clatext' ) . css ( { opacity : 1 } ) ;
} ;
if ( $ ( this ) . find ( "input" ) [ 0 ] . checked == false ) {
inactiveLI ++ ;
$ ( this ) . find ( '.clatext' ) . css ( { opacity : 0.6 } ) ;
} ;
} ) ;
switch ( activeLI + activeUL ) {
case 0 :
if ( $ ( placeholderID ) . length ) {
if ( inactiveLI > 0 ) {
$ ( placeholderID ) . text ( condLIplaceholderText2d ) ;
} else {
$ ( placeholderID ) . text ( condLIplaceholderText2 ) ;
} ;
} else {
if ( inactiveLI > 0 ) {
condLIplaceholder = condLIplaceholderPart1 + sortableID . slice ( - 1 ) + condLIplaceholderPart2 + condLIplaceholderText2d + '</li>' ;
} else {
condLIplaceholder = condLIplaceholderPart1 + sortableID . slice ( - 1 ) + condLIplaceholderPart2 + condLIplaceholderText2 + '</li>' ;
}
$ ( "#" + sortableID ) . append ( condLIplaceholder ) ;
} ;
if ( inactiveLI == 0 ) {
$ ( iconSpan ) . attr ( "class" , "iconClClass removeCond" ) ;
2023-01-13 16:49:40 +01:00
$ ( iconDiv ) . attr ( "class" , "p-0 mr-3 mt-0 text-right text-lida4" ) ;
2023-01-12 17:09:58 +01:00
} ;
break ;
case 1 :
if ( $ ( placeholderID ) . length ) {
if ( inactiveLI > 0 ) {
$ ( placeholderID ) . text ( condLIplaceholderText1d ) ;
} else {
$ ( placeholderID ) . text ( condLIplaceholderText1 ) ;
} ;
} else {
if ( inactiveLI > 0 ) {
condLIplaceholder = condLIplaceholderPart1 + sortableID . slice ( - 1 ) + condLIplaceholderPart2 + condLIplaceholderText1d + '</li>' ;
} else {
condLIplaceholder = condLIplaceholderPart1 + sortableID . slice ( - 1 ) + condLIplaceholderPart2 + condLIplaceholderText1 + '</li>' ;
}
$ ( "#" + sortableID ) . append ( condLIplaceholder ) ;
} ;
$ ( iconSpan ) . attr ( "class" , "iconClClass NOremoveCond" ) ;
$ ( iconDiv ) . attr ( "class" , "p-0 mr-3 mt-1 text-right text-muted" ) ;
break ;
case 2 :
if ( $ ( placeholderID ) . length ) {
$ ( placeholderID ) . remove ( ) ;
} ;
break ;
default :
if ( $ ( placeholderID ) . length ) {
$ ( placeholderID ) . remove ( ) ;
} ;
} ;
} ) ;
logicExprString = parseCond ( "#sortable0" , "AND" , 0 ) ;
guiLogicString = parseCond ( "#sortable0" , "AND" , 1 ) ;
queryJson . EsprLogica = logicExprString . split ( ' ' ) ;
queryJson . LogicaGui = guiLogicString . split ( ' ' ) ;
} ;
// Funzione di refresh dei collegamenti tra elementi sortable
function refreshConnectWith ( ) {
for ( var i = 0 ; i <= condListLen ; i ++ ) {
var cw = "" ;
for ( var j = 0 ; j <= condListLen ; j ++ ) {
if ( i != j ) {
cw = cw + "#sortable" + j + ", " ;
} ;
$ ( "#sortable" + i ) . sortable ( "option" , "connectWith" , cw . slice ( 0 , - 2 ) ) ;
} ;
} ;
} ;
// Funzione di parsing delle clausole e delle condizioni logiche
function parseCond ( sortableList , condType , forGui ) {
var condText = "" ;
var items = $ ( sortableList ) . children ( "li" ) ;
var itemsText = [ ] ;
$ ( items ) . each ( function ( ) {
if ( $ ( this ) . hasClass ( "condLI-AND" ) ) {
var andID = "#" + $ ( this ) . children ( "ul" ) . attr ( "id" ) ;
var andText = parseCond ( andID , "AND" , forGui ) ;
if ( andText . length ) {
itemsText . push ( andText ) ;
} ;
} ;
if ( $ ( this ) . hasClass ( "condLI-OR" ) ) {
var orID = "#" + $ ( this ) . children ( "ul" ) . attr ( "id" ) ;
var orText = parseCond ( orID , "OR" , forGui ) ;
if ( orText . length ) {
itemsText . push ( orText ) ;
} ;
} ;
if ( $ ( this ) . hasClass ( "claLI" ) ) {
var claNum = "Clausola" + $ ( this ) [ 0 ] . id . substr ( 6 ) ;
if ( forGui || ( $ ( this ) . find ( "input" ) [ 0 ] . checked == true ) ) {
itemsText . push ( claNum ) ;
} ;
} ;
} ) ;
var iTlen = itemsText . length ;
switch ( iTlen ) {
case 0 :
break ;
case 1 :
if ( forGui ) {
condText = "( " + condType + " " + itemsText [ 0 ] + " )" ;
} else {
condText += itemsText [ 0 ] ;
}
break ;
default :
condText = "( " + condType + " " ;
for ( let i = 0 ; i < iTlen ; i ++ ) {
condText += itemsText [ i ] + " " ;
}
condText += ")" ;
} ;
return condText ;
} ;
function hideContextCanti ( claIdNum ) {
2023-01-18 18:59:45 +01:00
$ ( '#selectable-xX' + claIdNum + " .ui-selected" ) . each ( function ( ) {
2023-01-12 17:09:58 +01:00
$ ( this ) . attr ( 'style' , "display: none;" ) ;
$ ( this ) . removeClass ( "ui-selected" )
} ) ;
} ;
2023-01-18 18:59:45 +01:00
/ * *
2023-01-12 17:09:58 +01:00
$ . fn . copy2clipboard = function ( ) {
$ ( 'div[id^="msgCopiati"]' ) . remove ( ) ;
this . select ( ) ;
$ ( this ) . focus ( ) ;
document . execCommand ( "copy" ) ;
document . getSelection ( ) . removeAllRanges ( ) ;
$ ( this ) . after ( '<div class="mt-2 text-lida3" id="msgCopiati">Copiati nella clipboard</div>' ) ;
} ;
2023-01-18 18:59:45 +01:00
* /
2023-01-12 17:09:58 +01:00
function makeUpGui ( queryJson ) {
//$("#risultatitesto").val(queryJson["LogicaGui"]);
// 1. verifica json legit --> TO DO
// -------------------
// Pulizia ricerca avanzata:
resetAdvGui ( ) ;
// Imposta checkbox:
if ( queryJson [ "QueryAvanzata" ] == 1 ) {
$ ( "#cla-Advanced" ) . attr ( 'style' , "display: block;" ) ;
$ ( "#advanSW" ) . prop ( "checked" , true ) ;
} else {
$ ( "#cla-Advanced" ) . attr ( 'style' , "display: none;" ) ;
$ ( "#advanSW" ) . prop ( "checked" , false ) ;
} ;
// Rigenerazione Clausola0:
if ( queryJson [ "Clausola0" ] . Attiva ) {
$ ( "#cla0 #lemma_forma" ) . val ( queryJson [ "Clausola0" ] . lemma _forma ) ;
$ ( "#cla0 #queryText" ) . val ( queryJson [ "Clausola0" ] . queryText ) ;
$ ( "#cla0 #opzioni_testo" ) . val ( queryJson [ "Clausola0" ] . opzioni _testo ) ;
} ;
// Generazione lista clausole e condizioni con elementi padre:
guiLogicString = queryJson . LogicaGui ;
var clau2Make = "" ;
var claParent = [ ] ; // array di coppie [elemento, elemento padre]
var treeLevel = [ ] ; // pila di elementi padre
var condNum = 0 ;
for ( var i = 0 ; i < guiLogicString . length ; i ++ ) {
switch ( guiLogicString [ i ] ) {
case "(" :
break ;
case ")" :
treeLevel . pop ( ) ;
break ;
case "OR" :
claParent . push ( [ guiLogicString [ i ] , treeLevel [ treeLevel . length - 1 ] ] ) ;
treeLevel . push ( "#sortable" + ++ condNum ) ;
break ;
case "AND" :
if ( i > 1 ) {
claParent . push ( [ guiLogicString [ i ] , treeLevel [ treeLevel . length - 1 ] ] ) ;
treeLevel . push ( "#sortable" + ++ condNum ) ;
} else {
treeLevel . push ( "#sortable0" ) ;
} ;
break ;
default :
claParent . push ( [ guiLogicString [ i ] . replace ( "Clausola" , "" ) , treeLevel [ treeLevel . length - 1 ] ] ) ;
} ;
} ;
$ ( claParent ) . each ( function ( ) { // rigenero le clausole nei tab PRIMA, per poter POI ricostruire la lista nel tab principale
var itm = $ ( this ) [ 0 ]
if ( itm != "OR" && itm != "AND" ) {
clau2Make = queryJson [ "Clausola" + itm ] . TipoClausola ;
active = queryJson [ "Clausola" + itm ] . Attiva
tabID ++ ;
switch ( clau2Make ) {
case "Grammaticale" :
selectedValue = queryJson [ "Clausola" + itm ] . typeGramm0 ;
addGramCla ( active , tabID ) ;
if ( selectedValue != "all" ) {
$ ( "#cla" + tabID + " .catgram" ) . val ( selectedValue ) ;
addCatgramSubcla ( "cla" + tabID , selectedValue ) ;
var ks = Object . keys ( queryJson [ "Clausola" + itm ] ) ;
for ( var j = 5 ; j < ks . length ; j ++ ) {
var melID = "cla" + tabID + ks [ j ] ;
var melement = document . getElementById ( melID ) ;
switch ( melement . type ) {
case "fieldset" :
var sval = queryJson [ "Clausola" + itm ] [ ks [ j ] ]
$ ( "#cla" + tabID + sval . replace ( /\s/g , '' ) ) . attr ( "checked" , true ) ;
break ;
case "select-one" :
melement . value = ( [ queryJson [ "Clausola" + itm ] [ ks [ j ] ] ] )
break ;
default :
} ;
} ;
} ;
break ;
case "Sintattico" :
addSyntCla ( active , tabID ) ;
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 ) ;
}
break ;
case "Metafore" :
addMetaCla ( active , tabID ) ;
break ;
default :
} ;
} ;
} ) ;
$ ( claParent ) . each ( function ( ) { // rigenero le liste di clausole e condizioni logiche nel tab principale
if ( $ ( this ) [ 0 ] == "OR" || $ ( this ) [ 0 ] == "AND" ) {
addLogicCond ( $ ( this ) [ 0 ] , $ ( this ) [ 1 ] ) ;
} else {
updateClaListItem ( $ ( this ) [ 0 ] , $ ( this ) [ 1 ] ) ;
refreshSortables ( ) ;
} ;
} ) ;
} ;
2023-01-13 16:49:40 +01:00
function resetSimpleGui ( ) {
$ ( '#queryText' ) . val ( "" )
setLemmaForma ( "" , "forma" ) ;
$ ( '#opzioni_testo' ) . 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 ( ) ;
$ . each ( newOptions , function ( key , value ) {
$ ( "#lemma_forma" ) . append ( $ ( "<option></option>" ) . attr ( "value" , value ) . text ( key ) ) ;
} ) ;
$ ( "#lemma_forma" ) . val ( newSelection ) ;
} ;
function resetContext ( claIdNum ) {
2023-01-18 18:59:45 +01:00
$ ( '#selectable-xX' + claIdNum + " .ui-selectee" ) . each ( function ( ) {
2023-01-13 16:49:40 +01:00
$ ( this ) . attr ( 'style' , "line-height: 1.2em" ) ;
} ) ;
2023-01-18 18:59:45 +01:00
$ ( '#selectable-xX' + claIdNum + " .ui-selected" ) . removeClass ( "ui-selected" )
$ ( '#selectable-xX' + claIdNum + ' .sel-canti-intro' ) . each ( function ( ) {
2023-01-13 16:49:40 +01:00
$ ( this ) . text ( "Seleziona i canti:" )
} ) ; ;
2023-01-18 18:59:45 +01:00
$ ( "#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" ) ;
2023-01-13 16:49:40 +01:00
} ;
2023-01-12 17:09:58 +01:00
function resetAdvGui ( ) {
var tabsContent = $ ( "#cla-TabContent" ) . find ( ".tab-pane:not(:first)" ) ;
if ( $ ( tabsContent ) . length ) {
var claIdNum = '' ;
$ ( tabsContent ) . each ( function ( ) {
claIdNum = $ ( this ) [ 0 ] . id . substring ( 3 ) ;
delete queryJson [ "Clausola" + claIdNum ] ;
2023-01-18 18:59:45 +01:00
delete window [ "context" + claIdNum ] ;
2023-01-12 17:09:58 +01:00
$ ( this ) . remove ( ) ;
} ) ;
} ;
claListLen = 0 ;
condListLen = 0 ;
tabID = 0 ;
$ ( '#sortable0' ) . html ( emptyClaList ) ;
} ;
function parseContext ( claIdNum ) {
var context = window [ "context" + claIdNum ] ;
var jsonContext = JSON . stringify ( context , jsonReplacer ) ;
2023-01-18 18:59:45 +01:00
queryJson [ "Clausola" + claIdNum ] . contesto = jsonContext ;
2023-01-12 17:09:58 +01:00
var contextStringParts = [ "" , "" , "" ] ;
var contextString = [ ] ;
var rangeHolderS = 0 ;
var rangeHolderE = - 1 ;
var lastElem = "" ;
for ( var i = 0 ; i < 3 ; i ++ ) {
for ( var j = 0 ; j <= context [ i ] . length ; j ++ ) {
if ( context [ i ] [ j ] == 1 ) {
if ( j == ( rangeHolderE + 1 ) ) {
rangeHolderE ++ ;
} else {
rangeHolderS = j ;
rangeHolderE = j ;
} ;
} else {
if ( rangeHolderE >= 0 ) {
if ( rangeHolderS == rangeHolderE ) {
lastElem = ( rangeHolderE + 1 ) ;
} else {
lastElem = ( rangeHolderS + 1 ) + "-" + ( rangeHolderE + 1 ) ;
} ;
rangeHolderE = - 1 ;
} ;
} ;
if ( lastElem != "" ) {
if ( contextStringParts [ i ] == "" ) {
contextStringParts [ i ] = " " + canticheList [ i ] + " [" + lastElem ;
} else {
contextStringParts [ i ] = contextStringParts [ i ] + "," + lastElem ;
} ;
lastElem = "" ;
} ;
} ;
rangeHolderS = 0 ;
rangeHolderE = - 1 ;
if ( contextStringParts [ i ] != "" ) {
contextStringParts [ i ] = contextStringParts [ i ] + "]"
contextString . push ( contextStringParts [ i ] ) ;
}
if ( contextString . toString ( ) != "" ) {
2023-01-18 18:59:45 +01:00
$ ( "#contextText-xX" + claIdNum ) . html ( contextString . toString ( ) ) ;
2023-01-12 17:09:58 +01:00
} else {
2023-01-18 18:59:45 +01:00
$ ( "#contextText-xX" + claIdNum ) . html ( "Tutta l'opera" ) ;
2023-01-12 17:09:58 +01:00
}
} ;
} ;
} ) ;