<commit_before>{$, $$, _, React, ReactBootstrap, FontAwesome, ROOT} = window
{Grid, Col, Button, ButtonGroup, Input, Modal, Alert, OverlayTrigger, DropdownButton, MenuItem, Popover, Row, Tooltip} = ReactBootstrap
remote = require 'remote'
webview = $('inner-page webview')
innerpage = $('inner-page')

# Not used yet, but may need in the future.
# i18n = remote.require './node_modules/i18n'
# path = 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)


NavigationBar = React.createClass
  getInitialState: ->
    navigateStatus: 'Loading'
  getIcon: ->
    switch @state.navigateStatus
      when 'Failed'
        <FontAwesome name='times' />
      when 'OK'
        <FontAwesome name='check' />
      when 'Loading'
        <FontAwesome name='spinner' spin />
  onResize: (e) ->
    $('inner-page')?.style?.height = "#{window.innerHeight - 50}px"
    $('inner-page webview')?.style?.height = $('inner-page webview /deep/ object[is=browserplugin]')?.style?.height = "#{window.innerHeight - 50}px"
  onStartedLoading: (e) ->
    @setState
      navigateStatus: 'Loading'
  onStoppedLoading: ->
    @setState
      navigateStatus: 'OK'
  onFailedToLoad: ->
    @setState
      navigateStatus: 'Failed'
  componentDidMount: ->
    window.addEventListener 'resize', @onResize
    webview.addEventListener 'did-start-loading', @onStartedLoading
    webview.addEventListener 'did-stop-loading', @onStoppedLoading
    webview.addEventListener 'did-fail-load', @onFailedToLoad<commit_msg>Added some debugging code<commit_after>{$, $$, _, React, ReactBootstrap, FontAwesome, ROOT} = window
{Grid, Col, Button, ButtonGroup, Input, Modal, Alert, OverlayTrigger, DropdownButton, MenuItem, Popover, Row, Tooltip} = ReactBootstrap
remote = require 'remote'
webview = $('inner-page webview')
innerpage = $('inner-page')

# Not used yet, but may need in the future.
# i18n = remote.require './node_modules/i18n'
# path = 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)

psLog = (msg) ->
  now = new Date()
  console.log "#{now.getTime()}: #{msg}"
psAddEventLogger = (ev) ->
  webview.addEventListener ev, psLog.bind(@, ev)

if remote.getCurrentWindow().isDevToolsOpened()
  psAddEventLogger 'did-start-loading'
  psAddEventLogger 'did-stop-loading'
  # psAddEventLogger 'did-finish-load'
  psAddEventLogger 'did-fail-load'

NavigationBar = React.createClass
  getInitialState: ->
    navigateStatus: 'Loading'
  getIcon: ->
    switch @state.navigateStatus
      when 'Failed'
        <FontAwesome name='times' />
      when 'OK'
        <FontAwesome name='check' />
      when 'Loading'
        <FontAwesome name='spinner' spin />
  onResize: (e) ->
    $('inner-page')?.style?.height = "#{window.innerHeight - 50}px"
    $('inner-page webview')?.style?.height = $('inner-page webview /deep/ object[is=browserplugin]')?.style?.height = "#{window.innerHeight - 50}px"
  onStartedLoading: (e) ->
    @setState
      navigateStatus: 'Loading'
  onStoppedLoading: ->
    @setState
      navigateStatus: 'OK'
  onFailedToLoad: ->
    @setState
      navigateStatus: 'Failed'
  componentDidMount: ->
    window.addEventListener 'resize', @onResize
    webview.addEventListener 'did-start-loading', @onStartedLoading
    webview.addEventListener 'did-stop-loading', @onStoppedLoading
    webview.addEventListener 'did-fail-load', @onFailedToLoad
{'fraction_non_alphanumeric': 0.15752165922814387, 'fraction_numerical': 0.00840115515883434, 'mean_word_length': 3.8535031847133756, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 25, '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': '2069103', 'n_tokens_mistral': 1279, 'n_tokens_neox': 1257, 'n_words': 266}