Uploaded the SheepstarTools V1
This commit is contained in:
parent
908b2b6964
commit
466b27eb02
5
SheepstarToolsV1/.idea/.gitignore
generated
vendored
Normal file
5
SheepstarToolsV1/.idea/.gitignore
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
15
SheepstarToolsV1/.idea/SheepstarTools.iml
generated
Normal file
15
SheepstarToolsV1/.idea/SheepstarTools.iml
generated
Normal file
@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="WEB_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<excludeFolder url="file://$MODULE_DIR$/temp" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/tmp" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="sweetalert2" level="application" />
|
||||
<orderEntry type="library" name="jquery-3.6.0" level="application" />
|
||||
<orderEntry type="library" name="bootstrap" level="application" />
|
||||
</component>
|
||||
</module>
|
7
SheepstarToolsV1/.idea/discord.xml
generated
Normal file
7
SheepstarToolsV1/.idea/discord.xml
generated
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="DiscordProjectSettings">
|
||||
<option name="show" value="ASK" />
|
||||
<option name="description" value="" />
|
||||
</component>
|
||||
</project>
|
6
SheepstarToolsV1/.idea/jsLibraryMappings.xml
generated
Normal file
6
SheepstarToolsV1/.idea/jsLibraryMappings.xml
generated
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="JavaScriptLibraryMappings">
|
||||
<file url="PROJECT" libraries="{bootstrap, jquery-3.6.0, sweetalert2}" />
|
||||
</component>
|
||||
</project>
|
8
SheepstarToolsV1/.idea/modules.xml
generated
Normal file
8
SheepstarToolsV1/.idea/modules.xml
generated
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/SheepstarTools.iml" filepath="$PROJECT_DIR$/.idea/SheepstarTools.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
17
SheepstarToolsV1/css/custom.css
Normal file
17
SheepstarToolsV1/css/custom.css
Normal file
@ -0,0 +1,17 @@
|
||||
body {
|
||||
padding-top: 5rem;
|
||||
}
|
||||
|
||||
.navbar-brand {
|
||||
padding-left: 20px;
|
||||
}
|
||||
|
||||
.form {
|
||||
padding-right: 20px;
|
||||
}
|
||||
|
||||
.starter-template {
|
||||
padding: 3rem 1.5rem;
|
||||
text-align: center;
|
||||
}
|
||||
|
80
SheepstarToolsV1/index.html
Normal file
80
SheepstarToolsV1/index.html
Normal file
@ -0,0 +1,80 @@
|
||||
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
<meta name="description" content="Sheepstar controller">
|
||||
<meta name="author" content="GNM">
|
||||
<title>Simple Sheepstar Controller</title>
|
||||
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link href="css/custom.css" rel="stylesheet">
|
||||
</head>
|
||||
|
||||
<body onload="load()">
|
||||
|
||||
<nav class="navbar navbar-expand-md navbar-dark bg-dark fixed-top d-flex justify-content-sm-between">
|
||||
<a class="navbar-brand" href="#">Sheepstar Control</a>
|
||||
|
||||
<div class="row row-cols-lg-auto g-3 av justify-content-center form">
|
||||
<div class="col-12">
|
||||
<div class="input-group">
|
||||
<div class="input-group-text">@</div>
|
||||
<input type="text" class="form-control" id="api_url" placeholder="Sheepstar API URL" value="">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<div class="input-group">
|
||||
<div class="input-group-text">🔑</div>
|
||||
<input type="text" class="form-control" id="api_key" placeholder="Sheepstar API Key">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<button onclick="save()" class="btn btn-primary">Save</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</nav>
|
||||
|
||||
<main role="main" class="container">
|
||||
|
||||
<div class="starter-template">
|
||||
<div class="gift">
|
||||
<h3>Gift Options</h3>
|
||||
<button onclick="createGift()" class="btn btn-primary">Create Gift</button>
|
||||
<button onclick="deleteGift()" class="btn btn-danger">Delete Gift</button>
|
||||
</div>
|
||||
<br>
|
||||
<div class="gift">
|
||||
<h3>Shop Options</h3>
|
||||
<button onclick="getItems()" class="btn btn-primary">Get items</button>
|
||||
<button onclick="enableItem()" class="btn btn-success">Enable item</button>
|
||||
<button onclick="disableItem()" class="btn btn-danger">Disable item</button>
|
||||
</div>
|
||||
<br>
|
||||
<div class="user">
|
||||
<h3>User Options</h3>
|
||||
<button onclick="getServer()" class="btn btn-primary">Show server</button>
|
||||
</div>
|
||||
<br>
|
||||
<div class="link">
|
||||
<h3>Shortener Options</h3>
|
||||
<button onclick="shortURL()" class="btn btn-primary">Short URL</button>
|
||||
<button onclick="deleteShortenURL()" class="btn btn-danger">Delete URL</button>
|
||||
</div>
|
||||
<br>
|
||||
<div class="apikey">
|
||||
<h3>ApiKey Options</h3>
|
||||
<button onclick="createAPIKey()" class="btn btn-primary">Create API-Key</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</main>
|
||||
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
||||
<script src="js/code.js"></script>
|
||||
</body>
|
||||
</html>
|
130
SheepstarToolsV1/js/code.js
Normal file
130
SheepstarToolsV1/js/code.js
Normal file
@ -0,0 +1,130 @@
|
||||
function load() {
|
||||
if (localStorage.getItem("api_url") != null) {
|
||||
document.getElementById("api_url").value = localStorage.getItem("api_url");
|
||||
}
|
||||
if (localStorage.getItem("api_key") != null) {
|
||||
document.getElementById("api_key").value = localStorage.getItem("api_key");
|
||||
}
|
||||
}
|
||||
|
||||
function save() {
|
||||
localStorage.setItem("api_url", document.getElementById("api_url").value);
|
||||
localStorage.setItem("api_key", document.getElementById("api_key").value);
|
||||
|
||||
sendSaveToast();
|
||||
}
|
||||
|
||||
function sendSaveToast() {
|
||||
const Toast = Swal.mixin({
|
||||
toast: true,
|
||||
position: 'top-end',
|
||||
showConfirmButton: false,
|
||||
timer: 3000,
|
||||
timerProgressBar: true
|
||||
})
|
||||
|
||||
Toast.fire({
|
||||
icon: 'success',
|
||||
title: 'Data saved successfully'
|
||||
})
|
||||
}
|
||||
|
||||
function sendRequest(type, endpoint, postData = {}) {
|
||||
return $.ajax({
|
||||
url: document.getElementById("api_url").value + "/" + endpoint,
|
||||
type: type,
|
||||
dataType: "json",
|
||||
headers: {
|
||||
Authorization: "Bearer " + document.getElementById("api_key").value
|
||||
},
|
||||
data: postData
|
||||
}).then(result => {
|
||||
handleResult(result);
|
||||
}).catch(result => {
|
||||
handleResult(result.responseJSON)
|
||||
});
|
||||
}
|
||||
|
||||
async function prepare(title, placeholder, confirm = "Execute") {
|
||||
return await Swal.fire({
|
||||
title: title,
|
||||
input: "text",
|
||||
inputPlaceholder: placeholder,
|
||||
showCancelButton: true,
|
||||
confirmButtonText: confirm,
|
||||
showLoaderOnConfirm: true
|
||||
});
|
||||
}
|
||||
|
||||
function handleResult(result) {
|
||||
console.log(result);
|
||||
Swal.fire({
|
||||
title: "Result received",
|
||||
html: `<pre id="json">${JSON.stringify(result, undefined, 1)}</pre><style>pre {text-align: left}</style>`
|
||||
});
|
||||
}
|
||||
|
||||
async function createGift() {
|
||||
let result = await prepare("Create gift", "Article ID");
|
||||
|
||||
if (result.isConfirmed) sendRequest("PUT", "gift", {articleID: result.value})
|
||||
}
|
||||
|
||||
async function deleteGift() {
|
||||
let result = await prepare("Delete gift", "Gift ID");
|
||||
|
||||
if (result.isConfirmed) sendRequest("DELETE", "gift/" + result.value)
|
||||
}
|
||||
|
||||
async function getItems() {
|
||||
let guild = await prepare("Show items", "Guild ID");
|
||||
|
||||
if (guild.isConfirmed) sendRequest("GET", "shop/?guildID=" +guild.value)
|
||||
}
|
||||
|
||||
async function enableItem() {
|
||||
let result = await prepare("Enable item", "Item ID", "Next");
|
||||
|
||||
if (!result.isConfirmed) return;
|
||||
|
||||
let guild = await prepare("Enable item", "Guild ID");
|
||||
|
||||
if (result.isConfirmed) sendRequest("PUT", "shop", {articleID: result.value, guildID: guild.value})
|
||||
}
|
||||
|
||||
async function disableItem() {
|
||||
let result = await prepare("Disable item", "Item ID", "Next");
|
||||
|
||||
if (!result.isConfirmed) return;
|
||||
|
||||
let guild = await prepare("Disable item", "Guild ID");
|
||||
|
||||
if (result.isConfirmed) sendRequest("DELETE", "shop", {articleID: result.value, guildID: guild.value})
|
||||
}
|
||||
|
||||
|
||||
async function getServer() {
|
||||
sendRequest("GET", "user/guilds");
|
||||
}
|
||||
|
||||
async function shortURL() {
|
||||
let origin = await prepare("Short URL", "Original URL", "Next");
|
||||
|
||||
if (!origin.isConfirmed) return;
|
||||
|
||||
let custom = await prepare("Short URL", "Custom URL (leave empty for random)");
|
||||
|
||||
let optionalJSON = custom.value === "" ? {} : {custom_url: custom.value};
|
||||
|
||||
if (custom.isConfirmed) sendRequest("PUT", "link", {original_url: origin.value, ...optionalJSON})
|
||||
}
|
||||
|
||||
async function deleteShortenURL() {
|
||||
let origin = await prepare("Short URL", "Shorten Code");
|
||||
|
||||
if (origin.isConfirmed) sendRequest("DELETE", "link/"+origin.value)
|
||||
}
|
||||
|
||||
async function createAPIKey() {
|
||||
sendRequest("PUT", "apikey")
|
||||
}
|
Reference in New Issue
Block a user