āĻāχāϚāϟāĻŋāĻāĻŽāĻāϞ āĻāύāϕ⧋āĻĄāĻžāϰ/āĻĄāĻŋāϕ⧋āĻĄāĻžāϰ

āωāĻ¨ā§āύāϤ āϏ⧁āϰāĻ•ā§āώāĻž āĻŦ⧈āĻļāĻŋāĻˇā§āĻŸā§āϝāϏāĻš āĻĒ⧇āĻļāĻžāĻĻāĻžāϰ āĻāχāϚāϟāĻŋāĻāĻŽāĻāϞ āĻāύāϕ⧋āĻĄāĻŋāĻ‚ āĻāĻŦāĻ‚ āĻĄāĻŋāϕ⧋āĻĄāĻŋāĻ‚ āϟ⧁āϞāĨ¤ āĻāĻ•ā§āϏāĻāϏāĻāϏ āφāĻ•ā§āϰāĻŽāĻŖ āĻĨ⧇āϕ⧇ āϏ⧁āϰāĻ•ā§āώāĻž āĻ•āϰ⧁āύ, āĻŦāĻŋāĻļ⧇āώ āĻ…āĻ•ā§āώāϰ āĻāύāϕ⧋āĻĄ āĻ•āϰ⧁āύ āĻāĻŦāĻ‚ āύāĻŋāϰāĻžāĻĒāĻĻ āĻ“āϝāĻŧ⧇āĻŦ āĻ•āĻ¨ā§āĻŸā§‡āĻ¨ā§āϟ āύāĻŋāĻļā§āϚāĻŋāϤ āĻ•āϰ⧁āύāĨ¤ āϰāĻŋāϝāĻŧ⧇āϞ-āϟāĻžāχāĻŽ āϏ⧁āϰāĻ•ā§āώāĻž āĻŦāĻŋāĻļā§āϞ⧇āώāĻŖāϏāĻš āύ⧇āĻŽāĻĄ āĻāύāϟāĻŋāϟāĻŋ, āύāĻŋāωāĻŽā§‡āϰāĻŋāĻ• āĻāύāϟāĻŋāϟāĻŋ āĻāĻŦāĻ‚ āχāωāφāϰāĻāϞ āĻāύāϕ⧋āĻĄāĻŋāĻ‚ āϏāĻŽāĻ°ā§āĻĨāύ āĻ•āϰ⧇āĨ¤

āĻāύāϕ⧋āĻĄāĻŋāĻ‚ āϟāĻžāχāĻĒ
āĻ…āϤāĻŋāϰāĻŋāĻ•ā§āϤ āĻ…āĻĒāĻļāύ
āĻ•āĻžāĻ°ā§āϝāĻ•ā§āϰāĻŽ
āĻāύāϕ⧋āĻĄ āĻ•āϰāĻž āφāωāϟāĻĒ⧁āϟ
āĻĄāĻŋāϕ⧋āĻĄ āĻ•āϰāĻž āφāωāϟāĻĒ⧁āϟ

āϏāĻžāϧāĻžāϰāĻŖ āĻāχāϚāϟāĻŋāĻāĻŽāĻāϞ āĻāύāϟāĻŋāϟāĻŋ āϰ⧇āĻĢāĻžāϰ⧇āĻ¨ā§āϏ

āĻ…āĻ•ā§āώāϰ āύ⧇āĻŽāĻĄ āĻāύāϟāĻŋāϟāĻŋ āϏāĻ‚āĻ–ā§āϝāĻžāϏ⧂āϚāĻ• āĻāύāϟāĻŋāϟāĻŋ āĻšā§‡āĻ•ā§āϏ āĻāύāϟāĻŋāϟāĻŋ āĻŦāĻŋāĻŦāϰāĻŖ
< < < < āĻāϰ āĻšā§‡āϝāĻŧ⧇ āĻ•āĻŽ
> > > > āĻāϰ āĻšā§‡āϝāĻŧ⧇ āĻŦ⧇āĻļāĻŋ
& & & & āĻ…ā§āϝāĻžāĻŽā§āĻĒāĻžāϰāĻ¸ā§āϝāĻžāĻ¨ā§āĻĄ
" " " " āĻĄāĻžāĻŦāϞ āϕ⧋āϟ
' ' ' ' āϏāĻŋāĻ™ā§āϗ⧇āϞ āϕ⧋āϟ
        āύāύ-āĻŦā§āϰ⧇āĻ•āĻŋāĻ‚ āĻ¸ā§āĻĒ⧇āϏ
