-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.js
73 lines (62 loc) · 1.96 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
'use strict';
const path = require('path');
const fs = require('fs');
const app = require('app');
const BrowserWindow = require('browser-window');
const shell = require('shell');
const Menu = require('menu');
const appMenu = require('./menu');
require('electron-debug')();
require('crash-reporter').start();
let mainWindow;
function createMainWindow() {
const win = new BrowserWindow({
'title': app.getName(),
'show': false,
'width': 400,
'height': 600,
'icon': path.join(__dirname, 'media', 'Icon.png'),
'min-width': 400,
'min-height': 600,
'transparent': true,
'frame': true,
'resizable':false,
'title':'Cyberoam Client',
'title-bar-style': 'hidden-inset',
'web-preferences': {
// fails without this because of CommonJS script detection
'node-integration': false,
'preload': path.join(__dirname, '/js/browser.js'),
'web-security': true, //set it false for testing
'plugins': true
}
});
win.setTitle("title");
win.loadUrl('http://172.50.1.1:8090/httpclient.html');
win.on('closed', app.quit);
// win.on('page-title-updated', (e, title) => updateBadge(title));
return win;
}
app.on('ready', () => {
Menu.setApplicationMenu(appMenu);
mainWindow = createMainWindow();
const page = mainWindow.webContents;
page.on('dom-ready', () => {
page.insertCSS(fs.readFileSync(path.join(__dirname, 'css/browser.css'), 'utf8'));
page.insertCSS(fs.readFileSync(path.join(__dirname, 'css/sweet.css'), 'utf8'));
page.executeJavaScript(fs.readFileSync(path.join(__dirname, 'js/jquery.js'), 'utf8'));
page.executeJavaScript(fs.readFileSync(path.join(__dirname, 'js/main.js'), 'utf8'));
page.executeJavaScript(fs.readFileSync(path.join(__dirname, 'js/sweet.js'), 'utf8'));
mainWindow.show();
});
page.on('did-finish-load',() => {
mainWindow.setTitle("Cyberoam Client");
});
page.on('did-fail-load',() => {
console.log("Failed to load");
});
page.on('new-window', (e, url) => {
e.preventDefault();
shell.openExternal(url);
});
});