<commit_before>var config = require('../config')
var debug = require('debug')('webtorrent-app:menu')
var electron = require('electron')
var windows = require('./windows')

var app = electron.app

function toggleFullScreen (flag) {
  debug('toggleFullScreen %s', flag)
  if (windows.main && windows.main.isVisible()) {
    flag = flag != null ? flag : !windows.main.isFullScreen()
    windows.main.setFullScreen(flag)
  }
}

// Sets whether the window should always show on top of other windows
function toggleFloatOnTop (flag) {
  debug('toggleFloatOnTop %s', flag)
  if (windows.main) {
    flag = flag != null ? flag : !windows.main.isAlwaysOnTop()
    windows.main.setAlwaysOnTop(flag)
    getMenuItem('Float on Top').checked = flag
  }
}

function toggleDevTools () {
  debug('toggleDevTools')
  if (windows.main) {
    windows.main.toggleDevTools()
  }
}

function reloadWindow () {
  debug('reloadWindow')
  if (windows.main) {
    app.startTime = Date.now()
    windows.main.webContents.reloadIgnoringCache()
  }
}

function addFakeDevice (device) {
  debug('addFakeDevice %s', device)
  windows.main.send('addFakeDevice', device)
}

function onWindowShow () {
  debug('onWindowShow')
  getMenuItem('Full Screen').enabled = true
  getMenuItem('Float on Top').enabled = true
}

function onWindowHide () {
  debug('onWindowHide')
  getMenuItem('Full Screen').enabled = false
  getMenuItem('Float on Top').enabled = false
}

function onToggleFullScreen () {
function onToggleFullScreen (isFullScreen) {
  isFullScreen = isFullScreen != null ? isFullScreen : windows.main.isFullScreen()
  windows.main.setMenuBarVisibility(!isFullScreen)
  getMenuItem('Full Screen').checked = isFullScreen
  windows.main.send('fullscreenChanged', isFullScreen)
}

function getMenuItem (label) {
  for (var i = 0; i < appMenu.items.length; i++) {
    var menuItem = appMenu.items[i].submenu.items.find(function (item) {
      return item.label === label
    })
    if (menuItem) return menuItem
  }<commit_msg>fix bad merge<commit_after>var config = require('../config')
var debug = require('debug')('webtorrent-app:menu')
var electron = require('electron')
var windows = require('./windows')

var app = electron.app

function toggleFullScreen (flag) {
  debug('toggleFullScreen %s', flag)
  if (windows.main && windows.main.isVisible()) {
    flag = flag != null ? flag : !windows.main.isFullScreen()
    windows.main.setFullScreen(flag)
  }
}

// Sets whether the window should always show on top of other windows
function toggleFloatOnTop (flag) {
  debug('toggleFloatOnTop %s', flag)
  if (windows.main) {
    flag = flag != null ? flag : !windows.main.isAlwaysOnTop()
    windows.main.setAlwaysOnTop(flag)
    getMenuItem('Float on Top').checked = flag
  }
}

function toggleDevTools () {
  debug('toggleDevTools')
  if (windows.main) {
    windows.main.toggleDevTools()
  }
}

function reloadWindow () {
  debug('reloadWindow')
  if (windows.main) {
    app.startTime = Date.now()
    windows.main.webContents.reloadIgnoringCache()
  }
}

function addFakeDevice (device) {
  debug('addFakeDevice %s', device)
  windows.main.send('addFakeDevice', device)
}

function onWindowShow () {
  debug('onWindowShow')
  getMenuItem('Full Screen').enabled = true
  getMenuItem('Float on Top').enabled = true
}

function onWindowHide () {
  debug('onWindowHide')
  getMenuItem('Full Screen').enabled = false
  getMenuItem('Float on Top').enabled = false
}

function onToggleFullScreen (isFullScreen) {
  isFullScreen = isFullScreen != null ? isFullScreen : windows.main.isFullScreen()
  windows.main.setMenuBarVisibility(!isFullScreen)
  getMenuItem('Full Screen').checked = isFullScreen
  windows.main.send('fullscreenChanged', isFullScreen)
}

function getMenuItem (label) {
  for (var i = 0; i < appMenu.items.length; i++) {
    var menuItem = appMenu.items[i].submenu.items.find(function (item) {
      return item.label === label
    })
    if (menuItem) return menuItem
  }
{'fraction_non_alphanumeric': 0.13715584743622128, 'fraction_numerical': 0.0005051780752715333, 'mean_word_length': 4.417236662106703, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '2038203', 'n_tokens_mistral': 1229, 'n_tokens_neox': 1217, 'n_words': 278}