Š © © © āĻ•āĻĒāĻŋāϰāĻžāχāϟ
ÂŽ ® ® ® āύāĻŋāĻŦāĻ¨ā§āϧāĻŋāϤ āĻŸā§āϰ⧇āĻĄāĻŽāĻžāĻ°ā§āĻ•

āύāĻŽā§āύāĻž āĻāύāϕ⧋āĻĄāĻŋāĻ‚/āĻĄāĻŋāϕ⧋āĻĄāĻŋāĻ‚ āωāĻĻāĻžāĻšāϰāĻŖ

āĻāĻ•ā§āϏāĻāϏāĻāϏ āφāĻ•ā§āϰāĻŽāĻŖ āĻĒā§āϰāϤāĻŋāϰ⧋āϧ
āϏāĻžāϧāĻžāϰāĻŖ āĻāĻ•ā§āϏāĻāϏāĻāϏ āφāĻ•ā§āϰāĻŽāϪ⧇āϰ āĻĒā§āϝāĻžāϟāĻžāĻ°ā§āύ āϝāĻžāϰ āϜāĻ¨ā§āϝ āωāĻĒāϝ⧁āĻ•ā§āϤ āĻāύāϕ⧋āĻĄāĻŋāĻ‚ āĻĒā§āϰāϝāĻŧā§‹āϜāύ
āĻāχāϚāϟāĻŋāĻāĻŽāĻāϞ āĻ•āĻ¨ā§āĻŸā§‡āĻ¨ā§āϟ
āĻšā§āϝāĻžāϞ⧋ āĻāĻŦāĻ‚ āĻ¸ā§āĻŦāĻžāĻ—āϤāĻŽ
āĻŦāĻŋāĻļ⧇āώ āĻ…āĻ•ā§āώāϰāϝ⧁āĻ•ā§āϤ āĻ¸ā§āĻŸā§āϝāĻžāĻ¨ā§āĻĄāĻžāĻ°ā§āĻĄ āĻāχāϚāϟāĻŋāĻāĻŽāĻāϞ
āωāĻĻā§āϧ⧃āϤāĻŋ āĻŦā§āϝāĻŦāĻ¸ā§āĻĨāĻžāĻĒāύāĻž
āϏ⧇ āĻŦāϞāϞ "āĻšā§āϝāĻžāϞ⧋" āĻāĻŦāĻ‚ āϏ⧇ āωāĻ¤ā§āϤāϰ āĻĻāĻŋāϞ 'āĻšāĻžāχ'
āĻāĻ•āĻ• āĻ“ āĻĻā§āĻŦ⧈āϤ āωāĻĻā§āϧ⧃āϤāĻŋ āϚāĻŋāĻšā§āύāϝ⧁āĻ•ā§āϤ āĻŸā§‡āĻ•ā§āϏāϟ
āχāωāύāĻŋāϕ⧋āĻĄ āĻ…āĻ•ā§āώāϰ
Š ⧍ā§Ļ⧍ā§Ģ āϕ⧋āĻŽā§āĻĒāĻžāύāĻŋâ„ĸ â€ĸ āϏāĻ°ā§āĻŦāĻ¸ā§āĻŦāĻ¤ā§āĻŦ āϏāĻ‚āϰāĻ•ā§āώāĻŋāϤ
āĻŦāĻŋāĻļ⧇āώ āĻĒā§āϰāϤ⧀āĻ• āĻ“ āχāωāύāĻŋāϕ⧋āĻĄ āĻ…āĻ•ā§āώāϰ
āϜāĻžāĻ­āĻžāĻ¸ā§āĻ•ā§āϰāĻŋāĻĒā§āϟ āχāύāĻœā§‡āĻ•āĻļāύ
javascript:alert(document.cookie)
āϜāĻžāĻ­āĻžāĻ¸ā§āĻ•ā§āϰāĻŋāĻĒā§āϟ āχāωāφāϰāĻāϞ āχāύāĻœā§‡āĻ•āĻļāύ āĻĒā§āϰāĻšā§‡āĻˇā§āϟāĻž
āĻĢāĻ°ā§āĻŽ āĻĄā§‡āϟāĻž
name=John&email=john@example.com&message=Hello!
āĻŦāĻŋāĻļ⧇āώ āĻ…āĻ•ā§āώāϰāϝ⧁āĻ•ā§āϤ āχāωāφāϰāĻāϞ-āĻāύāϕ⧋āĻĄā§‡āĻĄ āĻĢāĻ°ā§āĻŽ āĻĄā§‡āϟāĻž

