Skip to content

Commit bf1816e

Browse files
committed
Refactor index.blade.php: Translate comments to English for better clarity
1 parent 7da91f5 commit bf1816e

File tree

1 file changed

+21
-15
lines changed

1 file changed

+21
-15
lines changed

resources/views/admin/scan/index.blade.php

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<title>QR-Codes scannen</title>
77
<meta name="viewport" content="width=device-width, initial-scale=1.0">
88
<style>
9+
/* Basic layout and styling */
910
body {
1011
font-family: Arial, sans-serif;
1112
margin: 20px;
@@ -15,7 +16,6 @@
1516
#reader {
1617
width: 100%;
1718
height: 80vh;
18-
/* volles Browser-Viewport nutzen */
1919
margin: 0 auto;
2020
border: 2px solid #ccc;
2121
box-sizing: border-box;
@@ -29,24 +29,29 @@
2929
</head>
3030

3131
<body>
32+
{{-- Scan page header showing the currently active quiz question --}}
3233
<h2>Aktive Frage:</h2>
3334
<p id="active-question">
3435
{{ $activeQuestion ? $activeQuestion->question_text : 'Keine aktive Frage gefunden.' }}
3536
</p>
37+
38+
{{-- Hidden field to pass the active question ID into JavaScript --}}
3639
<input type="hidden" id="quiz_question_id" value="{{ $activeQuestion ? $activeQuestion->id : '' }}">
3740

41+
{{-- Container where the QR code scanner will render the camera feed --}}
3842
<div id="reader"></div>
3943

40-
<!-- html5-qrcode Bibliothek -->
44+
{{-- Include the html5-qrcode library for in-browser scanning --}}
4145
<script src="https://cdnjs.cloudflare.com/ajax/libs/html5-qrcode/2.3.8/html5-qrcode.min.js"
4246
integrity="sha512-r6rDA7W6ZeQhvl8S7yRVQUKVHdexq+GAlNkNNqVC7YyIV+NwqCTJe2hDWCiffTyRNOeGEzRRJ9ifvRm/HCzGYg=="
4347
crossorigin="anonymous" referrerpolicy="no-referrer"></script>
4448
<script>
49+
// Retrieve the quiz question ID for API requests
4550
const quizQuestionId = document.getElementById("quiz_question_id").value;
4651
47-
// Erfolgs-Callback
52+
// Called when a QR code is successfully decoded
4853
function qrCodeSuccessCallback(decodedText, decodedResult) {
49-
console.log("QR-Code erkannt:", decodedText);
54+
console.log("QR code detected:", decodedText);
5055
fetch("{{ route('admin.scan.store') }}", {
5156
method: "POST",
5257
headers: {
@@ -61,42 +66,43 @@ function qrCodeSuccessCallback(decodedText, decodedResult) {
6166
.then(res => res.json())
6267
.then(data => {
6368
if (data.success) {
64-
console.log("Scan gespeichert:", data.scan);
69+
console.log("Scan saved:", data.scan);
6570
} else {
66-
console.error("Fehler beim Speichern:", data.error);
71+
console.error("Error saving scan:", data.error);
6772
}
6873
})
69-
.catch(err => console.error("Fetch-Error:", err));
74+
.catch(err => console.error("Fetch error:", err));
7075
}
7176
72-
// Fehler-Callback (wird bei jedem Frame ohne QR-Code aufgerufen)
77+
// Called on each frame when no QR code is found (ignored here)
7378
function qrCodeFailureCallback(error) {
74-
// Ignoriere – wir scannen kontinuierlich
79+
// Continuous scanning - no action needed on failure
7580
}
7681
77-
// Wenn document ready
82+
// Initialize the scanner once the DOM is ready
7883
document.addEventListener("DOMContentLoaded", () => {
7984
const html5QrCode = new Html5Qrcode("reader");
8085
8186
const config = {
82-
fps: 10,
83-
qrbox: false, // false = ganze Kamera-Fläche wird gescant
87+
fps: 10, // scan 10 frames per second
88+
qrbox: false, // scan the full video area
8489
experimentalFeatures: {
8590
useBarCodeDetectorIfSupported: true
8691
},
8792
videoConstraints: {
88-
facingMode: { exact: "environment" },
89-
zoom: 2 // versuche Zoom-Level 2x (falls Kamera es unterstützt)
93+
facingMode: { exact: "environment" }, // use rear camera
94+
zoom: 2 // attempt 2x zoom if supported
9095
}
9196
};
9297
98+
// Start the camera and begin scanning
9399
html5QrCode.start(
94100
{ facingMode: "environment" },
95101
config,
96102
qrCodeSuccessCallback,
97103
qrCodeFailureCallback
98104
).catch(err => {
99-
console.error("Kamera konnte nicht gestartet werden:", err);
105+
console.error("Unable to start camera:", err);
100106
document.getElementById("reader").innerText =
101107
"Kamera konnte nicht gestartet werden. Bitte Browser-Berechtigungen prüfen.";
102108
});

0 commit comments

Comments
 (0)