<% const body = ` ${typeof worlds !== 'undefined' && worlds.length > 0 ? `
${worlds.map(world => `

${world.displayName}

${world.creativeMode ? 'Creative' : 'Survival'}
${world.description ? `

${world.description}

` : ''}
Game: ${world.gameTitle || world.gameid}
Players: ${world.playerCount || 0}
PvP: ${world.enablePvp ? 'Enabled' : 'Disabled'}
Damage: ${world.enableDamage ? 'Enabled' : 'Disabled'}
Last Modified: ${new Date(world.lastModified).toLocaleDateString()}
`).join('')}
` : `

No worlds created yet

Create your first world to get started with hosting Luanti servers.

Create First World
`} `; %> <%- include('../layout', { body: body, currentPage: 'worlds', title: title, inlineScript: ` // Handle world creation progress document.addEventListener('DOMContentLoaded', function() { const urlParams = new URLSearchParams(window.location.search); const creatingWorldName = urlParams.get('creating'); if (creatingWorldName) { // Show creating alert const creatingAlert = document.getElementById('creatingAlert'); const creatingWorldNameSpan = document.getElementById('creatingWorldName'); const progressBar = document.getElementById('progressBar'); if (creatingAlert && creatingWorldNameSpan) { creatingWorldNameSpan.textContent = creatingWorldName; creatingAlert.style.display = 'block'; // Quick progress animation (since creation is fast but not instant) let progress = 0; const progressInterval = setInterval(() => { progress += 15; if (progress > 85) progress = 85; // Don't complete until we get websocket confirmation progressBar.style.width = progress + '%'; }, 100); // Listen for websocket events if (typeof socket !== 'undefined') { socket.on('worldCreated', function(data) { if (data.worldName === creatingWorldName) { clearInterval(progressInterval); if (data.success) { progressBar.style.width = '100%'; setTimeout(() => { // Remove the creating parameter and reload const newUrl = new URL(window.location); newUrl.searchParams.delete('creating'); window.location.href = newUrl.toString(); }, 500); } else { creatingAlert.className = 'alert alert-danger'; creatingAlert.innerHTML = 'World creation failed:
' + (data.error || 'Unknown error occurred'); } } }); } // Fallback: reload after 5 seconds if no websocket response setTimeout(() => { clearInterval(progressInterval); const newUrl = new URL(window.location); newUrl.searchParams.delete('creating'); window.location.href = newUrl.toString(); }, 5000); } } }); ` }) %>