From db522bf82cc0c783c9d58fb9d5161b59435a9e89 Mon Sep 17 00:00:00 2001 From: SpikeHD Date: Sat, 30 Apr 2022 01:56:00 -0700 Subject: [PATCH] update notification --- resources/index.html | 8 ++++++++ resources/js/helpers.js | 31 ++++++++++++++++++++++++++++ resources/style/index.css | 43 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 82 insertions(+) diff --git a/resources/index.html b/resources/index.html index 4855168..f59f5ea 100644 --- a/resources/index.html +++ b/resources/index.html @@ -248,5 +248,13 @@ + + +
+ + + A new update is available! Newest version: + +
diff --git a/resources/js/helpers.js b/resources/js/helpers.js index 1beba4a..f4b9139 100644 --- a/resources/js/helpers.js +++ b/resources/js/helpers.js @@ -57,6 +57,37 @@ async function proxyIsInstalled() { return false } +async function checkForUpdates() { + const url = 'https://api.github.com/repos/Grasscutters/GrassClipper/releases/latest' + + const { data } = await axios.get(url) + const latest = data.tag_name + + return latest +} + +async function displayUpdate(version) { + const latest = await checkForUpdates() + const versionDisplay = document.querySelector('#newestVersion') + const notif = document.querySelector('#downloadNotif') + + //if (latest === `v${NL_APPVERSION}`) return + + versionDisplay.innerText = latest + + notif.classList.add('displayed') + + setTimeout(() => { + notif.classList.remove('displayed') + }, 5000) +} + +async function openLatestDownload() { + const downloadLink = 'https://github.com/Grasscutters/GrassClipper/releases/latest/' + + Neutralino.os.open(downloadLink) +} + async function openGameFolder() { const config = await getCfg() const folder = config.gameexe.match(/.*\\/g, '')[0] diff --git a/resources/style/index.css b/resources/style/index.css index d66290f..ba41cd8 100644 --- a/resources/style/index.css +++ b/resources/style/index.css @@ -7,6 +7,10 @@ body { font-family: Arial, Helvetica, sans-serif; } +a { + color: #fff; +} + .darken { filter: brightness(0.6); } @@ -535,4 +539,43 @@ body { #serverInput img:hover { cursor: pointer; +} + +#downloadNotif { + z-index: 99; + position: absolute; + + color: #fff; + background: #141414; + border: 1px solid #ccc; + + padding: 1em; + top: 80%; + left: 110%; + width: 20%; + border-radius: 5px; + + text-align: center; + + transition: left 0.4s ease-in-out; +} + +#downloadNotif:hover { + cursor: pointer; + border-color: #fff; +} + +#downloadNotif img { + height: 20px; + vertical-align: middle; + margin-right: 4px; + filter: invert(100%) sepia(100%) saturate(0%) hue-rotate(16deg) brightness(103%) contrast(101%); +} + +#downloadNotif.displayed { + left: 70%; +} + +#newestVersion { + font-weight: bold; } \ No newline at end of file