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

@ -1,15 +1,15 @@
*{ * {
background-color: darkgray; background-color: darkgray;
} }
#activeholder{ #activeholder {
position: absolute; position: absolute;
width: 100%; width: 100%;
left: 0%; left: 0%;
bottom: 0%; bottom: 0%;
} }
.activepart{ .activepart {
width: fit-content; width: fit-content;
margin: auto; margin: auto;
padding: auto; padding: auto;
@ -22,37 +22,38 @@
background-color: lightgray; background-color: lightgray;
} }
#audiopart{ #audiopart {
background-color: transparent; background-color: transparent;
background-image: url("assets/play.png"); background-image: url("assets/play.png");
} }
#trashcan{ #trashcan {
width: 32px; width: 32px;
height: 32px; height: 32px;
background-color:red; background-color: red;
background-image: url("assets/trashcan.png"); background-image: url("assets/trashcan.png");
} }
#verify{ #verify {
width: 32px; width: 32px;
height: 32px; height: 32px;
background-image: url("assets/verify.png"); background-image: url("assets/verify.png");
background-color: darksalmon; background-color: darksalmon;
} }
.status{ .status {
width: 64px; width: 64px;
height: 64px; height: 64px;
opacity: 0; opacity: 0;
background-image: url("assets/fail.png"); background-image: url("assets/fail.png");
} }
th, td { th,
td {
padding: 16px; padding: 16px;
} }
.itemcont{ .itemcont {
width: 100vw; width: 100vw;
} }
@ -61,18 +62,17 @@ 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;
position: relative; position: relative;
} }
.itemstor > *{ .itemstor>* {
margin: 16px; margin: 16px;
} }
#vzoritem{ #vzoritem {
bottom: 4%; bottom: 4%;
left: 4%; left: 4%;
position: absolute; position: absolute;

@ -44,7 +44,9 @@ function cleanup(){
// } // }
$(".finalplace").html(""); $(".finalplace").html("");
umami.trackEvent("Trash clear", { type: 'trashclear' }); try{
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();
umami.trackEvent('Successful round', { type: 'successround' }); try{
umami.trackEvent('Successful round', { type: 'successround' });
} catch(e) {}
} }
else{ else{
umami.trackEvent('Unsuccessful round', { type: 'failround' }); try{
umami.trackEvent('Unsuccessful round', { type: 'failround' });
} catch(e) {}
} }
umami.trackEvent("Round data", { type: 'rounddata', Vzor: vzorcodes, Lettercodes: lettercodes, Imagecodes: imagecodes }); try{
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++;
} }
umami.trackEvent("Round images", { type: 'roundimages', images: tmp_tabl }); try{
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());
umami.trackEvent('Clicked sign', { type: 'clicksign', datacode: targetElement.attr("datacode") }); try{
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);
umami.trackEvent('Clicked letter', { type: 'clickletter', datacode: targetElement.attr("datacode") }); try{
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 (){
umami.trackEvent('Clicked clear', { type: 'clickclear', datacode: $(this).children()[0].getAttribute("datacode") }); try{
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");
umami.trackEvent('Listened to image', { type: 'listenimage', datacode: $(this).attr("datacode") }); try{
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")){
umami.trackEvent('Dragged sign', { type: 'draggedsign', datacode: ev.target.getAttribute("datacode") }); try{
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")){
umami.trackEvent('Dragged letter', { type: 'draggedletter', datacode: ev.target.getAttribute("datacode") }); try{
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")){
umami.trackEvent('Dropped sign', { type: 'droppedsign', datacode: ev.target.getAttribute("datacode") }); try{
umami.trackEvent('Dropped sign', { type: 'droppedsign', datacode: ev.target.getAttribute("datacode") });
} catch(e) {}
} }
else if (classy.includes("lettervec")){ else if (classy.includes("lettervec")){
umami.trackEvent('Dropped letter', { type: 'droppedletter', datacode: ev.target.getAttribute("datacode") }); try{
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")){
umami.trackEvent('Dragged sign into trashcan', { type: 'dropsigntrash', datacode: ev.target.getAttribute("datacode") }); try{
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")){
umami.trackEvent('Dragged letter into trashcan', { type: 'droplettertrash', datacode: ev.target.getAttribute("datacode") }); try{
umami.trackEvent('Dragged letter into trashcan', { type: 'droplettertrash', datacode: ev.target.getAttribute("datacode") });
} catch(e) {}
} }
} }