From 9a3f3382bcddd7be71bb6da44d58e16acdc71eeb Mon Sep 17 00:00:00 2001 From: Kavin Muralikrishnan <921563@lcps.org> Date: Tue, 16 Dec 2025 17:51:14 -0500 Subject: [PATCH 1/3] Add Program Clearing Button --- index.html | 7 +++++++ js/editor_wrapper.js | 1 + js/filesystem_wrapper.js | 1 + js/main.js | 14 ++++++++++++++ js/repl.js | 32 ++++++++++++++++++++++++++++++++ 5 files changed, 55 insertions(+) diff --git a/index.html b/index.html index 1c5cf77..911c19e 100644 --- a/index.html +++ b/index.html @@ -141,6 +141,13 @@ title = "Save editor contents to file on XRP under a specific path"> Save As to XRP +
  • +
  • diff --git a/js/editor_wrapper.js b/js/editor_wrapper.js index 46bc7ef..69701bc 100644 --- a/js/editor_wrapper.js +++ b/js/editor_wrapper.js @@ -115,6 +115,7 @@ class EditorWrapper{ this.onOpen = undefined; this.onConvert = undefined; this.onDownloadFile = undefined; + this.onDeleteAllFiles = undefined; this.addNewEditor = undefined; // Make sure mouse down anywhere on panel focuses the panel diff --git a/js/filesystem_wrapper.js b/js/filesystem_wrapper.js index 9a20a93..84bb89a 100644 --- a/js/filesystem_wrapper.js +++ b/js/filesystem_wrapper.js @@ -126,6 +126,7 @@ class FILESYSTEM{ this.onUploadFiles = undefined; this.onRefresh = undefined; this.onDownloadFiles = undefined; + this.onDeleteAllFiles = undefined; // this.onNewFile = undefined; diff --git a/js/main.js b/js/main.js index 9d884b2..6aa8fe4 100644 --- a/js/main.js +++ b/js/main.js @@ -289,6 +289,12 @@ document.getElementById("IDFileSaveAs").onclick = (event) =>{ EDITORS[id].onSaveAsToThumby(); } +document.getElementById("IDFileDeleteAll").onclick = (event) =>{ + UIkit.dropdown(FILE_DROPDOWN).hide(); + let id = localStorage.getItem("activeTabId"); + EDITORS[id].onDeleteAllFiles(); +} + // View Menu Support VIEW_BUTTON.onclick = (event) =>{ //get active file id @@ -815,6 +821,14 @@ function registerEditor(_container, state) { window.alertMessage("No XRP is connected. Files can not be uploaded. Double-check that the XRP is connected before attempting to upload a file."); } } + + editor.onDeleteAllFiles = async () => { + if(REPL.DISCONNECT == false && await confirmMessage("This will delete ALL files on the XRP, with the exception of the lib folder, the trash folder, and the XRPExamples folder. Are you SURE you want to do this?")){ + REPL.deleteAllFiles(); + }else{ + window.alertMessage("No XRP is connected. Files can not be deleted. Double-check that the XRP is connected before attempting to delete a file."); + } + } editor.onSaveToThumby = async () => { // Warn user when trying to save and no Thumby is connected diff --git a/js/repl.js b/js/repl.js index 1d7c056..7515d60 100644 --- a/js/repl.js +++ b/js/repl.js @@ -872,6 +872,38 @@ class ReplJS{ await this.getOnBoardFSTree(); } + async deleteNonLibFiles(){ + if(this.BUSY == true){ + return; + } + this.BUSY = true; + + var cmd = "import os\n" + + "def rm(d): # Remove file or tree\n" + + " try:\n" + + " if os.stat(d)[0] & 0x4000: # Dir\n" + + " for f in os.ilistdir(d):\n" + + " if f[0] not in ('.', '..'):\n" + + " rm('/'.join((d, f[0]))) # File or Dir\n" + + " os.rmdir(d)\n" + + " else: # File\n" + + " os.remove(d)\n" + + " print('rm_worked')\n" + + " except:\n" + + " print('rm_failed')\n" + + "filelist = os.listdir('/')\n" + + "for f in filelist:\n" + + "if f != 'lib' and f != 'trash' and f!= 'XRPExamples'" + + " rm('/' + f)\n"; + + await this.writeUtilityCmdRaw(cmd, true, 1); + + // Get back into normal mode and omit the 3 lines from the normal message, + // don't want to repeat (assumes already on a normal prompt) + await this.getToNormal(3); + this.BUSY = false; + } + // Given a path, delete it on RP2040 async deleteFileOrDir(path){ From 9da9dd25c5c636ccc4fcfba68b99bc50c6bbf28b Mon Sep 17 00:00:00 2001 From: Kavin Muralikrishnan <921563@lcps.org> Date: Wed, 17 Dec 2025 09:38:49 -0500 Subject: [PATCH 2/3] Update Method Name --- index.html | 2 +- js/editor_wrapper.js | 2 +- js/filesystem_wrapper.js | 2 +- js/main.js | 11 ++++++----- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/index.html b/index.html index 911c19e..3041797 100644 --- a/index.html +++ b/index.html @@ -143,7 +143,7 @@