diff --git a/src/public/javascripts/api.js b/src/public/javascripts/script_api.js similarity index 64% rename from src/public/javascripts/api.js rename to src/public/javascripts/script_api.js index 247586f9f..8038e795c 100644 --- a/src/public/javascripts/api.js +++ b/src/public/javascripts/script_api.js @@ -1,25 +1,3 @@ -function ScriptContext(startNote, allNotes) { - const modules = {}; - - return { - modules: modules, - notes: utils.toObject(allNotes, note => [note.noteId, note]), - apis: utils.toObject(allNotes, note => [note.noteId, ScriptApi(startNote, note)]), - require: moduleNoteIds => { - return moduleName => { - const candidates = allNotes.filter(note => moduleNoteIds.includes(note.noteId)); - const note = candidates.find(c => c.title === moduleName); - - if (!note) { - throw new Error("Could not find module note " + moduleName); - } - - return modules[note.noteId].exports; - } - } - }; -} - function ScriptApi(startNote, currentNote) { const $pluginButtons = $("#plugin-buttons"); diff --git a/src/public/javascripts/script_context.js b/src/public/javascripts/script_context.js new file mode 100644 index 000000000..bf8ee68ef --- /dev/null +++ b/src/public/javascripts/script_context.js @@ -0,0 +1,21 @@ +function ScriptContext(startNote, allNotes) { + const modules = {}; + + return { + modules: modules, + notes: utils.toObject(allNotes, note => [note.noteId, note]), + apis: utils.toObject(allNotes, note => [note.noteId, ScriptApi(startNote, note)]), + require: moduleNoteIds => { + return moduleName => { + const candidates = allNotes.filter(note => moduleNoteIds.includes(note.noteId)); + const note = candidates.find(c => c.title === moduleName); + + if (!note) { + throw new Error("Could not find module note " + moduleName); + } + + return modules[note.noteId].exports; + } + } + }; +} \ No newline at end of file diff --git a/src/views/index.ejs b/src/views/index.ejs index cedc2ed11..f07375e32 100644 --- a/src/views/index.ejs +++ b/src/views/index.ejs @@ -555,7 +555,8 @@ - + +