Homepage and game info pages presentable.
This commit is contained in:
parent
88721378b2
commit
4100585a60
6 changed files with 252 additions and 261 deletions
5
.gitignore
vendored
5
.gitignore
vendored
|
@ -104,4 +104,7 @@ dist
|
||||||
.tern-port
|
.tern-port
|
||||||
|
|
||||||
# Ignore credentials
|
# Ignore credentials
|
||||||
server/model/creds.json
|
server/model/creds.json
|
||||||
|
|
||||||
|
#Ignore uploaded images
|
||||||
|
server/public/images/*
|
||||||
|
|
|
@ -95,7 +95,9 @@ async function getGame(id) {
|
||||||
m.id AS appID,
|
m.id AS appID,
|
||||||
m.game_title AS title,
|
m.game_title AS title,
|
||||||
d.name AS developer,
|
d.name AS developer,
|
||||||
|
d.homepage AS devURL,
|
||||||
p.name AS publisher,
|
p.name AS publisher,
|
||||||
|
p.homepage AS pubURL,
|
||||||
m.release_date AS releaseDate,
|
m.release_date AS releaseDate,
|
||||||
m.short_description AS summary,
|
m.short_description AS summary,
|
||||||
m.long_description AS longDescription,
|
m.long_description AS longDescription,
|
||||||
|
@ -104,7 +106,8 @@ async function getGame(id) {
|
||||||
m.linux_supported AS linux,
|
m.linux_supported AS linux,
|
||||||
m.cover_art_filename AS coverArt,
|
m.cover_art_filename AS coverArt,
|
||||||
m.short_description AS shortDescription,
|
m.short_description AS shortDescription,
|
||||||
m.long_description_markdown AS longDescription
|
m.long_description AS longDescription,
|
||||||
|
m.long_description_markdown AS markdown
|
||||||
FROM games_master_table m
|
FROM games_master_table m
|
||||||
INNER JOIN developers d ON m.developer_id = d.id
|
INNER JOIN developers d ON m.developer_id = d.id
|
||||||
INNER JOIN publishers p ON m.publisher_id = p.id`,
|
INNER JOIN publishers p ON m.publisher_id = p.id`,
|
||||||
|
|
|
@ -88,11 +88,9 @@ textarea {
|
||||||
========================================================================== */
|
========================================================================== */
|
||||||
#header {
|
#header {
|
||||||
background-color: #171a21;
|
background-color: #171a21;
|
||||||
color: #c6d4df;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#form {
|
#form {
|
||||||
background-image: linear-gradient(180deg, #171a21, #1b2838);
|
|
||||||
min-height: 750px;
|
min-height: 750px;
|
||||||
color: #c6d4df;
|
color: #c6d4df;
|
||||||
}
|
}
|
||||||
|
@ -111,6 +109,7 @@ hr{
|
||||||
}
|
}
|
||||||
|
|
||||||
body, html {
|
body, html {
|
||||||
|
background-image: linear-gradient(180deg, #171a21, #1b2838);
|
||||||
margin: 0px;
|
margin: 0px;
|
||||||
background-color: #171a21;
|
background-color: #171a21;
|
||||||
transition: all 0.4s ease 0s;
|
transition: all 0.4s ease 0s;
|
||||||
|
@ -141,6 +140,41 @@ input, select, textarea {
|
||||||
background-color: #316282;
|
background-color: #316282;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.gameEntry {
|
||||||
|
background-color: #22445b;
|
||||||
|
border-radius: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.gameEntry:hover {
|
||||||
|
background-color: #316282;
|
||||||
|
}
|
||||||
|
|
||||||
|
.gameEntry * {
|
||||||
|
text-decoration: none;
|
||||||
|
color: #b3d4fc;
|
||||||
|
}
|
||||||
|
|
||||||
|
.gamePage {
|
||||||
|
background-color: #22445b;
|
||||||
|
color: #b3d4fc;
|
||||||
|
margin-top: 70px;
|
||||||
|
border-radius: 30px;
|
||||||
|
padding: 30px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.coverArtContainer{
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.coverArt {
|
||||||
|
margin-left: auto;
|
||||||
|
margin-right: auto;
|
||||||
|
width:100%;
|
||||||
|
min-width: 250px;
|
||||||
|
}
|
||||||
|
|
||||||
#submitButton {
|
#submitButton {
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
border:0;
|
border:0;
|
||||||
|
|
|
@ -302,7 +302,7 @@
|
||||||
document.getElementById("currentArt").appendChild(coverImg);
|
document.getElementById("currentArt").appendChild(coverImg);
|
||||||
|
|
||||||
document.getElementById("shortDescription").value = gameData.shortDescription;
|
document.getElementById("shortDescription").value = gameData.shortDescription;
|
||||||
document.getElementById("longDescription").value = gameData.longDescription;
|
document.getElementById("longDescription").value = gameData.markdown;
|
||||||
} else {
|
} else {
|
||||||
document.getElementById("errorMessage").innerHTML = "Invalid App ID!";
|
document.getElementById("errorMessage").innerHTML = "Invalid App ID!";
|
||||||
document.getElementById("errorMessage").hidden = false;
|
document.getElementById("errorMessage").hidden = false;
|
||||||
|
|
|
@ -14,15 +14,68 @@
|
||||||
<link rel="stylesheet" href="css/normalize.css">
|
<link rel="stylesheet" href="css/normalize.css">
|
||||||
<link rel="stylesheet" href="css/main.css">
|
<link rel="stylesheet" href="css/main.css">
|
||||||
|
|
||||||
|
<script src="https://kit.fontawesome.com/55072ce5fd.js" crossorigin="anonymous" defer></script>
|
||||||
|
|
||||||
<meta name="theme-color" content="#488ea7">
|
<meta name="theme-color" content="#488ea7">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
<div id="navbar">
|
||||||
|
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
|
||||||
|
<div class="container-fluid">
|
||||||
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse"
|
||||||
|
data-bs-target="#navbarMenu" aria-controls="navbarSupportedContent"
|
||||||
|
aria-expanded="false" aria-label="Toggle navigation">
|
||||||
|
<span class="navbar-toggler-icon"></span>
|
||||||
|
</button>
|
||||||
|
<div class="collapse navbar-collapse" id="navbarMenu">
|
||||||
|
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
|
||||||
|
<li class="navbar-brand">
|
||||||
|
<a href="index.html">PRESSURIZED GAS</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<div class="nav-item m-2 align-content-end">
|
||||||
|
<a href="viewGameData.html">Admin View</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div id="gameTitle"></div>
|
<div class="container-fluid">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-1"></div>
|
||||||
|
<div class="col-10 gamePage">
|
||||||
|
<h1 id="gameTitle" class="text-center"></h1>
|
||||||
|
|
||||||
<div id="longDescription"></div>
|
<div class="coverArtContainer">
|
||||||
|
<div id="coverArt"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div id="coverArt"></div>
|
<div class="mb-3"></div>
|
||||||
|
|
||||||
|
<div class="text-center" id="developer"></div>
|
||||||
|
<div class="text-center" id="publisher"></div>
|
||||||
|
|
||||||
|
<div class="mb-3"></div>
|
||||||
|
|
||||||
|
<div id="osSupport" class="text-center"></div>
|
||||||
|
|
||||||
|
<div class="mb-3"></div>
|
||||||
|
|
||||||
|
<div id="longDescription"></div>
|
||||||
|
</div>
|
||||||
|
<div class="col-1"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-5"></div>
|
||||||
|
|
||||||
|
<footer id="footer">
|
||||||
|
<p>Page created by <a href="https://lunarpenguin.net/">Kaj Forney</a>, as work for class (GIMM 285).</p>
|
||||||
|
<p>All example data used is originally from <a href="https://store.steampowered.com/">Steam</a>.</p>
|
||||||
|
<p>(also, I can take no credit for the name "Pressurized Gas"... that was from the fantastically creative people who
|
||||||
|
made The Stanley Parable.)</p>
|
||||||
|
</footer>
|
||||||
|
|
||||||
<script src="js/vendor/modernizr-3.11.2.min.js"></script>
|
<script src="js/vendor/modernizr-3.11.2.min.js"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js"
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js"
|
||||||
|
@ -38,6 +91,23 @@
|
||||||
gameID = -1;
|
gameID = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function osSupport(win, mac, lnx) {
|
||||||
|
let osString = "";
|
||||||
|
if (win == 1) {
|
||||||
|
osString += "<i class=\"fa-brands fa-windows mx-2\"></i>"
|
||||||
|
}
|
||||||
|
;
|
||||||
|
if (mac == 1) {
|
||||||
|
osString += "<i class=\"fa-brands fa-apple mx-2\"></i>"
|
||||||
|
}
|
||||||
|
;
|
||||||
|
if (lnx == 1) {
|
||||||
|
osString += "<i class=\"fa-brands fa-linux mx-2\"></i>"
|
||||||
|
}
|
||||||
|
;
|
||||||
|
return osString;
|
||||||
|
}
|
||||||
|
|
||||||
//Settings for FETCH API request
|
//Settings for FETCH API request
|
||||||
let fetchSettings = {
|
let fetchSettings = {
|
||||||
method: 'GET'
|
method: 'GET'
|
||||||
|
@ -55,12 +125,37 @@
|
||||||
})
|
})
|
||||||
.then(({status, json}) => {
|
.then(({status, json}) => {
|
||||||
if (status === 200) {
|
if (status === 200) {
|
||||||
document.title = "Pressurized Gas - " + json.data[0].title;
|
let gameData = json.data[0];
|
||||||
document.getElementById("gameTitle").innerHTML = json.data[0].title;
|
|
||||||
document.getElementById("longDescription").innerHTML = json.data[0].longDescription;
|
document.title = "Pressurized Gas - " + gameData.title;
|
||||||
|
document.getElementById("gameTitle").innerHTML = gameData.title;
|
||||||
|
|
||||||
|
let developerHTML = "";
|
||||||
|
developerHTML += "<p>Developer: <a href='"
|
||||||
|
developerHTML += gameData.devURL;
|
||||||
|
developerHTML += "'>";
|
||||||
|
developerHTML += gameData.developer;
|
||||||
|
developerHTML += "</a></p>";
|
||||||
|
document.getElementById("developer").innerHTML = developerHTML;
|
||||||
|
|
||||||
|
if(gameData.publisher != "Self Published") {
|
||||||
|
let publisherHTML = "";
|
||||||
|
publisherHTML += "<p>Publisher: <a href='"
|
||||||
|
publisherHTML += gameData.pubURL;
|
||||||
|
publisherHTML += "'>";
|
||||||
|
publisherHTML += gameData.publisher;
|
||||||
|
publisherHTML += "</a></p>";
|
||||||
|
document.getElementById("publisher").innerHTML = publisherHTML;
|
||||||
|
}
|
||||||
|
|
||||||
|
document.getElementById("osSupport").innerHTML = osSupport(gameData.win, gameData.mac, gameData.linux)
|
||||||
|
|
||||||
let coverImg = document.createElement('img');
|
let coverImg = document.createElement('img');
|
||||||
coverImg.src = "http://localhost:8787/images/" + json.data[0].coverArt;
|
coverImg.src = "http://localhost:8787/images/" + gameData.coverArt;
|
||||||
|
coverImg.classList.add("coverArt");
|
||||||
document.getElementById("coverArt").appendChild(coverImg);
|
document.getElementById("coverArt").appendChild(coverImg);
|
||||||
|
|
||||||
|
document.getElementById("longDescription").innerHTML = gameData.longDescription;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
<link rel="stylesheet" href="css/main.css">
|
<link rel="stylesheet" href="css/main.css">
|
||||||
|
|
||||||
<meta name="theme-color" content="#488ea7">
|
<meta name="theme-color" content="#488ea7">
|
||||||
|
|
||||||
|
<script src="https://kit.fontawesome.com/55072ce5fd.js" crossorigin="anonymous" defer></script>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
@ -30,157 +32,55 @@
|
||||||
</button>
|
</button>
|
||||||
<div class="collapse navbar-collapse" id="navbarMenu">
|
<div class="collapse navbar-collapse" id="navbarMenu">
|
||||||
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
|
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
|
||||||
<li class="navbar-brand">ADMIN</li>
|
<li class="navbar-brand">
|
||||||
<li class="nav-item m-2">
|
<a href="index.html">PRESSURIZED GAS</a>
|
||||||
<a href="viewGameData.html">View Games</a>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item dropdown">
|
|
||||||
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button"
|
|
||||||
data-bs-toggle="dropdown" aria-expanded="false">
|
|
||||||
Add
|
|
||||||
</a>
|
|
||||||
|
|
||||||
<ul class="dropdown-menu bg-dark" aria-labelledby="navbarDropdown">
|
|
||||||
<li>
|
|
||||||
<a class="dropdown-item" href="insert.html">Add Game</a>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<a class="dropdown-item" href="insertDeveloper.html">Add Developer</a>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<a class="dropdown-item" href="insertPublisher.html">Add Publisher</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<div class="nav-item m-2 align-content-end">
|
<div class="nav-item m-2 align-content-end">
|
||||||
<a href="index.html">Exit Admin View</a>
|
<a href="viewGameData.html">Admin View</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="header" class="container">
|
<div id="header" class="container text-center">
|
||||||
<h1>View Game Data</h1>
|
<h1>Welcome to Pressurized Gas!</h1>
|
||||||
|
<h4>"The extremely popular online storefront for computer games"</h4>
|
||||||
<hr/>
|
<hr/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="form">
|
<!--
|
||||||
<div class="container">
|
<div class="row">
|
||||||
<div class="row mb-3">
|
<div class="col-xl-6 card gameEntry">
|
||||||
<div class="col">
|
<a href="game.html?ID=16">
|
||||||
<label>Application ID</label>
|
<div class="card-body">
|
||||||
</div>
|
<div class="row">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<input id="appID" type="text"/>
|
<img class="coverArt" src="images/megsmonster.png"/>
|
||||||
</div>
|
</div>
|
||||||
<div class="col"></div>
|
<div class="col">
|
||||||
</div>
|
<h2 class="text-center">Meg's Monster</h2>
|
||||||
|
<p> Take control of the Underworld’s grumpiest ghoul to help a lost little girl find her way home in
|
||||||
<div class="row mb-3">
|
this creepy-cute indie adventure. Just be warned: if she cries, the whole world dies. </p>
|
||||||
<div class="col">
|
</div>
|
||||||
<label>Title</label>
|
|
||||||
</div>
|
|
||||||
<div class="col">
|
|
||||||
<input id="title" type="text"/>
|
|
||||||
</div>
|
|
||||||
<div class="col"></div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="row mb-3">
|
|
||||||
<div class="col">
|
|
||||||
<label>Developer</label>
|
|
||||||
</div>
|
|
||||||
<div class="col">
|
|
||||||
<input id="developer" type="text"/>
|
|
||||||
</div>
|
|
||||||
<div class="col"></div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="row mb-3">
|
|
||||||
<div class="col">
|
|
||||||
<label>Publisher</label>
|
|
||||||
</div>
|
|
||||||
<div class="col">
|
|
||||||
<input id="publisher" type="text"/>
|
|
||||||
</div>
|
|
||||||
<div class="col"></div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="row mb-3">
|
|
||||||
<div class="col">
|
|
||||||
<label>Release Date</label>
|
|
||||||
</div>
|
|
||||||
<div class="col">
|
|
||||||
<input id="releaseDate" type="date"/>
|
|
||||||
</div>
|
|
||||||
<div class="col"></div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="row mb-3">
|
|
||||||
<div class="col">
|
|
||||||
<label>Supported OSes</label>
|
|
||||||
</div>
|
|
||||||
<div class="col">
|
|
||||||
<div class="row">
|
|
||||||
<div class="col">
|
|
||||||
<span>Windows</span>
|
|
||||||
<input id="win" type="checkbox"/>
|
|
||||||
</div>
|
|
||||||
<div class="col">
|
|
||||||
<span>MacOS</span>
|
|
||||||
<input id="mac" type="checkbox"/>
|
|
||||||
</div>
|
|
||||||
<div class="col">
|
|
||||||
<span>Linux</span>
|
|
||||||
<input id="linux" type="checkbox"/>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</a>
|
||||||
<div class="col"></div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<hr/>
|
|
||||||
|
|
||||||
<div class="row mb-3">
|
|
||||||
<div class="col">
|
|
||||||
<label>Limit Number of Results to:</label>
|
|
||||||
</div>
|
|
||||||
<div class="col">
|
|
||||||
<input id="limitNumber" type="text"/>
|
|
||||||
</div>
|
|
||||||
<div class="col"></div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="row mb-3">
|
|
||||||
<div class="col">
|
|
||||||
<label>Order by:</label>
|
|
||||||
</div>
|
|
||||||
<div class="col">
|
|
||||||
<select id="orderBy">
|
|
||||||
<option value="ASC">Ascending</option>
|
|
||||||
<option value="DESC">Descending</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
<div class="col"></div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="row mb-3">
|
|
||||||
<div class="col align-content-center">
|
|
||||||
<input id="submitButton" type="submit"/>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<hr/>
|
-->
|
||||||
</div>
|
<div class="container-fluid">
|
||||||
|
<div class="mx-5" id="gameList"></div>
|
||||||
|
|
||||||
<div id="outputTable" class="container overflow"></div>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-5"></div>
|
||||||
|
|
||||||
<footer id="footer">
|
<footer id="footer">
|
||||||
<p>Page created by <a href="https://lunarpenguin.net/">Kaj Forney</a>, as work for class (GIMM 285).</p>
|
<p>Page created by <a href="https://lunarpenguin.net/">Kaj Forney</a>, as work for class (GIMM 285).</p>
|
||||||
|
<p>All example data used is originally from <a href="https://store.steampowered.com/">Steam</a>.</p>
|
||||||
|
<p>(also, I can take no credit for the name "Pressurized Gas"... that was from the fantastically creative people who
|
||||||
|
made The Stanley Parable.)</p>
|
||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
<script src="js/vendor/modernizr-3.11.2.min.js"></script>
|
<script src="js/vendor/modernizr-3.11.2.min.js"></script>
|
||||||
|
@ -189,129 +89,85 @@
|
||||||
crossorigin="anonymous" defer></script>
|
crossorigin="anonymous" defer></script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const isEmpty = (obj) => Object.keys(obj).length === 0;
|
//Settings for FETCH API request
|
||||||
|
let fetchSettings = {
|
||||||
|
method: 'GET'
|
||||||
|
};
|
||||||
|
|
||||||
document.getElementById('submitButton').addEventListener('click', (event) => {
|
//Send FETCH API request
|
||||||
//const formData = new FormData();
|
fetch("http://localhost:8787/games", fetchSettings)
|
||||||
const getParameters = {};
|
.then((response) => {
|
||||||
|
return new Promise((resolve) => response.json()
|
||||||
|
.then((json) => resolve({
|
||||||
|
status: response.status,
|
||||||
|
json,
|
||||||
|
})
|
||||||
|
));
|
||||||
|
})
|
||||||
|
.then(({status, json}) => {
|
||||||
|
if (status === 200) {
|
||||||
|
let gameListDiv = document.getElementById("gameList")
|
||||||
|
let gameListData = json.data;
|
||||||
|
let numberOfGames = json.data.length - 1;
|
||||||
|
console.log(gameListData);
|
||||||
|
|
||||||
if (document.getElementById('appID').value.length !== 0) {
|
function osSupport(win, mac, lnx) {
|
||||||
//formData.append('appID', document.getElementById('appID').value);
|
let osString = "";
|
||||||
getParameters.appID = document.getElementById('appID').value;
|
if (win == 1) {
|
||||||
}
|
osString += "<i class=\"fa-brands fa-windows mx-2\"></i>"
|
||||||
if (document.getElementById('title').value.length !== 0) {
|
|
||||||
//formData.append('title', document.getElementById('title').value);
|
|
||||||
getParameters.title = document.getElementById('title').value;
|
|
||||||
}
|
|
||||||
if (document.getElementById('developer').value.length !== 0) {
|
|
||||||
//formData.append('developer', document.getElementById('developer').value);
|
|
||||||
getParameters.developer = document.getElementById('developer').value;
|
|
||||||
}
|
|
||||||
if (document.getElementById('publisher').value.length !== 0) {
|
|
||||||
//formData.append('publisher', document.getElementById('publisher').value);
|
|
||||||
getParameters.publisher = document.getElementById('publisher').value;
|
|
||||||
}
|
|
||||||
if (document.getElementById('releaseDate').value.length !== 0) {
|
|
||||||
//formData.append('releaseDate', document.getElementById('releaseDate').value);
|
|
||||||
getParameters.releaseDate = document.getElementById('releaseDate').value;
|
|
||||||
}
|
|
||||||
if (document.querySelector('#win:checked')) {
|
|
||||||
//formData.append('win', 1);
|
|
||||||
getParameters.win = 1;
|
|
||||||
}
|
|
||||||
if (document.querySelector('#mac:checked')) {
|
|
||||||
//formData.append('mac', 1);
|
|
||||||
getParameters.mac = 1;
|
|
||||||
}
|
|
||||||
if (document.querySelector('#linux:checked')) {
|
|
||||||
//formData.append('linux', 1);
|
|
||||||
getParameters.linux = 1;
|
|
||||||
}
|
|
||||||
if (document.getElementById('limitNumber').value.length !== 0) {
|
|
||||||
//formData.append('limitNumber', document.getElementById('limitNumber').value);
|
|
||||||
getParameters.limitNumber = document.getElementById('limitNumber').value;
|
|
||||||
}
|
|
||||||
if (document.getElementById('orderBy').value.length !== 0) {
|
|
||||||
//formData.append('orderBy', document.getElementById('orderBy').value);
|
|
||||||
getParameters.orderBy = document.getElementById('orderBy').value;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Settings for FETCH API request
|
|
||||||
let fetchSettings = {
|
|
||||||
method: 'GET'
|
|
||||||
};
|
|
||||||
|
|
||||||
//Send FETCH API request
|
|
||||||
fetch("http://localhost:8787/games" + (!isEmpty(getParameters) ? '?' + new URLSearchParams(getParameters) : ''), fetchSettings)
|
|
||||||
.then((response) => {
|
|
||||||
return new Promise((resolve) => response.json()
|
|
||||||
.then((json) => resolve({
|
|
||||||
status: response.status,
|
|
||||||
json,
|
|
||||||
})
|
|
||||||
));
|
|
||||||
})
|
|
||||||
.then(({status, json}) => {
|
|
||||||
if (status === 200) {
|
|
||||||
let displayTable = '<table>' +
|
|
||||||
'<thead>' +
|
|
||||||
'<tr>' +
|
|
||||||
'<th>Edit Game</th>' +
|
|
||||||
'<th>Delete Game</th>' +
|
|
||||||
'<th>AppID</th>' +
|
|
||||||
'<th>Title</th>' +
|
|
||||||
'<th>Developer</th>' +
|
|
||||||
'<th>Publisher</th>' +
|
|
||||||
'<th>Release Date</th> ' +
|
|
||||||
'<th>Supported OSes</th>' +
|
|
||||||
'<th>Summary</th>' +
|
|
||||||
'<th>Cover Art</th>' +
|
|
||||||
'</tr>' +
|
|
||||||
'</thead>' +
|
|
||||||
'<tbody>';
|
|
||||||
|
|
||||||
function osSupport(win, mac, lnx) {
|
|
||||||
let osString = "";
|
|
||||||
if (win == 1) {
|
|
||||||
osString += "Windows, "
|
|
||||||
}
|
|
||||||
;
|
|
||||||
if (mac == 1) {
|
|
||||||
osString += "Mac, "
|
|
||||||
}
|
|
||||||
;
|
|
||||||
if (lnx == 1) {
|
|
||||||
osString += "Linux"
|
|
||||||
}
|
|
||||||
;
|
|
||||||
return osString;
|
|
||||||
}
|
}
|
||||||
|
;
|
||||||
if (typeof json.data !== 'undefined') {
|
if (mac == 1) {
|
||||||
for (row of json.data) {
|
osString += "<i class=\"fa-brands fa-apple mx-2\"></i>"
|
||||||
displayTable += '<tr>' +
|
|
||||||
'<td> <a href="edit.html?id=' + row.appID.toString() + '">Edit</a></td>' +
|
|
||||||
'<td> <a href="delete.html?id=' + row.appID.toString() + '">Delete</a></td>' +
|
|
||||||
'<td>' + row.appID + '</td>' +
|
|
||||||
'<td>' + row.title + '</td>' +
|
|
||||||
'<td>' + row.developer + '</td>' +
|
|
||||||
'<td>' + row.publisher + '</td>' +
|
|
||||||
'<td>' + new Date(row.releaseDate).toDateString() + '</td>' +
|
|
||||||
'<td>' + osSupport(row.win.toString(), row.mac.toString(), row.linux.toString()) + '</td>' +
|
|
||||||
'<td>' + row.summary + '</td>' +
|
|
||||||
'<td> <img class="tableCoverArt" src="http://localhost:8787/images/' + row.coverArt + '"> </td>' +
|
|
||||||
'</tr>';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
displayTable += '</tbody></table>';
|
;
|
||||||
document.getElementById('outputTable').innerHTML = displayTable;
|
if (lnx == 1) {
|
||||||
|
osString += "<i class=\"fa-brands fa-linux mx-2\"></i>"
|
||||||
|
}
|
||||||
|
;
|
||||||
|
return osString;
|
||||||
}
|
}
|
||||||
})
|
|
||||||
.catch(error => {
|
const cardPt1 = "<div class=\"col-xl-6 card gameEntry\"><a href=\"game.html?ID="
|
||||||
console.error('Error:', error);
|
const cardPt2 = "\"><div class=\"card-body\"><div class=\"row\"><div class=\"col coverArtContainer\"><img class=\"coverArt\" src=\"images/"
|
||||||
});
|
const cardPt3 = "\"></div><div class=\"col\"><h2 class=\"text-center\">"
|
||||||
return;
|
const cardPt4 = "</p></div></div></div></a></div>"
|
||||||
});
|
|
||||||
|
let gameListHTML = ""
|
||||||
|
|
||||||
|
gameListHTML += "<div class=\"row\">";
|
||||||
|
|
||||||
|
console.log(gameListData[0]);
|
||||||
|
for (let i = 0; i <= numberOfGames; i++) {
|
||||||
|
let currentCard = "";
|
||||||
|
currentCard += cardPt1;
|
||||||
|
currentCard += gameListData[i].appID;
|
||||||
|
currentCard += cardPt2;
|
||||||
|
currentCard += gameListData[i].coverArt;
|
||||||
|
currentCard += cardPt3;
|
||||||
|
currentCard += gameListData[i].title;
|
||||||
|
currentCard += "</h2><div class='text-center'>"
|
||||||
|
currentCard += osSupport(gameListData[i].win, gameListData[i].mac, gameListData[i].linux);
|
||||||
|
currentCard += "</div><p>"
|
||||||
|
currentCard += gameListData[i].summary;
|
||||||
|
currentCard += cardPt4;
|
||||||
|
|
||||||
|
if (i % 2 == 1) {
|
||||||
|
currentCard += "</div><div class=\"row my-3\">"
|
||||||
|
} else {
|
||||||
|
currentCard += ""
|
||||||
|
}
|
||||||
|
|
||||||
|
gameListHTML += currentCard;
|
||||||
|
}
|
||||||
|
gameListHTML += "</div>";
|
||||||
|
console.log(gameListHTML);
|
||||||
|
gameListDiv.innerHTML = gameListHTML;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error('Error:', error);
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|
Loading…
Reference in a new issue