-
Notifications
You must be signed in to change notification settings - Fork 0
/
homepage.js
37 lines (31 loc) · 1.18 KB
/
homepage.js
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
var pbList = document.getElementsByClassName("projectBox")
s = "10px auto "
for (var i = pbList.length - 1; i >= 0; i--) {
s = s + "10px auto "
}
document.body.style.gridTemplateRows = s;
// at 600 px wide it starts to look weird: you should switch to mobile layout
// To switch, take the p and h1 out of the div, and style the p with grid-column: 1/3;
for (var i = pbList.length - 1; i >= 0; i--) {
pbList[i].style.gridRowStart = 2*(i+2);
pbList[i].style.gridRowEnd = 2*(i+2);
pbInnerDiv = apnd("div",pbList[i])
moveNode(pbList[i].querySelector("h1"),pbInnerDiv)
moveNode(pbList[i].querySelector("p"),pbInnerDiv)
// still need to move and format the link
// alert(i)
}
function apnd(nodeType,appendTo) {
var node = document.createElement(nodeType);
// node.id = nodeId; // pass nodeId to re-enable
appendTo.appendChild(node);
return node
}
function moveNode(node,newContainer) {
newContainer.appendChild(node.cloneNode(true));
node.remove();
}
// the js ultimately needs to:
// - wrap h1 and p in each projectbox in a div (really just format the box for mobile/desktop)
// - assign each projectbox a row in the grid
// - dynamically update the number of rows the grid has