Add versionCompare function for upgrades
This commit is contained in:
parent
71f0b33bf1
commit
e340ad8ecf
|
|
@ -1 +1 @@
|
||||||
1.0.7
|
1.0.8
|
||||||
|
|
|
||||||
|
|
@ -439,7 +439,8 @@ function checkVersion(branch) {
|
||||||
} else {
|
} else {
|
||||||
dataFloat = data.split(",")[1];
|
dataFloat = data.split(",")[1];
|
||||||
}
|
}
|
||||||
if (dataFloat > version) {
|
var compare = versionCompare(dataFloat, version);
|
||||||
|
if (comare == 1) {
|
||||||
document.getElementById('curver').innerHTML = version;
|
document.getElementById('curver').innerHTML = version;
|
||||||
document.getElementById('newver').innerHTML = dataFloat;
|
document.getElementById('newver').innerHTML = dataFloat;
|
||||||
$( "#version_div" ).removeClass("hide_update");
|
$( "#version_div" ).removeClass("hide_update");
|
||||||
|
|
@ -460,7 +461,8 @@ function checkVersionSettings(branch) {
|
||||||
} else {
|
} else {
|
||||||
dataFloat = data.split(",")[1];
|
dataFloat = data.split(",")[1];
|
||||||
}
|
}
|
||||||
if (dataFloat > version) {
|
var compare = versionCompare(dataFloat, version);
|
||||||
|
if (compare == 1) {
|
||||||
$( "#updateView_available" ).removeClass("hide_update");
|
$( "#updateView_available" ).removeClass("hide_update");
|
||||||
$( "#updateView_available" ).addClass("show_update");
|
$( "#updateView_available" ).addClass("show_update");
|
||||||
document.getElementById('curver_settings').innerHTML = version;
|
document.getElementById('curver_settings').innerHTML = version;
|
||||||
|
|
@ -473,3 +475,27 @@ function checkVersionSettings(branch) {
|
||||||
async:true
|
async:true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function versionCompare(a, b) {
|
||||||
|
if (a === b) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
var a_components = a.split(".");
|
||||||
|
var b_components = b.split(".");
|
||||||
|
var len = Math.min(a_components.length, b_components.length);
|
||||||
|
for (var i = 0; i < len; i++) {
|
||||||
|
if (parseInt(a_components[i]) > parseInt(b_components[i])) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (parseInt(a_components[i]) < parseInt(b_components[i])) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (a_components.length > b_components.length) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (a_components.length < b_components.length) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue