QR Code for WhatsApp
This commit is contained in:
1 parent
0a2070fcf5
commit
88115a62dd
6 files changed
+755
-1
No files matched your search
@@ -2477,14 +2477,49 @@ function closeSpeakerModal() {
|
||||
document.getElementById('speakerModal').close();
|
||||
}
|
||||
|
||||
function closeSpeakerQrModal() {
|
||||
const dialog = document.getElementById('speakerQrModal');
|
||||
if (dialog && dialog.open) dialog.close();
|
||||
}
|
||||
|
||||
function sendSpeakerMessage() {
|
||||
const input = document.getElementById('speakerText');
|
||||
const text = input.value.trim();
|
||||
if (!text) return;
|
||||
|
||||
if (sendWs({code: 1000, msg: JSON.stringify({text})})) {
|
||||
input.value = '';
|
||||
closeSpeakerModal();
|
||||
showSpeakerQr(text);
|
||||
input.value = '';
|
||||
}
|
||||
}
|
||||
|
||||
function showSpeakerQr(text) {
|
||||
const dialog = document.getElementById('speakerQrModal');
|
||||
if (!dialog) return;
|
||||
const encoded = encodeURIComponent(text);
|
||||
const url = `https://api.whatsapp.com/send?text=${encoded}`;
|
||||
const canvas = document.getElementById('speakerQrCanvas');
|
||||
const qrLink = document.getElementById('speakerQrLink');
|
||||
if (canvas && typeof QRious !== 'undefined') {
|
||||
try {
|
||||
new QRious({
|
||||
element: canvas,
|
||||
value: url,
|
||||
size: 240
|
||||
});
|
||||
} catch (e) {
|
||||
console.error('QRious error', e);
|
||||
}
|
||||
}
|
||||
if (qrLink) {
|
||||
qrLink.href = url;
|
||||
qrLink.textContent = 'WhatsApp öffnen';
|
||||
}
|
||||
if (typeof dialog.showModal === 'function') {
|
||||
dialog.showModal();
|
||||
} else {
|
||||
dialog.show();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user