<commit_before>'use strict'

import { app, BrowserWindow, Menu, shell } from 'electron'
import * as windowState from 'electron-window-state'
import config from '../config'

const log = require('electron-log')
log.transports.console.level = 'info'
log.transports.file.level = 'info'

/**
 * Set `__static` path to static files in production
 * https://simulatedgreg.gitbooks.io/electron-vue/content/en/using-static-assets.html
 */
if (process.env.NODE_ENV !== 'development') {
  global.__static = require('path').join(__dirname, '/static').replace(/\\/g, '\\\\')
}

let mainWindow
const winURL = process.env.NODE_ENV === 'development'
  ? `http://localhost:9080`
  : `file://${__dirname}/index.html`

function createWindow () {
  /**
   * Initial window options
   */
  let mainWindowState = windowState({
    file: 'chistr-window-state.json',
    defaultWidth: 1200,
    defaultHeight: 800
  })

  mainWindow = new BrowserWindow({
    x: mainWindowState.x,
    y: mainWindowState.y,
    width: mainWindowState.width,
    height: mainWindowState.height
  })

  mainWindowState.manage(mainWindow)

  mainWindow.loadURL(winURL)

  mainWindow.on('closed', () => {
    mainWindow = null
  })

  createMenu()

  // Open all target="_blank" link in external browser
  // See: http://www.qcode.in/convert-vue-js-app-native-desktop-app-using-electron/
  mainWindow.webContents.on('new-window', (event, url) => {
    event.preventDefault()
    shell.openExternal(url)
  })
}

function createMenu () {
  const template = [
    {
      label: 'File',
      submenu: [
        // {
        //   label: 'Edit settings file...',
        //   click () { electronstore.openInEditor() }
        // },
        {
          label: 'Settings...',
          click () { mainWindow.webContents.send('open-settings') }
        },
        {type: 'separator'},
        {role: 'quit'}
      ]
    },
    {
      label: 'View',
      submenu: [
        {
          role: 'reload',
          accelerator: 'CmdOrCtrl+R'
        },
        {
          role: 'forcereload',
          accelerator: 'CmdOrCtrl+Shift+R'
        }
        // {
        //   role: 'toggledevtools',
        //   accelerator: 'CmdOrCtrl+Shift+I'
        // }
      ]
    },
    {
      label: 'Help',
      submenu: [
        {
          label: 'About...',
          click () { mainWindow.webContents.send('open-about') }
        }
      ]
    }
  ]

  if (config.get('app.debug')) {
    template[0].submenu.unshift({ label: 'Edit settings file...', click () { config.openInEditor() } })
    template[1].submenu.push({ role: 'toggledevtools', accelerator: 'CmdOrCtrl+Shift+I' })
  }

  if (process.platform === 'darwin') {
    template.splice(1, 0, {
      label: 'Edit',
      submenu: [
        { role: 'undo' },<commit_msg>Zoom shortcuts<commit_after>'use strict'

import { app, BrowserWindow, Menu, shell } from 'electron'
import * as windowState from 'electron-window-state'
import config from '../config'

const path = require('path')
const log = require('electron-log')
log.transports.console.level = 'info'
log.transports.file.level = 'info'

/**
 * Set `__static` path to static files in production
 * https://simulatedgreg.gitbooks.io/electron-vue/content/en/using-static-assets.html
 */
if (process.env.NODE_ENV !== 'development') {
  global.__static = path.join(__dirname, '/static').replace(/\\/g, '\\\\')
}

let mainWindow
const winURL = process.env.NODE_ENV === 'development'
  ? `http://localhost:9080`
  : `file://${__dirname}/index.html`

function createWindow () {
  /**
   * Initial window options
   */
  let mainWindowState = windowState({
    file: 'chistr-window-state.json',
    defaultWidth: 1200,
    defaultHeight: 800
  })

  mainWindow = new BrowserWindow({
    x: mainWindowState.x,
    y: mainWindowState.y,
    width: mainWindowState.width,
    height: mainWindowState.height
  })

  mainWindowState.manage(mainWindow)

  mainWindow.loadURL(winURL)

  mainWindow.on('closed', () => {
    mainWindow = null
  })

  createMenu()

  // Open all target="_blank" link in external browser
  // See: http://www.qcode.in/convert-vue-js-app-native-desktop-app-using-electron/
  mainWindow.webContents.on('new-window', (event, url) => {
    event.preventDefault()
    shell.openExternal(url)
  })
}

function createMenu () {
  const template = [
    {
      label: 'File',
      submenu: [
        // {
        //   label: 'Edit settings file...',
        //   click () { electronstore.openInEditor() }
        // },
        {
          label: 'Settings...',
          click () { mainWindow.webContents.send('open-settings') }
        },
        {type: 'separator'},
        {role: 'quit'}
      ]
    },
    {
      label: 'View',
      submenu: [
        {
          role: 'reload',
          accelerator: 'CmdOrCtrl+R'
        },
        {
          role: 'forcereload',
          accelerator: 'CmdOrCtrl+Shift+R'
        },
        {
          type: 'separator'
        },
        {
          role: 'zoomin',
          accelerator: 'CmdOrCtrl+plus'
        },
        {
          role: 'zoomout',
          accelerator: 'CmdOrCtrl+Shift+-'
        }
        // {
        //   role: 'toggledevtools',
        //   accelerator: 'CmdOrCtrl+Shift+I'
        // }
      ]
    },
    {
      label: 'Help',
      submenu: [
        {
          label: 'About...',
          click () { mainWindow.webContents.send('open-about') }
        }
      ]
    }
  ]

  if (config.get('app.debug')) {
    template[0].submenu.unshift({ label: 'Edit settings file...', click () { config.openInEditor() } })
    template[1].submenu.push({ type: 'separator' })
    template[1].submenu.push({ role: 'toggledevtools', accelerator: 'CmdOrCtrl+Shift+I' })
  }

  if (process.platform === 'darwin') {
    template.splice(1, 0, {
      label: 'Edit',
      submenu: [
        { role: 'undo' },
{'fraction_non_alphanumeric': 0.1648389307745031, 'fraction_numerical': 0.005311857436600411, 'mean_word_length': 2.24819143016138, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2438188', 'n_tokens_mistral': 1921, 'n_tokens_neox': 1859, 'n_words': 337}