<commit_before>var $ = require('jquery')
var _ = require('underscore')
var translations = require('./translations')

var utils = {}

utils.isMac = /Mac/.test(navigator.platform)

function setModes () {
  // Keep in sync with value in litewrite.css
  utils.isMobile = window.matchMedia('(max-width:1024px)').matches
  utils.isDesktop = !utils.isMobile
}

$(window).on('resize', setModes)
setModes()

// For more info:
// http://stackoverflow.com/questions/3561493/is-there-a-regexp-escape-function-in-javascript/3561711#3561711
utils.escapeRegExp = function (str) {
  return str.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&')
}

// in seconds
var hour = 3600
var day = 24 * hour
var week = 7 * day
var month = 30.4 * day
var year = 365 * day

var quantifiers = [
  {
    name: 'yearsAgo',
    time: year
  },
  {
    name: 'monthsAgo',
    time: month
  },
  {
    name: 'weeksAgo',
    time: week
  },
  {
    name: 'daysAgo',
    time: day
  },
  {
    name: 'hoursAgo',
    time: hour
  },
  {
    name: 'minutesAgo',
    time: 60
  },
  {
    name: 'secondsAgo',
    time: 1
  }
]

utils.timeAgo = function (date) {
  var diff = (Date.now() - date) / 1000 // in seconds

  var quantifier = _.find(quantifiers, function (q) {
    return diff >= q.time
  })

  if (!quantifier) {
    return
  }

  var count = Math.round(diff / quantifier.time)
  return translations[quantifier.name](count)
}

utils.handleAppcacheUpdates = function () {
  var appcache = window.applicationCache
  if (!appcache) {
    return
  }

  appcache.addEventListener('updateready', function (e) {
    if (appcache.status !== appcache.UPDATEREADY) return
    if (!window.confirm(translations.updateCache)) return
    window.location.reload()
  }, false)
}

utils.hotKey = utils.isMac ? 'Alt' : 'Ctrl';

module.exports = utils<commit_msg>Delint<commit_after>var $ = require('jquery')
var _ = require('underscore')
var translations = require('./translations')

var utils = {}

utils.isMac = /Mac/.test(navigator.platform)

function setModes () {
  // Keep in sync with value in litewrite.css
  utils.isMobile = window.matchMedia('(max-width:1024px)').matches
  utils.isDesktop = !utils.isMobile
}

$(window).on('resize', setModes)
setModes()

// For more info:
// http://stackoverflow.com/questions/3561493/is-there-a-regexp-escape-function-in-javascript/3561711#3561711
utils.escapeRegExp = function (str) {
  return str.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&')
}

// in seconds
var hour = 3600
var day = 24 * hour
var week = 7 * day
var month = 30.4 * day
var year = 365 * day

var quantifiers = [
  {
    name: 'yearsAgo',
    time: year
  },
  {
    name: 'monthsAgo',
    time: month
  },
  {
    name: 'weeksAgo',
    time: week
  },
  {
    name: 'daysAgo',
    time: day
  },
  {
    name: 'hoursAgo',
    time: hour
  },
  {
    name: 'minutesAgo',
    time: 60
  },
  {
    name: 'secondsAgo',
    time: 1
  }
]

utils.timeAgo = function (date) {
  var diff = (Date.now() - date) / 1000 // in seconds

  var quantifier = _.find(quantifiers, function (q) {
    return diff >= q.time
  })

  if (!quantifier) {
    return
  }

  var count = Math.round(diff / quantifier.time)
  return translations[quantifier.name](count)
}

utils.handleAppcacheUpdates = function () {
  var appcache = window.applicationCache
  if (!appcache) {
    return
  }

  appcache.addEventListener('updateready', function (e) {
    if (appcache.status !== appcache.UPDATEREADY) return
    if (!window.confirm(translations.updateCache)) return
    window.location.reload()
  }, false)
}

utils.hotKey = utils.isMac ? 'Alt' : 'Ctrl'

module.exports = utils
{'fraction_non_alphanumeric': 0.16278424847476428, 'fraction_numerical': 0.024958402662229616, 'mean_word_length': 3.048260381593715, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '6108131', 'n_tokens_mistral': 1382, 'n_tokens_neox': 1291, 'n_words': 279}