<commit_before>{React, ReactBootstrap, FontAwesome} = window
{remote} = require 'electron'
windowManager = remote.require './lib/window'

i18n = remote.require 'i18n'
path = remote.require 'path-extra'
{__} = i18n

i18n.configure({
  locales:['en-US', 'ja-JP', 'zh-CN'],
  defaultLocale: 'zh-CN',
  directory: path.join(__dirname, "i18n"),
  updateFiles: false,
  indent: "\t",
  extension: '.json'
})
i18n.setLocale(window.language)


window.poiStatsWindow = null

handleWindowMoveResize = ->
  b1 = window.poiStatsWindow.getBounds()
  # console.log "Moved to: #{JSON.stringify(b1)}"
  setTimeout(( ->
    b2 = window.poiStatsWindow.getBounds()
    if JSON.stringify(b2) == JSON.stringify(b1)
      config.set 'plugin.PoiStatistics.bounds', b2
      # console.log "   Saved:  #{JSON.stringify(b2)}"
  ), 5000)

initialPoiStatsWindow = ->
  defaultBounds = {x: 0, y: 0, width: 800, height: 750}
  b = config.get 'plugin.PoiStatistics.bounds', defaultBounds
  newWindow = windowManager.createWindow
    x: b.x
    y: b.y
    width: b.width
    height: b.height
    realClose: true
  window.poiStatsWindow = newWindow
  newWindow.setMinimumSize 600, 425
  newWindow.on 'move', handleWindowMoveResize
  newWindow.on 'resize', handleWindowMoveResize
  newWindow.on 'closed', -> window.poiStatsWindow = null
  if process.env.DEBUG?
    window.log 'Poi Stats started.'
    newWindow.openDevTools
      detach: true
  newWindow.loadURL "file://#{__dirname}/index.html"
  newWindow.show()

module.exports =
  name: 'PoiStatistics'
  priority: 110
  displayName: <span><FontAwesome name='bar-chart' key={0} /> {__ 'Poi Statistics'}</span>
  author: '<NAME>'
  link: 'https://github.com/alvin-777/poi-plugin-poi-stats'
  version: '1.2.0'
  description: __ 'PluginDesc'
  handleClick: ->
    if window.poiStatsWindow != null
      window.poiStatsWindow.show()
    else
      initialPoiStatsWindow()<commit_msg>Yet another way to store window position and size<commit_after>{React, ReactBootstrap, FontAwesome} = window
{remote} = require 'electron'
windowManager = remote.require './lib/window'

i18n = remote.require 'i18n'
path = remote.require 'path-extra'
{__} = i18n

i18n.configure({
  locales:['en-US', 'ja-JP', 'zh-CN'],
  defaultLocale: 'zh-CN',
  directory: path.join(__dirname, "i18n"),
  updateFiles: false,
  indent: "\t",
  extension: '.json'
})
i18n.setLocale(window.language)


window.plugin ?= {}
window.plugin.poiStats =
  window: null
  bounds: null

handleWindowMoveResize = ->
  plugin.poiStats.bounds = plugin.poiStats.window.getBounds()
  # console.log "Poi Stats Bounds: #{JSON.stringify(plugin.poiStats.bounds)}"

initialPoiStatsWindow = ->
  defaultBounds = {x: 0, y: 0, width: 800, height: 750}
  b = config.get 'plugin.PoiStatistics.bounds', defaultBounds
  newWindow = windowManager.createWindow
    x: b.x
    y: b.y
    width: b.width
    height: b.height
    realClose: true
  ps = window.plugin.poiStats
  ps.window = newWindow
  newWindow.setMinimumSize 600, 425
  newWindow.on 'move', handleWindowMoveResize
  newWindow.on 'resize', handleWindowMoveResize
  newWindow.on 'close', ->
    if ps.bounds?
      config.set 'plugin.PoiStatistics.bounds', ps.bounds
  newWindow.on 'closed', ->
    ps.window = ps.bounds = null
  if process.env.DEBUG?
    window.log 'Poi Stats started.'
    newWindow.openDevTools
      detach: true
  newWindow.loadURL "file://#{__dirname}/index.html"
  newWindow.show()

module.exports =
  name: 'PoiStatistics'
  priority: 110
  displayName: <span><FontAwesome name='bar-chart' key={0} /> {__ 'Poi Statistics'}</span>
  author: '<NAME>'
  link: 'https://github.com/alvin-777/poi-plugin-poi-stats'
  version: '1.2.0'
  description: __ 'PluginDesc'
  handleClick: ->
    if window.plugin.poiStats.window?
      window.plugin.poiStats.window.show()
    else
      initialPoiStatsWindow()
{'fraction_non_alphanumeric': 0.14360177221787854, 'fraction_numerical': 0.021631482929371906, 'mean_word_length': 3.8705583756345177, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 21, 'https://': 2, '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': '1109034', 'n_tokens_mistral': 1393, 'n_tokens_neox': 1334, 'n_words': 276}