File: //tmp/dnssec-checker-0.js
const ORDER_POSTS = {
quick_fix: { action: 'https://support.panomity.com/cart/priority-support/DNS-Quick-Fix/&step=0', id: '867', cycle: 'Once' },
cleanup: { action: 'https://support.panomity.com/cart/priority-support/DNSMail-Security-Cleanup/&step=0', id: '868', cycle: 'Once' }
};
const API_KEY = 'dev-key';
const scanForm = document.getElementById('toolScanForm');
const domainInput = document.getElementById('domain');
const resultBox = document.getElementById('result');
let lastDomain = '';
function escapeHTML(value) {
return String(value ?? '').replace(/[&<>"']/g, (ch) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[ch]));
}
async function fetchJSON(url, opts) {
opts = opts || {};
opts.headers = Object.assign({ 'x-api-key': API_KEY }, opts.headers || {});
const res = await fetch(url, opts);
if (!res.ok) throw new Error(`HTTP ${res.status}`);
return res.json();
}
function sleep(ms) { return new Promise(resolve => setTimeout(resolve, ms)); }
async function pollScan(id) {
const start = Date.now();
while (Date.now() - start < 120000) {
await sleep(1800);
const scan = await fetchJSON(`/v1/scan/${encodeURIComponent(id)}`);
if (scan.status === 'done') return scan;
}
throw new Error('timeout');
}
async function recordToolLead(plan, extra = {}) {
try {
await fetch('/v1/leads', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(Object.assign({ source: 'tool_page', intent: 'tool_interaction', plan, domain: lastDomain, page: window.location.pathname }, extra || {}))
});
} catch (e) {}
}
function submitHostBillOrder(plan) {
const cfg = ORDER_POSTS[plan];
if (!cfg) return false;
const form = document.createElement('form');
form.method = 'post';
form.action = cfg.action;
for (const [name, value] of Object.entries({ action: 'add', id: cfg.id, cycle: cfg.cycle })) {
const input = document.createElement('input');
input.type = 'hidden';
input.name = name;
input.value = value;
form.appendChild(input);
}
document.body.appendChild(form);
form.submit();
return true;
}
function renderScan(scan) {
const findings = (scan.result && Array.isArray(scan.result.findings)) ? scan.result.findings : [];
const critical = findings.filter(f => f.severity === 'error').length;
const warnings = findings.filter(f => f.severity === 'warning').length;
const recommended = critical || findings.length > 1 ? 'cleanup' : 'quick_fix';
const top = findings.slice(0, 5);
const rows = top.length ? top.map((f) => `<div class="finding"><strong>${escapeHTML(f.category || 'DNS Finding')} · ${escapeHTML(f.severity || 'info')}</strong><span>${escapeHTML(f.message || 'Empfohlene Prüfung')}</span></div>`).join('') : '<div class="finding"><strong>Keine kritischen Findings sichtbar</strong><span>Für produktive Domains bleibt Monitoring sinnvoll, damit spätere DNS- und Mail-Änderungen auffallen.</span></div>';
resultBox.innerHTML = `
<h3>${escapeHTML(lastDomain || 'Domain')} geprüft</h3>
<p class="status">${critical} kritisch · ${warnings} Warnungen · ${findings.length} Findings</p>
<div class="findings">${rows}</div>
<div class="actions">
<a class="btn dark" href="/app/detail.html?id=${encodeURIComponent(scan.id)}">Report öffnen</a>
<a class="btn ${recommended === 'cleanup' ? 'primary' : 'blue'}" data-service-lead="${recommended}" href="${recommended === 'cleanup' ? 'https://support.panomity.com/cart/priority-support/DNSMail-Security-Cleanup/&step=0' : 'https://support.panomity.com/cart/priority-support/DNS-Quick-Fix/&step=0'}">${recommended === 'cleanup' ? 'Cleanup für 499 Euro buchen' : 'Quick Fix für 149 Euro buchen'}</a>
</div>
`;
}
if (scanForm) {
scanForm.addEventListener('submit', async (event) => {
event.preventDefault();
const domain = domainInput.value.trim().toLowerCase();
if (!domain) return;
lastDomain = domain;
const button = scanForm.querySelector('button');
button.disabled = true;
button.textContent = 'Scan läuft...';
resultBox.innerHTML = '<h3>Scan läuft</h3><p class="status">DNS-, Mail- und Sicherheitschecks werden ausgeführt.</p>';
await recordToolLead('free_scan', { intent: 'tool_scan_start', domain });
try {
const created = await fetchJSON('/v1/scan', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ domain, listed: true }) });
const scan = await pollScan(created.id);
renderScan(scan);
await recordToolLead('free_scan', { intent: 'tool_scan_done', domain });
} catch (e) {
resultBox.innerHTML = '<h3>Scan konnte nicht abgeschlossen werden</h3><p class="status">Bitte später erneut versuchen oder direkt eine Fix-Anfrage senden.</p>';
} finally {
button.disabled = false;
button.textContent = 'Jetzt prüfen';
}
});
}
document.querySelectorAll('[data-qualified-form]').forEach((form) => {
form.addEventListener('submit', async (event) => {
event.preventDefault();
const data = new FormData(form);
const plan = String(data.get('plan') || 'cleanup');
const status = form.querySelector('.quoteStatus');
if (status) status.textContent = 'Anfrage wird gespeichert...';
await recordToolLead(plan, {
intent: 'qualified_fix_request',
domain: String(data.get('domain') || lastDomain || '').trim().toLowerCase(),
contact_email: String(data.get('email') || '').trim(),
message: String(data.get('message') || '').trim(),
page: window.location.pathname + '#tool-request'
});
if (status) status.textContent = 'Gespeichert. Die Anfrage erscheint im Revenue-Report.';
});
});
document.addEventListener('click', async (event) => {
const cta = event.target.closest('[data-service-lead]');
if (!cta) return;
const plan = cta.dataset.serviceLead;
const fallbackUrl = cta.href;
event.preventDefault();
await recordToolLead(plan, { intent: 'tool_checkout' });
if (submitHostBillOrder(plan)) return;
window.location.href = fallbackUrl;
});