<commit_before>determineBrowser = ->
  [ 'chrome', 'firefox', 'safari', 'phantom_js', 'unsupported-browser' ]
  .filter( (browser) -> $('html.'+browser).length
  )[0]

extension_link_by_browser =
  firefox: 'https://static.factlink.com/extension/firefox/factlink-latest.xpi'
  safari: 'https://static.factlink.com/extension/firefox/factlink.safariextz'
  chrome: 'javascript:chrome.webstore.install()'

window.ReactInstallExtensionButton = React.createClass
  displayName: 'ReactInstallExtensionButton'
  render: ->
    browserName = determineBrowser()
    extension_link = extension_link_by_browser[browserName]
    extra_class = if @props.huge_button then 'button-huge' else null
    if document.documentElement.getAttribute('data-factlink-extension-loaded') != undefined
      _div [],
        _button ['button', extra_class,
          disabled: true],
          'Factlink already installed.'
    else
      _div [],
        _div ['visible-when-chrome'],
          _a ['button-success', extra_class, href: extension_link],
            _span ['install-chrome']
            'Install Factlink for ' + browserName.capitalize()
        _div ['visible-when-firefox'],
          _a ['button-success', extra_class, href: extension_link],
            _span ['install-firefox']
            'Install Factlink for ' + browserName.capitalize()
        _div ['visible-when-safari'],
          _a ['button-success', extra_class, href: extension_link],
            _span ['install-safari']
            'Install Factlink for ' + browserName.capitalize()
<commit_msg>Extract icon_class into reusable bit<commit_after>determineBrowser = ->
  [ 'chrome', 'firefox', 'safari', 'phantom_js', 'unsupported-browser' ]
  .filter( (browser) -> $('html.'+browser).length
  )[0]

extension_link_by_browser =
  firefox: 'https://static.factlink.com/extension/firefox/factlink-latest.xpi'
  safari: 'https://static.factlink.com/extension/firefox/factlink.safariextz'
  chrome: 'javascript:chrome.webstore.install()'

icon_class_by_browser =
  firefox: 'install-firefox'
  safari: 'install-safari'
  chrome: 'install-chrome'

window.ReactInstallExtensionButton = React.createClass
  displayName: 'ReactInstallExtensionButton'
  render: ->
    browserName = determineBrowser()
    extension_link = extension_link_by_browser[browserName]
    icon_class = icon_class_by_browser[browserName]
    extra_class = if @props.huge_button then 'button-huge' else null
    if document.documentElement.getAttribute('data-factlink-extension-loaded') != undefined
      _div [],
        _button ['button', extra_class,
          disabled: true],
          'Factlink already installed.'
    else
      _div [],
        _div ['visible-when-chrome'],
          _a ['button-success', extra_class, href: extension_link],
            _span [icon_class]
            'Install Factlink for ' + browserName.capitalize()
        _div ['visible-when-firefox'],
          _a ['button-success', extra_class, href: extension_link],
            _span [icon_class]
            'Install Factlink for ' + browserName.capitalize()
        _div ['visible-when-safari'],
          _a ['button-success', extra_class, href: extension_link],
            _span [icon_class]
            'Install Factlink for ' + browserName.capitalize()

{'fraction_non_alphanumeric': 0.12698898408812728, 'fraction_numerical': 0.0006119951040391676, 'mean_word_length': 3.364485981308411, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 4, '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': '7248205', 'n_tokens_mistral': 984, 'n_tokens_neox': 969, 'n_words': 185}