/g, '>') .replace(/"/g, '"') .replace(/'/g, '''); } function showLoading(show) { document.getElementById('loadingContainer').style.display = show ? 'block' : 'none'; document.getElementById('chestTable').style.display = show ? 'none' : 'table'; } function showError(show) { document.getElementById('errorContainer').style.display = show ? 'block' : 'none'; } function changeLanguage(lang) { if (!allowedLangs.includes(lang)) return; currentLang = lang; localStorage.setItem('selectedLanguage', lang); loadData(); } function updateUILanguage() { if (!siteLang || !siteLang[currentLang]) return; const lang = siteLang[currentLang]; document.querySelector('h1').textContent = lang.title; document.title = lang.title; document.getElementById('searchInput').placeholder = lang.search_placeholder; const buttons = document.querySelectorAll('.btn'); buttons.forEach(button => { const text = button.textContent.trim(); if (text === 'Server Status') button.textContent = lang.server_status; else if (text === 'Mob Database') button.textContent = lang.mob_database; else if (text === 'Mob Finder') button.textContent = lang.mob_finder; else if (text === 'Upgrade Database') button.textContent = lang.upgrade_database; }); const openButtons = document.querySelectorAll('.btn-warning'); openButtons.forEach(button => { if (button.innerHTML.includes('fas fa-gift')) { button.innerHTML = ` ${lang.open}`; } }); const loadingText = document.querySelector('.loading p'); if (loadingText) loadingText.textContent = lang.loading_chest_data; const errorText = document.querySelector('.error p'); if (errorText) errorText.textContent = lang.error_message; const tableHeaders = document.querySelectorAll('#chestTable th'); if (tableHeaders.length >= 2) { tableHeaders[0].textContent = lang.chest_name; tableHeaders[1].textContent = lang.drop_list; } const scrollBtn = document.getElementById('scrollTopBtn'); if (scrollBtn) { scrollBtn.title = lang.scroll_to_top; const btnText = scrollBtn.querySelector('span') || scrollBtn; btnText.textContent = lang.top; } updateMetaTags(lang); } function setupEventListeners() { document.getElementById('searchInput').addEventListener('keyup', function() { const filter = this.value.toLowerCase(); const rows = document.querySelectorAll('#chestTableBody tr'); rows.forEach(function(row) { const chestName = row.querySelector('td:nth-child(1)').textContent.toLowerCase(); const dropList = (row.dataset.drops || ''); if (chestName.indexOf(filter) > -1 || dropList.indexOf(filter) > -1) { row.style.display = ''; } else { row.style.display = 'none'; } }); }); window.onscroll = function() { if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) { document.getElementById("scrollTopBtn").style.display = "block"; } else { document.getElementById("scrollTopBtn").style.display = "none"; } }; document.getElementById('scrollTopBtn').addEventListener('click', function() { document.body.scrollTop = 0; document.documentElement.scrollTop = 0; }); } function openChest(chestId, chestName) { const dropList = chestData[chestId]; if (!dropList) return; const countInput = document.getElementById(`chestCount_${chestId}`); const openCount = parseInt(countInput.value) || 1; if (openCount > 1000) { alert(siteLang && siteLang[currentLang] ? siteLang[currentLang].maximum_1000 : 'Maksimum 1000 kere açabilirsiniz!'); return; } const chestIcon = itemIcons[chestId] || 'dummy.png'; const items = []; Object.entries(dropList).forEach(([dropIndex, item]) => { let chanceStr = item.chance || '0'; if (typeof chanceStr === 'string') { chanceStr = chanceStr.replace('%', '').trim(); } const chance = parseFloat(chanceStr) || 0; const count = item.count || 1; const vnum = item.vnum; const itemName = getItemName(item); const iconFile = getItemIcon(vnum); items.push({ name: itemName, chance: chance, count: count, vnum: vnum, icon: iconFile }); }); const random = Math.random() * 100; let cumulativeChance = 0; let selectedItem = null; for (const item of items) { cumulativeChance += item.chance; if (random <= cumulativeChance) { selectedItem = item; break; } } const results = {}; for (let i = 0; i < openCount; i++) { const random = Math.random() * 100; let cumulativeChance = 0; let selectedItem = null; for (const item of items) { cumulativeChance += item.chance; if (random <= cumulativeChance) { selectedItem = item; break; } } if (!selectedItem && items.length > 0) { selectedItem = items[0]; } if (selectedItem) { const itemKey = `${selectedItem.name}_${selectedItem.count}`; if (results[itemKey]) { results[itemKey].count += 1; } else { results[itemKey] = { name: selectedItem.name, icon: selectedItem.icon, itemCount: selectedItem.count, chance: selectedItem.chance, count: 1 }; } } } if (Object.keys(results).length > 0) { const lang = siteLang && siteLang[currentLang] ? siteLang[currentLang] : { opened: 'Açıldı', item: 'Item', quantity: 'Miktar', won: 'Kazanıldı', chance: 'Şans' }; let resultHtml = `
`; resultHtml += `
# | ${lang.item} | ${lang.quantity} | ${lang.won} | ${lang.chance} |
`; Object.values(results).forEach(result => { const countDisplay = result.itemCount > 1 ? (result.name.toLowerCase().includes('exp') || result.name.toLowerCase().includes('deneyim') || result.name.toLowerCase().includes('yang')) ? `(${result.itemCount.toLocaleString('tr-TR')})` : `(${result.itemCount}x)` : ''; resultHtml += `  | ${result.name} | ${countDisplay || '-'} | ${result.count}x | %${result.chance.toFixed(2)} |
`; }); resultHtml += `
`; resultHtml += `
`; showResultModal(resultHtml, chestId, chestName, openCount); } } function retryChest(chestId, chestName) { const dropList = chestData[chestId]; if (!dropList) return; const countInput = document.getElementById(`modalChestCount_${chestId}`); const openCount = parseInt(countInput.value) || 1; if (openCount > 1000) { alert(siteLang && siteLang[currentLang] ? siteLang[currentLang].maximum_1000 : 'Maksimum 1000 kere açabilirsiniz!'); return; } const chestIcon = itemIcons[chestId] || 'dummy.png'; const items = []; Object.entries(dropList).forEach(([dropIndex, item]) => { let chanceStr = item.chance || '0'; if (typeof chanceStr === 'string') { chanceStr = chanceStr.replace('%', '').trim(); } const chance = parseFloat(chanceStr) || 0; const count = item.count || 1; const vnum = item.vnum; const itemName = getItemName(item); const iconFile = getItemIcon(vnum); items.push({ name: itemName, chance: chance, count: count, vnum: vnum, icon: iconFile }); }); const random = Math.random() * 100; let cumulativeChance = 0; let selectedItem = null; for (const item of items) { cumulativeChance += item.chance; if (random <= cumulativeChance) { selectedItem = item; break; } } if (!selectedItem && items.length > 0) { selectedItem = items[0]; } if (selectedItem) { const countDisplay = selectedItem.count > 1 ? (selectedItem.name.toLowerCase().includes('exp') || selectedItem.name.toLowerCase().includes('deneyim') || selectedItem.name.toLowerCase().includes('yang')) ? `(${selectedItem.count.toLocaleString('tr-TR')})` : `(${selectedItem.count}x)` : ''; const results = {}; for (let i = 0; i < openCount; i++) { const random = Math.random() * 100; let cumulativeChance = 0; let selectedItem = null; for (const item of items) { cumulativeChance += item.chance; if (random <= cumulativeChance) { selectedItem = item; break; } } if (!selectedItem && items.length > 0) { selectedItem = items[0]; } if (selectedItem) { const itemKey = `${selectedItem.name}_${selectedItem.count}`; if (results[itemKey]) { results[itemKey].count += 1; } else { results[itemKey] = { name: selectedItem.name, icon: selectedItem.icon, itemCount: selectedItem.count, chance: selectedItem.chance, count: 1 }; } } } if (Object.keys(results).length > 0) { const lang = siteLang && siteLang[currentLang] ? siteLang[currentLang] : { opened: 'Açıldı', item: 'Item', quantity: 'Miktar', won: 'Kazanıldı', chance: 'Şans' }; let resultHtml = ` `; resultHtml += `
# | ${lang.item} | ${lang.quantity} | ${lang.won} | ${lang.chance} |
`; Object.values(results).forEach(result => { const countDisplay = result.itemCount > 1 ? (result.name.toLowerCase().includes('exp') || result.name.toLowerCase().includes('deneyim') || result.name.toLowerCase().includes('yang')) ? `(${result.itemCount.toLocaleString('tr-TR')})` : `(${result.itemCount}x)` : ''; resultHtml += `  | ${result.name} | ${countDisplay || '-'} | ${result.count}x | %${result.chance.toFixed(2)} |
`; }); resultHtml += `
`; resultHtml += `
`; const modalBody = document.querySelector('#resultModal .modal-body'); if (modalBody) { modalBody.innerHTML = resultHtml; } } } } function showResultModal(content, chestId, chestName, openCount = 1) { const lang = siteLang && siteLang[currentLang] ? siteLang[currentLang] : { chest_result: 'Sandık Sonucu', retry: 'Tekrar Dene', download_image: 'Resim İndir' }; const modalHtml = ` `; const oldModal = document.getElementById('resultModal'); if (oldModal) { oldModal.remove(); } document.body.insertAdjacentHTML('beforeend', modalHtml); const modal = new bootstrap.Modal(document.getElementById('resultModal')); modal.show(); } function downloadResult(chestId) { const modalBody = document.querySelector('#resultModal .modal-body'); if (!modalBody) return; const chestIcon = itemIcons[chestId] || 'dummy.png'; const chestName = itemNames[chestId] || `Sandık #${chestId}`; const openCountInput = document.getElementById(`modalChestCount_${chestId}`); const openCount = openCountInput ? parseInt(openCountInput.value) || 1 : 1; const now = new Date(); const timestamp = `${now.toLocaleDateString('tr-TR')} ${now.toLocaleTimeString('tr-TR')}`; const container = document.createElement('div'); container.style.cssText = ` background:#121212; color:#ffffff; padding:24px 18px; border-radius:12px; font-family:Arial, sans-serif; width:420px; position:fixed; left:-9999px; top:0; `; container.innerHTML = `
${chestName} (${openCount}x)
Metin2Alerts • ${timestamp}
`; const contentClone = modalBody.cloneNode(true); contentClone.querySelectorAll('.chest-result-header').forEach(el => el.remove()); contentClone.querySelectorAll('table').forEach(tbl => { tbl.style.fontSize = '12px'; tbl.style.width = '100%'; }); contentClone.querySelectorAll('th, td').forEach(cell => { cell.style.padding = '6px'; }); container.appendChild(contentClone); document.body.appendChild(container); html2canvas(container, { backgroundColor: '#121212', scale: 2, useCORS: true, allowTaint: true, width: 420, height: container.scrollHeight }).then(canvas => { const link = document.createElement('a'); const safeTs = now.toISOString().replace(/[:.]/g, '-'); link.download = `metin2alerts_${safeTs}.png`; link.href = canvas.toDataURL('image/png'); link.click(); }).catch(error => { console.error('Resim oluşturma hatası:', error); alert('Resim oluşturulurken bir hata oluştu!'); }).finally(() => { document.body.removeChild(container); }); } function updateMetaTags(lang) { const ogTitle = document.querySelector('meta[property="og:title"]'); if (ogTitle) ogTitle.setAttribute('content', `Metin2 Alerts ${lang.title}`); const ogDesc = document.querySelector('meta[property="og:description"]'); if (ogDesc) { const descriptions = { 'tr': 'Metin2 Alerts Sandık Drop Listesi: Tüm sandıkların drop listelerini görüntüleyin ve sandık simülasyonu yapın.', 'en': 'Metin2 Alerts Chest Drop List: View all chest drop lists and simulate chest opening.', 'de': 'Metin2 Alerts Truhen Drop Liste: Alle Truhen-Drop-Listen anzeigen und Truhen-Öffnung simulieren.', 'es': 'Metin2 Alerts Lista de Drops de Cofres: Ve todas las listas de drops de cofres y simula la apertura de cofres.', 'fr': 'Metin2 Alerts Liste des Drops de Coffres: Consultez toutes les listes de drops de coffres et simulez l\'ouverture de coffres.', 'it': 'Metin2 Alerts Lista Drop Casseforti: Visualizza tutte le liste di drop delle casseforti e simula l\'apertura.', 'nl': 'Metin2 Alerts Kist Drop Lijst: Bekijk alle kist drop lijsten en simuleer kist opening.', 'pl': 'Metin2 Alerts Lista Drop Skrzyń: Zobacz wszystkie listy dropów skrzyń i symuluj otwieranie skrzyń.', 'pt': 'Metin2 Alerts Lista de Drop de Baús: Veja todas as listas de drop de baús e simule a abertura de baús.', 'ro': 'Metin2 Alerts Lista Drop Cofre: Vizualizați toate listele de drop ale cofrelor și simulați deschiderea cofrelor.', 'ru': 'Metin2 Alerts Список Дропа Сундуков: Просмотрите все списки дропа сундуков и симулируйте открытие сундуков.', 'gr': 'Metin2 Alerts Λίστα Drop Κιβωτίων: Προβάλετε όλες τις λίστες drop κιβωτίων και προσομοιώστε το άνοιγμα κιβωτίων.', 'cz': 'Metin2 Alerts Seznam Drop Truhel: Zobrazte všechny seznamy dropů truhel a simulujte otevírání truhel.', 'dk': 'Metin2 Alerts Kiste Drop Liste: Se alle kiste drop lister og simuler kiste åbning.', 'hu': 'Metin2 Alerts Láda Drop Lista: Nézd meg az összes láda drop listát és szimuláld a ládák nyitását.', 'ae': 'Metin2 Alerts قائمة دروب الصناديق: اعرض جميع قوائم دروب الصناديق وحاك فتح الصناديق.' }; ogDesc.setAttribute('content', descriptions[currentLang] || descriptions['tr']); } const ogLocale = document.querySelector('meta[property="og:locale"]'); if (ogLocale) { const locales = { 'tr': 'tr_TR', 'en': 'en_US', 'de': 'de_DE', 'es': 'es_ES', 'fr': 'fr_FR', 'it': 'it_IT', 'nl': 'nl_NL', 'pl': 'pl_PL', 'pt': 'pt_PT', 'ro': 'ro_RO', 'ru': 'ru_RU', 'gr': 'el_GR', 'cz': 'cs_CZ', 'dk': 'da_DK', 'hu': 'hu_HU', 'ae': 'ar_SA' }; ogLocale.setAttribute('content', locales[currentLang] || 'tr_TR'); } const twitterTitle = document.querySelector('meta[name="twitter:title"]'); if (twitterTitle) twitterTitle.setAttribute('content', `Metin2 Alerts ${lang.title}`); const twitterDesc = document.querySelector('meta[name="twitter:description"]'); if (twitterDesc) { const descriptions = { 'tr': 'Metin2 Alerts Sandık Drop Listesi: Tüm sandıkların drop listelerini görüntüleyin ve sandık simülasyonu yapın.', 'en': 'Metin2 Alerts Chest Drop List: View all chest drop lists and simulate chest opening.', 'de': 'Metin2 Alerts Truhen Drop Liste: Alle Truhen-Drop-Listen anzeigen und Truhen-Öffnung simulieren.', 'es': 'Metin2 Alerts Lista de Drops de Cofres: Ve todas las listas de drops de cofres y simula la apertura de cofres.', 'fr': 'Metin2 Alerts Liste des Drops de Coffres: Consultez toutes les listes de drops de coffres et simulez l\'ouverture de coffres.', 'it': 'Metin2 Alerts Lista Drop Casseforti: Visualizza tutte le liste di drop delle casseforti e simula l\'apertura.', 'nl': 'Metin2 Alerts Kist Drop Lijst: Bekijk alle kist drop lijsten en simuleer kist opening.', 'pl': 'Metin2 Alerts Lista Drop Skrzyń: Zobacz wszystkie listy dropów skrzyń i symuluj otwieranie skrzyń.', 'pt': 'Metin2 Alerts Lista de Drop de Baús: Veja todas as listas de drop de baús e simule a abertura de baús.', 'ro': 'Metin2 Alerts Lista Drop Cofre: Vizualizați toate listele de drop ale cofrelor și simulați deschiderea cofrelor.', 'ru': 'Metin2 Alerts Список Дропа Сундуков: Просмотрите все списки дропа сундуков и симулируйте открытие сундуков.', 'gr': 'Metin2 Alerts Λίστα Drop Κιβωτίων: Προβάλετε όλες τις λίστες drop κιβωτίων και προσομοιώστε το άνοιγμα κιβωτίων.', 'cz': 'Metin2 Alerts Seznam Drop Truhel: Zobrazte všechny seznamy dropů truhel a simulujte otevírání truhel.', 'dk': 'Metin2 Alerts Kiste Drop Liste: Se alle kiste drop lister og simuler kiste åbning.', 'hu': 'Metin2 Alerts Láda Drop Lista: Nézd meg az összes láda drop listát és szimuláld a ládák nyitását.', 'ae': 'Metin2 Alerts قائمة دروب الصناديق: اعرض جميع قوائم دروب الصناديق وحاك فتح الصناديق.' }; twitterDesc.setAttribute('content', descriptions[currentLang] || descriptions['tr']); } } function initTooltips() { const tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]')); tooltipTriggerList.map(function(tooltipTriggerEl) { return new bootstrap.Tooltip(tooltipTriggerEl); }); }