From 3a1330c8fd9fa2c74860c1d927f3f1c5ed857010 Mon Sep 17 00:00:00 2001 From: Leonard Oest O'Leary Date: Fri, 21 Jan 2022 00:06:08 -0500 Subject: [PATCH 1/5] fix bug with reveal.js going on first slide --- include/fs.js | 1 - 1 file changed, 1 deletion(-) diff --git a/include/fs.js b/include/fs.js index 41610516..86ef29d6 100644 --- a/include/fs.js +++ b/include/fs.js @@ -390,7 +390,6 @@ CodeBootFileSystem.prototype.newMenuItem = function (elem, cls, text) { var item = document.createElement('a'); item.className = cls; - item.href = '#'; var span = document.createElement('span'); span.innerText = text; From 88c1c53b5f6b0e6064275471528f1ff23049d4b2 Mon Sep 17 00:00:00 2001 From: Leonard Oest O'Leary Date: Fri, 21 Jan 2022 00:08:41 -0500 Subject: [PATCH 2/5] fix bug creating infinite files --- include/fs.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/include/fs.js b/include/fs.js index 86ef29d6..5bd92c0e 100644 --- a/include/fs.js +++ b/include/fs.js @@ -684,6 +684,21 @@ CodeBootFileSystem.prototype.openFileExistingOrNew = function (filename) { } }; +CodeBootFileSystem.prototype.openFileWithContentOrNew = function (content){ + + for (var filename in fs.files) { + file_content = fs.files[filename].getContent(); + if (content == file_content) { + fs.openFile(filename) + return true + } + } + + fs.newFile(undefined, content) + return false + +} + CodeBootFileSystem.prototype.removeAllEditors = function () { var fs = this; fs.fem.removeAllEditors(); From 299b070151f60ddb8d3b92abf1a34e8c41907bfc Mon Sep 17 00:00:00 2001 From: Leonard Oest O'Leary Date: Fri, 21 Jan 2022 01:24:28 -0500 Subject: [PATCH 3/5] Adding syntax to create files --- include/codeboot.js | 10 +++++++--- include/fs.js | 48 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 3 deletions(-) diff --git a/include/codeboot.js b/include/codeboot.js index d1aec79c..a74ec97f 100644 --- a/include/codeboot.js +++ b/include/codeboot.js @@ -2967,7 +2967,12 @@ CodeBootVM.prototype.initRoot = function (opts, floating) { vm.setAttribute('data-cb-editable', vm.editable); if (content !== null) { - vm.fs.newFile(filename, content); + if (vm.editable){ + vm.fs.parseContentIntoFiles(filename, content) + } + else{ + vm.fs.openFileWithContentOrNew(content) + } } // In order to resize the repl's height, the CodeMirror-scroll @@ -2998,8 +3003,7 @@ CodeBootVM.prototype.initRoot = function (opts, floating) { if (vm.root.tagName === 'PRE') { - - content = vm.root.innerText; + content = $.trim(vm.root.innerText); var elem = document.createElement('div'); elem.className = 'cb-vm'; diff --git a/include/fs.js b/include/fs.js index 5bd92c0e..979878a2 100644 --- a/include/fs.js +++ b/include/fs.js @@ -686,6 +686,8 @@ CodeBootFileSystem.prototype.openFileExistingOrNew = function (filename) { CodeBootFileSystem.prototype.openFileWithContentOrNew = function (content){ + var fs = this; + for (var filename in fs.files) { file_content = fs.files[filename].getContent(); if (content == file_content) { @@ -704,6 +706,52 @@ CodeBootFileSystem.prototype.removeAllEditors = function () { fs.fem.removeAllEditors(); }; +CodeBootFileSystem.prototype.parseContentIntoFiles = function (filename, content){ + + var fs = this; + + var lines = $.trim(content).split("\n") + var files = [] + var content = "" + + for (let line of lines){ + line = $.trim(line) + if (line.length > 0 && line[0] === "#"){ + + i = 1; + while (line.length > i && line[i] === "#") i++ + while (line.length > i && line[i] === " ") i++ + + if (line.length > i + 5 && line.substring(i, i+5).toLowerCase() === "file:"){ + content = $.trim(content) + if (content.length > 0) files.push([filename, content]) + content = "" + filename = $.trim(line.substring(i+5, line.length)) + } + + } + else { + content += line + "\n" + } + + } + + content = $.trim(content) + if (content.length > 0) files.push([filename, content]) + + for (file of files){ + filename = file[0] + content = file[1] + + if (filename === undefined){ + fs.openFileWithContentOrNew(content) + } + else{ + fs.newFile(filename, content) + } + } +} + //----------------------------------------------------------------------------- function CodeBootFileEditorManager(fs) { From cb3176fc3fd515fd257267ade1f54a002c2068d2 Mon Sep 17 00:00:00 2001 From: Leonard Oest O'Leary Date: Fri, 21 Jan 2022 01:33:17 -0500 Subject: [PATCH 4/5] Removing unused '#' in href --- include/codeboot.js | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/include/codeboot.js b/include/codeboot.js index a74ec97f..810851ac 100644 --- a/include/codeboot.js +++ b/include/codeboot.js @@ -1260,8 +1260,8 @@ CodeBootVM.prototype.menuLangHTML = function () { \ \ '; @@ -1312,24 +1312,24 @@ CodeBootVM.prototype.menuSettingsHTML = function () { \ \ From 7a7b27b033e18dfe4840833a7e8775d7d7d749aa Mon Sep 17 00:00:00 2001 From: Leonard Oest O'Leary Date: Fri, 21 Jan 2022 01:38:03 -0500 Subject: [PATCH 5/5] Forgot one # --- include/codeboot.js | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/include/codeboot.js b/include/codeboot.js index 810851ac..e7fd71ed 100644 --- a/include/codeboot.js +++ b/include/codeboot.js @@ -1279,7 +1279,7 @@ CodeBootVM.prototype.menuSettingsLangHTML = function () { var name = levels[level]; var id_and_level = id + '-' + level; var svg = lang.prototype.getSVG(level, false); - html += '' + vm.SVG['checkmark'] + '  ' + svg.onLight + '  ' + name + ''; @@ -1343,15 +1343,15 @@ CodeBootVM.prototype.menuContextHTML = function () { return '\n\ \n\ '; @@ -1412,13 +1412,13 @@ CodeBootVM.prototype.helpHTML = function () { \ \ \ @@ -2306,13 +2306,13 @@ CodeBootVM.prototype.helpHTML = function () { \ \ \