-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathscript.js
424 lines (360 loc) · 13.1 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
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
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
/********_--_--_--_--*********/
/*****_- Contact Card -_******/
/*********_--_--_--_--*********/
function show() {
const contentme = document.querySelector(".contectme");
const showButton = document.getElementById("contact");
const hideButton = document.getElementsByClassName("hide");
let isContentVisible = false;
const text = `
<div class="Contect-Container">
<div class="card">
<div class="touch touch__1"></div>
<div class="touch touch__2"></div>
<div class="touch touch__3"></div>
<div class="touch touch__4"></div>
<div class="touch touch__6"></div>
<div class="touch touch__7"></div>
<div class="touch touch__8"></div>
<div class="touch touch__9"></div>
<div class="main">
<div class="icon">
<img class="img logo-img" src="img/logo.png" alt="logo" />
</div>
<span class="name user-name"
><i class="fa-solid fa-user fa-lg"></i
><span class="top">Subham Narayan Deb</span></span
>
<span class="name location"
><i class="fa-solid fa-location-dot fa-lg"></i
><span class="top">Jamshedpur, Jharkhend</span></span
>
<span class="name mail"
><i class="fa-solid fa-envelope fa-lg"></i
><span class="top">sdeb5003@gmail.com</span></span
>
<span class="name number"
><i class="fa-solid fa-phone fa-lg"></i
><span class="top">+911234567890</span></span
>
<span class="name service"
><i class="fa-solid fa-gear fa-lg"></i
><span class="top"
>Full Stack Web-Development, UI & UX Designer & Photos and
Videos Editing, Logo Designer</span
></span
>
<span class="comment text">
<a href="https://github.com/dashboard" class="github"
><i class="fa-brands fa-github fa-2xl" style="color: #32025c"></i
></a>
<a href="https://www.linkedin.com/feed/" class="linkedin"
><i class="fa-brands fa-linkedin fa-2xl" style="color: #32025c"></i
></a>
<a href="https://twitter.com/home" class="twitter"
><i class="fa-brands fa-twitter fa-2xl" style="color: #32025c"></i
></a>
<a href="https://discord.com/channels/@me" class="discord"
><i class="fa-brands fa-discord fa-2xl" style="color: #32025c"></i>
</a>
</span>
</div>
</div>
</div>
`;
showButton.addEventListener("mouseenter", () => {
if (!isContentVisible) {
contentme.innerHTML = text;
isContentVisible = true;
contentme.style.animation = "slideIn 0.5s ease-in-out forwards";
}
});
hideButton[0].addEventListener("mouseleave", () => {
if (isContentVisible) {
contentme.style.animation = "slideOut 0.5s ease-in-out forwards";
setTimeout(() => {
contentme.innerHTML = "";
isContentVisible = false;
}, 900);
}
});
}
window.onload = show;
/****************************************/
/******** Photos Instagram Link *********/
/***************************************/
document.addEventListener("DOMContentLoaded", () => {
const photosLinks = document.querySelectorAll(".visit-button");
photosLinks.forEach((link) => {
link.addEventListener("click", () => {
const url = link.getAttribute("data-instagram-link");
window.open(url, "_blank");
});
link.setAttribute("target", "_blank");
});
});
/*\\\\\\\ *********** ///////*/
/*\\\\\\\ Disable key ///////*/
/*\\\\\\\ *********** ///////*/
// document.addEventListener("contextmenu", function (e) {
// e.preventDefault();
// showMessage("Warning: Unauthorized access is not allowed!");
// });
// document.addEventListener("keydown", function (e) {
// if (e.ctrlKey && (e.key === "u" || e.key === "U")) {
// e.preventDefault();
// showMessage("Warning: Unauthorized access is not allowed!");
// return false;
// }
// });
// document.addEventListener("keydown", function (e) {
// if (e.key === "F12") {
// e.preventDefault();
// showMessage("Warning: Unauthorized access is not allowed!");
// return false;
// }
// });
function showMessage(message) {
const messageDiv = document.createElement("div");
messageDiv.className = "message";
messageDiv.textContent = message;
document.body.appendChild(messageDiv);
document.querySelector(".card-blur").classList.add("blur");
setTimeout(function () {
document.body.removeChild(messageDiv);
document.querySelector(".card-blur").classList.remove("blur");
}, 2000);
}
/* =========================== */
/* ===== Download Resume ===== */
/* =========================== */
// document.addEventListener("DOMContentLoaded", function () {
// const downloadBtn = document.getElementById("downloadBtn");
// // URL of the file you want to download
// const fileUrl = "CV.pdf";
// downloadBtn.addEventListener("click", function () {
// downloadFile(fileUrl);
// // Add the animation class to the download button
// downloadBtn.classList.add("rotate3d-animation");
// // Remove the animation class after the animation completes
// setTimeout(() => {
// downloadBtn.classList.remove("rotate3d-animation");
// }, 2000);
// });
// });
// function downloadFile(url) {
// fetch(url, {
// method: "HEAD"
// })
// .then(response => {
// const contentLength = response.headers.get("Content-Length");
// const contentRange = `bytes=0-${contentLength}`;
// return fetch(url, {
// method: "GET",
// headers: {
// "Range": contentRange
// }
// });
// })
// .then(response => response.blob())
// .then(blob => {
// const objectURL = URL.createObjectURL(blob);
// const link = document.createElement("a");
// link.href = objectURL;
// link.download = "Subham_Resume.pdf"; // Set the desired file name
// link.click();
// URL.revokeObjectURL(objectURL);
// })
// .catch(error => {
// console.error("Error downloading the file:", error);
// });
// }
document.addEventListener("DOMContentLoaded", function () {
const downloadBtn = document.getElementById("downloadBtn");
const message = document.getElementById("message");
// URL of the file you want to download
const fileUrl = "CV.pdf";
downloadBtn.addEventListener("click", function () {
const isUpToDate = false;
if (!isUpToDate) {
message.style.display = "block";
setTimeout(() => {
message.style.display = "none";
}, 2000);
return;
}
downloadFile(fileUrl);
// Add the animation class to the download button
downloadBtn.classList.add("rotate3d-animation");
// Remove the animation class after the animation completes
setTimeout(() => {
downloadBtn.classList.remove("rotate3d-animation");
}, 2000);
});
});
function downloadFile(url) {
fetch(url, {
method: "HEAD",
})
.then((response) => {
const contentLength = response.headers.get("Content-Length");
const contentRange = `bytes=0-${contentLength}`;
return fetch(url, {
method: "GET",
headers: {
Range: contentRange,
},
});
})
.then((response) => response.blob())
.then((blob) => {
const objectURL = URL.createObjectURL(blob);
const link = document.createElement("a");
link.href = objectURL;
link.download = "Subham_Resume.pdf"; // Set the desired file name
link.click();
URL.revokeObjectURL(objectURL);
})
.catch((error) => {
console.error("Error downloading the file:", error);
});
}
/* ====== My Project [Section's] ===== */
// 1st Method
// document.addEventListener("DOMContentLoaded", async function () {
// const projectsContainer = document.getElementById("projects-container");
// const username = "s-pro-dev";
// const apiUrl = `https://api.github.com/users/${username}/repos`;
// async function fetchProjects() {
// try {
// const response = await fetch(apiUrl);
// const projects = await response.json();
// projects.forEach((project) => {
// const card = document.createElement("div");
// card.classList.add("project-card");
// card.innerHTML = `
// <p>${project.description}</p>
// <img src="${project.image_url}" alt="Project Screenshot">
// <span class="project-language">${project.language}</span>
// <a class="project-button" href="${project.homepage}" target="_blank">Go Live</a>
// `;
// projectsContainer.appendChild(card);
// });
// } catch (error) {
// console.error("Error fetching projects:", error);
// }
// }
// fetchProjects();
// });
//2nd Method
document.addEventListener("DOMContentLoaded", async function () {
const projectsContainer = document.getElementById("projects-container");
const username = "s-pro-dev";
const apiUrl = `https://api.github.com/users/${username}/repos`;
// Define a mapping of GitHub language colors
const languageColors = {
JavaScript: "#f1e05a",
HTML: "#e34c26",
CSS: "#1f62dee3",
// Add more languages and their colors as needed
};
async function fetchProjects() {
try {
const response = await fetch(apiUrl);
if (!response.ok) {
throw new Error(`Failed to fetch projects. Status: ${response.status}`);
}
const repositories = await response.json();
for (const repository of repositories) {
const card = document.createElement("div");
card.classList.add("project-card");
card.innerHTML = `
<img src="${repository.img}" alt="Project Screenshot">
<div class="project-details">
<p>${repository.description || "No description available"}</p>
<span class="code-usage"></span>
<a class="project-button" href="${
repository.homepage || repository.html_url
}" target="_blank">
<i class="fa-solid fa-eye"></i>
</a>
</div>
`;
// console.log(card.innerHTML)
projectsContainer.appendChild(card);
// Fetch the languages used in the repository
const languagesUrl = `https://api.github.com/repos/${username}/${repository.name}/languages`;
const languagesResponse = await fetch(languagesUrl);
if (!languagesResponse.ok) {
console.error(
`Failed to fetch languages for ${repository.name}. Status: ${languagesResponse.status}`
);
continue;
}
const languagesData = await languagesResponse.json();
// Calculate and display the percentages of code usage for each language
const totalSize = Object.values(languagesData).reduce(
(total, size) => total + size,
0
);
const codeUsageElement = card.querySelector(".code-usage"); // Select the .code-usage element within this card
Object.entries(languagesData).forEach(([language, size]) => {
const percentage = ((size / totalSize) * 100).toFixed(2);
// Get the Font Awesome icon class for programming languages
let iconClass = "";
switch (language.toLowerCase()) {
case "html":
iconClass = "fab fa-html5";
break;
case "css":
iconClass = "fab fa-css3";
break;
case "javascript":
iconClass = "fab fa-js";
break;
default:
iconClass = "fas fa-code";
}
// Get the color for the language from the mapping
const languageColor = languageColors[language] || "#333";
// Display language icon and percentage with the correct color
codeUsageElement.innerHTML += `
<i class="${iconClass} language-icon" style="color: ${languageColor}"></i>
<span>${percentage}%</span><br>
`;
});
}
} catch (error) {
console.error("Error fetching projects:", error);
}
}
fetchProjects();
});
/* ====== My Project [HIDE AND UN-HIDE] ===== */
document.addEventListener("DOMContentLoaded", function () {
const projectLink = document.getElementById("project");
const navBar = document.getElementById("nav");
const firstPage = document.getElementById("firstPage");
const myProjects = document.getElementById("myprojects");
const backButton = document.querySelector(".back-button");
projectLink.addEventListener("click", function () {
navBar.style.animation = "slideUp 0.5s forwards";
firstPage.style.animation = "slideUp 0.5s forwards";
myProjects.style.animation = "slideIn 0.5s forwards";
setTimeout(function () {
navBar.style.display = "none";
firstPage.style.display = "none";
myProjects.style.display = "block";
}, 500);
});
backButton.addEventListener("click", function () {
myProjects.style.animation = "slideUp 0.5s forwards";
navBar.style.animation = "slideDown 0.5s forwards";
firstPage.style.animation = "slideDown 0.5s forwards";
setTimeout(function () {
navBar.style.display = "";
firstPage.style.display = "block";
myProjects.style.display = "none";
}, 500);
});
});