From f46fc7a22da67cab59d575bca909b188a526f571 Mon Sep 17 00:00:00 2001 From: Bui Date: Wed, 10 Oct 2018 21:00:50 +0100 Subject: [PATCH 1/2] add version information to corner of screen --- .gitignore | 3 ++- public/index.html | 1 + public/src/css/main.css | 17 +++++++++++++++++ public/src/js/loader.js | 17 +++++++++++++++++ 4 files changed, 37 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 69906bf..6c5ccf6 100644 --- a/.gitignore +++ b/.gitignore @@ -43,4 +43,5 @@ Temporary Items .apdisk public/songs public/api -taiko.db \ No newline at end of file +taiko.db +public/version.json \ No newline at end of file diff --git a/public/index.html b/public/index.html index a9062d4..b6d0023 100644 --- a/public/index.html +++ b/public/index.html @@ -56,6 +56,7 @@
+
diff --git a/public/src/css/main.css b/public/src/css/main.css index faeaba9..f2c6be7 100644 --- a/public/src/css/main.css +++ b/public/src/css/main.css @@ -224,3 +224,20 @@ kbd{ height: 12.5vmin; opacity: 0.5; } + +#version { + position: fixed; + z-index: 1000; + font-size: 2vh; + position: absolute; + bottom: 1vh; + right: 1vh; + opacity: 0.7; + font-family: TnT; +} + +#version a { + color: inherit; + text-decoration: none; + cursor: default; +} \ No newline at end of file diff --git a/public/src/js/loader.js b/public/src/js/loader.js index 62dce66..a50d510 100644 --- a/public/src/js/loader.js +++ b/public/src/js/loader.js @@ -13,6 +13,23 @@ class Loader{ this.screen.innerHTML = page this.loaderPercentage = document.querySelector("#loader .percentage") this.loaderProgress = document.querySelector("#loader .progress") + + var versionTag = document.getElementById("version") + this.ajax("/version.json").then(function(resp){ + var versionLink = document.createElement("a") + versionLink.setAttribute("target", "_blank") + + try { + var parsed = JSON.parse(resp) + versionLink.setAttribute("href", "https://github.com/bui/taiko-web/commit/" + parsed.commit) + versionLink.appendChild(document.createTextNode("taiko-web ver." + parsed.version + " (" + parsed.commit_short + ")")) + } catch(SyntaxError) { + versionLink.setAttribute("href", "https://github.com/bui/taiko-web") + versionLink.appendChild(document.createTextNode("taiko-web (unknown version)")) + } finally { + versionTag.appendChild(versionLink) + } + }) snd.buffer = new SoundBuffer() snd.musicGain = snd.buffer.createGain() From 3e32dbdb57fcc8f78cc3806801f4b807ca7b6a86 Mon Sep 17 00:00:00 2001 From: Bui Date: Wed, 10 Oct 2018 21:07:27 +0100 Subject: [PATCH 2/2] change exception name --- public/src/js/loader.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/src/js/loader.js b/public/src/js/loader.js index a50d510..68362e5 100644 --- a/public/src/js/loader.js +++ b/public/src/js/loader.js @@ -23,7 +23,7 @@ class Loader{ var parsed = JSON.parse(resp) versionLink.setAttribute("href", "https://github.com/bui/taiko-web/commit/" + parsed.commit) versionLink.appendChild(document.createTextNode("taiko-web ver." + parsed.version + " (" + parsed.commit_short + ")")) - } catch(SyntaxError) { + } catch(e) { versionLink.setAttribute("href", "https://github.com/bui/taiko-web") versionLink.appendChild(document.createTextNode("taiko-web (unknown version)")) } finally {