diff --git a/docs/content/data.ndtl b/docs/content/data.ndtl index 1eb6aa3..fca65f1 100644 --- a/docs/content/data.ndtl +++ b/docs/content/data.ndtl @@ -2236,11 +2236,21 @@ ON ICONS LINK : https://ia.net/topics/on-icons PERS : rutherford SRCE : Merveilles + TAGS : design TURBO + DATE : 12018-08-05 + TYPE : term + TAGS : car TERM > Turbo: compressor forcing additional air into an engine to allow for increased fuel ignition and thus increased power output. A turbo has two halves, one is driven by the exhaust from the engine the other forces air into the engine. Negative 'turbo lag' time until the engine can provide enough exhaust to spin up the turbo compressor. > Supercharger: Like a turbo but instead of being driven by exhaust gas it is driven mechanically (belt to engine). Negative Takes power/efficiency away from driving engine output in order to drive the compressor. > Electic supercharger: fully electronically driven turbo (generally powered by a higher voltage (48v) seperate from car 12v). Negative high electricity use. > Electic turbo: a hybrid electric-assisted turbo (generally powered by a higher voltage (48v) seperate from car 12v) using a DC motor to start the turbo spinning sooner to remove turbo lag or at low revs when not enough exhaust to produced. Once the engine is providing enough exhaust to spin the turbo the motor will stop output. It can also be a seperate electric supercharger working in conjunction with a standard turbo. Negative complexity. + +ELECTRON IPC + DATE : 12018-08-06 + LINK : https://ourcodeworld.com/articles/read/537/how-to-execute-a-function-of-the-main-process-inside-the-renderer-process-in-electron-framework + PROJ : Memex + TAGS : web, code ` \ No newline at end of file diff --git a/docs/logic/add.js b/docs/logic/add.js index 8cbe0f7..f306bea 100644 --- a/docs/logic/add.js +++ b/docs/logic/add.js @@ -94,15 +94,8 @@ function Add() document.getElementById("enter").addEventListener('click', () => { - console.log('test test'); - // ipcRenderer.send('write', 'test'); - let Data = - { - message: "Hi", - someData: "Let's go" - }; - - ipcRenderer.send('request-mainprocess-action', Data); + console.log('called write'); + ipcRenderer.send('write', '
'+this.display.innerHTML); }); for (var i = 0; i < this.keys.length; i++) diff --git a/foo.txt b/foo.txt new file mode 100644 index 0000000..e2e107a --- /dev/null +++ b/foo.txt @@ -0,0 +1 @@ +123456789 \ No newline at end of file diff --git a/main.js b/main.js index 1846484..6285a48 100644 --- a/main.js +++ b/main.js @@ -3,6 +3,7 @@ const path = require('path') const url = require('url') const shell = require('electron').shell; const fs = require('fs'); +const { ipcMain } = require('electron'); let is_shown = true; @@ -54,24 +55,6 @@ app.on('ready', () => }, 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.webContents.on('did-finish-load', () => { - // let code = ` - // console.log("3"); - // document.getElementById("enter").addEventListener("click", - // function (e) - // { - // let foo = fs.openSync('foo.txt','r+'); - // let buf = new Buffer("hello"); - // fs.writeSync(foo, buf, 0, buf.length, 5); - // fs.close(foo); - // console.log('WROTE!'); - - // console.log(document.getElementById("display").value); - // });`; - // app.win.webContents.executeJavaScript(code); - // }); - // app.win.toggleDevTools(); app.win.on('closed', () => { @@ -109,25 +92,12 @@ app.on('activate', () => { } }) -// write = function(data) -// { -// let foo = fs.openSync('foo.txt','r+'); -// let buf = new Buffer("hello"); -// fs.writeSync(foo, buf, 0, buf.length, 5); -// fs.close(foo); -// console.log('WROTE!'); -// } +ipcMain.on('write', (event, arg) => +{ + console.log('Write called! Entry = ' + arg); -const {ipcMain} = require('electron'); - -// Attach listener in the main process with the given ID -ipcMain.on('request-mainprocess-action', (event, arg) => { - // Displays the object sent from the renderer process: - //{ - // message: "Hi", - // someData: "Let's go" - //} - console.log( - arg - ); + let foo = fs.openSync('foo.txt','r+'); + let buf = new Buffer(arg); + fs.writeSync(foo, buf, 0, buf.length, 5); + fs.close(foo); }); \ No newline at end of file