Skip to content

Commit 6675d70

Browse files
committed
feature improvements nothing special
1 parent 9e01396 commit 6675d70

2 files changed

Lines changed: 12 additions & 6 deletions

File tree

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ <h3>Verschlüsselungs Programm</h3>
129129
<dialog id="newRecord" class="newRecord">
130130
<h1>Neuer Rekord:</h1>
131131
<div><h1 id="recordField"></h1></div>
132-
<p>Versuche: <span id="trysField"></span></p>
132+
<p>Fehlgeschlagende Versuche: <span id="trysField"></span></p>
133133
<button onclick="newRecord.close()">Fertig</button>
134134
</dialog>
135135
<script src="./script.js"></script>

script.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const scratch = document.getElementById("scratch");
77
const scratchStartRect = scratch.getBoundingClientRect();
88
if (localStorage.getItem("scratchRecordHeight") == null) {
99
localStorage.setItem("scratchRecordHeight", 0);
10+
localStorage.setItem("scratchTrysTotal", 0);
1011
localStorage.setItem("scratchTrys", 0);
1112
}
1213
// const ha = document.getElementById("ha");
@@ -50,18 +51,23 @@ scratch.addEventListener("mouseout", () => {
5051
const scratchRect = scratch.getBoundingClientRect();
5152
const scratchHeight = Math.abs(scratchRect.top - scratchStartRect.top);
5253
const scratchRecordHeight = localStorage.getItem("scratchRecordHeight");
54+
let scratchTrysTotal = localStorage.getItem("scratchTrysTotal");
5355
let scratchTrys = localStorage.getItem("scratchTrys");
54-
scratchTrys++;
5556
console.log("scratchHeight: " + scratchHeight);
5657

57-
//Versuche counter
58-
localStorage.setItem("scratchTrys", scratchTrys);
59-
trysField.innerHTML = scratchTrys;
60-
6158
if (scratchHeight > scratchRecordHeight) {
6259
localStorage.setItem("scratchRecordHeight", scratchHeight);
6360
console.log("NEUER REKORD");
6461
recordField.innerHTML = parseInt(scratchHeight);
6562
newRecord.showModal();
63+
} else {
64+
scratchTrys++;
65+
localStorage.setItem("scratchTrys", scratchTrys);
6666
}
67+
68+
//Versuche counter
69+
scratchTrysTotal++;
70+
localStorage.setItem("scratchTrysTotal", scratchTrysTotal);
71+
72+
trysField.innerHTML = scratchTrys + "/" + scratchTrysTotal;
6773
});

0 commit comments

Comments
 (0)