<commit_before>/* global $ */

function initializeUI () {
  const spookyMeterImage = $('#spooky-meter').children('img')
  const spookyMeterImageSource = spookyMeterImage.attr('src')
  const title = $('title')
  const spookyDescriptions = ['Not Spooky - It is safe but always be alert for skeletons',
    'Spoopy - No skeletons nearby but I\'m kind of scared anyway',
    'P Spoopy - Imminent danger of skeletons',
    'Spooky - There is a skeleton right behind you look out',
    '2Spooky - It is too late a skeleton is inside you']

  var spookyLevel = spookyMeterImageSource[spookyMeterImageSource.length - 5]

  function randomizeSpookyLevel () {
    spookyLevel = Math.floor(Math.random() * (4 - 0 + 1)) + 0
  }

  function updateSpookyMeterImage (src) {
    if (src) {
      spookyMeterImage.attr('src', src)
      return
    }
    spookyMeterImage.attr('src', '/images/level' + spookyLevel + '.gif')
  }

  function updateTitle (text) {
    if (text) {
      title.html(text)
      return
    }
    title.html(spookyDescriptions[spookyLevel])
  }

  window.PullToRefresh.init({
    mainElement: 'body',
    onRefresh: function () {
      randomizeSpookyLevel()
      updateSpookyMeterImage()
      updateTitle()
    }
  })
}

$(function () {
  initializeUI()
})<commit_msg>Removed initializeUI function from main.js and moved its body to the outermost scope.<commit_after>const spookyMeterImage = $('#spooky-meter').children('img')
const spookyMeterImageSource = spookyMeterImage.attr('src')
const title = $('title')
const spookyDescriptions = ['Not Spooky - It is safe but always be alert for skeletons',
  'Spoopy - No skeletons nearby but I\'m kind of scared anyway',
  'P Spoopy - Imminent danger of skeletons',
  'Spooky - There is a skeleton right behind you look out',
  '2Spooky - It is too late a skeleton is inside you']

var spookyLevel = spookyMeterImageSource[spookyMeterImageSource.length - 5]

function randomizeSpookyLevel () {
  spookyLevel = Math.floor(Math.random() * (4 - 0 + 1)) + 0
}

function updateSpookyMeterImage (src) {
  if (src) {
    spookyMeterImage.attr('src', src)
    return
  }
  spookyMeterImage.attr('src', '/images/level' + spookyLevel + '.gif')
}

function updateTitle (text) {
  if (text) {
    title.html(text)
    return
  }
  title.html(spookyDescriptions[spookyLevel])
}

window.PullToRefresh.init({
  mainElement: 'body',
  onRefresh: function () {
    randomizeSpookyLevel()
    updateSpookyMeterImage()
    updateTitle()
  }
})
{'fraction_non_alphanumeric': 0.12096774193548387, 'fraction_numerical': 0.004838709677419355, 'mean_word_length': 3.672316384180791, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5241063', 'n_tokens_mistral': 866, 'n_tokens_neox': 834, 'n_words': 214}