add try catch

This commit is contained in:
Bruno Rybársky 2023-04-01 22:17:02 +02:00
parent 6eb82d0a01
commit 4f56fbf7c6
No known key found for this signature in database
GPG Key ID: DFE2C061EF985CD4
2 changed files with 58 additions and 29 deletions

@ -48,7 +48,8 @@
background-image: url("assets/fail.png"); background-image: url("assets/fail.png");
} }
th, td { th,
td {
padding: 16px; padding: 16px;
} }
@ -61,7 +62,6 @@ th, td {
flex-direction: row; flex-direction: row;
flex-wrap: wrap; flex-wrap: wrap;
margin: 10px; margin: 10px;
overflow-wrap: break-word;
width: fit-content; width: fit-content;
margin: auto; margin: auto;
padding: auto; padding: auto;

@ -44,7 +44,9 @@ function cleanup(){
// } // }
$(".finalplace").html(""); $(".finalplace").html("");
try{
umami.trackEvent("Trash clear", { type: 'trashclear' }); umami.trackEvent("Trash clear", { type: 'trashclear' });
} catch(e) {}
} }
@ -106,12 +108,18 @@ function checkAnswers() {
if (vzorcodes == imagecodes && vzorcodes == lettercodes){ if (vzorcodes == imagecodes && vzorcodes == lettercodes){
cleanup(); cleanup();
generatePair(); generatePair();
try{
umami.trackEvent('Successful round', { type: 'successround' }); umami.trackEvent('Successful round', { type: 'successround' });
} catch(e) {}
} }
else{ else{
try{
umami.trackEvent('Unsuccessful round', { type: 'failround' }); umami.trackEvent('Unsuccessful round', { type: 'failround' });
} catch(e) {}
} }
try{
umami.trackEvent("Round data", { type: 'rounddata', Vzor: vzorcodes, Lettercodes: lettercodes, Imagecodes: imagecodes }); umami.trackEvent("Round data", { type: 'rounddata', Vzor: vzorcodes, Lettercodes: lettercodes, Imagecodes: imagecodes });
} catch(e) {}
} }
function getRandomInt(min, max) { function getRandomInt(min, max) {
@ -173,8 +181,9 @@ function showImages(word) {
now_count++; now_count++;
} }
try{
umami.trackEvent("Round images", { type: 'roundimages', images: tmp_tabl }); umami.trackEvent("Round images", { type: 'roundimages', images: tmp_tabl });
} catch(e) {}
for (let i = 0 ; i < tmp_tabl.length; i++) { for (let i = 0 ; i < tmp_tabl.length; i++) {
let imagepath = prefix + "images/" + tmp_tabl[i] + ".png"; let imagepath = prefix + "images/" + tmp_tabl[i] + ".png";
let letterpath = prefix + "letters/" + tmp_tabl[i] + ".png"; let letterpath = prefix + "letters/" + tmp_tabl[i] + ".png";
@ -212,7 +221,9 @@ function showImages(word) {
if (emptyindex > -1){ if (emptyindex > -1){
let changingelement = $("#" + idcko); let changingelement = $("#" + idcko);
changingelement.html(targetElement.html()); changingelement.html(targetElement.html());
try{
umami.trackEvent('Clicked sign', { type: 'clicksign', datacode: targetElement.attr("datacode") }); umami.trackEvent('Clicked sign', { type: 'clicksign', datacode: targetElement.attr("datacode") });
} catch(e) {}
} }
} }
@ -221,7 +232,9 @@ function showImages(word) {
let [emptyindex, idcko] = getEmptyIndex($(".finalletterplace")); let [emptyindex, idcko] = getEmptyIndex($(".finalletterplace"));
if (emptyindex > -1){ if (emptyindex > -1){
let changingelement = $("#" + idcko); let changingelement = $("#" + idcko);
try{
umami.trackEvent('Clicked letter', { type: 'clickletter', datacode: targetElement.attr("datacode") }); umami.trackEvent('Clicked letter', { type: 'clickletter', datacode: targetElement.attr("datacode") });
} catch(e) {}
changingelement.html(targetElement.html()); changingelement.html(targetElement.html());
} }
@ -229,7 +242,9 @@ function showImages(word) {
}); });
$(".finalplace").on("click", function (){ $(".finalplace").on("click", function (){
try{
umami.trackEvent('Clicked clear', { type: 'clickclear', datacode: $(this).children()[0].getAttribute("datacode") }); umami.trackEvent('Clicked clear', { type: 'clickclear', datacode: $(this).children()[0].getAttribute("datacode") });
} catch(e) {}
$(this).html(""); $(this).html("");
}); });
@ -279,7 +294,9 @@ function generateItem(word){
$(".itemholderak").each(function(){ $(".itemholderak").each(function(){
$(this).on("click", function (e){ $(this).on("click", function (e){
let datacode = $(this).attr("datacode"); let datacode = $(this).attr("datacode");
try{
umami.trackEvent('Listened to image', { type: 'listenimage', datacode: $(this).attr("datacode") }); umami.trackEvent('Listened to image', { type: 'listenimage', datacode: $(this).attr("datacode") });
} catch(e) {}
document.getElementById("audplayitem"+ datacode).play(); document.getElementById("audplayitem"+ datacode).play();
}) })
}); });
@ -325,10 +342,14 @@ function drag(ev) {
let datacode = $(ev.target).attr("datacode"); let datacode = $(ev.target).attr("datacode");
document.getElementById("audplay"+ datacode).play(); document.getElementById("audplay"+ datacode).play();
if (ev.target.classList.contains("imagevec")){ if (ev.target.classList.contains("imagevec")){
try{
umami.trackEvent('Dragged sign', { type: 'draggedsign', datacode: ev.target.getAttribute("datacode") }); umami.trackEvent('Dragged sign', { type: 'draggedsign', datacode: ev.target.getAttribute("datacode") });
} catch(e) {}
} }
else if (ev.target.classList.contains("lettervec")){ else if (ev.target.classList.contains("lettervec")){
try{
umami.trackEvent('Dragged letter', { type: 'draggedletter', datacode: ev.target.getAttribute("datacode") }); umami.trackEvent('Dragged letter', { type: 'draggedletter', datacode: ev.target.getAttribute("datacode") });
} catch(e) {}
} }
} }
@ -359,10 +380,14 @@ function drop(ev) {
//$('[returntarget="' + returnto + '"]').html(htmldata); //$('[returntarget="' + returnto + '"]').html(htmldata);
} }
if (classy.includes("imagevec")){ if (classy.includes("imagevec")){
try{
umami.trackEvent('Dropped sign', { type: 'droppedsign', datacode: ev.target.getAttribute("datacode") }); umami.trackEvent('Dropped sign', { type: 'droppedsign', datacode: ev.target.getAttribute("datacode") });
} catch(e) {}
} }
else if (classy.includes("lettervec")){ else if (classy.includes("lettervec")){
try{
umami.trackEvent('Dropped letter', { type: 'droppedletter', datacode: ev.target.getAttribute("datacode") }); umami.trackEvent('Dropped letter', { type: 'droppedletter', datacode: ev.target.getAttribute("datacode") });
} catch(e) {}
} }
} }
@ -375,10 +400,14 @@ function droptrash(ev) {
let classy = ev.dataTransfer.getData("classy"); let classy = ev.dataTransfer.getData("classy");
$('[returntarget="' + returnto + '"]').html(htmldata); $('[returntarget="' + returnto + '"]').html(htmldata);
if (classy.includes("imagevec")){ if (classy.includes("imagevec")){
try{
umami.trackEvent('Dragged sign into trashcan', { type: 'dropsigntrash', datacode: ev.target.getAttribute("datacode") }); umami.trackEvent('Dragged sign into trashcan', { type: 'dropsigntrash', datacode: ev.target.getAttribute("datacode") });
} catch(e) {}
} }
else if (classy.includes("lettervec")){ else if (classy.includes("lettervec")){
try{
umami.trackEvent('Dragged letter into trashcan', { type: 'droplettertrash', datacode: ev.target.getAttribute("datacode") }); umami.trackEvent('Dragged letter into trashcan', { type: 'droplettertrash', datacode: ev.target.getAttribute("datacode") });
} catch(e) {}
} }
} }