Fix version loading fixes

This commit is contained in:
Mikołaj Pich 2018-05-04 11:51:59 +02:00
parent 4597a73c14
commit c6985b4b5b
2 changed files with 12 additions and 4 deletions

View file

@ -73,3 +73,7 @@ body {
.github:hover, .github:focus, .github:active { .github:hover, .github:focus, .github:active {
opacity: 0.7; opacity: 0.7;
} }
[id$="version"] {
font-size: small;
}

View file

@ -5,7 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge"> <meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico?v=1"> <link rel="shortcut icon" type="image/x-icon" href="favicon.ico?v=1">
<title>Wulkanowy</title> <title>Aplikacja mobilna Androidowy klient dziennika VULCAN UONET+</title>
<link rel="stylesheet" href="app.css"> <link rel="stylesheet" href="app.css">
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-99646499-3"></script> <script async src="https://www.googletagmanager.com/gtag/js?id=UA-99646499-3"></script>
<script> <script>
@ -53,6 +53,8 @@
var betaButton = document.querySelector("#beta-button"); var betaButton = document.querySelector("#beta-button");
betaButton.addEventListener("click", disableClick); betaButton.addEventListener("click", disableClick);
var betaVersion = document.querySelector("#beta-version");
betaVersion.innerHTML = "Ładowanie…";
var betaRes = new XMLHttpRequest(); var betaRes = new XMLHttpRequest();
betaRes.open('GET', 'https://api.github.com/repos/wulkanowy/wulkanowy/releases/latest', true); betaRes.open('GET', 'https://api.github.com/repos/wulkanowy/wulkanowy/releases/latest', true);
@ -60,7 +62,7 @@
if(betaRes.status === 200) { if(betaRes.status === 200) {
var json = JSON.parse(betaRes.responseText); var json = JSON.parse(betaRes.responseText);
betaButton.href = json.assets[0].browser_download_url; betaButton.href = json.assets[0].browser_download_url;
document.querySelector("#beta-version").innerHTML = json.name; betaVersion.innerHTML = json.name;
} else { } else {
console.log("Błąd podczas ładowania strony\n"); console.log("Błąd podczas ładowania strony\n");
} }
@ -70,7 +72,8 @@
var alfaButton = document.querySelector("#alfa-button"); var alfaButton = document.querySelector("#alfa-button");
alfaButton.addEventListener("click", disableClick); alfaButton.addEventListener("click", disableClick);
var alfaVersion = document.querySelector("#alfa-version");
alfaVersion.innerHTML = "Ładowanie…";
var alfaRes = new XMLHttpRequest(); var alfaRes = new XMLHttpRequest();
alfaRes.open('GET', 'https://bitrise-redirector.herokuapp.com/v0.1/apps/daeff1893f3c8128/builds/master/artifacts/app-debug-bitrise-signed.apk/info', true); alfaRes.open('GET', 'https://bitrise-redirector.herokuapp.com/v0.1/apps/daeff1893f3c8128/builds/master/artifacts/app-debug-bitrise-signed.apk/info', true);
@ -78,8 +81,9 @@
if(alfaRes.status === 200) { if(alfaRes.status === 200) {
var json = JSON.parse(alfaRes.responseText); var json = JSON.parse(alfaRes.responseText);
alfaButton.href = json.url; alfaButton.href = json.url;
document.querySelector("#alfa-version").innerHTML = json.latestVersionCode; alfaVersion.innerHTML = json.latestVersionCode;
} else { } else {
alfaVersion.innerHTML = 'wersja nieznana';
console.log("Błąd podczas ładowania strony\n"); console.log("Błąd podczas ładowania strony\n");
} }
alfaButton.removeEventListener("click", disableClick); alfaButton.removeEventListener("click", disableClick);