Passed
Push — master ( 50e407...d83b42 )
by Magnus
20:39 queued 19:12
created

mainWindow.js ➔ ... ➔ ???   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
c 2
b 0
f 0
nc 1
dl 0
loc 4
rs 10
nop 2
1
"use strict";
2
3
const {
4
    BrowserWindow,
5
    TouchBar
6
} = require('electron');
7
8
9
const path = require('path');
10
const url = require('url');
11
12
const touchbar = require('./touchbar');
13
14
const open = require("open");
15
16
let mainWindow;
17
18
let createWindow = () => {
19
    // Create the browser window.
20
    mainWindow = new BrowserWindow({
21
        width: 800,
22
        height: 600
23
    });
24
25
    mainWindow.maximize();
26
27
28
    // mainWindow.webContents.loadURL('http://example.com');
29
30
    // and load the index.html of the app.
31
    mainWindow.loadURL(url.format({
32
        pathname: path.join(__dirname, '../views/index.html'),
33
        protocol: 'file:',
34
        slashes: true
35
    }));
36
37
    mainWindow.webContents.on('new-window', (event, url) => {
38
        event.preventDefault();
39
        open(url);
40
    });
41
42
    // Open the DevTools.
43
    mainWindow.webContents.openDevTools();
44
45
    touchbar.setMainWindow(mainWindow);
46
    mainWindow.setTouchBar(touchbar.touchBar);
47
    //
48
49
50
    // Emitted when the window is closed.
51
    mainWindow.on('closed', () => {
52
        // Dereference the window object, usually you would store windows
53
        // in an array if your app supports multi windows, this is the time
54
        // when you should delete the corresponding element.
55
        mainWindow = null;
56
    });
57
};
58
59
module.exports = {
60
    createWindow: createWindow
61
};
62