Switch to xmlhttprequest
This commit is contained in:
parent
8673aea296
commit
d458492c81
2 changed files with 30 additions and 14 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
.idea/
|
43
index.html
43
index.html
|
@ -114,27 +114,42 @@
|
||||||
</footer>
|
</footer>
|
||||||
</section>
|
</section>
|
||||||
<script>
|
<script>
|
||||||
const disableClick = e => e.preventDefault();
|
var disableClick = function(e) {e.preventDefault()};
|
||||||
|
|
||||||
const betaButton = document.querySelector("#beta-button");
|
var betaButton = document.querySelector("#beta-button");
|
||||||
betaButton.addEventListener("click", disableClick);
|
betaButton.addEventListener("click", disableClick);
|
||||||
fetch("https://api.github.com/repos/wulkanowy/wulkanowy/releases/latest")
|
|
||||||
.then(res => { return res.json() })
|
var betaRes = new XMLHttpRequest();
|
||||||
.then(json => {
|
betaRes.open('GET', 'https://api.github.com/repos/wulkanowy/wulkanowy/releases/latest', true);
|
||||||
betaButton.removeEventListener("click", disableClick);
|
betaRes.onreadystatechange = function () {
|
||||||
|
if(betaRes.status === 200) {
|
||||||
|
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;
|
document.querySelector("#beta-version").innerHTML = json.name;
|
||||||
});
|
} else {
|
||||||
|
console.log("Błąd podczas ładowania strony\n");
|
||||||
|
}
|
||||||
|
betaButton.removeEventListener("click", disableClick);
|
||||||
|
};
|
||||||
|
betaRes.send(null);
|
||||||
|
|
||||||
const alfaButton = document.querySelector("#alfa-button")
|
var alfaButton = document.querySelector("#alfa-button");
|
||||||
alfaButton.addEventListener("click", disableClick);
|
alfaButton.addEventListener("click", disableClick);
|
||||||
fetch("https://bitrise-redirector.herokuapp.com/v0.1/apps/daeff1893f3c8128/builds/master/artifacts/app-debug-bitrise-signed.apk/info")
|
|
||||||
.then(res => { return res.json() })
|
|
||||||
.then(json => {
|
var alfaRes = new XMLHttpRequest();
|
||||||
alfaButton.removeEventListener("click", disableClick);
|
alfaRes.open('GET', 'https://bitrise-redirector.herokuapp.com/v0.1/apps/daeff1893f3c8128/builds/master/artifacts/app-debug-bitrise-signed.apk/info', true);
|
||||||
alfaButton.href = json.url;
|
alfaRes.onreadystatechange = function () {
|
||||||
|
if(alfaRes.status === 200) {
|
||||||
|
var json = JSON.parse(alfaRes.responseText);
|
||||||
|
alfaButton.href = json.assets[0].browser_download_url;
|
||||||
document.querySelector("#alfa-version").innerHTML = json.latestVersionCode;
|
document.querySelector("#alfa-version").innerHTML = json.latestVersionCode;
|
||||||
});
|
} else {
|
||||||
|
console.log("Błąd podczas ładowania strony\n");
|
||||||
|
}
|
||||||
|
alfaButton.removeEventListener("click", disableClick);
|
||||||
|
};
|
||||||
|
alfaRes.send(null);
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
Loading…
Reference in a new issue