mirror of
https://github.com/TangentFoxy/memex.git
synced 2024-11-22 04:54:23 +00:00
Refactor. Clean up and fixing electron version write functionality breaking web version.
This commit is contained in:
parent
dfc294ad86
commit
8d2eed7f3c
@ -5,15 +5,7 @@
|
||||
<title>memex</title>
|
||||
<link rel="stylesheet" href="asset/style.css">
|
||||
<link rel="stylesheet" href="asset/fontawesome/css/all.css">
|
||||
<!-- <meta name="viewport" content="width=device-width, initial-scale=1.0"> -->
|
||||
|
||||
<script>
|
||||
window.nodeRequire = require;
|
||||
delete window.require;
|
||||
delete window.exports;
|
||||
delete window.module;
|
||||
</script>
|
||||
|
||||
<script src="logic/lib/imagesloaded.js"></script>
|
||||
<script src="logic/lib/masonry.js"></script>
|
||||
<script src="logic/lib/runic.js"></script>
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
89
main.js
89
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!');
|
||||
});
|
||||
|
4
preload.js
Normal file
4
preload.js
Normal file
@ -0,0 +1,4 @@
|
||||
window.nodeRequire = require;
|
||||
delete window.require;
|
||||
delete window.exports;
|
||||
delete window.module;
|
Loading…
Reference in New Issue
Block a user