jquery script

This commit is contained in:
cesare 2022-02-05 01:27:46 +01:00
parent 1ea0ec2b0f
commit 1c21f92d4b
1 changed files with 123 additions and 0 deletions

123
js/guimanager.js Normal file
View File

@ -0,0 +1,123 @@
/**
*
*/
$(document).ready(function(){
grammarconditions=0
var aggettivoJson=null
$.getJSON("aggettivo.json", function(aggettivo){
//var keys = Object.values(aggettivo.filtri["Con oggetto indiretto"]);
//alert(keys);
aggettivoJson=aggettivo
}).fail(function(){
console.log("An error has occurred.");
});
$('.tabs__menu-item').on('click', function() {
$(this).addClass('bg-white').addClass('red');
$(this).siblings().removeClass('bg-white').removeClass('red');
});
jQuery(document).delegate('a.add-record', 'click', function(e) {
e.preventDefault();
var content = jQuery('#categoriagrammaticale div'),
size = jQuery('#condizioni >div').length + 1,
element = null,
element = content.clone();
//alert(size);
element.attr('id', 'cg-'+size);
//element.attr('class', "stripe-dark")
//element.find('.delete-record').attr('data-id', size);
element.appendTo('#condizioni');
element.find('.sn').html(size);
grammarconditions=grammarconditions+1
if (size==1)
jQuery('#grammarbutton').attr('style', "display:block;")
});
jQuery(document).delegate('a.add-record-sint', 'click', function(e) {
e.preventDefault();
var content = jQuery('#tiposintattico div'),
size = jQuery('#condizioni >div').length + 1,
element = null,
element = content.clone();
element.attr('id', 'ts-'+size);
//element.attr('class', "stripe-dark")
//element.find('.delete-record').attr('data-id', size);
element.appendTo('#condizioni');
element.find('.sn').html(size);
if (size==1)
jQuery('#grammarbutton').attr('style', "display:block;")
});
jQuery(document).delegate('select.catgram', 'change', function(e) {
e.preventDefault();
//alert ($('#types').find(":selected").val())
alert ($(this).closest('div').attr('id'))
containerid='dettaglio_'+$(this).closest('div').attr('id')
//if ($('#types').find(":selected").val()=='verbovolgare'){
if ($(this).val()=='verbovolgare'){
//alert($('#types').find(":selected").val());
var content = jQuery('#categoriaverbo >div'),
size = jQuery('#dettaglifiltri').length + 1,
element = null,
element = content.clone();
}
if ($(this).val()=='sostantivovolgare'){
//alert($('#types').find(":selected").val());
var content = jQuery('#categoriasostantivo >div'),
size = jQuery('#dettaglifiltri').length + 1,
element = null,
element = content.clone();
}
if ($(this).val()=='aggettivovolgare'){
var keys = Object.keys(aggettivoJson.filtri);
alert(keys)
}
element.attr('style',"display: block;")
//element.appendTo('#dettaglifiltri');
var test=jQuery('#'+containerid)
test.remove()
element.appendTo('#dettaglifiltri');
var container = jQuery('#dettaglifiltri');
container.attr('id', containerid);
var divdf = jQuery('#divdettaglifiltri >div'),
detelement = null,
detelement = divdf.clone();
detelement.attr('id','dettaglifiltri')
detelement.appendTo("#query")
element.find('.sn').html(size);
});
jQuery(document).delegate('input.delete-record', 'click', function(e) {
e.preventDefault();
var didConfirm = confirm("Sei sicuro di voler eliminare la condizione?");
if (didConfirm == true) {
var id = jQuery(this).attr('data-id');
var targetDiv = jQuery(this).attr('targetDiv');
jQuery('#rec-' + id).remove();
if (jQuery('#condizioni >tbody >tr').length==0)
jQuery('#grammarbutton').attr('style', "display:none;")
//regnerate index number on table
$('#condizioni_body tr').each(function(index){
$(this).find('span.sn').html(index+1);
});
return true;
} else {
return false;
}
});
});