Homepage and game info pages presentable.
This commit is contained in:
parent
88721378b2
commit
4100585a60
6 changed files with 252 additions and 261 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -105,3 +105,6 @@ dist
|
|||
|
||||
# Ignore credentials
|
||||
server/model/creds.json
|
||||
|
||||
#Ignore uploaded images
|
||||
server/public/images/*
|
||||
|
|
|
@ -95,7 +95,9 @@ async function getGame(id) {
|
|||
m.id AS appID,
|
||||
m.game_title AS title,
|
||||
d.name AS developer,
|
||||
d.homepage AS devURL,
|
||||
p.name AS publisher,
|
||||
p.homepage AS pubURL,
|
||||
m.release_date AS releaseDate,
|
||||
m.short_description AS summary,
|
||||
m.long_description AS longDescription,
|
||||
|
@ -104,7 +106,8 @@ async function getGame(id) {
|
|||
m.linux_supported AS linux,
|
||||
m.cover_art_filename AS coverArt,
|
||||
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
|
||||
INNER JOIN developers d ON m.developer_id = d.id
|
||||
INNER JOIN publishers p ON m.publisher_id = p.id`,
|
||||
|
|
|
@ -88,11 +88,9 @@ textarea {
|
|||
========================================================================== */
|
||||
#header {
|
||||
background-color: #171a21;
|
||||
color: #c6d4df;
|
||||
}
|
||||
|
||||
#form {
|
||||
background-image: linear-gradient(180deg, #171a21, #1b2838);
|
||||
min-height: 750px;
|
||||
color: #c6d4df;
|
||||
}
|
||||
|
@ -111,6 +109,7 @@ hr{
|
|||
}
|
||||
|
||||
body, html {
|
||||
background-image: linear-gradient(180deg, #171a21, #1b2838);
|
||||
margin: 0px;
|
||||
background-color: #171a21;
|
||||
transition: all 0.4s ease 0s;
|
||||
|
@ -141,6 +140,41 @@ input, select, textarea {
|
|||
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 {
|
||||
border-radius: 5px;
|
||||
border:0;
|
||||
|
|
|
@ -302,7 +302,7 @@
|
|||
document.getElementById("currentArt").appendChild(coverImg);
|
||||
|
||||
document.getElementById("shortDescription").value = gameData.shortDescription;
|
||||
document.getElementById("longDescription").value = gameData.longDescription;
|
||||
document.getElementById("longDescription").value = gameData.markdown;
|
||||
} else {
|
||||
document.getElementById("errorMessage").innerHTML = "Invalid App ID!";
|
||||
document.getElementById("errorMessage").hidden = false;
|
||||
|
|
|
@ -14,15 +14,68 @@
|
|||
<link rel="stylesheet" href="css/normalize.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">
|
||||
</head>
|
||||
<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 class="coverArtContainer">
|
||||
<div id="coverArt"></div>
|
||||
</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 id="coverArt"></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="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js"
|
||||
|
@ -38,6 +91,23 @@
|
|||
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
|
||||
let fetchSettings = {
|
||||
method: 'GET'
|
||||
|
@ -55,12 +125,37 @@
|
|||
})
|
||||
.then(({status, json}) => {
|
||||
if (status === 200) {
|
||||
document.title = "Pressurized Gas - " + json.data[0].title;
|
||||
document.getElementById("gameTitle").innerHTML = json.data[0].title;
|
||||
document.getElementById("longDescription").innerHTML = json.data[0].longDescription;
|
||||
let gameData = json.data[0];
|
||||
|
||||
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');
|
||||
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("longDescription").innerHTML = gameData.longDescription;
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
<link rel="stylesheet" href="css/main.css">
|
||||
|
||||
<meta name="theme-color" content="#488ea7">
|
||||
|
||||
<script src="https://kit.fontawesome.com/55072ce5fd.js" crossorigin="anonymous" defer></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
@ -30,157 +32,55 @@
|
|||
</button>
|
||||
<div class="collapse navbar-collapse" id="navbarMenu">
|
||||
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
|
||||
<li class="navbar-brand">ADMIN</li>
|
||||
<li class="nav-item m-2">
|
||||
<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 class="navbar-brand">
|
||||
<a href="index.html">PRESSURIZED GAS</a>
|
||||
</li>
|
||||
</ul>
|
||||
<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>
|
||||
</nav>
|
||||
</div>
|
||||
|
||||
<div id="header" class="container">
|
||||
<h1>View Game Data</h1>
|
||||
<div id="header" class="container text-center">
|
||||
<h1>Welcome to Pressurized Gas!</h1>
|
||||
<h4>"The extremely popular online storefront for computer games"</h4>
|
||||
<hr/>
|
||||
</div>
|
||||
|
||||
<div id="form">
|
||||
<div class="container">
|
||||
<div class="row mb-3">
|
||||
<div class="col">
|
||||
<label>Application ID</label>
|
||||
</div>
|
||||
<div class="col">
|
||||
<input id="appID" type="text"/>
|
||||
</div>
|
||||
<div class="col"></div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<div class="col">
|
||||
<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-xl-6 card gameEntry">
|
||||
<a href="game.html?ID=16">
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<span>Windows</span>
|
||||
<input id="win" type="checkbox"/>
|
||||
<img class="coverArt" src="images/megsmonster.png"/>
|
||||
</div>
|
||||
<div class="col">
|
||||
<span>MacOS</span>
|
||||
<input id="mac" type="checkbox"/>
|
||||
</div>
|
||||
<div class="col">
|
||||
<span>Linux</span>
|
||||
<input id="linux" type="checkbox"/>
|
||||
<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
|
||||
this creepy-cute indie adventure. Just be warned: if she cries, the whole world dies. </p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col"></div>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
-->
|
||||
<div class="container-fluid">
|
||||
<div class="mx-5" id="gameList"></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>
|
||||
<hr/>
|
||||
</div>
|
||||
|
||||
|
||||
<div id="outputTable" class="container overflow"></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>
|
||||
|
@ -189,60 +89,13 @@
|
|||
crossorigin="anonymous" defer></script>
|
||||
|
||||
<script>
|
||||
const isEmpty = (obj) => Object.keys(obj).length === 0;
|
||||
|
||||
document.getElementById('submitButton').addEventListener('click', (event) => {
|
||||
//const formData = new FormData();
|
||||
const getParameters = {};
|
||||
|
||||
if (document.getElementById('appID').value.length !== 0) {
|
||||
//formData.append('appID', document.getElementById('appID').value);
|
||||
getParameters.appID = document.getElementById('appID').value;
|
||||
}
|
||||
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)
|
||||
fetch("http://localhost:8787/games", fetchSettings)
|
||||
.then((response) => {
|
||||
return new Promise((resolve) => response.json()
|
||||
.then((json) => resolve({
|
||||
|
@ -253,65 +106,68 @@
|
|||
})
|
||||
.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>';
|
||||
let gameListDiv = document.getElementById("gameList")
|
||||
let gameListData = json.data;
|
||||
let numberOfGames = json.data.length - 1;
|
||||
console.log(gameListData);
|
||||
|
||||
function osSupport(win, mac, lnx) {
|
||||
let osString = "";
|
||||
if (win == 1) {
|
||||
osString += "Windows, "
|
||||
osString += "<i class=\"fa-brands fa-windows mx-2\"></i>"
|
||||
}
|
||||
;
|
||||
if (mac == 1) {
|
||||
osString += "Mac, "
|
||||
osString += "<i class=\"fa-brands fa-apple mx-2\"></i>"
|
||||
}
|
||||
;
|
||||
if (lnx == 1) {
|
||||
osString += "Linux"
|
||||
osString += "<i class=\"fa-brands fa-linux mx-2\"></i>"
|
||||
}
|
||||
;
|
||||
return osString;
|
||||
}
|
||||
|
||||
if (typeof json.data !== 'undefined') {
|
||||
for (row of json.data) {
|
||||
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>';
|
||||
const cardPt1 = "<div class=\"col-xl-6 card gameEntry\"><a href=\"game.html?ID="
|
||||
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\">"
|
||||
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;
|
||||
}
|
||||
displayTable += '</tbody></table>';
|
||||
document.getElementById('outputTable').innerHTML = displayTable;
|
||||
gameListHTML += "</div>";
|
||||
console.log(gameListHTML);
|
||||
gameListDiv.innerHTML = gameListHTML;
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error:', error);
|
||||
});
|
||||
return;
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
|
Loading…
Reference in a new issue