Compare commits

...

3 Commits

Author SHA1 Message Date
Markus Busche
5478d943e5 Teilen-Button, Klartext-Hinweis und README aktualisiert (WLAN-Passwort im Link sichtbar) 2025-07-08 11:59:35 +02:00
Markus Busche
9c5d022604 Update Caddyfile 2025-07-03 12:04:56 +02:00
Markus Busche
83f49d14bc Add main.js to Dockerfile 2025-07-03 11:51:16 +02:00
5 changed files with 69 additions and 5 deletions

View File

@@ -2,8 +2,10 @@
root * /usr/share/caddy root * /usr/share/caddy
file_server file_server
# Behandle die HTML-Datei als Index @notStatic {
try_files {path} /Just%20a%20QR%20Code.html not path_regexp static \.\(js|css|png|jpg|jpeg|gif|svg|ico|json|webmanifest|map|txt|woff2?\)$
}
try_files {path} /index.html @notStatic
# CORS-Header für Cross-Origin-Requests # CORS-Header für Cross-Origin-Requests
header { header {

View File

@@ -2,6 +2,7 @@ FROM caddy:2-alpine
# Kopiere die HTML-Datei # Kopiere die HTML-Datei
COPY index.html /usr/share/caddy/ COPY index.html /usr/share/caddy/
COPY main.js /usr/share/caddy/
# Kopiere den Ordner mit den JavaScript-Dateien # Kopiere den Ordner mit den JavaScript-Dateien
COPY assets /usr/share/caddy/assets/ COPY assets /usr/share/caddy/assets/

View File

@@ -11,6 +11,8 @@ Dieses Projekt basiert auf dem Code von https://qr.alster.space/. Er wurde um ve
- Anpassbare Größen und Farben - Anpassbare Größen und Farben
- Verschiedene Fehlerkorrektur-Level - Verschiedene Fehlerkorrektur-Level
- Download-Funktion - Download-Funktion
- Teilen-Funktion (Link mit aktuellen Einstellungen kopieren)
- Hinweis bei WiFi: Passwort im Link im Klartext
- Responsive Design - Responsive Design
- WiFi QR-Code Unterstützung mit eigener UI - WiFi QR-Code Unterstützung mit eigener UI
- Dynamische Klartext-Anzeige - Dynamische Klartext-Anzeige
@@ -90,6 +92,8 @@ http://localhost:8080/?ssid=MeinWLAN&password=MeinPasswort123
http://localhost:8080/?ssid=OffenesWLAN http://localhost:8080/?ssid=OffenesWLAN
``` ```
**Achtung:** Das WLAN-Passwort ist im Link im Klartext sichtbar!
## WiFi QR-Code Format ## WiFi QR-Code Format
Die App generiert automatisch QR-Codes im Standard-WiFi-Format: Die App generiert automatisch QR-Codes im Standard-WiFi-Format:
@@ -127,6 +131,12 @@ Das Smartphone erkennt automatisch, dass es sich um WiFi-Daten handelt und biete
- WiFi-Passwort ohne SSID wird als Fehler angezeigt - WiFi-Passwort ohne SSID wird als Fehler angezeigt
- Leere Eingaben werden entsprechend behandelt - Leere Eingaben werden entsprechend behandelt
### Teilen-Funktion
Mit dem Button "Teilen" kann ein Link mit allen aktuellen Einstellungen (inkl. WiFi-Daten) in die Zwischenablage kopiert werden. Dieser Link kann weitergegeben werden und öffnet die App direkt mit den gewählten Einstellungen.
**Achtung:** Wenn ein WLAN-Passwort eingegeben ist, wird dieses im Link im Klartext übertragen!
## Sicherheit & Content Security Policy (CSP) ## Sicherheit & Content Security Policy (CSP)
Die Anwendung ist gegen XSS-Angriffe abgesichert: Die Anwendung ist gegen XSS-Angriffe abgesichert:

File diff suppressed because one or more lines are too long

47
main.js
View File

@@ -16,6 +16,8 @@ document.addEventListener('DOMContentLoaded', function() {
const infoPanel = document.getElementById('info-panel'); const infoPanel = document.getElementById('info-panel');
const infoClose = document.getElementById('info-close'); const infoClose = document.getElementById('info-close');
const titleElement = document.getElementById('title'); const titleElement = document.getElementById('title');
const shareBtn = document.getElementById('share');
const shareHint = document.getElementById('share-hint');
// Title Easter egg // Title Easter egg
let titleClickCount = 0; let titleClickCount = 0;
@@ -292,4 +294,49 @@ document.addEventListener('DOMContentLoaded', function() {
// Update clear button visibility // Update clear button visibility
toggleClearButton(); toggleClearButton();
} }
function updateShareHint() {
const wifiPassword = wifiPasswordInput.value.trim();
if (wifiPassword) {
shareHint.style.display = 'block';
} else {
shareHint.style.display = 'none';
}
}
wifiPasswordInput.addEventListener('input', updateShareHint);
wifiSsidInput.addEventListener('input', updateShareHint);
textInput.addEventListener('input', updateShareHint);
// Initial anzeigen, falls Passwort schon gesetzt
updateShareHint();
shareBtn.addEventListener('click', function() {
const params = new URLSearchParams();
const text = textInput.value.trim();
const wifiSsid = wifiSsidInput.value.trim();
const wifiPassword = wifiPasswordInput.value.trim();
const size = sizeSelect.value;
const errorCorrection = errorCorrectionSelect.value;
const fgColor = foregroundColor.value;
const bgColor = backgroundColor.value;
// Entscheide, was kodiert werden soll
if (wifiSsid) params.set('ssid', wifiSsid);
if (wifiPassword) params.set('password', wifiPassword);
if (!wifiSsid && !wifiPassword && text) params.set('text', text);
if (size !== '256') params.set('size', size);
if (errorCorrection !== 'M') params.set('errorCorrection', errorCorrection);
if (fgColor !== '#000000') params.set('foreground', fgColor);
if (bgColor !== '#ffffff') params.set('background', bgColor);
const url = window.location.origin + window.location.pathname + '?' + params.toString();
// In Zwischenablage kopieren
navigator.clipboard.writeText(url).then(() => {
const original = shareBtn.textContent;
shareBtn.textContent = 'Link kopiert!';
setTimeout(() => { shareBtn.textContent = original; }, 2000);
}, () => {
alert('Konnte Link nicht kopieren.');
});
});
}); });