diff --git a/docs/index.html b/docs/index.html
index 0c4beb1..ed97631 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -5,15 +5,7 @@
memex
-
-
-
diff --git a/docs/logic/main.js b/docs/logic/main.js
index 7e20ece..d02afcb 100644
--- a/docs/logic/main.js
+++ b/docs/logic/main.js
@@ -7,18 +7,17 @@ function Main()
this.queryPrev = '';
this.queryCur = '';
var parent = this;
+ const FILELOCATION = 'content/data.ndtl';
this.install = function()
{
- let dbLoaded = false;
- const FILELOCATION = 'content/data.ndtl';
var client = new XMLHttpRequest();
client.open('GET', FILELOCATION);
client.onreadystatechange = function()
{
- if (!dbLoaded && client.responseText.trim() != '')
+ if (client.responseText.trim() != '')
{
- dbLoaded = true;
+ client.onreadystatechange = null;
parent.setup(client.responseText);
}
}
diff --git a/main.js b/main.js
index 8a8f9f8..8e47962 100644
--- a/main.js
+++ b/main.js
@@ -29,10 +29,27 @@ app.toggle_fullscreen = function()
app.toggle_visible = function()
{
- if(process.platform == "win32"){
- if(!app.win.isMinimized()){ app.win.minimize(); } else{ app.win.restore(); }
- } else {
- if(is_shown){ app.win.hide(); } else{ app.win.show(); }
+ if(process.platform == "win32")
+ {
+ if(!app.win.isMinimized())
+ {
+ app.win.minimize();
+ }
+ else
+ {
+ app.win.restore();
+ }
+ }
+ else
+ {
+ if(is_shown)
+ {
+ app.win.hide();
+ }
+ else
+ {
+ app.win.show();
+ }
}
}
@@ -50,34 +67,33 @@ app.win = null;
app.on('ready', () =>
{
- app.win = new BrowserWindow({
- webPreferences: {
- nodeIntegration: true
- }, width: 950, height: 950, backgroundColor:"#ddd", minWidth: 587, minHeight: 540, frame:true, autoHideMenuBar: true, icon: __dirname + '/icon.ico'})
+ app.win = new BrowserWindow(
+ {
+ webPreferences:
+ {
+ nodeIntegration: true,
+ preload: path.join(__dirname, 'preload.js')
+ }, width: 950, height: 950, backgroundColor:"#ddd", minWidth: 587, minHeight: 540, frame:true, autoHideMenuBar: true, icon: __dirname + '/icon.ico'
+ })
app.win.loadURL(`file://${__dirname}/docs/index.html`);
- // app.win.toggleDevTools();
- app.win.on('closed', () => {
+ app.win.on('closed', () =>
+ {
win = null
app.quit()
})
- app.win.on('hide',function() {
+ app.win.on('hide', function()
+ {
is_shown = false;
})
- app.win.on('show',function() {
+ app.win.on('show', function()
+ {
is_shown = true;
})
- // app.win.webContents.on('new-window', function(event, url){
- // event.preventDefault();
- // // open(url);
- // console.log('CALLED NEW WIN');
- // child_process.execSync('start ' + url)
- // })
-
app.win.webContents.on('will-navigate', this.handleRedirect)
app.win.webContents.on('new-window', this.handleRedirect)
})
@@ -87,7 +103,8 @@ app.on('window-all-closed', () =>
app.quit()
})
-app.on('activate', () => {
+app.on('activate', () =>
+{
if (app.win === null) {
createWindow()
}
@@ -95,36 +112,8 @@ app.on('activate', () => {
ipcMain.on('write', (event, arg) =>
{
- // var fileLength = fs.statSync(FILELOCATION)['size'];
- // console.log('Write called! Length = ' + fileLength);
- // console.log('Write called! Entry = ' + arg);
-
- // const stream = fs.createReadStream(FILELOCATION, { encoding: 'utf8' });
- // stream.on('data', data => {
- // header = data.split(/\n/)[0];
- // stream.destroy();
- // });
- // stream.on('close', () => {
- // console.timeEnd(label);
- // resolve();
- // });
-
- // fs.readFile(FILELOCATION, "utf8",
- // function(err, data)
- // {
- // console.log(data);
- // var position = data.lastIndexOf('`');
- // console.log('Write called! position = ' + position);
-
- // let fileStream = fs.openSync(FILELOCATION, 'r+');
- // // let buf = new Buffer(arg);
- // let buf = new Buffer('_____HERE_____');
- // fs.writeSync(fileStream, buf, 0, buf.length, position);
- // fs.close(fileStream);
- // }
- // );
-
- fs.appendFile(FILELOCATION, arg, function (err) {
+ fs.appendFile(FILELOCATION, arg, function (err)
+ {
if (err) throw err;
console.log('Saved!');
});
diff --git a/preload.js b/preload.js
new file mode 100644
index 0000000..2456569
--- /dev/null
+++ b/preload.js
@@ -0,0 +1,4 @@
+window.nodeRequire = require;
+delete window.require;
+delete window.exports;
+delete window.module;
\ No newline at end of file