@@ -75,53 +75,7 @@ function copyToClipboard(text, button) {
7575 }
7676}
7777
78- // Download file function
79- function downloadFile ( filePath , button ) {
80- function showSuccessMessage ( ) {
81- if ( button ) {
82- const originalText = button . textContent ;
83- const originalColor = button . style . color ;
84- button . textContent = "✓ Downloading" ;
85- button . style . color = "green" ;
86- setTimeout ( ( ) => {
87- button . textContent = originalText ;
88- button . style . color = originalColor ;
89- } , 1500 ) ;
90- }
91- }
92-
93- function showErrorMessage ( ) {
94- if ( button ) {
95- const originalText = button . textContent ;
96- const originalColor = button . style . color ;
97- button . textContent = "✗ Failed" ;
98- button . style . color = "red" ;
99- setTimeout ( ( ) => {
100- button . textContent = originalText ;
101- button . style . color = originalColor ;
102- } , 1500 ) ;
103- }
104- }
105-
106- try {
107- // Create a temporary link element to trigger download
108- const downloadUrl = `/download-file?path=${ encodeURIComponent ( filePath ) } ` ;
109- const link = document . createElement ( "a" ) ;
110- link . href = downloadUrl ;
111- link . style . display = "none" ;
112- document . body . appendChild ( link ) ;
113- link . click ( ) ;
114- document . body . removeChild ( link ) ;
115-
116- showSuccessMessage ( ) ;
117- console . log ( "Downloading file:" , filePath ) ;
118- } catch ( err ) {
119- console . error ( "Failed to download file:" , err ) ;
120- showErrorMessage ( ) ;
121- }
122- }
123-
124- // Setup copy and download button event listeners
78+ // Setup copy button event listeners
12579function setupCopyButtons ( ) {
12680 // Add event listeners to all copy path buttons
12781 document
@@ -140,23 +94,3 @@ function setupCopyButtons() {
14094 } ) ;
14195 } ) ;
14296}
143-
144- // Setup download button event listeners
145- function setupDownloadButtons ( ) {
146- // Add event listeners to all download buttons
147- document
148- . querySelectorAll ( ".download-btn, .download-btn-small" )
149- . forEach ( ( button ) => {
150- button . addEventListener ( "click" , function ( e ) {
151- e . preventDefault ( ) ;
152- e . stopPropagation ( ) ;
153-
154- const path = this . getAttribute ( "data-path" ) ;
155- if ( path ) {
156- downloadFile ( path , this ) ;
157- } else {
158- console . error ( "No path found on download button:" , this ) ;
159- }
160- } ) ;
161- } ) ;
162- }
0 commit comments