aboutsummaryrefslogtreecommitdiff
path: root/modules/ext/mindmap.js
diff options
context:
space:
mode:
Diffstat (limited to 'modules/ext/mindmap.js')
-rw-r--r--modules/ext/mindmap.js20
1 files changed, 11 insertions, 9 deletions
diff --git a/modules/ext/mindmap.js b/modules/ext/mindmap.js
index 30d6889..9f62cba 100644
--- a/modules/ext/mindmap.js
+++ b/modules/ext/mindmap.js
@@ -166,7 +166,9 @@ class MindmapModule {
if (!args[0]) return this.terminal.print('Usage: mindmap save <name>', 'warning');
if (!this.root) return this.terminal.print('No mindmap to save.', 'warning');
try {
- localStorage.setItem('webx11_mindmap_' + args[0], JSON.stringify(this.root));
+ const fs = this.terminal.fs;
+ fs.mkdirRecursive('/mindmaps');
+ fs.writeFile('/mindmaps/' + args[0] + '.json', JSON.stringify(this.root, null, 2));
this.terminal.print('Mindmap saved as: ' + args[0], 'success');
} catch (e) {
this.terminal.print('Failed to save: ' + e.message, 'error');
@@ -175,7 +177,8 @@ class MindmapModule {
_load(args) {
if (!args[0]) return this.terminal.print('Usage: mindmap load <name>', 'warning');
try {
- const data = localStorage.getItem('webx11_mindmap_' + args[0]);
+ const fs = this.terminal.fs;
+ const data = fs.readFile('/mindmaps/' + args[0] + '.json');
if (!data) return this.terminal.print('No saved mindmap: ' + args[0], 'error');
this.root = JSON.parse(data);
this.terminal.print('Loaded mindmap: ' + args[0] + ' (' + this._countNodes(this.root) + ' nodes)', 'success');
@@ -184,18 +187,17 @@ class MindmapModule {
}
}
_list() {
- const keys = [];
- for (let i = 0; i < localStorage.length; i++) {
- const k = localStorage.key(i);
- if (k && k.startsWith('webx11_mindmap_')) keys.push(k.replace('webx11_mindmap_', ''));
- }
+ const fs = this.terminal.fs;
+ const files = fs.readDir('/mindmaps') || [];
+ const keys = files.filter(f => f.name.endsWith('.json')).map(f => f.name.replace('.json', ''));
if (!keys.length) return this.terminal.print('No saved mindmaps.', 'info');
this.terminal.print('=== Saved Mindmaps ===', 'info');
keys.forEach(k => this.terminal.print(' ' + k));
}
_delete(args) {
if (!args[0]) return this.terminal.print('Usage: mindmap delete <name>', 'warning');
- localStorage.removeItem('webx11_mindmap_' + args[0]);
+ const fs = this.terminal.fs;
+ fs.deleteFile('/mindmaps/' + args[0] + '.json');
this.terminal.print('Deleted mindmap: ' + args[0], 'success');
}
_rename(args) {
@@ -232,5 +234,5 @@ class MindmapModule {
}
}
if (typeof window.webx11 !== 'undefined' && window.webx11) {
- webx11.moduleManager.registerModule(new MindmapModule(), 'https://webx11.duckdns.org/spaces/chatstudio/newos4/modules/mindmap.js');
+ webx11.moduleManager.registerModule(new MindmapModule(), 'https://webx11.duckdns.org/spaces/newos4/modules/ext/mindmap.js');
}