-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
79 lines (59 loc) · 1.78 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
const electron=require('electron');
const app=electron.app;
const path=require('path');
const url=require('url');
const browser=electron.BrowserWindow;
const fs=require('fs');
const { Script } = require('vm');
const { getCreationTime } = require('process');
const { getDiffieHellman } = require('crypto');
const textract=require('textract');
const folder='./files/';
const ipc=electron.ipcMain;
const shell=electron.shell;
function getfile(file,keyword){
textract.fromFileWithPath(`${folder}${file}`, function( error, text ) {
if((text.search(keyword))!=-1)
{
console.log(`${folder}${file}`);
}
})
}
let win;
function createWindow(){
const newLocal = 'false';
win = new browser({webPreferences:{nodeIntegration:true}});
win.loadURL(url.format({
pathname:path.join(__dirname,'index.html'),
protocol:'file',
slashes:true
}));
win.webContents.openDevTools();
win.on('closed',()=>{
win=null;
})
var text2;
ipc.on('asynchronous-message',(event,text)=>
{
fs.readdir(folder,(err,files)=>{
files.forEach(file=>{
//to reject trash files of word
if(file.indexOf('~')!== 0){
textract.fromFileWithPath(`${folder}${file}`, function( error, data ) {
if(((data.search(text))!= -1)==true)
{ c=1;
event.sender.send('asynchronous-reply',`${file}`)
}
})
}
});
});
});
}
app.on('ready',createWindow);
function toggle(){
document.querySelector('#button').addEventListener('click',()=>{
document.querySelector('#body').style.backgroundColor="red";
console.log(1);
});
}