VSPAN commited on
Commit
6a71443
·
verified ·
1 Parent(s): 0916e12

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +41 -44
index.html CHANGED
@@ -498,11 +498,12 @@
498
  // Инициализация при загрузке страницы
499
  window.addEventListener('load', init)
500
  </script>
501
- <script>
502
- // Функция для "установки" игры
503
- function installGame(gameId) {
 
504
  const game = games.find(g => g.id === gameId);
505
- if (!game) return;
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
- const interval = setInterval(() => {
519
- progress += 10;
520
  progressBar.style.width = `${progress}%`;
521
-
522
- if (progress >= 100) {
523
- clearInterval(interval);
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
- }, 300);
 
534
  }
535
- }
536
-
537
- // Отрисовка библиотеки с кнопкой установки
538
- function renderLibrary() {
539
- const library = document.getElementById('userGames');
540
- if (library) {
541
- library.innerHTML = account.library.length ?
542
- account.library.map(game => `
543
- <div class="game-card">
544
- <img src="${game.image}" class="game-image">
545
- <div style="padding: 15px">
546
- <h3>${game.title}</h3>
547
- <button class="steam-button install-button" data-game-id="${game.id}" onclick="installGame(${game.id})">
548
- Установить
549
- </button>
550
- <div class="install-progress" data-game-id="${game.id}">
551
- <div class="install-progress-bar"></div>
552
- </div>
553
- <div class="install-message" data-game-id="${game.id}">
554
- Установка...
555
- </div>
556
  </div>
 
557
  </div>
558
- `).join('') :
559
- '<p>Ваша библиотека пуста. Купите игры в магазине!</p>';
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>