Skip to content
This repository was archived by the owner on Jan 19, 2025. It is now read-only.

Commit c898cac

Browse files
committed
Automatic update checking and CSS adjustments
1 parent e5b20f5 commit c898cac

File tree

3 files changed

+129
-35
lines changed

3 files changed

+129
-35
lines changed

assets/css/openfusion.css

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@ body {
6565
right: 8px;
6666
}
6767

68+
#of-about-flash-div {
69+
position: fixed;
70+
bottom: 4px;
71+
right: 8px;
72+
}
73+
6874
#of-config-button-div {
6975
position: fixed;
7076
bottom: 4px;
@@ -91,6 +97,18 @@ body {
9197
background-repeat: repeat;
9298
}
9399

100+
.form-check-input {
101+
width: 25px;
102+
height: 25px;
103+
}
104+
105+
.form-check-label {
106+
height: 25px;
107+
margin-top: 5px;
108+
margin-left: 10px;
109+
font-size: 1rem;
110+
}
111+
94112
#of-aboutmodal > .modal-dialog > .modal-content {
95113
background-color: #093363;
96114
border-color: #6699ff;
@@ -192,3 +210,19 @@ button > i {
192210
background: #000;
193211
clear: both;
194212
}
213+
214+
@keyframes pulse {
215+
0% {
216+
opacity: 1;
217+
}
218+
50% {
219+
opacity: 0;
220+
}
221+
100% {
222+
opacity: 1;
223+
}
224+
}
225+
226+
.pulsing {
227+
animation: pulse 2s infinite;
228+
}

assets/js/server-selector.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,36 @@ function setAppVersionText() {
8080
$("#of-aboutversionnumber").text("Version " + getAppVersion());
8181
}
8282

83+
function checkForNewAppVersion() {
84+
$("#of-about-button").removeClass("pulsing");
85+
setAppVersionText();
86+
if (config["autoupdate-check"] === true) {
87+
$.getJSON(
88+
"https://api.github.com/repos/OpenFusionProject/OpenFusionClient/releases/latest",
89+
{},
90+
function (data) {
91+
$.each(data, function (index, element) {
92+
if (index === "tag_name" && element > getAppVersion()) {
93+
console.log("New version available: " + element);
94+
var downloadPage =
95+
"https://github.com/OpenFusionProject/OpenFusionClient/releases/latest";
96+
$("#of-aboutversionnumber").html(
97+
"Version " +
98+
getAppVersion() +
99+
`<br>A new version is available! ` +
100+
`Click <a href="#" onclick='remote.require("shell").openExternal("` +
101+
downloadPage +
102+
`");'>here</a> to download.`
103+
);
104+
$("#of-about-button").addClass("pulsing");
105+
return false; // break out of loop early
106+
}
107+
});
108+
}
109+
);
110+
}
111+
}
112+
83113
function validateServerSave(modalName) {
84114
// works everytime a key is entered into the server save form
85115
var descInput = document.getElementById(modalName + "server-descinput");
@@ -382,6 +412,7 @@ function loadConfig() {
382412
offlineRoot = config["offline-cache-location"] || offlineRootDefault;
383413
$("#editconfig-offlinecachelocation:text").val(offlineRoot);
384414

415+
checkForNewAppVersion();
385416
validateCacheLocation();
386417
}
387418

index.html

Lines changed: 64 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!DOCTYPE html>
1+
<!doctype html>
22
<html>
33
<head>
44
<meta charset="utf-8" />
@@ -490,40 +490,63 @@ <h4 class="modal-title">Edit Configuration</h4>
490490
</button>
491491
</div>
492492
<div class="modal-body">
493-
<form id="editconfig-form" class="needs-validation">
494-
<label for="editconfig-autoupdate"
495-
>Automatically update the client:</label
496-
><input
497-
class="form-control form-row w-75"
498-
type="checkbox"
499-
id="editconfig-autoupdate"
500-
/>
501-
<label for="editconfig-cacheswapping"
502-
>Swap game caches to avoid unnecessary
503-
downloads:</label
504-
><input
505-
class="form-control form-row w-75"
506-
type="checkbox"
507-
id="editconfig-cacheswapping"
508-
/>
509-
<label for="editconfig-enableofflinecache"
510-
>Use offline caches when they are
511-
available:</label
512-
><input
513-
class="form-control form-row w-75"
514-
type="checkbox"
515-
id="editconfig-enableofflinecache"
516-
/>
517-
<label for="editconfig-verifyofflinecache"
518-
>Verify offline caches every time they are
519-
loaded:</label
520-
><input
521-
class="form-control form-row w-75"
522-
type="checkbox"
523-
id="editconfig-verifyofflinecache"
524-
/>
493+
<form
494+
id="editconfig-form"
495+
class="needs-validation form-group"
496+
>
497+
<div class="form-check form-row">
498+
<input
499+
class="form-check-input"
500+
type="checkbox"
501+
id="editconfig-autoupdate"
502+
/>
503+
<label
504+
class="form-check-label"
505+
for="editconfig-autoupdate"
506+
>Automatically check for updates</label
507+
>
508+
</div>
509+
<div class="form-check form-row">
510+
<input
511+
class="form-check-input"
512+
type="checkbox"
513+
id="editconfig-cacheswapping"
514+
/>
515+
<label
516+
class="form-check-label"
517+
for="editconfig-cacheswapping"
518+
>Swap game caches to avoid unnecessary
519+
downloads</label
520+
>
521+
</div>
522+
<div class="form-check form-row">
523+
<input
524+
class="form-check-input"
525+
type="checkbox"
526+
id="editconfig-enableofflinecache"
527+
/>
528+
<label
529+
class="form-check-label"
530+
for="editconfig-enableofflinecache"
531+
>Use offline caches when they are
532+
available</label
533+
>
534+
</div>
535+
<div class="form-check form-row mb-3">
536+
<input
537+
class="form-check-input"
538+
type="checkbox"
539+
id="editconfig-verifyofflinecache"
540+
/>
541+
<label
542+
class="form-check-label"
543+
for="editconfig-verifyofflinecache"
544+
>Verify offline caches every time they
545+
are loaded</label
546+
>
547+
</div>
525548
<label for="editconfig-offlinecachelocation"
526-
>Select Offline Cache Location:</label
549+
><h5>Offline Cache Location:</h5></label
527550
>
528551
<div class="form-row">
529552
<input
@@ -534,8 +557,9 @@ <h4 class="modal-title">Edit Configuration</h4>
534557
/>
535558
<button
536559
type="button"
537-
class="btn btn-primary mb-2 ml-1"
560+
class="btn btn-primary ml-1"
538561
onclick="browseOfflineCache()"
562+
title="Browse"
539563
>
540564
<i class="fas fa-folder"></i>
541565
</button>
@@ -913,6 +937,11 @@ <h4 class="modal-title">Are you sure?</h4>
913937
<i class="fas fa-info-circle"></i>
914938
</button>
915939
</div>
940+
<div id="of-about-flash-div" style="z-index: -1">
941+
<button class="btn btn-warning mr-1" type="button">
942+
<i class="fas fa-info-circle"></i>
943+
</button>
944+
</div>
916945
</section>
917946
<section>
918947
<div id="client"></div>

0 commit comments

Comments
 (0)