āφāĻĒāύāĻžāϰ āĻĒā§āϰāĻœā§‡āĻ•ā§āĻŸā§‡āϰ āϜāĻ¨ā§āϝ āĻ“āϝāĻŧ⧇āĻŦ āύāĻŋāϰāĻžāĻĒāĻ¤ā§āϤāĻž āϏāĻŽāĻžāϧāĻžāύ āĻĒā§āϰāϝāĻŧā§‹āϜāύ?

āĻļā§€āĻ°ā§āώ āĻ•ā§āϞāĻžāωāĻĄ āύāĻŋāϰāĻžāĻĒāĻ¤ā§āϤāĻž āĻĒāϰāĻŋāώ⧇āĻŦāĻž āϏāĻš āύāĻŋāϰāĻžāĻĒāĻĻ āĻ…ā§āϝāĻžāĻĒā§āϞāĻŋāϕ⧇āĻļāύ āĻĄā§‡āĻĒā§āϞāϝāĻŧ āĻ•āϰ⧁āύ

✨ Smart Nation's Core Infrastructure: WIA Code ✨

āĻĄā§āϰ⧋āĻ¨Âˇāϰ⧋āĻŦāϟ āĻĄā§‡āϞāĻŋāĻ­āĻžāϰāĻŋ, āĻ¸ā§āĻŦāϝāĻŧāĻ‚āĻ•ā§āϰāĻŋāϝāĻŧ āĻĄā§āϰāĻžāχāĻ­āĻŋāĻ‚, āϜāϰ⧁āϰāĻŋ āωāĻĻā§āϧāĻžāϰ āĻāĻŦāĻ‚ āφāϰāĻ“ āĻ…āύ⧇āĻ• āĻ•āĻŋāϛ⧁ - āφāĻĒāύāĻžāϰ āĻĻ⧇āĻļ⧇āϰ āϜāĻ¨ā§āϝ ā§Šā§Ļ āĻĻāĻŋāύ āϏāĻŽā§āĻĒā§‚āĻ°ā§āĻŖ āĻŦāĻŋāύāĻžāĻŽā§‚āĻ˛ā§āϝ⧇ āĻ­āĻŦāĻŋāĻˇā§āϝāϤ⧇āϰ āĻ…āĻ­āĻŋāĻœā§āĻžāϤāĻž āύāĻŋāύ!

āĻĄāĻŦā§āϞāĻŋāωāφāχāĻ āϕ⧋āĻĄ āϏāĻŽā§āĻĒāĻ°ā§āϕ⧇ āφāϰāĻ“ āϜāĻžāύ⧁āύ

🤖 āφāĻĒāύāĻžāϰ āĻāφāχ āϏāĻšāĻ•āĻžāϰ⧀ āĻŦ⧇āϛ⧇ āύāĻŋāύ

