-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathordered.js
More file actions
67 lines (56 loc) · 1.64 KB
/
Copy pathordered.js
File metadata and controls
67 lines (56 loc) · 1.64 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
var container = document.getElementById("orderItems");
class Order {
constructor(name, cost, size) {
this.name = name;
this.cost = cost;
this.size = size;
}
}
var orders = [ new Order("Cheese Pizza", 12.25, "Large"),
new Order("Pepperoni Pizza", 11.35, "Medium"),
new Order("Hawaiian Pizza", 12.95, "Medium")
];
function createText(text, bold, fontSize) {
var newText = document.createElement("div");
newText.textContent = text;
newText.style.fontSize = fontSize;
newText.style.margin = "0 5px 0 5px";
newText.style.fontWeight = "5s00";
if (bold) {
newText.style.fontWeight = "Bold";
}
return newText;
}
function createItem(order) {
var div = document.createElement("div");
div.style.display = "grid";
div.style.gridTemplateColumns = "12px 5fr 1fr";
div.style.gridTemplateRows = "1fr 10px";
div.style.margin = "5px 0 5px 0";
var x = createText("X", false, "1.1vw");
x.style.color = "#FE4848";
x.style.gridColumn = "1";
x.style.gridRow = "1";
var text = createText(order.size + " " + order.name, false, "1.1vw");
text.style.gridColumn = "2";
text.style.gridRow = "1";
var cost = createText("$" + order.cost, false, "1.1vw");
cost.style.gridColumn = "3";
cost.style.gridRow = "1";
cost.style.textAlign = "right";
var edit = createText("(EDIT)", false, "1vw");
edit.style.color = "#6270EB";
edit.style.gridColumn = "2 / 4";
edit.style.gridRow = "2";
edit.style.verticalAlign = "Top";
edit.style.marginTop = "-3px";
div.appendChild(text);
div.appendChild(x);
div.appendChild(cost);
div.appendChild(edit);
container.appendChild(div);
}
var i;
for (i = 0; i < orders.length; i++) {
createItem(orders[i]);
}