Skip to content

Commit 8306d24

Browse files
author
parthivk
committed
Some changes
1 parent c792bef commit 8306d24

21 files changed

+71
-3
lines changed
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

Diff for: index.html

+5-3
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@
88
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
99
<link href="https://fonts.googleapis.com/css2?family=Josefin+Sans:ital@1&display=swap" rel="stylesheet">
1010
<link rel="stylesheet" href="./style.css">
11+
<script src="script.js" defer></script>
1112
<title>CSS Battle Solutions </title>
1213
</head>
1314
<body>
1415
<h2>Well, here you go!</h2>
15-
<div class="container">
16-
<div class="card-container">
16+
<div class="container" id="list">
17+
18+
<!-- <div class="card-container">
1719
<span class="heading">Battle #1 - Pilot Battle</span>
1820
<div class="cards">
1921
<div class="card"><a target="_blank" href="./Pilot Battle/1.SimplySquare.html">1. Simply Square</a></div>
@@ -71,7 +73,7 @@ <h2>Well, here you go!</h2>
7173
<div class="card"><a target="_blank" href="./Battle20/119.Pacman.html">119. Pacman</a></div>
7274
<div class="card"><a target="_blank" href="./Battle20/121.DuckHunt.html">121. Duck Hunt</a></div>
7375
</div>
74-
</div>
76+
</div> -->
7577
</div>
7678
</body>
7779
</html>

Diff for: script.js

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
const battles = [
2+
{
3+
name: "Battle #1 - Pilot Battle",
4+
battle : ["1. Simply Square", "2. Carrom", "4. Ups And Downs", "5. Acid Rain", "6. Missing Slice", "7. Leafy Trail",
5+
"10. Cloaked Spirits", "11. Eye Of Sauron", "12. Wiggly Moustache"]
6+
}, {
7+
name: "Battle #2 - Visibility",
8+
battle: ["13. Totally Triangle", "14. Web Maker Logo"]
9+
}, {
10+
name: "Battle #3 - Cursor",
11+
battle: ["19. Cube"]
12+
}, {
13+
name: "Battle #4 - Display",
14+
battle: ["25. Blossom", "28. Cups & Balls"]
15+
}, {
16+
name: "Battle #14 - ZIndex",
17+
battle: ["77. Notes"]
18+
}, {
19+
name: "Battle #15 - Filter",
20+
battle: ["81. Odoo"]
21+
}, {
22+
name: "Battle #19 - Spacing",
23+
battle: ["109. Curtain"]
24+
}, {
25+
name: "Battle #20 - Hover",
26+
battle: ["119. Pacman", "120. Duck Hunt"]
27+
}
28+
];
29+
30+
function createCardContainer(name, battle) {
31+
let cards = createCards(name, battle);
32+
let str = `
33+
<div class="card-container">
34+
<span class="heading">${name}</span>
35+
<div class="cards">
36+
${cards}
37+
</div>
38+
</div>
39+
`
40+
return str;
41+
}
42+
43+
function createCards(name, battles) {
44+
console.log("battles are" + battles);
45+
let result = battles.map(el => createCard(name, el));
46+
return result;
47+
}
48+
49+
function createCard(name, battle) {
50+
let str = `
51+
<div class="card">
52+
<a target="_blank" href="/${formatString(name)}/${formatString(battle)}.html">${battle}</a>
53+
</div>
54+
`;
55+
return str;
56+
}
57+
58+
function formatString(str) {
59+
return str.replace(/\s/g, '');
60+
}
61+
62+
const html = battles.map(({ name, battle}) => createCardContainer(name, battle));
63+
console.log(html);
64+
65+
const container = document.getElementById('list');
66+
container.innerHTML = html;

0 commit comments

Comments
 (0)