-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
126 lines (111 loc) · 4.15 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
document.addEventListener("DOMContentLoaded", function () {
const screenWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
const dropdownElement = document.querySelector(".dropdown");
const navElement = document.querySelector(".hide-on-small-screen ul");
if (screenWidth <= 760) {
const menuImgSrc = "../images/menu.png"; // Replace with the actual menu image source
const crossImgSrc = "../images/cross.png"; // Replace with the actual cross image source
const imgElement = document.createElement("img");
imgElement.src = menuImgSrc;
imgElement.alt = "Menu";
imgElement.style.height = "60px";
imgElement.style.width = "60px";
dropdownElement.appendChild(imgElement);
dropdownElement.addEventListener("click", function () {
navElement.classList.toggle("nav-hidden");
navElement.classList.toggle("nav-visible");
imgElement.src = navElement.classList.contains("nav-visible") ? crossImgSrc : menuImgSrc;
imgElement.alt = navElement.classList.contains("nav-visible") ? "Cross" : "Menu";
});
}
});
// Initialize Prism.js
Prism.highlightAll();
function copyCode() {
const codeBlock = document.getElementById("code-block");
navigator.clipboard.writeText(codeBlock.innerText)
.then(() => {
showNotification("Code Copied !!", "success");
})
.catch((error) => {
showNotification("Failed To Copy: " + error, "error");
});
}
function copyCode1() {
const codeBlock = document.getElementById("code-block1");
navigator.clipboard.writeText(codeBlock.innerText)
.then(() => {
showNotification("Code Copied !!", "success");
})
.catch((error) => {
showNotification("Failed To Copy: " + error, "error");
});
}
function copyCode2() {
const codeBlock = document.getElementById("code-block2");
navigator.clipboard.writeText(codeBlock.innerText)
.then(() => {
showNotification("Code Copied !!", "success");
})
.catch((error) => {
showNotification("Failed To Copy: " + error, "error");
});
}
function copyCode3() {
const codeBlock = document.getElementById("code-block3");
navigator.clipboard.writeText(codeBlock.innerText)
.then(() => {
showNotification("Code Copied !!", "success");
})
.catch((error) => {
showNotification("Failed To Copy: " + error, "error");
});
}
function copyCode4() {
const codeBlock = document.getElementById("code-block4");
navigator.clipboard.writeText(codeBlock.innerText)
.then(() => {
showNotification("Code Copied !!", "success");
})
.catch((error) => {
showNotification("Failed To Copy: " + error, "error");
});
}
function copyCode5() {
const codeBlock = document.getElementById("code-block5");
navigator.clipboard.writeText(codeBlock.innerText)
.then(() => {
showNotification("Code Copied !!", "success");
})
.catch((error) => {
showNotification("Failed To Copy: " + error, "error");
});
}
function copyCode6() {
const codeBlock = document.getElementById("code-block6");
navigator.clipboard.writeText(codeBlock.innerText)
.then(() => {
showNotification("Code Copied !!", "success");
})
.catch((error) => {
showNotification("Failed To Copy: " + error, "error");
});
}
function copyCode7() {
const codeBlock = document.getElementById("code-block7");
navigator.clipboard.writeText(codeBlock.innerText)
.then(() => {
showNotification("Code Copied !!", "success");
})
.catch((error) => {
showNotification("Failed To Copy: " + error, "error");
});
}
function showNotification(message, type) {
const notification = document.getElementById("notification");
notification.textContent = message;
notification.classList.add(type, "show");
setTimeout(() => {
notification.classList.remove("show");
}, 3000);
}