forked from CiderSqueezy/bt-desktop
-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.js
196 lines (177 loc) · 4.57 KB
/
main.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
var app = require('app'); // Module to control application life.
var BrowserWindow = require('browser-window'); // Module to create native browser window.
var shell = require('shell');
var Menu = require('menu');
// Report crashes to our server.
require('crash-reporter').start();
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the javascript object is GCed.
var mainWindow, tcWindow = null;
// Quit when all windows are closed.
app.on('window-all-closed', function() {
app.quit();
});
// This method will be called when atom-shell has done everything
// initialization and ready for creating browser windows.
app.on('ready', function() {
var template = [{
label: 'BerryTube',
submenu: [
{
label: 'About BerryTube',
selector: 'orderFrontStandardAboutPanel:'
},
{
type: 'separator'
},
{
label: 'Services',
submenu: []
},
{
type: 'separator'
},
{
label: 'Hide Atom Shell',
accelerator: 'Command+H',
selector: 'hide:'
},
{
label: 'Hide Others',
accelerator: 'Command+Shift+H',
selector: 'hideOtherApplications:'
},
{
label: 'Show All',
selector: 'unhideAllApplications:'
},
{
type: 'separator'
},
{
label: 'Quit',
accelerator: 'Command+Q',
click: function() { app.quit(); }
},
]
},
{
label: 'Edit',
submenu: [
{
label: 'Undo',
accelerator: 'Command+Z',
selector: 'undo:'
},
{
label: 'Redo',
accelerator: 'Shift+Command+Z',
selector: 'redo:'
},
{
type: 'separator'
},
{
label: 'Cut',
accelerator: 'Command+X',
selector: 'cut:'
},
{
label: 'Copy',
accelerator: 'Command+C',
selector: 'copy:'
},
{
label: 'Paste',
accelerator: 'Command+V',
selector: 'paste:'
},
{
label: 'Select All',
accelerator: 'Command+A',
selector: 'selectAll:'
},
]
},
{
label: 'View',
submenu: [
{
label: 'Reload',
accelerator: 'Command+R',
click: function() { BrowserWindow.getFocusedWindow().reloadIgnoringCache(); }
},
{
label: 'Toggle DevTools',
accelerator: 'Alt+Command+I',
click: function() { BrowserWindow.getFocusedWindow().toggleDevTools(); }
},
]
},
{
label: 'Window',
submenu: [
{
label: 'Minimize',
accelerator: 'Command+M',
selector: 'performMiniaturize:'
},
{
label: 'Close',
accelerator: 'Command+W',
selector: 'performClose:'
}
]
}];
var menu = Menu.buildFromTemplate(template);
Menu.setApplicationMenu(menu); // Must be called within app.on('ready', function(){ ... });
// Create the browser window.
mainWindow = new BrowserWindow({
width: 960,
height: 800,
center: true,
frame: false,
"auto-hide-menu-bar": true
});
mainWindow.webContents.on('new-window', function(e, url) {
console.log("NEW WINDOW", e, url)
e.preventDefault();
shell.openExternal(url);
});
// and load the index.html of the app.
mainWindow.loadUrl('file://' + __dirname + '/index.html');
// mainWindow.loadUrl("http://localhost:8080/");
// mainWindow.loadUrl("http://bt-desktop.cidersqueezy.com/");
mainWindow.on('blur', function(e) {
mainWindow.webContents.send('blur');
});
mainWindow.on('focus', function(e) {
mainWindow.webContents.send('focus');
});
// Emitted when the window is closed.
mainWindow.on('closed', function() {
// Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
mainWindow = null;
});
// tcWindow = new BrowserWindow({
// width: 960,
// height: 590,
// 'web-preferences':{
// 'plugins': true
// },
// frame: false,
// "auto-hide-menu-bar": true
// });
// tcWindow.webContents.on('new-window', function(e, url) {
// e.preventDefault();
// });
// tcWindow.webContents.on('did-finish-load', function(e, url) {
// tcWindow.webContents.insertCSS("#left_block, html, body, #tinychat, #tinychat_sub, #wrapper, #page, #container, #room, #chat {width: 100% !important; height: 100% !important; box-sizing: border-box; margin: 0; padding: 0 !important;} #iframe_ad, #header, #room_header, #share-bar, #footer {display: none;} body {width: calc(100% + 282px) !important; overflow: hidden; left: -8px; position: relative; top: -12px; height: calc(100% + 93px) !important; } body:after {content: ''; position: absolute; top: 0; left: 240px; height: 54px; width: calc(100% - 576px); -webkit-app-region: drag; cursor: move;}");
// });
// tcWindow.loadUrl("http://tinychat.com/berrytube");
// tcWindow.on('closed', function() {
// tcWindow = null;
// });
});