diff --git a/templates/index.phtml b/templates/index.phtml index 6709d85..1b3fc0f 100644 --- a/templates/index.phtml +++ b/templates/index.phtml @@ -275,7 +275,7 @@ $.getJSON("index.php", {'op':'version_info'}, function(data) { - if (data.latest_version>) { + if (isNewer('', data.latest_version)) { $("#version_info").append('Version '+data.latest_version+' is available for download.'); } else { $("#version_info").append('You have the latest version.'); @@ -285,6 +285,16 @@ ); } + function parseVersion(version) { + return (version + '.0.0' ).split('.').slice(0, 3).map(x => parseInt(x, 10)); + } + + function isNewer(oldV, newV) { + var oldP = parseVersion(oldV); + var newP = parseVersion(newV); + return newP[0] > oldP[0] || newP[1] > oldP[1] || newP[2] > oldP[2]; + } + function clearFiles() { $.getJSON("index.php", {'op':'clear_files'},