2023-04-18 14:41:16 -06:00
|
|
|
<!doctype html>
|
|
|
|
<html>
|
|
|
|
|
|
|
|
<head>
|
2023-04-29 20:48:03 -06:00
|
|
|
<meta charset="utf-8">
|
|
|
|
<title>Kaj Forney -- GIMM 285 CRUD API Project</title>
|
|
|
|
<meta name="description" content="">
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
2023-04-18 14:41:16 -06:00
|
|
|
|
2023-04-29 20:48:03 -06:00
|
|
|
<link rel="manifest" href="site.webmanifest">
|
|
|
|
<link rel="apple-touch-icon" href="icon.png">
|
2023-04-18 14:41:16 -06:00
|
|
|
|
2023-04-29 20:48:03 -06:00
|
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet"
|
|
|
|
integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">
|
|
|
|
<link rel="stylesheet" href="css/normalize.css">
|
|
|
|
<link rel="stylesheet" href="css/main.css">
|
2023-04-18 14:41:16 -06:00
|
|
|
|
2023-04-29 20:48:03 -06:00
|
|
|
<meta name="theme-color" content="#488ea7">
|
2023-04-18 14:41:16 -06:00
|
|
|
</head>
|
|
|
|
|
|
|
|
<body>
|
2023-04-29 20:48:03 -06:00
|
|
|
<div id="header" class="container">
|
2023-04-18 14:41:16 -06:00
|
|
|
<h1>View Game Data</h1>
|
2023-04-29 20:48:03 -06:00
|
|
|
<hr/>
|
|
|
|
</div>
|
2023-04-18 14:41:16 -06:00
|
|
|
|
2023-04-29 20:48:03 -06:00
|
|
|
<div id="form">
|
2023-04-18 14:41:16 -06:00
|
|
|
<div class="container">
|
2023-04-29 20:48:03 -06:00
|
|
|
<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>
|
2023-04-18 14:41:16 -06:00
|
|
|
</div>
|
|
|
|
|
2023-04-29 20:48:03 -06:00
|
|
|
<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>
|
2023-04-18 14:41:16 -06:00
|
|
|
</div>
|
|
|
|
|
2023-04-29 20:48:03 -06:00
|
|
|
<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>
|
2023-04-18 14:41:16 -06:00
|
|
|
</div>
|
|
|
|
|
2023-04-29 20:48:03 -06:00
|
|
|
<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>
|
2023-04-18 14:41:16 -06:00
|
|
|
</div>
|
|
|
|
|
2023-04-29 20:48:03 -06:00
|
|
|
<div class="row mb-3">
|
|
|
|
<div class="col">
|
|
|
|
<label>Release Date</label>
|
|
|
|
</div>
|
2023-04-18 14:41:16 -06:00
|
|
|
<div class="col">
|
2023-04-29 20:48:03 -06:00
|
|
|
<input id="releaseDate" type="date"/>
|
2023-04-18 14:41:16 -06:00
|
|
|
</div>
|
2023-04-29 20:48:03 -06:00
|
|
|
<div class="col"></div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="row mb-3">
|
2023-04-18 14:41:16 -06:00
|
|
|
<div class="col">
|
2023-04-29 20:48:03 -06:00
|
|
|
<label>Supported OSes</label>
|
2023-04-18 14:41:16 -06:00
|
|
|
</div>
|
|
|
|
<div class="col">
|
2023-04-29 20:48:03 -06:00
|
|
|
<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>
|
2023-04-18 14:41:16 -06:00
|
|
|
</div>
|
2023-04-29 20:48:03 -06:00
|
|
|
<div class="col"></div>
|
2023-04-18 14:41:16 -06:00
|
|
|
</div>
|
|
|
|
|
2023-04-29 20:48:03 -06:00
|
|
|
<hr/>
|
2023-04-18 14:41:16 -06:00
|
|
|
|
2023-04-29 20:48:03 -06:00
|
|
|
<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>
|
2023-04-18 14:41:16 -06:00
|
|
|
</div>
|
|
|
|
|
2023-04-29 20:48:03 -06:00
|
|
|
<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>
|
2023-04-18 14:41:16 -06:00
|
|
|
</div>
|
|
|
|
|
2023-04-29 20:48:03 -06:00
|
|
|
<div class="row mb-3">
|
|
|
|
<div class="col align-content-center">
|
|
|
|
<input id="submitButton" type="submit"/>
|
|
|
|
</div>
|
2023-04-18 14:41:16 -06:00
|
|
|
</div>
|
2023-04-29 20:48:03 -06:00
|
|
|
<hr/>
|
2023-04-18 14:41:16 -06:00
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div id="outputTable" class="container overflow"></div>
|
|
|
|
|
2023-04-29 20:48:03 -06:00
|
|
|
</div>
|
2023-04-18 14:41:16 -06:00
|
|
|
|
2023-04-29 20:48:03 -06:00
|
|
|
<footer id="footer">
|
2023-04-18 14:41:16 -06:00
|
|
|
<p>Page created by <a href="https://lunarpenguin.net/">Kaj Forney</a>, as work for class (GIMM 285).</p>
|
2023-04-29 20:48:03 -06:00
|
|
|
</footer>
|
2023-04-18 14:41:16 -06:00
|
|
|
|
2023-04-29 20:48:03 -06:00
|
|
|
<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"
|
|
|
|
integrity="sha384-kenU1KFdBIe4zVF0s0G1M5b4hcpxyD9F7jL+jjXkk+Q2h455rYXK/7HAuoJl+0I4"
|
|
|
|
crossorigin="anonymous" defer></script>
|
2023-04-18 14:41:16 -06:00
|
|
|
|
2023-04-29 20:48:03 -06:00
|
|
|
<script>
|
2023-04-18 14:41:16 -06:00
|
|
|
const isEmpty = (obj) => Object.keys(obj).length === 0;
|
|
|
|
|
|
|
|
document.getElementById('submitButton').addEventListener('click', (event) => {
|
2023-04-29 20:48:03 -06:00
|
|
|
//const formData = new FormData();
|
|
|
|
const getParameters = {};
|
2023-04-18 14:41:16 -06:00
|
|
|
|
2023-04-29 20:48:03 -06:00
|
|
|
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;
|
|
|
|
}
|
2023-04-18 14:41:16 -06:00
|
|
|
|
2023-04-29 20:48:03 -06:00
|
|
|
//Settings for FETCH API request
|
|
|
|
let fetchSettings = {
|
|
|
|
method: 'GET'
|
|
|
|
};
|
2023-04-18 14:41:16 -06:00
|
|
|
|
2023-04-29 20:48:03 -06:00
|
|
|
//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>' +
|
2023-04-29 23:00:06 -06:00
|
|
|
'<th>Delete Game</th>' +
|
2023-04-29 20:48:03 -06:00
|
|
|
'<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>';
|
2023-04-18 14:41:16 -06:00
|
|
|
|
2023-04-29 20:48:03 -06:00
|
|
|
function osSupport(win, mac, lnx) {
|
|
|
|
let osString = "";
|
|
|
|
if (win == 1) {
|
|
|
|
osString += "Windows, "
|
|
|
|
}
|
|
|
|
;
|
|
|
|
if (mac == 1) {
|
|
|
|
osString += "Mac, "
|
|
|
|
}
|
|
|
|
;
|
|
|
|
if (lnx == 1) {
|
|
|
|
osString += "Linux"
|
|
|
|
}
|
|
|
|
;
|
|
|
|
return osString;
|
|
|
|
}
|
2023-04-18 14:41:16 -06:00
|
|
|
|
2023-04-29 20:48:03 -06:00
|
|
|
if (typeof json.data !== 'undefined') {
|
|
|
|
for (row of json.data) {
|
|
|
|
displayTable += '<tr>' +
|
|
|
|
'<td> <a href="edit.html?id=' + row.appID.toString() + '">Edit</a></td>' +
|
2023-04-29 23:00:06 -06:00
|
|
|
'<td> <a href="delete.html?id=' + row.appID.toString() + '">Edit</a></td>' +
|
2023-04-29 20:48:03 -06:00
|
|
|
'<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;
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.catch(error => {
|
|
|
|
console.error('Error:', error);
|
|
|
|
});
|
|
|
|
return;
|
2023-04-18 14:41:16 -06:00
|
|
|
});
|
2023-04-29 20:48:03 -06:00
|
|
|
</script>
|
2023-04-18 14:41:16 -06:00
|
|
|
|
|
|
|
</body>
|
|
|
|
|
|
|
|
</html>
|