common JS module system prototype

This commit is contained in:
azivner
2018-03-04 10:32:53 -05:00
parent 83d6c2970f
commit 7a865a9081
5 changed files with 71 additions and 16 deletions

View File

@@ -9,12 +9,21 @@ const config = require('./config');
const Repository = require('./repository');
const axios = require('axios');
function ScriptContext(dataKey) {
function ScriptContext(dataKey, note, allNotes) {
dataKey = protected_session.getDataKey(dataKey);
const repository = new Repository(dataKey);
this.axios = axios;
this.__startNote = note;
this.__notes = {};
if (allNotes) {
allNotes.forEach(note => this.__notes[note.noteId] = note);
}
this.__modules = {};
this.utils = {
unescapeHtml: utils.unescapeHtml,
isoDateTimeStr: utils.dateStr