Skip to content

Commit

Permalink
Automatic update checking and CSS adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
CakeLancelot committed Oct 6, 2024
1 parent e5b20f5 commit c898cac
Show file tree
Hide file tree
Showing 3 changed files with 129 additions and 35 deletions.
34 changes: 34 additions & 0 deletions assets/css/openfusion.css
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ body {
right: 8px;
}

#of-about-flash-div {
position: fixed;
bottom: 4px;
right: 8px;
}

#of-config-button-div {
position: fixed;
bottom: 4px;
Expand All @@ -91,6 +97,18 @@ body {
background-repeat: repeat;
}

.form-check-input {
width: 25px;
height: 25px;
}

.form-check-label {
height: 25px;
margin-top: 5px;
margin-left: 10px;
font-size: 1rem;
}

#of-aboutmodal > .modal-dialog > .modal-content {
background-color: #093363;
border-color: #6699ff;
Expand Down Expand Up @@ -192,3 +210,19 @@ button > i {
background: #000;
clear: both;
}

@keyframes pulse {
0% {
opacity: 1;
}
50% {
opacity: 0;
}
100% {
opacity: 1;
}
}

.pulsing {
animation: pulse 2s infinite;
}
31 changes: 31 additions & 0 deletions assets/js/server-selector.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,36 @@ function setAppVersionText() {
$("#of-aboutversionnumber").text("Version " + getAppVersion());
}

function checkForNewAppVersion() {
$("#of-about-button").removeClass("pulsing");
setAppVersionText();
if (config["autoupdate-check"] === true) {
$.getJSON(
"https://api.github.com/repos/OpenFusionProject/OpenFusionClient/releases/latest",
{},
function (data) {
$.each(data, function (index, element) {
if (index === "tag_name" && element > getAppVersion()) {
console.log("New version available: " + element);
var downloadPage =
"https://github.com/OpenFusionProject/OpenFusionClient/releases/latest";
$("#of-aboutversionnumber").html(
"Version " +
getAppVersion() +
`<br>A new version is available! ` +
`Click <a href="#" onclick='remote.require("shell").openExternal("` +
downloadPage +
`");'>here</a> to download.`
);
$("#of-about-button").addClass("pulsing");
return false; // break out of loop early
}
});
}
);
}
}

function validateServerSave(modalName) {
// works everytime a key is entered into the server save form
var descInput = document.getElementById(modalName + "server-descinput");
Expand Down Expand Up @@ -382,6 +412,7 @@ function loadConfig() {
offlineRoot = config["offline-cache-location"] || offlineRootDefault;
$("#editconfig-offlinecachelocation:text").val(offlineRoot);

checkForNewAppVersion();
validateCacheLocation();
}

Expand Down
99 changes: 64 additions & 35 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
Expand Down Expand Up @@ -490,40 +490,63 @@ <h4 class="modal-title">Edit Configuration</h4>
</button>
</div>
<div class="modal-body">
<form id="editconfig-form" class="needs-validation">
<label for="editconfig-autoupdate"
>Automatically update the client:</label
><input
class="form-control form-row w-75"
type="checkbox"
id="editconfig-autoupdate"
/>
<label for="editconfig-cacheswapping"
>Swap game caches to avoid unnecessary
downloads:</label
><input
class="form-control form-row w-75"
type="checkbox"
id="editconfig-cacheswapping"
/>
<label for="editconfig-enableofflinecache"
>Use offline caches when they are
available:</label
><input
class="form-control form-row w-75"
type="checkbox"
id="editconfig-enableofflinecache"
/>
<label for="editconfig-verifyofflinecache"
>Verify offline caches every time they are
loaded:</label
><input
class="form-control form-row w-75"
type="checkbox"
id="editconfig-verifyofflinecache"
/>
<form
id="editconfig-form"
class="needs-validation form-group"
>
<div class="form-check form-row">
<input
class="form-check-input"
type="checkbox"
id="editconfig-autoupdate"
/>
<label
class="form-check-label"
for="editconfig-autoupdate"
>Automatically check for updates</label
>
</div>
<div class="form-check form-row">
<input
class="form-check-input"
type="checkbox"
id="editconfig-cacheswapping"
/>
<label
class="form-check-label"
for="editconfig-cacheswapping"
>Swap game caches to avoid unnecessary
downloads</label
>
</div>
<div class="form-check form-row">
<input
class="form-check-input"
type="checkbox"
id="editconfig-enableofflinecache"
/>
<label
class="form-check-label"
for="editconfig-enableofflinecache"
>Use offline caches when they are
available</label
>
</div>
<div class="form-check form-row mb-3">
<input
class="form-check-input"
type="checkbox"
id="editconfig-verifyofflinecache"
/>
<label
class="form-check-label"
for="editconfig-verifyofflinecache"
>Verify offline caches every time they
are loaded</label
>
</div>
<label for="editconfig-offlinecachelocation"
>Select Offline Cache Location:</label
><h5>Offline Cache Location:</h5></label
>
<div class="form-row">
<input
Expand All @@ -534,8 +557,9 @@ <h4 class="modal-title">Edit Configuration</h4>
/>
<button
type="button"
class="btn btn-primary mb-2 ml-1"
class="btn btn-primary ml-1"
onclick="browseOfflineCache()"
title="Browse"
>
<i class="fas fa-folder"></i>
</button>
Expand Down Expand Up @@ -913,6 +937,11 @@ <h4 class="modal-title">Are you sure?</h4>
<i class="fas fa-info-circle"></i>
</button>
</div>
<div id="of-about-flash-div" style="z-index: -1">
<button class="btn btn-warning mr-1" type="button">
<i class="fas fa-info-circle"></i>
</button>
</div>
</section>
<section>
<div id="client"></div>
Expand Down

0 comments on commit c898cac

Please sign in to comment.