Update index.html
Browse files- index.html +41 -44
index.html
CHANGED
@@ -498,11 +498,12 @@
|
|
498 |
// Инициализация при загрузке страницы
|
499 |
window.addEventListener('load', init)
|
500 |
</script>
|
501 |
-
|
502 |
-
|
503 |
-
|
|
|
504 |
const game = games.find(g => g.id === gameId);
|
505 |
-
if (!game)
|
506 |
|
507 |
const installButton = document.querySelector(`.install-button[data-game-id="${gameId}"]`);
|
508 |
const progressBar = document.querySelector(`.install-progress[data-game-id="${gameId}"] .install-progress-bar`);
|
@@ -513,54 +514,50 @@
|
|
513 |
installButton.textContent = 'Установка...';
|
514 |
progressBar.parentElement.style.display = 'block';
|
515 |
message.style.display = 'block';
|
|
|
516 |
|
517 |
let progress = 0;
|
518 |
-
|
519 |
-
progress +=
|
520 |
progressBar.style.width = `${progress}%`;
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
installButton.textContent = '
|
525 |
message.textContent = 'Игра успешно установлена!';
|
526 |
-
|
527 |
-
// Шутка после установки
|
528 |
-
setTimeout(() => {
|
529 |
-
window.location.href = 'https://www.youtube.com/watch?v=dQw4w9WgXcQ';
|
530 |
-
// Здесь можно добавить ссылку или что-то ещё
|
531 |
-
}, 1000);
|
532 |
}
|
533 |
-
}
|
|
|
534 |
}
|
535 |
-
}
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
</div>
|
556 |
</div>
|
|
|
557 |
</div>
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
}
|
562 |
-
|
563 |
-
|
564 |
-
</script>
|
565 |
</body>
|
566 |
</html>
|
|
|
498 |
// Инициализация при загрузке страницы
|
499 |
window.addEventListener('load', init)
|
500 |
</script>
|
501 |
+
<script>
|
502 |
+
// Функция для "установки" игры с улучшениями
|
503 |
+
function installGame(gameId) {
|
504 |
+
try {
|
505 |
const game = games.find(g => g.id === gameId);
|
506 |
+
if (!game) throw new Error('Игра не найдена');
|
507 |
|
508 |
const installButton = document.querySelector(`.install-button[data-game-id="${gameId}"]`);
|
509 |
const progressBar = document.querySelector(`.install-progress[data-game-id="${gameId}"] .install-progress-bar`);
|
|
|
514 |
installButton.textContent = 'Установка...';
|
515 |
progressBar.parentElement.style.display = 'block';
|
516 |
message.style.display = 'block';
|
517 |
+
progressBar.style.transition = 'width 0.3s ease';
|
518 |
|
519 |
let progress = 0;
|
520 |
+
function updateProgress() {
|
521 |
+
progress += 5;
|
522 |
progressBar.style.width = `${progress}%`;
|
523 |
+
if (progress < 100) {
|
524 |
+
requestAnimationFrame(updateProgress);
|
525 |
+
} else {
|
526 |
+
installButton.textContent = 'Играть';
|
527 |
message.textContent = 'Игра успешно установлена!';
|
528 |
+
installButton.disabled = false;
|
|
|
|
|
|
|
|
|
|
|
529 |
}
|
530 |
+
}
|
531 |
+
requestAnimationFrame(updateProgress);
|
532 |
}
|
533 |
+
} catch (error) {
|
534 |
+
console.error('Ошибка установки:', error.message);
|
535 |
+
}
|
536 |
+
}
|
537 |
+
|
538 |
+
// Отрисовка библиотеки с кнопкой установки или игры
|
539 |
+
function renderLibrary() {
|
540 |
+
const library = document.getElementById('userGames');
|
541 |
+
if (library) {
|
542 |
+
library.innerHTML = account.library.length ?
|
543 |
+
account.library.map(game => `
|
544 |
+
<div class="game-card">
|
545 |
+
<img src="${game.image}" class="game-image">
|
546 |
+
<div style="padding: 15px">
|
547 |
+
<h3>${game.title}</h3>
|
548 |
+
<button class="steam-button install-button" data-game-id="${game.id}" onclick="installGame(${game.id})">
|
549 |
+
${game.installed ? 'Играть' : 'Установить'}
|
550 |
+
</button>
|
551 |
+
<div class="install-progress" data-game-id="${game.id}">
|
552 |
+
<div class="install-progress-bar"></div>
|
|
|
553 |
</div>
|
554 |
+
<div class="install-message" data-game-id="${game.id}"></div>
|
555 |
</div>
|
556 |
+
</div>
|
557 |
+
`).join('') :
|
558 |
+
'<p>Ваша библиотека пуста. Купите игры в магазине!</p>';
|
559 |
}
|
560 |
+
}
|
561 |
+
</script>
|
|
|
562 |
</body>
|
563 |
</html>
|