-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
298 lines (268 loc) · 9.06 KB
/
script.js
File metadata and controls
298 lines (268 loc) · 9.06 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
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
// Static badge data
const badges = [
{
id: "https://certify.zairza.co.in/badges/skillpp25wk1/metadata.json",
title: "Skill++ Week 0",
description: "For completing week-1 of Skill++",
image: "https://skillspp2k25.vercel.app/assets/week0-BZc6ZB8D.png",
criteria: "https://certify.zairza.co.in/index.html",
tags: ["Zairza", "skill++"],
alignment: [
{
targetName: "Skill-Development",
targetUrl: "https://skillspp.zairza.co.in/",
targetDescription:
"Gain expert knowledge, hands-on experience, boost your skills in various tech domains.",
targetFramework: "Zairza Skills++",
},
],
folder: "badges/skillpp25wk1",
},
{
id: "https://certify.zairza.co.in/badges/skillpp25wk2/metadata.json",
title: "Skill++ Week 1",
description: "For completing week-1 of Skill++",
image: "https://skills.zairza.co.in/assets/week1-CTqsX_Sa.png",
criteria: "https://certify.zairza.co.in/index.html",
tags: ["Zairza", "skills++"],
alignment: [
{
targetName: "Skill-Development",
targetUrl: "https://skillspp.zairza.co.in/",
targetDescription:
"Gain expert knowledge, hands-on experience, boost your skills in various tech domains.",
targetFramework: "Zairza Skills++",
},
],
folder: "badges/skillpp25wk3",
},
{
id: "https://certify.zairza.co.in/badges/skillpp25wk3/metadata.json",
title: "Skill++ Week 2",
description: "For completing week-2 of Skill++",
image: "https://skills.zairza.co.in/assets/week2-DWIwj_ob.png",
criteria: "https://certify.zairza.co.in/index.html",
tags: ["Zairza", "skill++"],
alignment: [
{
targetName: "Skill-Development",
targetUrl: "https://skillspp.zairza.co.in/",
targetDescription:
"Gain expert knowledge, hands-on experience, boost your skills in various tech domains.",
targetFramework: "Zairza Skills++",
},
],
folder: "badges/skillpp25wk3",
},
{
id: "https://certify.zairza.co.in/badges/skillppmentor/metadata.json",
title: "Skills++ Mentor",
description: "For Mentoring in Skills++",
image: "badges/skillppmentor/mentorBadge.png",
criteria: "https://certify.zairza.co.in/index.html",
tags: ["Zairza", "skills++", "Mentorship"],
alignment: [
{
targetName: "Skill-Development",
targetUrl: "https://skillspp.zairza.co.in/",
targetDescription:
"Gain expert knowledge, hands-on experience, boost your skills in various tech domains.",
targetFramework: "Zairza Skills++",
},
],
folder: "badges/skillppmentor",
},
{
id: "https://certify.zairza.co.in/badges/skillpp25wk4/metadata.json",
title: "Skill++ Week 3",
description: "For completing week-3 of Skill++",
image: "https://skills.zairza.co.in/assets/week3-BBSgTnN6.png",
criteria: "https://certify.zairza.co.in/index.html",
tags: ["Zairza", "skill++"],
alignment: [
{
targetName: "Skill-Development",
targetUrl: "https://skillspp.zairza.co.in/",
targetDescription:
"Gain expert knowledge, hands-on experience, boost your skills in various tech domains.",
targetFramework: "Zairza Skills++",
},
],
folder: "badges/skillpp25wk4",
},
];
// Static certificate data
const certificates = [
{
id: "cert1",
title: "Full Stack Development",
description:
"Certification for completing the full stack development bootcamp",
image: "https://via.placeholder.com/300x200?text=Full+Stack+Development",
issueDate: "2023-04-25",
expiration: "2026-04-25",
skills: ["JavaScript", "React", "Node.js", "MongoDB"],
criteria:
"Successfully complete all modules of the full stack development bootcamp including final project",
tags: ["Web Development", "Full Stack"],
folder: "certificates/full-stack",
},
];
// Initialize the page
document.addEventListener("DOMContentLoaded", () => {
// Populate grids
populateGrid("badges-grid", badges);
populateGrid("certificates-grid", certificates);
// Set up modal close button
const closeBtn = document.querySelector(".close");
closeBtn.addEventListener("click", closeModal);
// Close modal when clicking outside
window.addEventListener("click", (event) => {
const modal = document.getElementById("modal");
if (event.target === modal) {
closeModal();
}
});
});
// Function to show the selected tab
function showTab(tabId) {
// Hide all tab contents
const tabContents = document.querySelectorAll(".tab-content");
tabContents.forEach((tab) => tab.classList.remove("active"));
// Deactivate all tab buttons
const tabButtons = document.querySelectorAll(".tab-btn");
tabButtons.forEach((btn) => btn.classList.remove("active"));
// Show the selected tab content
document.getElementById(tabId).classList.add("active");
// Activate the clicked tab button
document
.querySelector(`.tab-btn[onclick="showTab('${tabId}')"]`)
.classList.add("active");
}
// Function to populate grid with items
function populateGrid(gridId, items) {
const grid = document.getElementById(gridId);
grid.innerHTML = ""; // Clear existing content
items.forEach((item) => {
const card = document.createElement("div");
card.className = "card";
// Create card content with image if available
let cardContent = "";
if (item.image) {
cardContent += `<div class="card-image"><img src="${item.image}" alt="${item.title}"></div>`;
}
cardContent += `
<h3>${item.title}</h3>
<p>${item.description.substring(0, 60)}${
item.description.length > 60 ? "..." : ""
}</p>
`;
// Add tags if available
if (item.tags && item.tags.length > 0) {
cardContent += `<div class="tags">${item.tags
.slice(0, 3)
.map((tag) => `<span class="tag">${tag}</span>`)
.join("")}</div>`;
}
card.innerHTML = cardContent;
// Add click event to open modal
card.addEventListener("click", () => openModal(item));
grid.appendChild(card);
});
}
// Function to open modal with item details
function openModal(item) {
const modal = document.getElementById("modal");
const modalBody = document.getElementById("modal-body");
// Determine if it's a badge or certificate
const isCertificate = item.hasOwnProperty("skills");
// Create modal content
let content = `
<div class="modal-details">
`;
// Add image if available
if (item.image) {
content += `<div class="modal-image"><img src="${item.image}" alt="${item.title}"></div>`;
}
content += `
<h2>${item.title}</h2>
<p class="description">${item.description}</p>
`;
// Add tags if available
if (item.tags && item.tags.length > 0) {
content += `
<div class="tags-container">
<strong>Tags:</strong>
<div class="tags">
${item.tags
.map((tag) => `<span class="tag">${tag}</span>`)
.join("")}
</div>
</div>
`;
}
if (item.issueDate) {
content += `<p><strong>Issue Date:</strong> ${formatDate(
item.issueDate
)}</p>`;
}
if (isCertificate) {
if (item.expiration) {
content += `<p><strong>Expiration Date:</strong> ${formatDate(
item.expiration
)}</p>`;
}
if (item.skills && item.skills.length > 0) {
content += `<p><strong>Skills:</strong> ${item.skills.join(", ")}</p>`;
}
}
// Add criteria
if (item.criteria) {
content += `<p><strong>Criteria:</strong> ${item.criteria}</p>`;
}
// Add alignment if available (for badges)
if (item.alignment && item.alignment.length > 0) {
content += `
<div class="alignment">
<h3>Alignments</h3>
${item.alignment
.map(
(align) => `
<div class="alignment-item">
<p><strong>${align.targetName}</strong></p>
<p>${align.targetDescription || ""}</p>
${
align.targetFramework
? `<p class="meta">Framework: ${align.targetFramework}</p>`
: ""
}
</div>
`
)
.join("")}
</div>
`;
}
content += `
<p class="meta"><strong>ID:</strong> ${item.id}</p>
</div>
`;
modalBody.innerHTML = content;
modal.style.display = "block";
}
// Function to close modal
function closeModal() {
const modal = document.getElementById("modal");
modal.style.display = "none";
}
// Helper function to format dates
function formatDate(dateString) {
if (!dateString) return null;
try {
const options = { year: "numeric", month: "long", day: "numeric" };
return new Date(dateString).toLocaleDateString(undefined, options);
} catch (err) {
console.error("Error formatting date:", err);
return dateString; // Return the original string if parsing fails
}
}