aggiunti try-catch error sulla query e controllo sul valore undefined

This commit is contained in:
Luca Trupiano 2022-10-21 14:56:48 +02:00
parent 5896481f4d
commit b87fe4b1d0
1 changed files with 43 additions and 32 deletions

View File

@ -456,38 +456,49 @@ $(document).ready(function() {
$('#resultsId1').empty();
$('#resultsId1').addClass("small pb-2")
$("#risultatitesto").empty();
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++) {
resultTablePart4 = resultTablePart4 + '<td class="text-muted">' + binding.get(queryFields[i]).value + "</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);
});
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();
};
};
// Funzione di creazione del tab delle clausole grammaticali