Skip to content

Commit

Permalink
fixes #155
Browse files Browse the repository at this point in the history
  • Loading branch information
KelvinTegelaar committed Oct 29, 2021
1 parent 6208f3e commit d0507d9
Showing 1 changed file with 49 additions and 43 deletions.
92 changes: 49 additions & 43 deletions js/version-checker.js
Original file line number Diff line number Diff line change
@@ -1,49 +1,55 @@
$(function () {
var RemoteURLCIPP = 'https://raw.githubusercontent.com/KelvinTegelaar/CIPP/master/version_latest.txt';
var LocalURLCIPP = '/version_latest.txt';
var RemoteURLCIPPAPI = 'https://raw.githubusercontent.com/KelvinTegelaar/CIPP-API/master/version_latest.txt';
var LocalURLCIPPAPI = '/api/GetVersion';
let searchParams = new URLSearchParams(window.location.search)
var Page = '';
if (searchParams.has('page')) {
Page = searchParams.get('page')
} else {
var RemoteURLCIPP = 'https://raw.githubusercontent.com/KelvinTegelaar/CIPP/master/version_latest.txt';
var LocalURLCIPP = '/version_latest.txt';
var RemoteURLCIPPAPI = 'https://raw.githubusercontent.com/KelvinTegelaar/CIPP-API/master/version_latest.txt';
var LocalURLCIPPAPI = '/api/GetVersion';

$.when(
$.ajax(RemoteURLCIPP),
$.ajax(LocalURLCIPP),
$.ajax(RemoteURLCIPPAPI),
$.ajax(LocalURLCIPPAPI)
).then(
(data1, data2, data3, data4) => {
RemoteCIPPVersionRaw = data1[0];
LocalCIPPVersionRaw = data2[0];
RemoteCIPPAPIVersionRaw = data3[0];
LocalCIPPAPIVersionRaw = data4[0];
},
err => {
console.log(err);
}
).then(() => {
var RemoteCIPPVersion = RemoteCIPPVersionRaw.replace(/(\r\n|\n|\r)/gm, "");
var LocalCIPPVersion = LocalCIPPVersionRaw.replace(/(\r\n|\n|\r)/gm, "");
var RemoteCIPPAPIVersion = RemoteCIPPAPIVersionRaw.replace(/(\r\n|\n|\r)/gm, "");
var LocalCIPPAPIVersion = LocalCIPPAPIVersionRaw.replace(/(\r\n|\n|\r)/gm, "");
$.when(
$.ajax(RemoteURLCIPP),
$.ajax(LocalURLCIPP),
$.ajax(RemoteURLCIPPAPI),
$.ajax(LocalURLCIPPAPI)
).then(
(data1, data2, data3, data4) => {
RemoteCIPPVersionRaw = data1[0];
LocalCIPPVersionRaw = data2[0];
RemoteCIPPAPIVersionRaw = data3[0];
LocalCIPPAPIVersionRaw = data4[0];
},
err => {
console.log(err);
}
).then(() => {
var RemoteCIPPVersion = RemoteCIPPVersionRaw.replace(/(\r\n|\n|\r)/gm, "");
var LocalCIPPVersion = LocalCIPPVersionRaw.replace(/(\r\n|\n|\r)/gm, "");
var RemoteCIPPAPIVersion = RemoteCIPPAPIVersionRaw.replace(/(\r\n|\n|\r)/gm, "");
var LocalCIPPAPIVersion = LocalCIPPAPIVersionRaw.replace(/(\r\n|\n|\r)/gm, "");

document.getElementById('dashversionlocalcipp').innerHTML = LocalCIPPVersion;
document.getElementById('dashversionremotecipp').innerHTML = RemoteCIPPVersion;
document.getElementById('dashversionlocalcippapi').innerHTML = LocalCIPPAPIVersion;
document.getElementById('dashversionremotecippapi').innerHTML = RemoteCIPPAPIVersion;
document.getElementById('dashversionlocalcipp').innerHTML = LocalCIPPVersion;
document.getElementById('dashversionremotecipp').innerHTML = RemoteCIPPVersion;
document.getElementById('dashversionlocalcippapi').innerHTML = LocalCIPPAPIVersion;
document.getElementById('dashversionremotecippapi').innerHTML = RemoteCIPPAPIVersion;

if (RemoteCIPPVersion == LocalCIPPVersion) {
console.log("CIPP Local Version is same as Remote");
} else {
console.log("CIPP Remote and Local Versions are Different")
document.getElementById('versionalertcipp').innerHTML = '<div><strong>WARNING:&nbsp;&nbsp;</strong> The version of CIPP you are running is out of date. Your version is ' + LocalCIPPVersion + ' and the latest version is ' + RemoteCIPPVersion + '. Please Update your CIPP Repository.</div>';
document.getElementById('versionalertcipp').classList.remove("d-none");
}
if (RemoteCIPPVersion == LocalCIPPVersion) {
console.log("CIPP Local Version is same as Remote");
} else {
console.log("CIPP Remote and Local Versions are Different")
document.getElementById('versionalertcipp').innerHTML = '<div><strong>WARNING:&nbsp;&nbsp;</strong> The version of CIPP you are running is out of date. Your version is ' + LocalCIPPVersion + ' and the latest version is ' + RemoteCIPPVersion + '. Please Update your CIPP Repository.</div>';
document.getElementById('versionalertcipp').classList.remove("d-none");
}

if (RemoteCIPPAPIVersion == LocalCIPPAPIVersion) {
console.log("CIPPAPI Local Version is same as Remote");
} else {
console.log("CIPPAPI Remote and Local Versions are Different")
document.getElementById('versionalertcippapi').innerHTML = '<div><strong>WARNING:&nbsp;&nbsp;</strong> The version of CIPP-API you are running is out of date. Your version is ' + LocalCIPPAPIVersion + ' and the latest version is ' + RemoteCIPPAPIVersion + '. Please Update your CIPP-API Repository.</div>';
document.getElementById('versionalertcippapi').classList.remove("d-none");
}
});
if (RemoteCIPPAPIVersion == LocalCIPPAPIVersion) {
console.log("CIPPAPI Local Version is same as Remote");
} else {
console.log("CIPPAPI Remote and Local Versions are Different")
document.getElementById('versionalertcippapi').innerHTML = '<div><strong>WARNING:&nbsp;&nbsp;</strong> The version of CIPP-API you are running is out of date. Your version is ' + LocalCIPPAPIVersion + ' and the latest version is ' + RemoteCIPPAPIVersion + '. Please Update your CIPP-API Repository.</div>';
document.getElementById('versionalertcippapi').classList.remove("d-none");
}
});
}
});

0 comments on commit d0507d9

Please sign in to comment.