đŸ’Ŧ āĻšā§āϝāĻžāϟāϜāĻŋāĻĒāĻŋāϟāĻŋ
āϏāĻ°ā§āĻŦāĻžāϧāĻŋāĻ• āĻŦāĻšā§āĻŽā§āĻ–ā§€ â€ĸ āϏāĻžāϧāĻžāϰāĻŖ āĻ•āĻžāĻœā§‡āϰ āϜāĻ¨ā§āϝ āϏ⧇āϰāĻž
🧠 āĻ•ā§āϞāĻĄ
āϏ⧇āϰāĻž āϝ⧁āĻ•ā§āϤāĻŋ â€ĸ āĻŦāĻŋāĻļā§āϞ⧇āώāϪ⧇āϰ āϜāĻ¨ā§āϝ āύāĻŋāϖ⧁āρāϤ
✨ āĻœā§‡āĻŽāĻŋāύāĻžāχ āĻŦāĻŋāύāĻžāĻŽā§‚āĻ˛ā§āϝ
āĻĻ⧈āύāĻŋāĻ• āĻĢā§āϰāĻŋ āϏ⧀āĻŽāĻž â€ĸ āĻ…āĻ¨ā§āϤāĻ°ā§āύāĻŋāĻ°ā§āĻŽāĻŋāϤ āĻšā§āϝāĻžāϟ
', html: '
āĻšā§āϝāĻžāϞ⧋ āĻāĻŦāĻ‚ āĻ¸ā§āĻŦāĻžāĻ—āϤāĻŽ
', quotes: 'He said "Hello" & she replied \'Hi\'', unicode: 'Š 2025 Companyâ„ĸ â€ĸ All Rights Reserved', javascript: 'javascript:alert(document.cookie)', form: 'name=John&email=john@example.com&message=Hello!' }; // HTML Entities Map const HTML_ENTITIES = { '&': '&', '<': '<', '>': '>', '"': '"', "'": ''', '\n': ' ', '\r': ' ', '\t': ' ' }; // Extended HTML Entities const EXTENDED_ENTITIES = { 'Š': 'Š', 'ÂŽ': 'ÂŽ', 'â„ĸ': 'â„ĸ', 'â‚Ŧ': 'â‚Ŧ', 'ÂŖ': 'ÂŖ', 'ÂĨ': 'ÂĨ', '§': '§', 'Âļ': 'Âļ', 'â€ĸ': 'â€ĸ', 'â€Ļ': 'â€Ļ', '–': '–', '—': '—', ''': '‘', ''': '’', '"': '“', '"': '”', 'ÂĢ': 'ÂĢ', 'Âģ': 'Âģ', '°': '°', 'Âą': 'Âą', '×': '×', 'Ãˇ': 'Ãˇ', 'Âŧ': 'Âŧ', 'ÂŊ': 'ÂŊ', 'ž': 'ž', 'Îą': 'Îą', 'β': 'β', 'Îŗ': 'Îŗ', 'δ': 'δ', 'Îĩ': 'Îĩ', 'Îģ': 'Îģ', 'Îŧ': 'Îŧ', 'Ī€': 'Ī€', '΃': '΃', 'Ī„': 'Ī„', 'Ά': 'Ά', 'Ή': 'Ή' }; // XSS Pattern Detection const XSS_PATTERNS = [ /]*>/i, /javascript:/i, /vbscript:/i, /onload\s*=/i, /onclick\s*=/i, /onerror\s*=/i, /onmouseover\s*=/i, /onfocus\s*=/i, /onblur\s*=/i, /eval\s*\(/i, /document\.cookie/i, /document\.write/i, /window\.location/i, /alert\s*\(/i, /confirm\s*\(/i, /prompt\s*\(/i, /]*>/i, /]*>/i, /]*>/i, /]*>/i, /]*>/i, /data:[^;]*;base64/i, /\.innerHTML/i, /\.outerHTML/i ]; // ========== MAIN PROCESSING FUNCTIONS ========== // Main processing function function processText() { const input = document.getElementById('inputText').value; if (!input.trim()) { document.getElementById('encodedOutput').textContent = ''; document.getElementById('decodedOutput').textContent = ''; hideSecurityAnalysis(); return; } try { // Encode const encoded = encodeHTML(input); document.getElementById('encodedOutput').textContent = encoded; // Decode const decoded = decodeHTML(input); document.getElementById('decodedOutput').textContent = decoded; // Security analysis performSecurityAnalysis(input); // Show OTA after successful processing showOTA(); // Track usage trackEvent('html_processed', { hasXSSPatterns: detectXSSPatterns(input).length > 0 }); } catch (error) { showNotification(`Error: ${error.message}`, 'error'); } } // HTML Encoding Function function encodeHTML(text) { let encoded = text; // Basic HTML encoding if (document.getElementById('encodeBasic').checked) { encoded = encoded.replace(/&/g, '&') .replace(//g, '>'); } // Quote encoding if (document.getElementById('encodeQuotes').checked) { encoded = encoded.replace(/"/g, '"') .replace(/'/g, '''); } // Extended characters if (document.getElementById('encodeExtended').checked) { for (const [char, entity] of Object.entries(EXTENDED_ENTITIES)) { encoded = encoded.replace(new RegExp(escapeRegExp(char), 'g'), entity); } } // Numeric entities if (document.getElementById('encodeNumeric').checked) { encoded = encoded.replace(/[^\x00-\x7F]/g, function(char) { return '&#' + char.charCodeAt(0) + ';'; }); } // Newlines if (document.getElementById('encodeNewlines').checked) { encoded = encoded.replace(/\n/g, ' ') .replace(/\r/g, ' ') .replace(/\t/g, ' '); } // URL encoding if (document.getElementById('urlEncode').checked) { encoded = encodeURIComponent(encoded); } return encoded; } // HTML Decoding Function function decodeHTML(text) { let decoded = text; try { // URL decode first if needed if (text.includes('%')) { try { decoded = decodeURIComponent(decoded); } catch (e) { // If URL decoding fails, continue with original text } } // Decode HTML entities const tempDiv = document.createElement('div'); tempDiv.innerHTML = decoded; decoded = tempDiv.textContent || tempDiv.innerText || ''; return decoded; } catch (error) { return text; // Return original if decoding fails } } // XSS Pattern Detection function detectXSSPatterns(text) { const detectedPatterns = []; for (const pattern of XSS_PATTERNS) { if (pattern.test(text)) { detectedPatterns.push(pattern.source); } } return detectedPatterns; } // Security Analysis function performSecurityAnalysis(text) { const items = []; // XSS pattern detection const xssPatterns = detectXSSPatterns(text); if (xssPatterns.length > 0) { items.push({ type: 'error', icon: '🚨', message: `Potential XSS patterns detected: ${xssPatterns.length} suspicious patterns found` }); } else { items.push({ type: 'success', icon: '✅', message: 'āϕ⧋āύ⧋ āĻ¸ā§āĻĒāĻˇā§āϟ XSS āĻĒā§āϝāĻžāϟāĻžāĻ°ā§āύ āĻĒāĻžāĻ“āϝāĻŧāĻž āϝāĻžāϝāĻŧāύāĻŋ' }); } // HTML tag detection const htmlTags = text.match(/<[^>]+>/g); if (htmlTags) { if (htmlTags.length > 5) { items.push({ type: 'warning', icon: 'âš ī¸', message: `Contains ${htmlTags.length} HTML tags - verify if intentional` }); } else { items.push({ type: 'info', icon: 'â„šī¸', message: `Contains ${htmlTags.length} HTML tags` }); } } // JavaScript protocol detection if (/javascript:/i.test(text)) { items.push({ type: 'error', icon: '🛑', message: 'āϜāĻžāĻ­āĻžāĻ¸ā§āĻ•ā§āϰāĻŋāĻĒā§āϟ āĻĒā§āϰ⧋āĻŸā§‹āĻ•āϞ āϰāϝāĻŧ⧇āϛ⧇ - āωāĻšā§āϚ XSS āĻā§āρāĻ•āĻŋ!' }); } // Event handler detection if (/on\w+\s*=/i.test(text)) { items.push({ type: 'error', icon: '⚡', message: 'HTML āχāϭ⧇āĻ¨ā§āϟ āĻšā§āϝāĻžāĻ¨ā§āĻĄāϞāĻžāϰ āϰāϝāĻŧ⧇āϛ⧇ - āϏāĻŽā§āĻ­āĻžāĻŦā§āϝ XSS āϭ⧇āĻ•ā§āϟāϰ' }); } // Special characters analysis const specialChars = text.match(/[<>&"']/g); if (specialChars) { items.push({ type: 'info', icon: '🔤', message: `Contains ${specialChars.length} special HTML characters` }); } // Unicode analysis const unicodeChars = text.match(/[^\x00-\x7F]/g); if (unicodeChars) { items.push({ type: 'info', icon: '🌐', message: `Contains ${unicodeChars.length} Unicode characters` }); } // Encoding recommendations if (xssPatterns.length > 0 || htmlTags) { items.push({ type: 'warning', icon: '💡', message: 'āϏ⧁āĻĒāĻžāϰāĻŋāĻļ: āĻ“āϝāĻŧ⧇āĻŦ āφāωāϟāĻĒ⧁āĻŸā§‡āϰ āϜāĻ¨ā§āϝ āĻ•āύāĻŸā§‡āĻ•ā§āϏāϟ-āϏāĻšā§‡āϤāύ āĻāύāϕ⧋āĻĄāĻŋāĻ‚ āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰ⧁āύ' }); } displaySecurityAnalysis(items); } // Display Security Analysis function displaySecurityAnalysis(items) { const container = document.getElementById('securityItems'); const analysisSection = document.getElementById('securityAnalysis'); container.innerHTML = ''; items.forEach(item => { const div = document.createElement('div'); div.className = `security-item ${item.type}`; div.innerHTML = ` ${item.icon} ${item.message} `; container.appendChild(div); }); analysisSection.style.display = 'block'; } // Hide Security Analysis function hideSecurityAnalysis() { document.getElementById('securityAnalysis').style.display = 'none'; } // Use Sample function useSample(sampleId) { const sample = HTML_SAMPLES[sampleId]; if (!sample) return; document.getElementById('inputText').value = sample; processText(); // Smooth scroll to results setTimeout(() => { document.querySelector('.results-section').scrollIntoView({ behavior: 'smooth', block: 'start' }); }, 100); trackEvent('sample_used', { sample: sampleId }); } // Clear All function clearAll() { document.getElementById('inputText').value = ''; document.getElementById('encodedOutput').textContent = ''; document.getElementById('decodedOutput').textContent = ''; hideSecurityAnalysis(); } // Swap Input/Output function swapInputOutput() { const input = document.getElementById('inputText'); const encoded = document.getElementById('encodedOutput').textContent; if (encoded) { input.value = encoded; processText(); } } // ========== UTILITY FUNCTIONS ========== // Escape RegExp function escapeRegExp(string) { return string.replace(/[.*+?^${}()|[\]\\]/g, '\\ āĻāĻĒāĻŋāφāχ āϕ⧀ āĻĒāϰāĻŋāĻŦāĻ°ā§āϤāύ āĻ•āϰ⧁āύ'; } else { statusEl.textContent = 'āϕ⧋āύ⧋ āĻāĻĒāĻŋāφāχ āϕ⧀ āϏ⧇āϟ āĻ•āϰāĻž āύ⧇āχ'; } } // ėą„íŒ… ëŠ”ė‹œė§€ ėļ”ę°€ function addMessage(type, content) { const chatMessages = document.getElementById('chatMessages'); const messageDiv = document.createElement('div'); messageDiv.className = `message ${type}`; if (type === 'user') { messageDiv.innerHTML = `You: ${content}`; } else { messageDiv.innerHTML = `✨ Gemini:
${content.replace(/\n/g, '
')}`; } chatMessages.appendChild(messageDiv); chatMessages.scrollTop = chatMessages.scrollHeight; } // Gemini뗐 ëŠ”ė‹œė§€ ė „ė†Ą async function sendToGemini() { const input = document.getElementById('geminiInput'); const message = input.value.trim(); if (!message) return; addMessage('user', message); input.value = ''; const loadingMsg = document.createElement('div'); loadingMsg.className = 'message assistant'; loadingMsg.innerHTML = '✨ Gemini:
Thinking...'; loadingMsg.id = 'loading-message'; document.getElementById('chatMessages').appendChild(loadingMsg); try { const currentText = document.getElementById('inputText').value.trim(); let contextInfo = ''; if (currentText) { const xssPatterns = detectXSSPatterns(currentText); contextInfo = `\n\nCurrent HTML content context: - Length: ${currentText.length} characters - Contains HTML tags: ${/<[^>]+>/.test(currentText)} - XSS patterns detected: ${xssPatterns.length} - Special characters: ${/[<>&"']/.test(currentText)}`; } const response = await fetch(`https://generativelanguage.googleapis.com/v1beta/models/gemini-pro:generateContent?key=${aiModalState.apiKey}`, { method: 'āĻĒā§‹āĻ¸ā§āϟ', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ contents: [{ parts: [{ text: `You are a web security expert helping a developer with HTML encoding/decoding and XSS prevention. Context: The user is working with an HTML encoder/decoder tool for web security purposes. They need help with proper character encoding, XSS prevention, and secure web development practices. Please provide accurate, security-focused advice about: - HTML entity encoding/decoding - XSS prevention techniques - Context-aware output encoding - Web security best practices - Character set handling ${contextInfo} User question: ${message}` }] }], generationConfig: { temperature: 0.7, maxOutputTokens: 1000 } }) }); const data = await response.json(); document.getElementById('loading-message').remove(); if (data.candidates && data.candidates[0] && data.candidates[0].content) { const reply = data.candidates[0].content.parts[0].text; addMessage('assistant', reply); } else { addMessage('assistant', 'Sorry, I could not generate a response. Please try again.'); } } catch (error) { document.getElementById('loading-message')?.remove(); if (error.message.includes('āĻāĻĒāĻŋāφāχ āϕ⧀')) { addMessage('error', 'Invalid API key. Please check your API key and try again.'); showAPIKeySetup(); } else { addMessage('error', 'Failed to connect to Gemini. Please check your internet connection and try again.'); } } } // ========== EVENT LISTENERS ========== document.addEventListener('āĻĄāĻŽāĻ•āύāĻŸā§‡āĻ¨ā§āϟāϞ⧋āĻĄā§‡āĻĄ', function() { // AI 버íŠŧ ė´ë˛¤íŠ¸ document.getElementById('aiBtn').addEventListener('click', openAIModal); // ëǍë‹Ŧ 뙏ëļ€ í´ëĻ­ė‹œ ë‹Ģ기 document.getElementById('aiModal').addEventListener('click', function(e) { if (e.target === this) { closeAIModal(); } }); // í‚¤ëŗ´ë“œ ė´ë˛¤íŠ¸ document.addEventListener('keydown', function(e) { if (e.key === 'āĻāĻ¨ā§āϟāĻžāϰ') { const geminiInput = document.getElementById('geminiInput'); if (document.activeElement === geminiInput) { sendToGemini(); } } if (e.key === 'āĻāĻ¸ā§āϕ⧇āĻĒ') { closeAIModal(); } }); // ė´ˆę¸°í™” updateAPIKeyStatus(); updateCurrentYear(); updateToolCount(); // Load default sample useSample('html'); }); // ========== DYNAMIC TOOL COUNT ========== async function updateToolCount() { try { const response = await fetch('/api/tool-count.php'); const data = await response.json(); document.querySelectorAll('.dynamic-tools-count').forEach(el => { el.textContent = `${data.count}+ free online tools in 206 languages. No signup, no fees, just tools that work.`; }); document.querySelectorAll('.dynamic-count').forEach(el => { const prefix = el.getAttribute('data-text') || ''; const suffix = el.getAttribute('data-suffix') || ''; const icon = el.textContent.split(' ')[0] || ''; el.textContent = `${icon} ${prefix} ${data.count}+ ${suffix}`; }); } catch (error) { const fallbackCount = 333; document.querySelectorAll('.dynamic-tools-count').forEach(el => { el.textContent = `${fallbackCount}+ free online tools in 206 languages. No signup, no fees, just tools that work.`; }); document.querySelectorAll('.dynamic-count').forEach(el => { const prefix = el.getAttribute('data-text') || ''; const suffix = el.getAttribute('data-suffix') || ''; const icon = el.textContent.split(' ')[0] || ''; el.textContent = `${icon} ${prefix} ${fallbackCount}+ ${suffix}`; }); } } function updateCurrentYear() { const currentYear = new Date().getFullYear(); document.querySelectorAll('.current-year').forEach(el => { el.textContent = currentYear; }); } // ========== ANALYTICS ========== window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'G-XXXXXXXXX'); trackEvent('page_view', { tool: TOOL_CONFIG.name, category: TOOL_CONFIG.category });