This repository has been archived by the owner on Nov 8, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.js
147 lines (115 loc) · 3.4 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
/**
* This is the file handling the startup and lifetime of the game
* running in Electron Runtime.
*/
// Modules to control application life and create native browser window
const { app, BrowserWindow, shell, Menu } = require("electron");
// Menu.setApplicationMenu(false);
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let mainWindow = null;
function createWindow() {
// Create the browser window.
mainWindow = new BrowserWindow({
width: 1980,
height: 1080,
useContentSize: true,
title: "embTools",
backgroundColor: '#ffffff',
icon: path.join(__dirname, 'logo/favIcon-32x32.png')
});
// Open external link in the OS default browser
// mainWindow.webContents.on("new-window", function(e, url) {
// e.preventDefault();
// shell.openExternal(url);
// });
// and load the index.html of the app.
mainWindow.loadFile("embTools.html");
// Open the DevTools.
// mainWindow.webContents.openDevTools()
// Emitted when the window is closed.
mainWindow.on("closed", function() {
mainWindow = null;
});
const mainMenu = Menu.buildFromTemplate(menuTemplate)
Menu.setApplicationMenu(mainMenu)
}
// Functions for Secondary Windows
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.on("ready", createWindow);
// Quit when all windows are closed.
app.on("window-all-closed", function() {
app.quit();
});
// Menu Template
const menuTemplate = [
{
label: 'Menu',
submenu: [
{label: 'Notes', click(){notes()},
accelerator: 'Ctrl+N'},
{label: 'Unit Conversions', click(){conversions()},
accelerator: 'Ctrl+U'},
{label: 'Stitch Run Timer', click(){timer()},
accelerator: 'Ctrl+R'},
{label: 'Quote', click(){quote()},
accelerator: 'Ctrl+Q'},
{type: 'separator'},
{label: 'Quit', click(){app.quit()},
accelerator: 'Ctrl+X'}
]
},
{label: 'About',
submenu: [
{label: 'About embTools', click(){about()}}
]
}
]
// Menu Functions
// Notes Menu Function
function notes(){
mainWindow.loadFile("notes/notes.html");
mainWindow.on("closed", function() {
mainWindow = null;
});
};
// Unit Conversions Menu Function
function conversions(){
mainWindow.loadFile("unitConversion/unitconversions.html");
mainWindow.on("closed", function() {
mainWindow = null;
});
};
// Stitch Run Timer Menu Function
function timer(){
mainWindow.loadFile("stitchTimer/stitchtimer.html");
mainWindow.on("closed", function() {
mainWindow = null;
});
};
// Quote Menu Function
function quote(){
mainWindow.loadFile("quickQuotes/quickQuote.html");
mainWindow.on("closed", function() {
mainWindow = null;
});
};
// About embTools Program
function about(){
aboutWindow = new BrowserWindow({
width: 566,
height: 725,
useContentSize: true,
title: "about embTools",
backgroundColor: '#ffffff',
frame: false,
parent: mainWindow,
icon: path.join(__dirname, 'logo/favIcon-32x32.png')
});
aboutWindow.loadFile("about/about.html");
aboutWindow.on("closed", function() {
aboutWindow = null;
});
};