Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
jeffalo
GitHub Repository: jeffalo/kahoot-gui
Path: blob/master/main.js
1754 views
1
const { app, BrowserWindow, globalShortcut } = require("electron");
2
//const yeeter = require('./yeeter.js');
3
// Keep a global reference of the window object, if you don't, the window will
4
// be closed automatically when the JavaScript object is garbage collected.
5
let win;
6
7
function createWindow() {
8
// Create the browser window.
9
win = new BrowserWindow({
10
width: 800,
11
height: 625,
12
frame: false,
13
webPreferences: {
14
nodeIntegration: true
15
}
16
});
17
18
// and load the index.html of the app.
19
win.loadFile("index.html");
20
21
// Open the DevTools.
22
//win.webContents.openDevTools()
23
24
// Emitted when the window is closed.
25
win.on("close", () => {
26
// Dereference the window object, usually you would store windows
27
// in an array if your app supports multi windows, this is the time
28
// when you should delete the corresponding element.
29
// Unregiste all shortcuts when app is closed
30
globalShortcut.unregisterAll();
31
win = null;
32
});
33
}
34
35
// This method will be called when Electron has finished
36
// initialization and is ready to create browser windows.
37
// Some APIs can only be used after this event occurs.
38
app.on("ready", () => {
39
// Create shortcuts for stealth mode on app ready
40
const hideWindowShortcut = globalShortcut.register(
41
"CommandOrControl+Shift+P",
42
() => {
43
win.hide();
44
}
45
);
46
const showWindowShortcut = globalShortcut.register(
47
"CommandOrControl+P",
48
() => {
49
win.show();
50
}
51
);
52
createWindow();
53
});
54
55
// Quit when all windows are closed.
56
app.on("window-all-closed", () => {
57
// On macOS it is common for applications and their menu bar
58
// to stay active until the user quits explicitly with Cmd + Q
59
if (process.platform !== "darwin") {
60
app.quit();
61
}
62
});
63
64
app.on("activate", () => {
65
// On macOS it's common to re-create a window in the app when the
66
// dock icon is clicked and there are no other windows open.
67
if (win === null) {
68
createWindow();
69
}
70
});
71
72
// In this file you can include the rest of your app's specific main process
73
// code. You can also put them in separate files and require them here.
74
75