-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
66 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,34 @@ | ||
<html> | ||
<head> | ||
<title>TGUI at home</title> | ||
<link rel="stylesheet" href="css/shared.css"> | ||
<link rel="stylesheet" href="css/layout_default.css"> | ||
<link rel="stylesheet" href="css/icons.css"> | ||
</head> | ||
<body> | ||
<div id='uiWrapper'> | ||
<div id='uiTitleWrapper'> | ||
<div id="uiTitle" class="icon"> | ||
<span id="uiStatusIcon" class="icon24 uiStatusGood"></span> | ||
<span id="uiTitleText">We have TGUI at home</span> | ||
</div> | ||
</div> | ||
<div id='uiContent'> | ||
<div id='uiLoadingNotice'>Loading...</div> | ||
</div> | ||
<head> | ||
<title>TGUI at home</title> | ||
<link rel="stylesheet" href="css/shared.css" /> | ||
<link rel="stylesheet" href="css/layout_default.css" /> | ||
<link rel="stylesheet" href="css/icons.css" /> | ||
<script src="js/index.js"></script> | ||
</head> | ||
<body> | ||
<div id="uiWrapper"> | ||
<div id="uiTitleWrapper"> | ||
<div id="uiTitle" class="icon"> | ||
<span id="uiStatusIcon" class="icon24 uiStatusGood"></span> | ||
<span id="uiTitleText">We have TGUI at home</span> | ||
</div> | ||
</body> | ||
</div> | ||
<div id="uiContent"> | ||
<div style="padding: 20px;"> | ||
<input | ||
type="text" | ||
id="ckeyInput" | ||
placeholder="Enter ckey..." | ||
style="padding: 8px; margin-right: 10px;" | ||
> | ||
<button class="width75btn" | ||
onclick="fetchPlayer()" | ||
> | ||
Search | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
function displayPlayerInfo(playerData) { | ||
const uiContent = document.getElementById("uiContent"); | ||
uiContent.innerHTML = ` | ||
<div>Ckey: ${playerData.ckey}</div> | ||
<div>Discord ID: ${playerData.discord_id}</div> | ||
`; | ||
} | ||
|
||
function displayError(error) { | ||
const uiContent = document.getElementById("uiContent"); | ||
uiContent.innerHTML = `Error: ${error.message}`; | ||
} | ||
|
||
function fetchPlayer() { | ||
const ckeyInput = document.getElementById("ckeyInput"); | ||
const ckey = ckeyInput.value.trim(); | ||
const uiContent = document.getElementById("uiContent"); | ||
|
||
if (!ckey) { | ||
displayError(new Error("Please enter a ckey")); | ||
return; | ||
} | ||
|
||
uiContent.innerHTML = "Loading..."; | ||
|
||
fetch(`http://127.0.0.1:8000/v1/player?ckey=${encodeURIComponent(ckey)}`) | ||
.then((response) => { | ||
if (!response.ok) { | ||
throw new Error(`HTTP error! status: ${response.status}`); | ||
} | ||
return response.json(); | ||
}) | ||
.then(displayPlayerInfo) | ||
.catch(displayError); | ||
} |