Update index.html
Browse files- index.html +18 -3
index.html
CHANGED
|
@@ -13101,6 +13101,21 @@ async function copyShareLink(url) {
|
|
| 13101 |
// QR scanner (camera-based, via vendored jsQR — no external dependency)
|
| 13102 |
// ---------------------------------------------------------------------
|
| 13103 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13104 |
function stopQrScanner() {
|
| 13105 |
if (scannerFrame) cancelAnimationFrame(scannerFrame);
|
| 13106 |
scannerFrame = null;
|
|
@@ -13136,10 +13151,10 @@ async function startQrScanner(onCode) {
|
|
| 13136 |
ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
|
| 13137 |
const frame = ctx.getImageData(0, 0, canvas.width, canvas.height);
|
| 13138 |
const result = jsQR(frame.data, frame.width, frame.height);
|
| 13139 |
-
const
|
| 13140 |
-
if (
|
| 13141 |
stopQrScanner();
|
| 13142 |
-
onCode(
|
| 13143 |
return;
|
| 13144 |
}
|
| 13145 |
}
|
|
|
|
| 13101 |
// QR scanner (camera-based, via vendored jsQR — no external dependency)
|
| 13102 |
// ---------------------------------------------------------------------
|
| 13103 |
|
| 13104 |
+
function extractRoomCode(rawText) {
|
| 13105 |
+
if (!rawText) return null;
|
| 13106 |
+
const text = rawText.trim();
|
| 13107 |
+
|
| 13108 |
+
try {
|
| 13109 |
+
const url = new URL(text);
|
| 13110 |
+
const fromParam = url.searchParams.get('code');
|
| 13111 |
+
if (fromParam && /^[A-Z0-9]{6}$/i.test(fromParam)) return fromParam.toUpperCase();
|
| 13112 |
+
} catch {
|
| 13113 |
+
// Not a URL — fall through and treat it as a plain code below.
|
| 13114 |
+
}
|
| 13115 |
+
|
| 13116 |
+
return /^[A-Z0-9]{6}$/i.test(text) ? text.toUpperCase() : null;
|
| 13117 |
+
}
|
| 13118 |
+
|
| 13119 |
function stopQrScanner() {
|
| 13120 |
if (scannerFrame) cancelAnimationFrame(scannerFrame);
|
| 13121 |
scannerFrame = null;
|
|
|
|
| 13151 |
ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
|
| 13152 |
const frame = ctx.getImageData(0, 0, canvas.width, canvas.height);
|
| 13153 |
const result = jsQR(frame.data, frame.width, frame.height);
|
| 13154 |
+
const code = extractRoomCode(result?.data);
|
| 13155 |
+
if (code) {
|
| 13156 |
stopQrScanner();
|
| 13157 |
+
onCode(code);
|
| 13158 |
return;
|
| 13159 |
}
|
| 13160 |
}
|