-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscript.js
More file actions
42 lines (39 loc) · 1.49 KB
/
script.js
File metadata and controls
42 lines (39 loc) · 1.49 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
function generate(){
let issueContainer = document.getElementById("issueContainer");
fetch("./issues.json")
.then(res=>res.json()
).then(data=>{
// console.log(data);
for(let i=data.length-1;i>=0;i--){
// console.log(data);
let maxWidth = 700;
let link = document.createElement("a");
link.href = data[i].link;
link.className = "containerLink";
let title = document.createElement("h1");
title.innerHTML = data[i].title;
title.className = "postTitle";
let image = document.createElement("img");
image.src = data[i].image;
image.className = "postImage";
let scale = maxWidth/image.width
image.height = image.height * scale;
image.width = image.width * scale;
let body = document.createElement("p");
body.innerHTML = data[i].body;
body.className = "postBody";
let container = document.createElement("div");
container.className = "postContainer";
container.style.maxWidth = maxWidth+"px";
// console.log(image.width);
container.appendChild(title);
container.appendChild(image);
container.appendChild(body);
//link.appendChild(container);
issueContainer.appendChild(container);
}
})
}
window.addEventListener("load",(e)=>{
generate();
})