-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathheader.html
75 lines (66 loc) · 2.71 KB
/
header.html
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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jMonkeyEngine Javadoc</title>
<link rel="stylesheet" href="style.css">
<script>
function setLabels(latestVersion){
const cnt=document.querySelector("section");
const ps=cnt.querySelectorAll("p");
const createLabel=function(cnt,title,classes){
let label=document.createElement("span");
label.classList.add("label");
label.innerHTML=title;
if(classes){
for(let i in classes){
label.classList.add(classes[i]);
}
}
let labels=cnt.querySelector("span.labels");
if(!labels){
labels=document.createElement("span");
labels.classList.add("labels");
cnt.append(labels);
}
labels.append(label);
}
for(let i=0;i<ps.length;i++){
const a=ps[i].querySelector("a");
const tag=a.innerHTML;
// We add a "latest" label and move to the top if it is the latest version
if(tag===latestVersion){
cnt.removeChild(ps[i]);
cnt.prepend(ps[i]);
ps[i].classList.add("latest");
createLabel(ps[i],"Latest release",["latest"]);
}
// We add labels based on the -suffix
if(tag.indexOf("-alpha")!=-1){
createLabel(ps[i],"Alpha",["alpha"]);
}else if(tag.indexOf("-stable")!=-1){
createLabel(ps[i],"Stable",["stable"]);
}
}
}
// Get the last release and load the labels
window.onload=function(){
const latestReleaseUrl="https://api.github.com/repos/jMonkeyEngine/jmonkeyengine/releases/latest";
const req = new XMLHttpRequest();
req.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
const json=JSON.parse(this.responseText);
console.log("Detect latest version",json["tag_name"]);
setLabels(json["tag_name"]);
}
};
req.open("GET", latestReleaseUrl, true);
req.send();
};
</script>
</head>
<body>
<header>
<h1>jMonkeyEngine</h1><h2>javadoc</h2>
</header>
<section>