Skip to content
This repository has been archived by the owner on Jul 5, 2022. It is now read-only.

Commit

Permalink
update notification
Browse files Browse the repository at this point in the history
  • Loading branch information
SpikeHD committed Apr 30, 2022
1 parent 364b6c6 commit db522bf
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 0 deletions.
8 changes: 8 additions & 0 deletions resources/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -248,5 +248,13 @@
</div>
</div>
</div>

<!-- Download notification -->
<div id="downloadNotif" onclick="openLatestDownload()">
<img src="icons/alert.svg" />
<span id="updateNotifText">
A new update is available! Newest version:
</span><span id="newestVersion"></span>
</div>
</body>
</html>
31 changes: 31 additions & 0 deletions resources/js/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
43 changes: 43 additions & 0 deletions resources/style/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ body {
font-family: Arial, Helvetica, sans-serif;
}

a {
color: #fff;
}

.darken {
filter: brightness(0.6);
}
Expand Down Expand Up @@ -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;
}

0 comments on commit db522bf

Please sign in to comment.