Skip to content

Commit

Permalink
Fix banner bug
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelGoerentz committed Aug 15, 2024
1 parent 770af8a commit e1d7b74
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 12 deletions.
2 changes: 1 addition & 1 deletion html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<body onload="javascript: PageReady();">

<div class="banner">
Neue Version verfügbar! Klicken Sie <a href="https://github.com/marcelGoerentz/Threadfin/releases/latest">hier</a>, um sie herunterzuladen.
New Version available! Click <a href="https://github.com/marcelGoerentz/Threadfin/releases/latest">here</a> to download.
</div>

<div id="loading" class="modal fade">
Expand Down
2 changes: 1 addition & 1 deletion src/webserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -1188,7 +1188,7 @@ func setDefaultResponseData(response ResponseStruct, data bool) (defaults Respon
switch System.Branch {

case "master":
defaults.ClientInfo.Version =System.Version
defaults.ClientInfo.Version = System.Version

default:
defaults.ClientInfo.Version = fmt.Sprintf("%s (%s)", System.Version, System.Build)
Expand Down
4 changes: 2 additions & 2 deletions threadfin.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ var GitHub = GitHubStruct{Branch: "Main", User: "marcelGoerentz", Repo: "Threadf
const Name = "Threadfin"

// Version : Version, die Build Nummer wird in der main func geparst.
const Version = "1.2.4"
const Version = "1.2.5"

// DBVersion : Datanbank Version
const DBVersion = "0.5.0"

// APIVersion : API Version
const APIVersion = "1.2.4"
const APIVersion = "1.2.5"

var homeDirectory = fmt.Sprintf("%s%s.%s%s", src.GetUserHomeDirectory(), string(os.PathSeparator), strings.ToLower(Name), string(os.PathSeparator))
var samplePath = fmt.Sprintf("%spath%sto%sthreadfin%s", string(os.PathSeparator), string(os.PathSeparator), string(os.PathSeparator), string(os.PathSeparator))
Expand Down
29 changes: 21 additions & 8 deletions ts/banner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,28 @@ async function getNewestReleaseFromGithub() {
}));
// Get tag name
var release_tag = releases[0]["tag_name"];
const regex = /[^\d]/gi;
// Create Number from tag name
const latest_version = Number(release_tag.replace(regex, ''));
const version_elemnt = document.getElementById('version') as HTMLInputElement;
const current_version = Number(version_elemnt.value.replace(regex, ''));
if (latest_version > current_version) {
bannerElement.style.display = 'block'; // Show Banner if newer version is available
const split = release_tag.split(".");
const release_major_version = split[0][1]
const release_minor_version = split[1]
const release_build_version = split[2]
const release_version = [release_major_version, release_minor_version, release_build_version]
let current_version = []

if (SERVER) {
var current_version_string = SERVER["clientInfo"]["version"];
current_version.push(current_version_string.split(".")[0]);
current_version.push(current_version_string.split(".")[1][0]);
current_version.push(current_version_string.split("(")[1][0]);
}
for (let i = 0; i < 3; i++) {
if (release_version[i] > current_version[i]) {
bannerElement.innerHTML = 'New Version available! Click <a href="https://github.com/marcelGoerentz/Threadfin/releases/latest">here</a> to download.';
bannerElement.style.display = 'block'; // Show Banner if newer version is available
break
} else if (release_version[i] < current_version[i]) {
break
}
}

} else {
console.log('Error fetching releases or no releases found.');
}
Expand Down

0 comments on commit e1d7b74

Please sign in to comment.