File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -104,17 +104,25 @@ layout: layouts/base.njk
104104
105105<script >
106106 function copyToClipboard (text , el ) {
107- navigator .clipboard .writeText (text);
108- const span = el .querySelector (' span:last-child' );
109- span .innerText = ' Copied!' ;
110- setTimeout (() => span .innerText = ' Copy' , 2000 );
107+ if (! navigator .clipboard ) {
108+ console .warn (' Clipboard API not available' );
109+ return ;
110+ }
111+ navigator .clipboard .writeText (text)
112+ .then (() => {
113+ const span = el .querySelector (' span:last-child' );
114+ if (span) {
115+ span .innerText = ' Copied!' ;
116+ setTimeout (() => span .innerText = ' Copy' , 2000 );
117+ }
118+ })
119+ .catch (err => console .error (' Failed to copy:' , err));
111120 }
112121
113122 document .querySelector (' .copy-email-btn' )? .addEventListener (' click' , function () {
114123 copyToClipboard (this .getAttribute (' data-email' ), this );
115124 });
116125
117- // Pass profile data to game modules
118126 const profileData = document .getElementById (' profile-data' );
119127 window .PROFILE_NAME = profileData ? profileData .dataset .name : " " ;
120128 window .PROFILE_SKILLS = profileData && profileData .dataset .skills ? profileData .dataset .skills .trim ().split (/ \s + / ).filter (Boolean ) : [];
You can’t perform that action at this time.
0 commit comments