<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>Niveles de Geometry Dash</title>
<style>
@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@500&display=swap');
body {
font-family: 'Orbitron', sans-serif;
background: linear-gradient(135deg, #000 0%, #000 100%);
background-color: black;
color: #fff;
margin: 0;
padding: 20px;
background-image: url('https://gdbrowser.com/assets/bg.png');
background-size: cover;
background-repeat: no-repeat;
}
h1 {
text-align: center;
font-size: 2.5rem;
color: #0ff;
text-shadow: 2px 2px #000;
}
.controls {
text-align: center;
margin-bottom: 30px;
}
.controls button, .controls select, .controls input {
margin: 5px;
padding: 10px 20px;
font-size: 16px;
border: none;
border-radius: 5px;
cursor: pointer;
font-family: 'Orbitron', sans-serif;
}
.controls button {
background-color: #0ff;
color: #000;
box-shadow: 0 0 10px #0ff;
}
.controls button:hover {
background-color: #0cc;
}
.controls input {
width: 200px;
}
.level-list {
display: flex;
flex-wrap: wrap;
justify-content: center;
gap: 20px;
}
.level-card {
background-color: rgba(0, 0, 0, 0.8);
border: 2px solid #0ff;
border-radius: 10px;
padding: 20px;
width: 320px;
box-shadow: 0 0 20px #0ff;
text-align: center;
}
.level-card h3 {
margin: 0 0 10px;
font-size: 22px;
color: #0ff;
}
.level-card p {
margin: 6px 0;
}
.difficulty-icon {
width: 32px;
height: 32px;
vertical-align: middle;
}
.play-button, .download-button {
margin-top: 10px;
padding: 8px 16px;
background-color: #0f8;
color: #000;
border: none;
border-radius: 5px;
font-weight: bold;
cursor: pointer;
}
.play-button:hover, .download-button:hover {
background-color: #0c6;
}
audio {
margin-top: 10px;
width: 100%;
}
.controls label {
color: #fff;
font-weight: bold;
margin-left: 10px;
}
</style>
</head>
<body>
<h1>Niveles de Geometry Dash</h1>
<div class="controls">
<button onclick="getLevels('featured')">Populares</button>
<button onclick="getLevels('likes')">Más Likeados</button>
<button onclick="getLevels('recent')">Más Nuevos</button>
<select id="difficultySelect" onchange="searchByDifficulty()">
<option value="">Buscar por Dificultad</option>
<option value="auto">Auto</option>
<option value="easy">Easy</option>
<option value="normal">Normal</option>
<option value="hard">Hard</option>
<option value="harder">Harder</option>
<option value="insane">Insane</option>
<option value="demon">Demon</option>
</select>
<div style="margin-top: 10px;">
<input type="text" id="userInput" placeholder="Nombre de usuario"/>
<button onclick="searchByUser()">Buscar usuario</button>
</div>
<div style="margin-top: 10px;">
<label for="clientSelect">Cliente:</label>
<select id="clientSelect">
<option value="gmd">Geometry Dash</option>
<option value="geode">Geode</option>
</select>
</div>
</div>
<div class="level-list" id="levelsContainer"></div>
<script>
const API_URL = 'https://gdbrowser.com/api/';
async function getLevels(type) {
let endpoint = '';
if (type === 'featured') endpoint = 'search/*?type=featured';
else if (type === 'likes') endpoint = 'search/*?type=likes';
else if (type === 'recent') endpoint = 'search/*?type=recent';
const res = await fetch(`${API_URL}${endpoint}`);
const levels = await res.json();
renderLevels(levels);
}
async function searchByDifficulty() {
const difficulty = document.getElementById("difficultySelect").value;
if (!difficulty) return;
const res = await fetch(`${API_URL}search/${difficulty}`);
const levels = await res.json();
renderLevels(levels);
}
async function searchByUser() {
const username = document.getElementById("userInput").value.trim();
if (!username) return alert("Ingresa un nombre de usuario");
const userRes = await fetch(`${API_URL}player/${encodeURIComponent(username)}`);
const userData = await userRes.json();
if (!userData || !userData.accountID) {
alert("Usuario no encontrado");
return;
}
const levelsRes = await fetch(`${API_URL}levels/${userData.accountID}`);
const levels = await levelsRes.json();
renderLevels(levels);
}
async function renderLevels(levels) {
const container = document.getElementById("levelsContainer");
container.innerHTML = '';
if (!Array.isArray(levels) || levels.length === 0) {
container.innerHTML = '<p>No se encontraron niveles.</p>';
return;
}
for (const level of levels) {
const difficultyImg = getDifficultyIcon(level);
const card = document.createElement('div');
card.className = 'level-card';
let musicHTML = '<p><strong>Música no disponible</strong></p>';
if (level.song && level.song.name) {
const song = level.song;
musicHTML = `
<p><strong>Música:</strong> ${song.name}</p>
<p><strong>ID:</strong> ${song.id}</p>
<audio controls src="${song.url}"></audio>
${song.url ? `<a href="${song.url}" class="download-button" download>Descargar Música</a>` : ''}
`;
}
card.innerHTML = `
<h3>${level.name}</h3>
<p><strong>Autor:</strong> ${level.author}</p>
<p><strong>ID:</strong> ${level.id}</p>
<p><strong>Likes:</strong> ${level.likes}</p>
<p><strong>Dificultad:</strong> <img src="${difficultyImg}" alt="dif" class="difficulty-icon"/></p>
<p><strong>Descargas:</strong> ${level.downloads}</p>
${musicHTML}
<button class="play-button" onclick="playLevel(${level.id})">Jugar</button>
`;
container.appendChild(card);
}
}
function getDifficultyIcon(level) {
const base = "https://gdbrowser.com/assets/difficulties/";
const diff = (level.difficulty || "").toLowerCase();
if (diff.includes("demon")) {
if (diff.includes("easy")) return base + "demon-easy.png";
if (diff.includes("medium")) return base + "demon-medium.png";
if (diff.includes("insane")) return base + "demon-insane.png";
if (diff.includes("extreme")) return base + "demon-extreme.png";
return base + "demon-hard.png";
}
switch (diff) {
case "auto": return base + "auto.png";
case "easy": return base + "easy.png";
case "normal": return base + "normal.png";
case "hard": return base + "hard.png";
case "harder": return base + "harder.png";
case "insane": return base + "insane.png";
default: return base + "na.png";
}
}
function playLevel(levelID) {
const client = document.getElementById("clientSelect").value;
const url = `${client}://level/${levelID}`;
window.location.href = url;
}
// Carga inicial
getLevels('featured');
</script>
</body>
</html>
Comentarios (1)
Inicia sesión para comentar
XD