-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVersionUtils.js
More file actions
90 lines (83 loc) · 2.81 KB
/
Copy pathVersionUtils.js
File metadata and controls
90 lines (83 loc) · 2.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
var configs = {
"manifests": {
"url": "https://raw.githubusercontent.com/NotToDisturb/VersionArchive/master/out/manifests.json",
"data": {}
},
"ue_versions": {
"url": "https://raw.githubusercontent.com/NotToDisturb/VersionUtils/master/versionutils/ue_versions.json",
"data": {}
}
};
function loaded(){
getNavbar();
getConfig(configs.manifests);
getConfig(configs.ue_versions);
getFooter();
}
function getConfig(config){
var xhr = new XMLHttpRequest();
xhr.open("GET", config.url);
xhr.onreadystatechange = function() {
if (xhr.readyState == 4 && xhr.status == 200) {
var configText = "";
configText = xhr.responseText;
config.data = JSON.parse(configText);
}
}
xhr.send();
}
function updateVersionQueries(){
branches = [];
if (document.getElementById("release-checkbox").checked){
branches.push("release");
}
if (document.getElementById("pbe-checkbox").checked){
branches.push("pbe");
}
version = document.getElementById("valorant-version-input").value;
document.getElementById("manifests-textarea").value = getManifests(version, branches);
document.getElementById("datamine-textarea").value = getUEVersion(version);
}
function getManifests(version, branches) {
var result = "";
versionData = configs.manifests.data;
for (var idx in versionData) {
if (versionData[idx].version.includes(version) && branches.includes(versionData[idx].branch)) {
if (result.length > 0){
result += ", ";
}
result += versionData[idx].manifest;
}
}
return result;
}
function getUEVersion(version) {
versionOrder = configs.ue_versions.data.order;
versionData = configs.ue_versions.data.data;
for (idx in versionOrder) {
ueVersion = versionData[versionOrder[idx]];
if (isVersionNewer(version, versionOrder[idx])){
return "Unreal Engine version: " + ueVersion.unreal_engine + "\nFModel version: " + ueVersion.fmodel;
}
}
}
function isVersionNewer(versionA, versionB) {
var splitVersionA = versionA.split(".");
var splitVersionB = versionB.split(".");
var minVersionLength = Math.min(splitVersionA.length, splitVersionB.length);
for (var idx = 0; idx < minVersionLength; idx++) {
if (splitVersionA[idx] == "") {
splitVersionA[idx] = "0";
}
if (splitVersionB[idx] == "") {
splitVersionB[idx] = "0";
}
if (parseInt(splitVersionA[idx]) > parseInt(splitVersionB[idx])) {
return true;
}
if (parseInt(splitVersionA[idx]) < parseInt(splitVersionB[idx])) {
return false;
}
}
return splitVersionA.length >= splitVersionB.length;
}