mirror of
https://github.com/krateng/maloja.git
synced 2023-08-10 21:12:55 +03:00
Version now compares to latest pypi release
This commit is contained in:
parent
905c6e8e02
commit
8cf39adc91
@ -7,7 +7,7 @@ author = {
|
|||||||
"email":"maloja@krateng.dev",
|
"email":"maloja@krateng.dev",
|
||||||
"github": "krateng"
|
"github": "krateng"
|
||||||
}
|
}
|
||||||
version = 2,1
|
version = 2,1,1
|
||||||
versionstr = ".".join(str(n) for n in version)
|
versionstr = ".".join(str(n) for n in version)
|
||||||
|
|
||||||
|
|
||||||
|
@ -10,9 +10,20 @@
|
|||||||
<pyhp include="common/header.html" />
|
<pyhp include="common/header.html" />
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
neo.xhttprequest("https://maloja.krateng.ch/api/serverinfo",{},"GET",json=true).then((response)=>{
|
|
||||||
|
function versioncompare(a,b) {
|
||||||
|
for (var pos=0;pos<3;pos++) {
|
||||||
|
var v1 = parseInt(a[pos]) || 0;
|
||||||
|
var v2 = parseInt(b[pos]) || 0;
|
||||||
|
if (v1 > v2) { return 1;}
|
||||||
|
if (v1 < v2) { return -1;}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
neo.xhttprequest("https://pypi.org/pypi/malojaserver/json",{},"GET",json=true).then((response)=>{
|
||||||
result = JSON.parse(response.responseText);
|
result = JSON.parse(response.responseText);
|
||||||
latestvers = result.version;
|
latestvers = result.info.version.split(".");
|
||||||
|
|
||||||
neo.xhttprequest("/api/serverinfo",{},"GET",json=true).then((response)=>{
|
neo.xhttprequest("/api/serverinfo",{},"GET",json=true).then((response)=>{
|
||||||
|
|
||||||
@ -22,7 +33,7 @@
|
|||||||
document.getElementById("latestversion").innerHTML = latestvers.join(".");
|
document.getElementById("latestversion").innerHTML = latestvers.join(".");
|
||||||
document.getElementById("currentversion").innerHTML = thisvers.join(".");
|
document.getElementById("currentversion").innerHTML = thisvers.join(".");
|
||||||
|
|
||||||
if (latestvers <= thisvers) {
|
if (versioncompare(latestvers,thisvers) <= 0) {
|
||||||
document.getElementById("currentversion").style.color = "green";
|
document.getElementById("currentversion").style.color = "green";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
Loading…
Reference in New Issue
Block a user