Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added routing for game page #5

Merged
merged 1 commit into from
Dec 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions docs/IgorFromUA/scripts/game.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
function loadingSwitch(switching, place) {
function loadingSwitch(switching) {
const LOADING_ELEMENT = document.querySelector('[data-loading]');
if (switching && place) place.textContent = '';
LOADING_ELEMENT.style.visibility = switching ? 'visible' : 'hidden';
}

function getGameId() {
const currentUrl = window.location.href;
return currentUrl.split('?').at(-1);
}

function getGame(id) {
const url = 'https://mmo-games.p.rapidapi.com/game?id=';
const optionsGamesUrl = {
Expand All @@ -29,7 +33,7 @@ function createGameCardStr(game) {
thumbnail,
status,
game_url: gameUrl,
minimum_system_requirements: minSys,
minimum_system_requirements: minSys = {},
description,
genre,
platform,
Expand Down Expand Up @@ -82,11 +86,11 @@ function createGameCardStr(game) {
</div>
<div><span class="semiBold">minimum system requirements:</span>
<ul class="card__actors">
<li class="card__actor"><span class="semiBold">OS:</span> ${minSys.os || '?'}</li>
<li class="card__actor"><span class="semiBold">memory:</span> ${minSys.memory || '?'}</li>
<li class="card__actor"><span class="semiBold">storege:</span> ${minSys.storege || '?'}</li>
<li class="card__actor"><span class="semiBold">processor:</span> ${minSys.processor || '?'}</li>
<li class="card__actor"><span class="semiBold">graphics:</span> ${minSys.graphics || '?'}</li>
<li class="card__actor"><span class="semiBold">OS:</span> ${minSys.os || '-'}</li>
<li class="card__actor"><span class="semiBold">memory:</span> ${minSys.memory || '-'}</li>
<li class="card__actor"><span class="semiBold">storege:</span> ${minSys.storege || '-'}</li>
<li class="card__actor"><span class="semiBold">processor:</span> ${minSys.processor || '-'}</li>
<li class="card__actor"><span class="semiBold">graphics:</span> ${minSys.graphics || '-'}</li>
</ul>
</div>
`;
Expand Down Expand Up @@ -124,7 +128,7 @@ async function createCard(gameProm) {
}

function init() {
createCard(getGame(localStorage.getItem('gameId')));
createCard(getGame(getGameId()));
}

init();
3 changes: 1 addition & 2 deletions docs/IgorFromUA/scripts/games.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,9 @@ function createCardElement(game) {
cardElement.setAttribute('id', game.id);
cardElement.classList.add('card');
cardElement.addEventListener('click', (event) => {
localStorage.setItem('gameId', `${event.currentTarget.id}`);
const currentUrl = window.location.href;
const endUrl = currentUrl.split('/');
endUrl[endUrl.length - 1] = 'game.html';
endUrl[endUrl.length - 1] = `game.html?${event.currentTarget.id}`;
window.location.href = endUrl.join('/');
});
cardElement.insertAdjacentHTML('afterbegin', createGameCardStr(game));
Expand Down
15 changes: 1 addition & 14 deletions docs/IgorFromUA/styles/game.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,6 @@
align-items: flex-start;
}

/*.back-btn {*/
/* padding: 13px 20px;*/
/* font-size: 12px;*/
/* color: #FFF;*/
/* background: #EF4934;*/
/* border: none;*/
/* border-radius: 6px;*/
/* cursor: pointer;*/
/*}*/

.card-header__link, .back-btn {
padding: 6px 10px;
font-size: 12px;
Expand All @@ -49,10 +39,6 @@
object-fit: cover;
}

/*.card-content {*/
/* padding: 5px 10px;*/
/*}*/

.description__title {
font-size: 24px;
color: #333;
Expand Down Expand Up @@ -168,6 +154,7 @@
.card__actors {
flex-direction: row;
font-size: 16px;
margin-top: 8px;
}

.card__actor {
Expand Down
Loading