-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
161 lines (149 loc) · 4.79 KB
/
script.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
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
const projects = [
{
name: "Counter App",
link: "counter/index.html",
image: "counter/Counter.png",
description: "DOM Manipulation, Events Handling",
youtube: "https://youtu.be/IfHdXb3Gxe0",
github: "https://github.com/DzmitryUr/js-html-css-apps/tree/main/counter",
},
{
name: "Image Gallery",
link: "image-gallery/index.html",
image: "image-gallery/Image-Gallery-JavaScript.png",
description: "DOM Manipulation, Events Handling",
youtube: "https://youtu.be/pAc1hW3eKr0",
github:
"https://github.com/DzmitryUr/js-html-css-apps/tree/main/image-gallery",
},
{
name: "Facts App",
link: "facts-api/index.html",
image: "facts-api/Facts-API.png",
description: "Fetch API, Promises",
youtube: "https://youtu.be/ZrOqRrcpsEs",
github: "https://github.com/DzmitryUr/js-html-css-apps/tree/main/facts-api",
},
{
name: "Jokes App",
link: "jokes-app/index.html",
image: "jokes-app/Jokes-APP.png",
description: "Fetch API, Async, Await",
youtube: "https://youtu.be/b7Cgpu541lQ",
github: "https://github.com/DzmitryUr/js-html-css-apps/tree/main/jokes-app",
},
{
name: "Accordion",
link: "accordion/index.html",
image: "accordion/Accordion Component JS.png",
description: "DOM Manipulation, Events Handling",
youtube: "https://youtu.be/81q_kEgbNPA",
github:
"https://github.com/DzmitryUr/js-html-css-apps/tree/main/image-gallery",
},
{
name: "Native Popups",
link: "native-popups/index.html",
image: "native-popups/Native-PopUps.png",
description: "Alert, Confirm, Prompt Popups",
youtube: "https://youtu.be/mqYTk7XoRBs",
github:
"https://github.com/DzmitryUr/js-html-css-apps/tree/main/native-popups",
},
{
name: "Timer App",
link: "timer/index.html",
image: "timer/Timer.png",
description: "Date object, setInterval, clearInterval",
youtube: "https://youtu.be/9nMLgtFKfNc",
github: "https://github.com/DzmitryUr/js-html-css-apps/tree/main/timer",
},
{
name: "Contact Us Form",
link: "form-contact-us/index.html",
image: "form-contact-us/Contact-Us-Form.png",
description: "Form, Input, Textarea, Validation",
youtube: "https://youtu.be/x2ItMNJI-rc",
github:
"https://github.com/DzmitryUr/js-html-css-apps/tree/main/form-contact-us",
},
{
name: "Memory Words Game",
link: "memory-words-game/index.html",
image: "memory-words-game/MemoryWordsGameJS.png",
description: "CSS Flexbox Layout, Rem Measurement",
youtube: "https://youtu.be/oZpgtx6T6MY",
github:
"https://github.com/DzmitryUr/js-html-css-apps/tree/main/memory-words-game",
},
];
const cardsContainer = document.querySelector(".cards-container");
function createCard({ name, link, image, description, youtube, github }) {
const card = createElement("div", "card");
card.appendChild(createHeader(name));
const imageLink = createLink(link, "_blank");
imageLink.appendChild(createImage(image, `Image ${name}`));
card.appendChild(imageLink);
card.appendChild(createParagraph(description));
const linksContainer = createElement("div", "links-container");
linksContainer.appendChild(createGithHubLink(github));
linksContainer.appendChild(createYoutubeLink(youtube));
linksContainer.appendChild(createAppLink(link, name));
card.appendChild(linksContainer);
return card;
}
function createElement(tagName, className) {
const element = document.createElement(tagName);
if (className) {
element.classList.add(className);
}
return element;
}
function createHeader(name) {
const cardHeader = createElement("div", "card-header");
cardHeader.textContent = name;
return cardHeader;
}
function createProjects() {
projects.forEach((project) => {
const card = createCard(project);
cardsContainer.appendChild(card);
});
}
function createLink(href, target) {
const link = createElement("a");
link.href = href;
link.target = target;
return link;
}
function createImage(src, alt) {
const image = createElement("img");
image.src = src;
image.alt = alt;
return image;
}
function createParagraph(text) {
const paragraph = createElement("p");
paragraph.textContent = text;
return paragraph;
}
function createGithHubLink(link) {
const linkElement = createLink(link, "_blank");
linkElement.appendChild(
createImage("images/github.svg", "Link to GitHub source code")
);
return linkElement;
}
function createYoutubeLink(link) {
const linkElement = createLink(link, "_blank");
linkElement.appendChild(
createImage("images/youtube.svg", "Link to YouTube video")
);
return linkElement;
}
function createAppLink(link, name) {
const linkElement = createLink(link, "_blank");
linkElement.appendChild(createImage("images/website.svg", `Link to ${name}`));
return linkElement;
}
createProjects();