1+ document . addEventListener ( "DOMContentLoaded" , function ( ) {
2+ const screenWidth = window . innerWidth || document . documentElement . clientWidth || document . body . clientWidth ;
3+ const dropdownElement = document . querySelector ( ".dropdown" ) ;
4+ const navElement = document . querySelector ( ".hide-on-small-screen ul" ) ;
5+
6+ if ( screenWidth <= 760 ) {
7+ const menuImgSrc = "../images/menu.png" ; // Replace with the actual menu image source
8+ const crossImgSrc = "../images/cross.png" ; // Replace with the actual cross image source
9+
10+ const imgElement = document . createElement ( "img" ) ;
11+ imgElement . src = menuImgSrc ;
12+ imgElement . alt = "Menu" ;
13+ imgElement . style . height = "60px" ;
14+ imgElement . style . width = "60px" ;
15+
16+ dropdownElement . appendChild ( imgElement ) ;
17+
18+ dropdownElement . addEventListener ( "click" , function ( ) {
19+ navElement . classList . toggle ( "nav-hidden" ) ;
20+ navElement . classList . toggle ( "nav-visible" ) ;
21+ imgElement . src = navElement . classList . contains ( "nav-visible" ) ? crossImgSrc : menuImgSrc ;
22+ imgElement . alt = navElement . classList . contains ( "nav-visible" ) ? "Cross" : "Menu" ;
23+ } ) ;
24+ }
25+ } ) ;
26+
27+ // Initialize Prism.js
28+ Prism . highlightAll ( ) ;
29+
30+ function copyCode ( ) {
31+ const codeBlock = document . getElementById ( "code-block" ) ;
32+ navigator . clipboard . writeText ( codeBlock . innerText )
33+ . then ( ( ) => {
34+ showNotification ( "Code Copied !!" , "success" ) ;
35+ } )
36+ . catch ( ( error ) => {
37+ showNotification ( "Failed To Copy: " + error , "error" ) ;
38+ } ) ;
39+ }
40+
41+ function copyCode1 ( ) {
42+ const codeBlock = document . getElementById ( "code-block1" ) ;
43+ navigator . clipboard . writeText ( codeBlock . innerText )
44+ . then ( ( ) => {
45+ showNotification ( "Code Copied !!" , "success" ) ;
46+ } )
47+ . catch ( ( error ) => {
48+ showNotification ( "Failed To Copy: " + error , "error" ) ;
49+ } ) ;
50+ }
51+
52+ function copyCode2 ( ) {
53+ const codeBlock = document . getElementById ( "code-block2" ) ;
54+ navigator . clipboard . writeText ( codeBlock . innerText )
55+ . then ( ( ) => {
56+ showNotification ( "Code Copied !!" , "success" ) ;
57+ } )
58+ . catch ( ( error ) => {
59+ showNotification ( "Failed To Copy: " + error , "error" ) ;
60+ } ) ;
61+ }
62+
63+ function copyCode3 ( ) {
64+ const codeBlock = document . getElementById ( "code-block3" ) ;
65+ navigator . clipboard . writeText ( codeBlock . innerText )
66+ . then ( ( ) => {
67+ showNotification ( "Code Copied !!" , "success" ) ;
68+ } )
69+ . catch ( ( error ) => {
70+ showNotification ( "Failed To Copy: " + error , "error" ) ;
71+ } ) ;
72+ }
73+
74+ function copyCode4 ( ) {
75+ const codeBlock = document . getElementById ( "code-block4" ) ;
76+ navigator . clipboard . writeText ( codeBlock . innerText )
77+ . then ( ( ) => {
78+ showNotification ( "Code Copied !!" , "success" ) ;
79+ } )
80+ . catch ( ( error ) => {
81+ showNotification ( "Failed To Copy: " + error , "error" ) ;
82+ } ) ;
83+ }
84+
85+ function copyCode5 ( ) {
86+ const codeBlock = document . getElementById ( "code-block5" ) ;
87+ navigator . clipboard . writeText ( codeBlock . innerText )
88+ . then ( ( ) => {
89+ showNotification ( "Code Copied !!" , "success" ) ;
90+ } )
91+ . catch ( ( error ) => {
92+ showNotification ( "Failed To Copy: " + error , "error" ) ;
93+ } ) ;
94+ }
95+
96+ function copyCode6 ( ) {
97+ const codeBlock = document . getElementById ( "code-block6" ) ;
98+ navigator . clipboard . writeText ( codeBlock . innerText )
99+ . then ( ( ) => {
100+ showNotification ( "Code Copied !!" , "success" ) ;
101+ } )
102+ . catch ( ( error ) => {
103+ showNotification ( "Failed To Copy: " + error , "error" ) ;
104+ } ) ;
105+ }
106+
107+ function copyCode7 ( ) {
108+ const codeBlock = document . getElementById ( "code-block7" ) ;
109+ navigator . clipboard . writeText ( codeBlock . innerText )
110+ . then ( ( ) => {
111+ showNotification ( "Code Copied !!" , "success" ) ;
112+ } )
113+ . catch ( ( error ) => {
114+ showNotification ( "Failed To Copy: " + error , "error" ) ;
115+ } ) ;
116+ }
117+
118+ function showNotification ( message , type ) {
119+ const notification = document . getElementById ( "notification" ) ;
120+ notification . textContent = message ;
121+ notification . classList . add ( type , "show" ) ;
122+
123+ setTimeout ( ( ) => {
124+ notification . classList . remove ( "show" ) ;
125+ } , 3000 ) ;
126+ }
0 commit comments