Skip to content

Commit

Permalink
Fix version check
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinverschoor committed Mar 26, 2024
1 parent 4aee5e1 commit 16459dd
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion view/adminhtml/web/js/versioncheck.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,29 @@
require([
'jquery'
], function (jQuery) {

function compareversion(version1,version2){
var result=false;

if(typeof version1 !=='object'){ version1=version1.toString().split('.'); }
if(typeof version2 !=='object'){ version2=version2.toString().split('.'); }

for(var i=0;i<(Math.max(version1.length,version2.length));i++){

if(version1[i]==undefined){ version1[i]=0; }
if(version2[i]==undefined){ version2[i]=0; }

if(Number(version1[i])<Number(version2[i])){
result=true;
break;
}
if(version1[i]!=version2[i]){
break;
}
}
return(result);
}

jQuery('#paynl_version_check_button').click(function () {
new Ajax.Request(jQuery('#ajaxurl').text(), {
loaderArea: false,
Expand All @@ -19,7 +42,7 @@ require([
var newest_version = json.version.substring(1);
var current_version = jQuery('#current_version').text();

if (newest_version > current_version) {
if (compareversion(current_version, newest_version)) {
result = 'There is a new version available (' + json.version + ')'
} else {
jQuery('#paynl_version_check_button').hide();
Expand Down

0 comments on commit 16459dd

Please sign in to comment.