Teilen-Button, Klartext-Hinweis und README aktualisiert (WLAN-Passwort im Link sichtbar)

This commit is contained in:
Markus Busche
2025-07-08 11:59:35 +02:00
parent 9c5d022604
commit 5478d943e5
3 changed files with 63 additions and 2 deletions

47
main.js
View File

@@ -16,6 +16,8 @@ document.addEventListener('DOMContentLoaded', function() {
const infoPanel = document.getElementById('info-panel');
const infoClose = document.getElementById('info-close');
const titleElement = document.getElementById('title');
const shareBtn = document.getElementById('share');
const shareHint = document.getElementById('share-hint');
// Title Easter egg
let titleClickCount = 0;
@@ -292,4 +294,49 @@ document.addEventListener('DOMContentLoaded', function() {
// Update clear button visibility
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.');
});
});
});