Files
public
api.php
package.json
server.js
Code
7 2,939
public/script.js
// ============================================================
// SCRIPT.JS — SkyUniverse Panel
// Aquatic Theme Client-Side Logic
// ============================================================
// ─── PARTICLE SYSTEM ──────────────────────────────────────
(function() {
const canvas = document.getElementById('particleCanvas');
if (!canvas) return;
const ctx = canvas.getContext('2d');
let particles = [];
let animationId = null;
function resize() {
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
}
window.addEventListener('resize', resize);
resize();
class Particle {
constructor() {
this.reset();
}
reset() {
this.x = Math.random() * canvas.width;
this.y = Math.random() * canvas.height;
this.size = Math.random() * 3 + 1;
this.speedX = (Math.random() - 0.5) * 0.5;
this.speedY = (Math.random() - 0.5) * 0.5;
this.opacity = Math.random() * 0.5 + 0.1;
this.pulse = Math.random() * Math.PI * 2;
this.pulseSpeed = Math.random() * 0.02 + 0.005;
}
update() {
this.x += this.speedX;
this.y += this.speedY;
this.pulse += this.pulseSpeed;
this.currentOpacity = this.opacity * (0.5 + 0.5 * Math.sin(this.pulse));
if (this.x < 0 || this.x > canvas.width || this.y < 0 || this.y > canvas.height) {
this.reset();
}
}
draw() {
ctx.beginPath();
ctx.arc(this.x, this.y, this.size, 0, Math.PI * 2);
ctx.fillStyle = `rgba(0, 212, 255, ${this.currentOpacity})`;
ctx.fill();
// Glow effect
ctx.beginPath();
ctx.arc(this.x, this.y, this.size * 3, 0, Math.PI * 2);
ctx.fillStyle = `rgba(0, 212, 255, ${this.currentOpacity * 0.15})`;
ctx.fill();
}
}
const particleCount = Math.min(80, Math.floor(window.innerWidth / 15));
for (let i = 0; i < particleCount; i++) {
particles.push(new Particle());
}
function animate() {
ctx.clearRect(0, 0, canvas.width, canvas.height);
// Draw connections
for (let i = 0; i < particles.length; i++) {
for (let j = i + 1; j < particles.length; j++) {
const dx = particles[i].x - particles[j].x;
const dy = particles[i].y - particles[j].y;
const dist = Math.sqrt(dx * dx + dy * dy);
if (dist < 120) {
ctx.beginPath();
ctx.moveTo(particles[i].x, particles[i].y);
ctx.lineTo(particles[j].x, particles[j].y);
ctx.strokeStyle = `rgba(0, 212, 255, ${0.08 * (1 - dist / 120)})`;
ctx.lineWidth = 0.5;
ctx.stroke();
}
}
}
particles.forEach(p => {
p.update();
p.draw();
});
animationId = requestAnimationFrame(animate);
}
animate();
})();
// ─── PASSWORD TOGGLE ──────────────────────────────────────
const passwordToggle = document.getElementById('passwordToggle');
const passwordInput = document.getElementById('password');
if (passwordToggle && passwordInput) {
passwordToggle.addEventListener('click', () => {
const type = passwordInput.getAttribute('type') === 'password' ? 'text' : 'password';
passwordInput.setAttribute('type', type);
passwordToggle.innerHTML = type === 'password'
? '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/><circle cx="12" cy="12" r="3"/></svg>'
: '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24"/><line x1="1" y1="1" x2="23" y2="23"/></svg>';
});
}
// ─── LOGIN FORM ──────────────────────────────────────────
const loginForm = document.getElementById('loginForm');
const loginBtn = document.getElementById('loginBtn');
const errorMessage = document.getElementById('errorMessage');
if (loginForm) {
loginForm.addEventListener('submit', async (e) => {
e.preventDefault();
const username = document.getElementById('username').value.trim();
const password = document.getElementById('password').value;
if (!username || !password) {
showError('Completează toate câmpurile!');
return;
}
setLoading(true);
try {
const response = await fetch('/api/login', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ username, password })
});
const data = await response.json();
if (data.success) {
window.location.href = '/dashboard';
} else {
showError(data.error || 'Autentificare eșuată!');
setLoading(false);
}
} catch (err) {
showError('Eroare de conexiune. Serverul este pornit?');
setLoading(false);
}
});
}
function showError(msg) {
if (errorMessage) {
errorMessage.textContent = msg;
errorMessage.style.display = 'block';
setTimeout(() => {
errorMessage.style.opacity = '1';
}, 10);
}
}
function setLoading(loading) {
if (!loginBtn) return;
const text = loginBtn.querySelector('.btn-text');
const loader = loginBtn.querySelector('.btn-loader');
if (loading) {
text.style.display = 'none';
loader.style.display = 'block';
loginBtn.disabled = true;
} else {
text.style.display = 'inline';
loader.style.display = 'none';
loginBtn.disabled = false;
}
}
// ─── DASHBOARD ───────────────────────────────────────────
let dashboardData = null;
async function loadDashboard() {
try {
const res = await fetch('/api/dashboard');
const data = await res.json();
if (data.error === 'Eroare conexiune baza de date. Verifica remote MySQL access!') {
showToast('❌ Baza de date nu e conectată!');
updateServerStatusUI({ online: false });
return;
}
if (!data.success) {
window.location.href = '/';
return;
}
dashboardData = data;
updateUI(data);
} catch (err) {
console.error('Dashboard load error:', err);
showToast('❌ Eroare la încărcarea datelor');
}
}