<commit_before>ko.bindingHandlers.popover =
  init: (el, valueAccessor, allBindingsAccessor, viewModel, bindingContext) =>
    options = valueAccessor()
    $(el).popover(options)

ko.bindingHandlers.slider =
  init: (el, valueAccessor, allBindingsAccessor, viewModel, bindingContext) =>
    options = valueAccessor()
    $(el).slider(options)

ko.bindingHandlers.track =
  init: (el, valueAccessor) =>
    $(el).click ->
      mixpanel.track(valueAccessor())

# Prefer track_link for links to external sites, like github, because the redirect prevents JS from running/completing
ko.bindingHandlers.track_link =
  init: (el, valueAccessor) =>
    $(el).click (event) ->
      event.preventDefault()
      redirect = () ->
        window.location.replace($(el).attr('href'))
      backup_redirect = setTimeout(redirect, 1000)
      mixpanel.track valueAccessor(), {}, ->
        clearTimeout(backup_redirect)
        redirect()

# Takes any kind of jQueryExtension, e.g. popover, tooltip, etc.
jQueryExt = (type) =>
  init: (el, valueAccessor) =>
    options = valueAccessor()
    $el = $(el)
    $el[type].call($el, options)

# Usage: %a{href: "#", tooltip: {title: myObservable}}
ko.bindingHandlers.popover = jQueryExt('popover')
ko.bindingHandlers.tooltip = jQueryExt('tooltip')
ko.bindingHandlers.typeahead = jQueryExt('typeahead')

## copy of html binding. Uses innerHTML directly, which is faster than
## jQuery, but does less. Seems to work well for just spans.
ko.bindingHandlers.fastHtml =
  init: () ->
    # copied from ko.bindingHandlers.html, don't really know what it does..
    {'controlsDescendentBindings': true }

  update: (el, valueAccessor) ->
    html = ko.utils.unwrapObservable(valueAccessor())

    if html?
      if typeof html != 'string'
        html = html.toString()

      el.innerHTML = html

## Money custom binding

# Add helper that was minified
ieVersion = () ->
  version = 3
  div = document.createElement('div')
  iElems = div.getElementsByTagName('i')
  null while (div.innerHTML = "<!--[if gt IE #{++version}]><i></i><![endif]-->" and iElems[0])

  if version > 4 then version else undefined
<commit_msg>remove the fastHtml custom binding (it's only noticably faster for large inputs and we don't really have those anymore)<commit_after>ko.bindingHandlers.popover =
  init: (el, valueAccessor, allBindingsAccessor, viewModel, bindingContext) =>
    options = valueAccessor()
    $(el).popover(options)

ko.bindingHandlers.slider =
  init: (el, valueAccessor, allBindingsAccessor, viewModel, bindingContext) =>
    options = valueAccessor()
    $(el).slider(options)

ko.bindingHandlers.track =
  init: (el, valueAccessor) =>
    $(el).click ->
      mixpanel.track(valueAccessor())

# Prefer track_link for links to external sites, like github, because the redirect prevents JS from running/completing
ko.bindingHandlers.track_link =
  init: (el, valueAccessor) =>
    $(el).click (event) ->
      event.preventDefault()
      redirect = () ->
        window.location.replace($(el).attr('href'))
      backup_redirect = setTimeout(redirect, 1000)
      mixpanel.track valueAccessor(), {}, ->
        clearTimeout(backup_redirect)
        redirect()

# Takes any kind of jQueryExtension, e.g. popover, tooltip, etc.
jQueryExt = (type) =>
  init: (el, valueAccessor) =>
    options = valueAccessor()
    $el = $(el)
    $el[type].call($el, options)

# Usage: %a{href: "#", tooltip: {title: myObservable}}
ko.bindingHandlers.popover = jQueryExt('popover')
ko.bindingHandlers.tooltip = jQueryExt('tooltip')
ko.bindingHandlers.typeahead = jQueryExt('typeahead')

## Money custom binding

# Add helper that was minified
ieVersion = () ->
  version = 3
  div = document.createElement('div')
  iElems = div.getElementsByTagName('i')
  null while (div.innerHTML = "<!--[if gt IE #{++version}]><i></i><![endif]-->" and iElems[0])

  if version > 4 then version else undefined

{'fraction_non_alphanumeric': 0.14055299539170507, 'fraction_numerical': 0.0035842293906810036, 'mean_word_length': 4.008974358974359, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 37, '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': '4203164', 'n_tokens_mistral': 1203, 'n_tokens_neox': 1168, 'n_words': 308}