mirror of
https://github.com/azures04/crafatar.git
synced 2026-03-21 23:41:18 +01:00
improve mojang status message
as Mojang has removed their status page and their status API is no longer updating, status information is now fetched from https://mc-heads.net/json/mc_status and the warning message links to https://mc-heads.net/mcstatus see #271, closes #272
This commit is contained in:
parent
265a98d404
commit
29955a1765
@ -1,5 +1,4 @@
|
||||
var valid_user_id = /^[0-9a-f-A-F-]{32,36}$/; // uuid
|
||||
var xhr = new XMLHttpRequest();
|
||||
|
||||
var quotes = [
|
||||
["Crafatar is the best at what it does.", "Shotbow Network", "https://twitter.com/ShotbowNetwork/status/565201303555829762"],
|
||||
@ -37,25 +36,18 @@ function changeQuote() {
|
||||
current_quote = (current_quote + 1) % quotes.length;
|
||||
}
|
||||
|
||||
xhr.onload = function() {
|
||||
var response = JSON.parse(xhr.responseText);
|
||||
var status = {};
|
||||
response.map(function(elem) {
|
||||
var key = Object.keys(elem)[0];
|
||||
status[key] = elem[key];
|
||||
});
|
||||
|
||||
var textures_err = status["textures.minecraft.net"] !== "green";
|
||||
var session_err = status["sessionserver.mojang.com"] !== "green";
|
||||
fetch('https://mc-heads.net/json/mc_status').then(r => r.json()).then(data => {
|
||||
var textures_err = data.report.skins.status !== "up";
|
||||
var session_err = data.report.session.status !== "up";
|
||||
|
||||
if (textures_err || session_err) {
|
||||
var warn = document.createElement("div");
|
||||
warn.setAttribute("class", "alert alert-warning");
|
||||
warn.setAttribute("role", "alert");
|
||||
warn.innerHTML = "<h5>Mojang issues</h5> Mojang's servers are having trouble <i>right now</i>, this may affect requests at Crafatar. <small><a href=\"https://help.mojang.com\" target=\"_blank\">check status</a>";
|
||||
warn.innerHTML = "<h5>Mojang issues</h5> Mojang's servers are having trouble <i>right now</i>, this may affect requests at Crafatar. <small><a href=\"https://mc-heads.net/mcstatus\" target=\"_blank\">check status</a>";
|
||||
document.querySelector("#alerts").appendChild(warn);
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function(event) {
|
||||
var avatars = document.querySelector("#avatar-wrapper");
|
||||
@ -82,7 +74,4 @@ document.addEventListener("DOMContentLoaded", function(event) {
|
||||
images[j].src = images[j].dataset.src.replace("$", value);
|
||||
}
|
||||
};
|
||||
|
||||
xhr.open("GET", "https://status.mojang.com/check", true);
|
||||
xhr.send();
|
||||
});
|
||||
Loading…
x
Reference in New Issue
Block a user