From a872bdde76eed8efc35a26ca28c933fb76ef487a Mon Sep 17 00:00:00 2001 From: "Sebastian L." Date: Mon, 25 Aug 2025 20:08:02 +0000 Subject: [PATCH 1/3] Added the download confirmation dialogue --- src/ifm.js | 10 ++++++++++ src/templates/filetable.html | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/ifm.js b/src/ifm.js index e47b637..eaaf9ff 100644 --- a/src/ifm.js +++ b/src/ifm.js @@ -1,3 +1,13 @@ +// Shows the download dialogue +window.confirmDownload = function(event, el) { + event.preventDefault(); + var filename = el.getAttribute('data-filename') || ''; + var msg = filename ? 'Are you sure to download "' + filename + '"?' : 'Start download?'; + if (window.confirm(msg)) { + window.location.href = el.getAttribute('href'); + } + return false; +} /** * IFM constructor * diff --git a/src/templates/filetable.html b/src/templates/filetable.html index 6921868..03a3ff6 100644 --- a/src/templates/filetable.html +++ b/src/templates/filetable.html @@ -14,7 +14,7 @@ {{#config.download}} - + {{/config.download}} {{#config.showlastmodified}} From dd642e0950602d0f9eeaedef4fe1da8cfb6f8bd4 Mon Sep 17 00:00:00 2001 From: "Sebastian L." Date: Mon, 25 Aug 2025 20:13:37 +0000 Subject: [PATCH 2/3] show dialogue only if folder ist clicked --- src/templates/filetable.html | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/templates/filetable.html b/src/templates/filetable.html index 03a3ff6..c958d18 100644 --- a/src/templates/filetable.html +++ b/src/templates/filetable.html @@ -14,7 +14,14 @@ {{#config.download}} - + {{#type}} + {{#isDir}} + + {{/isDir}} + {{^isDir}} + + {{/isDir}} + {{/type}} {{/config.download}} {{#config.showlastmodified}} From fc230ac9725142f13342d3fb75fc1e3a7ab9fc78 Mon Sep 17 00:00:00 2001 From: "Sebastian L." Date: Mon, 25 Aug 2025 20:48:42 +0000 Subject: [PATCH 3/3] overwrite warning --- src/i18n/en.json | 1 + src/ifm.js | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/i18n/en.json b/src/i18n/en.json index 4ca6c0e..834bbf6 100644 --- a/src/i18n/en.json +++ b/src/i18n/en.json @@ -40,6 +40,7 @@ "file_save_confirm": "Do you want to save the following file:", "file_save_error": "Could not save file.", "file_save_success": "File saved.", + "file_overwrite_confirm": "File already exists. Overwrite?", "file_upload_error": "Could not upload file.", "file_upload_success": "File uploaded.", "filename": "Filename", diff --git a/src/ifm.js b/src/ifm.js index eaaf9ff..767f192 100644 --- a/src/ifm.js +++ b/src/ifm.js @@ -521,9 +521,19 @@ function IFM(params) { form.addEventListener( 'click', function( e ) { if( e.target.id == "buttonSave" ) { e.preventDefault(); - self.saveFile( document.querySelector( '#formFile input[name=filename]' ).value, self.editor.getValue() ); - self.isModalClosedByButton = true; - self.hideModal(); + let filename = document.querySelector( '#formFile input[name=filename]' ).value; + let exists = self.fileCache.map(x => x.name).indexOf(filename) !== -1; + if (exists) { + if (window.confirm(self.i18n.file_overwrite_confirm || 'Die Datei existiert bereits. Überschreiben?')) { + self.saveFile(filename, self.editor.getValue()); + self.isModalClosedByButton = true; + self.hideModal(); + } + } else { + self.saveFile(filename, self.editor.getValue()); + self.isModalClosedByButton = true; + self.hideModal(); + } } else if( e.target.id == "buttonSaveNotClose" ) { e.preventDefault(); self.saveFile( document.querySelector( '#formFile input[name=filename]' ).value, self.editor.getValue() );