Skip to content

Commit e2215dd

Browse files
improve UI
1 parent bb0c7fb commit e2215dd

10 files changed

+486
-1736
lines changed

Cargo.lock

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ serde_json = "1"
1616
thiserror = "1"
1717
tracing = "0.1"
1818
vss = "0.1"
19+
parking_lot = "0.12.1"
1920

2021
[workspace]
2122
members = [

assets/api.js

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
async function loadExampleResponses() {
2+
const servicesElement = document.getElementById("exampleServicesResponse");
3+
const pingResponseElement = document.getElementById("examplePingResponse");
4+
fetch("/api/java/mcping.me", {})
5+
.then((response) => {
6+
return response.json();
7+
})
8+
.then((resp) => {
9+
let ping_response = JSON.stringify(resp, null, " ");
10+
pingResponseElement.innerHTML = new Option(ping_response).innerHTML;
11+
});
12+
fetch("/api/services", {})
13+
.then((response) => {
14+
return response.json();
15+
})
16+
.then((resp) => {
17+
const services_string = JSON.stringify(resp, null, " ");
18+
servicesElement.innerHTML = new Option(services_string).innerHTML;
19+
});
20+
}
21+
22+
window.addEventListener("load", (_) => {
23+
loadExampleResponses().then(() => {
24+
hljs.highlightAll();
25+
});
26+
});

assets/api/index.html

+8-27
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
<meta charset="UTF-8" />
55
<link rel="icon" type="image/png" href="/icon.png" />
66
<link rel="stylesheet" href="/index.css" />
7-
<link rel="stylesheet" href="/hljs/default.min.css" />
7+
<link
8+
rel="stylesheet"
9+
href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/default.min.css"
10+
/>
811
<meta name="viewport" content="width=device-width" />
912
<meta
1013
property="og:title"
@@ -43,7 +46,7 @@ <h1>MCping API</h1>
4346
Bedrock API response is the same, with the caveat of never returning the
4447
icon. The bedrock player list may also be synthetic.
4548
</p>
46-
<pre><code id="examplePingResponse" class="language-json" style="text-align: left; display: inline-block;"></code></pre>
49+
<pre><code id="examplePingResponse" class="language-json"></code></pre>
4750
<br />
4851
<p>
4952
There is also a Mojang Services API, at
@@ -53,30 +56,8 @@ <h1>MCping API</h1>
5356
<code>DefiniteProblems</code>, <code>PossibleProblems</code>, and
5457
<code>Operational</code>.
5558
</p>
56-
<pre><code id="exampleServicesResponse" class="language-json"
57-
style="text-align: left; display: inline-block;"></code></pre>
59+
<pre><code id="exampleServicesResponse" class="language-json"></code></pre>
60+
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script>
61+
<script src="/api.js"></script>
5862
</body>
59-
<script src="/hljs/highlight.min.js"></script>
60-
<script>
61-
async function loadExampleResponses() {
62-
let ping = await fetch("/api/java/mcping.me", {}).then((response) =>
63-
response.json(),
64-
);
65-
let ping_response = JSON.stringify(ping, null, " ");
66-
document.getElementById("examplePingResponse").innerHTML = new Option(
67-
ping_response,
68-
).innerHTML;
69-
let services = await fetch("/api/services", {}).then((response) =>
70-
response.json(),
71-
);
72-
const services_string = JSON.stringify(services, null, " ");
73-
document.getElementById("exampleServicesResponse").innerHTML = new Option(
74-
services_string,
75-
).innerHTML;
76-
}
77-
78-
loadExampleResponses().then(() => {
79-
hljs.highlightAll();
80-
});
81-
</script>
8263
</html>

assets/hljs/default.min.css

-86
This file was deleted.

0 commit comments

Comments
 (0)