From b030e245370ffa6a31405e3e2e3732dd1382e07b Mon Sep 17 00:00:00 2001 From: john4650-hub Date: Thu, 14 Sep 2023 05:40:24 +0300 Subject: [PATCH] now settings can be remembered on app start --- www/index.html | 17 ++++++++++------- www/js/app.js | 12 +----------- www/js/components/main_FileEntry.js | 15 +++++++++++++-- 3 files changed, 24 insertions(+), 20 deletions(-) diff --git a/www/index.html b/www/index.html index 029f761..27d1ebd 100644 --- a/www/index.html +++ b/www/index.html @@ -7,7 +7,7 @@ - + @@ -28,9 +28,12 @@
-
-
- +
+
+
+ + +
@@ -49,7 +52,7 @@
FILE SYSTEM
- +
- +
Recent files
@@ -71,7 +74,7 @@
Recent files
    - +
    diff --git a/www/js/app.js b/www/js/app.js index 12c6ada..140b2cc 100644 --- a/www/js/app.js +++ b/www/js/app.js @@ -24,7 +24,7 @@ export const SAVEFS = document.getElementById('saveFs'); export const OPENFS = document.getElementById('openFs'); export const SETFILE = document.getElementById('setFile'); - +export let recentFilesTab = document.getElementById('recent_file') const MENU_TAB = document.querySelector("#menuTab"); let tabContent = document.querySelector(".tab-content") @@ -73,13 +73,3 @@ aboutMe('#aboutme') // recent files -export function addRecentlyOpenedFile(name, url, fs) { - let recentFilesTab = document.getElementById('recent_file') - - let openedFile = makeElm('li') - insertAttr(['class=list-group-item'], openedFile) - openedFile.innerText = name - openedFile.addEventListener('click', function() { fs(url) }) - - recentFilesTab.appendChild(openedFile) -} \ No newline at end of file diff --git a/www/js/components/main_FileEntry.js b/www/js/components/main_FileEntry.js index bbcc501..ed86fb4 100644 --- a/www/js/components/main_FileEntry.js +++ b/www/js/components/main_FileEntry.js @@ -1,4 +1,4 @@ -import { OPENFS, SAVEFS, addRecentlyOpenedFile } from "../app.js"; +import { OPENFS, SAVEFS, recentFilesTab } from "../app.js"; import { writeFile } from "./File_System/writeFile.js"; import { readFile } from "./File_System/readFile.js"; import { entryIcon } from "./File_System/fileSysUi.js"; @@ -73,13 +73,14 @@ export async function onDeviceReady() { }) if (checkValidity == undefined) { workWithFile(fileTruePath); + addRecentlyOpenedFile(filename,fileTruePath) window.aceEditor.session.setMode(`ace/mode/${FILE_EXTENSIONS[extension]}`) } else { alert(`file ${filename} is not valid`) } - addRecentlyOpenedFile(filename,fileTruePath,workWithFile) } + fs.root.getFile('Android/data/com.ace.code/files/settings.json', { create: true, exclusive: false @@ -101,11 +102,21 @@ export async function onDeviceReady() { fE = fileEntry readFile(fE); //SAVE FILE when saveFs btn is clicked + SAVEFS.addEventListener('click', saveFile); function saveFile() { writeFile(fE, null); } }, () => { console.log('failed to save file'); }); } + + function addRecentlyOpenedFile(name,url) { + let openedFile = makeElm('li') + insertAttr(['class=list-group-item'], openedFile) + openedFile.innerText = name + openedFile.addEventListener('click', function() { workWithFile(url) }) + + recentFilesTab.appendChild(openedFile) + } }, () => { console.log('failed to load file system'); }); } \ No newline at end of file