From 4f56fbf7c6fa7275de02aa5c9db85ae81efb5344 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Ryb=C3=A1rsky?= Date: Sat, 1 Apr 2023 22:17:02 +0200 Subject: [PATCH] add try catch --- index.css | 26 ++++++++++++------------ index.js | 61 ++++++++++++++++++++++++++++++++++++++++--------------- 2 files changed, 58 insertions(+), 29 deletions(-) diff --git a/index.css b/index.css index a113da2..47b8bef 100644 --- a/index.css +++ b/index.css @@ -1,15 +1,15 @@ -*{ +* { background-color: darkgray; } -#activeholder{ +#activeholder { position: absolute; width: 100%; left: 0%; bottom: 0%; } -.activepart{ +.activepart { width: fit-content; margin: auto; padding: auto; @@ -22,37 +22,38 @@ background-color: lightgray; } -#audiopart{ +#audiopart { background-color: transparent; background-image: url("assets/play.png"); } -#trashcan{ +#trashcan { width: 32px; height: 32px; - background-color:red; + background-color: red; background-image: url("assets/trashcan.png"); } -#verify{ +#verify { width: 32px; height: 32px; background-image: url("assets/verify.png"); background-color: darksalmon; } -.status{ +.status { width: 64px; height: 64px; opacity: 0; background-image: url("assets/fail.png"); } -th, td { +th, +td { padding: 16px; } -.itemcont{ +.itemcont { width: 100vw; } @@ -61,18 +62,17 @@ th, td { flex-direction: row; flex-wrap: wrap; margin: 10px; - overflow-wrap: break-word; width: fit-content; margin: auto; padding: auto; position: relative; } -.itemstor > *{ +.itemstor>* { margin: 16px; } -#vzoritem{ +#vzoritem { bottom: 4%; left: 4%; position: absolute; diff --git a/index.js b/index.js index b90e6eb..2073b41 100644 --- a/index.js +++ b/index.js @@ -44,7 +44,9 @@ function cleanup(){ // } $(".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){ cleanup(); generatePair(); - umami.trackEvent('Successful round', { type: 'successround' }); + try{ + umami.trackEvent('Successful round', { type: 'successround' }); + } catch(e) {} } 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) { @@ -173,8 +181,9 @@ function showImages(word) { 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++) { let imagepath = prefix + "images/" + tmp_tabl[i] + ".png"; let letterpath = prefix + "letters/" + tmp_tabl[i] + ".png"; @@ -212,7 +221,9 @@ function showImages(word) { if (emptyindex > -1){ let changingelement = $("#" + idcko); 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")); if (emptyindex > -1){ 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()); } @@ -229,7 +242,9 @@ function showImages(word) { }); $(".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(""); }); @@ -279,7 +294,9 @@ function generateItem(word){ $(".itemholderak").each(function(){ $(this).on("click", function (e){ 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(); }) }); @@ -325,10 +342,14 @@ function drag(ev) { let datacode = $(ev.target).attr("datacode"); document.getElementById("audplay"+ datacode).play(); 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")){ - 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); } 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")){ - 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"); $('[returntarget="' + returnto + '"]').html(htmldata); 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")){ - 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) {} } }