aboutsummaryrefslogtreecommitdiff
path: root/src/app
diff options
context:
space:
mode:
Diffstat (limited to 'src/app')
-rw-r--r--src/app/index.html1
-rw-r--r--src/app/js/browser.js12
-rw-r--r--src/app/js/misc.js44
3 files changed, 48 insertions, 9 deletions
diff --git a/src/app/index.html b/src/app/index.html
index 9a571f0..d9e8e14 100644
--- a/src/app/index.html
+++ b/src/app/index.html
@@ -259,6 +259,7 @@
<script src="lang.js"></script>
<script src="main.js"></script>
+ <script src="js/misc.js"></script>
<script src="js/mods.js"></script>
<script src="js/toast.js"></script>
<script src="js/browser.js"></script>
diff --git a/src/app/js/browser.js b/src/app/js/browser.js
index cfd0c03..fcb79a2 100644
--- a/src/app/js/browser.js
+++ b/src/app/js/browser.js
@@ -328,12 +328,8 @@ function BrowserEl(properties) {
if (normalized_mods.includes(normalize(properties.title))) {
installstr = lang("gui.browser.reinstall");
- for (let i = 0; i < modsobj.all.length; i++) {
- if (normalize(modsobj.all[i].Name) == normalize(properties.title)
- && "v" + modsobj.all[i].Version != properties.version) {
-
- installstr = lang("gui.browser.update");
- }
+ if (version.is_newer(properties.version, modsobj.all[i].Version)) {
+ installstr = lang("gui.browser.update");
}
} else {
for (let i = 0; i < modsobj.all.length; i++) {
@@ -347,9 +343,7 @@ function BrowserEl(properties) {
if (title.includes(folder) || title.includes(manifestname)) {
installstr = lang("gui.browser.reinstall");
- if (folder == title
- && "v" + modsobj.all[i].Version != properties.version) {
-
+ if (version.is_newer(properties.version, modsobj.all[i].Version)) {
installstr = lang("gui.browser.update");
}
}
diff --git a/src/app/js/misc.js b/src/app/js/misc.js
new file mode 100644
index 0000000..b35f239
--- /dev/null
+++ b/src/app/js/misc.js
@@ -0,0 +1,44 @@
+version = {
+ is_newer: (version1, version2) => {
+ version1 = version.format(version1, true).split(".");
+ version2 = version.format(version2, true).split(".");
+
+ for (let i = 0; i < version1.length; i++) {
+
+
+ let nums = [
+ parseInt(version1[i]) || 0,
+ parseInt(version2[i]) || 0
+ ];
+ if (nums[0] > nums[1]) {
+ return true;
+ } else if (nums[0] < nums[1]) {
+ return false;
+ }
+ }
+
+ return false;
+ },
+ format: (version_number, no_leading_v) => {
+ version_number = version_number.trim();
+
+ if (no_leading_v) {
+ if (version_number[0] == "v") {
+ return version_number.slice(1, version_number.length);
+ }
+
+ return version_number;
+ if (no_leading_v) {
+ return version_number
+ }
+
+ return "v" + version_number;
+ } else {
+ if (version_number[0] != "v") {
+ return "v" + version_number;
+ }
+ }
+
+ return version_number;
+ }
+}