<commit_before>window.app = {
  views: {}
}

networkCount = 0

registerTemplate = (service, name) ->
  $.ajax "templates/#{service}/#{name}.html",
    success: (data) ->
      ich.addTemplate(name, data)
    complete: -> checkIfFinishedLoading()

checkIfFinishedLoading = ->
  networkCount--
  if networkCount is 0
    app.list?.view.el = document.getElementById("content")
    app.router.refresh()

app.loadTheme = (service) ->
  return unless service in ['Twitter', '4chan']

  ich.clearAll()
  $fbRoot = $("#fb-root")

  for view in ['post', 'comment', 'like', 'loading', 'intro', 'inlineLoading', 'user']
    networkCount++
    registerTemplate(service, view)

  networkCount++
  $.get "templates/#{service.toLowerCase()}/site.html", (data) =>
    ich.addTemplate 'site', data
    $("body").html(ich.site)

    # TODO: Can we just re-initialize FB or do something less horrendous?
    $("body").append($fbRoot)

    $.get "templates/#{service.toLowerCase()}/stylesheets.html", (data) =>
      checkIfFinishedLoading()
      $('head').append(data)

  app.theme = service

app.showLoading = -> app.showStatic('loading')
app.showPartialLoading = -> $("#content").prepend(ich.inlineLoading())
app.showIntro = -> app.showStatic('intro')

app.showStatic = (name) ->
  $("#content").html(ich[name]?())

app.params = ->
  unless params
    setters = window.location.search[1..].split('&')
    params = {}
    for setter in setters
      [key, value] = setter.split('=')
      params[key] = value
  params


app.renderList = ->
  if app.list?
    app.list.view.render()
    app.showPartialLoading()
  else
    app.showLoading()
    app.list = new app.PostList
    app.list.view = new app.views.PostList({model:app.list})

  app.list.fetch<commit_msg>Wipe out CSS when switching themes<commit_after>window.app = {
  views: {}
}

networkCount = 0

registerTemplate = (service, name) ->
  $.ajax "templates/#{service}/#{name}.html",
    success: (data) ->
      ich.addTemplate(name, data)
    complete: -> checkIfFinishedLoading()

checkIfFinishedLoading = ->
  networkCount--
  if networkCount is 0
    app.list?.view.el = document.getElementById("content")
    app.router.refresh()

app.loadTheme = (service) ->
  return unless service in ['Twitter', '4chan']

  ich.clearAll()
  $fbRoot = $("#fb-root")

  for view in ['post', 'comment', 'like', 'loading', 'intro', 'inlineLoading', 'user']
    networkCount++
    registerTemplate(service, view)

  networkCount++
  $.get "templates/#{service.toLowerCase()}/site.html", (data) =>
    ich.addTemplate 'site', data
    $("body").html(ich.site)

    # TODO: Can we just re-initialize FB or do something less horrendous?
    $("body").append($fbRoot)

    $.get "templates/#{service.toLowerCase()}/stylesheets.html", (data) =>
      checkIfFinishedLoading()
      $('body').append(data)

  app.theme = service

app.showLoading = -> app.showStatic('loading')
app.showPartialLoading = -> $("#content").prepend(ich.inlineLoading())
app.showIntro = -> app.showStatic('intro')

app.showStatic = (name) ->
  $("#content").html(ich[name]?())

app.params = ->
  unless params
    setters = window.location.search[1..].split('&')
    params = {}
    for setter in setters
      [key, value] = setter.split('=')
      params[key] = value
  params


app.renderList = ->
  if app.list?
    app.list.view.render()
    app.showPartialLoading()
  else
    app.showLoading()
    app.list = new app.PostList
    app.list.view = new app.views.PostList({model:app.list})

  app.list.fetch
{'fraction_non_alphanumeric': 0.17772714326402733, 'fraction_numerical': 0.0022785531187695814, 'mean_word_length': 3.537467700258398, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 29, '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': '2847354', 'n_tokens_mistral': 1157, 'n_tokens_neox': 1138, 'n_words': 232}