|
|
| Linia 1: |
Linia 1: |
| − | <!DOCTYPE html>
| |
| − | <html lang="en">
| |
| − | <head>
| |
| − | <meta charset="UTF-8">
| |
| − | <meta name="viewport" content="width=device-width, initial-scale=1.0">
| |
| − | <title>Metin2 Loot</title>
| |
| − | </head>
| |
| − | <body style="background-color: #26211D; color: white;">
| |
| − | <div style="display: flex; border: 1px solid #8B4513; padding: 5px; width: 300px;">
| |
| − | <!-- Column for Monsters -->
| |
| − | <div style="flex: 1; border-right: 1px solid #8B4513; padding: 5px;">
| |
| − | <div style="height: 200px; overflow-y: scroll;">
| |
| − | <ul style="list-style-type: none; padding-left: 0;">
| |
| − | <li onclick="fetchLoot('Câine_Sălbatic')">Câine Sălbatic</li>
| |
| − | <li onclick="fetchLoot('Lup')">Lup</li>
| |
| − | <!-- Add other monsters here -->
| |
| − | </ul>
| |
| − | </div>
| |
| − | </div>
| |
| | | | |
| − | <!-- Column for Possible Loot -->
| |
| − | <div style="flex: 1; padding: 5px;">
| |
| − | <div style="height: 200px; overflow-y: scroll;">
| |
| − | <ul id="loot-list" style="list-style-type: none; padding-left: 0;">
| |
| − | <li>Selectează un monstru pentru a vedea prada</li>
| |
| − | </ul>
| |
| − | </div>
| |
| − | </div>
| |
| − | </div>
| |
| − |
| |
| − | <script>
| |
| − | async function fetchLoot(monster) {
| |
| − | console.log('Fetching loot for:', monster); // Debugging line
| |
| − | var lootList = document.getElementById('loot-list');
| |
| − | lootList.innerHTML = ''; // Clear existing content
| |
| − |
| |
| − | // Construct the API URL to fetch the page content
| |
| − | var apiUrl = `https://ro-wiki.metin2.gameforge.com/api.php?action=parse&page=${monster}&prop=wikitext&format=json&origin=*`;
| |
| − | console.log('API URL:', apiUrl); // Debugging line
| |
| − |
| |
| − | try {
| |
| − | const response = await fetch(apiUrl);
| |
| − | const data = await response.json();
| |
| − |
| |
| − | console.log('API Response:', data); // Debugging line
| |
| − |
| |
| − | // Get the wikitext content of the page
| |
| − | var wikitext = data.parse.wikitext['*'];
| |
| − |
| |
| − | // Extract the Weapondrops section using regex
| |
| − | var weapondropsMatch = wikitext.match(/\|Weapondrops\s*=\s*(.*?)(\n|$)/s);
| |
| − |
| |
| − | if (weapondropsMatch) {
| |
| − | var weapondrops = weapondropsMatch[1].trim();
| |
| − |
| |
| − | // Split the weapondrops by "::" (assuming they are separated this way)
| |
| − | var lootItems = weapondrops.split('::');
| |
| − |
| |
| − | lootItems.forEach(function(item) {
| |
| − | if (item.trim()) {
| |
| − | var li = document.createElement('li');
| |
| − | li.textContent = item.trim();
| |
| − | lootList.appendChild(li);
| |
| − | }
| |
| − | });
| |
| − | } else {
| |
| − | var li = document.createElement('li');
| |
| − | li.textContent = 'No weapon drops found';
| |
| − | lootList.appendChild(li);
| |
| − | }
| |
| − | } catch (error) {
| |
| − | var li = document.createElement('li');
| |
| − | li.textContent = 'Error fetching loot';
| |
| − | lootList.appendChild(li);
| |
| − | console.error('Error:', error);
| |
| − | }
| |
| − | }
| |
| − | </script>
| |
| − | </body>
| |
| − | </html>
| |