<commit_before># Copyright (c) ppy Pty Ltd <<EMAIL>>. Licensed under the GNU Affero General Public License v3.0.
# See the LICENCE file in the repository root for full licence text.

@osu =
  isIos: /iPad|iPhone|iPod/.test(navigator.platform)
  urlRegex: /(https?:\/\/((?:(?:[a-z0-9]\.|[a-z0-9][a-z0-9-]*[a-z0-9]\.)*[a-z][a-z0-9-]*[a-z0-9](?::\d+)?)(?:(?:(?:\/+(?:[a-z0-9$_\.\+!\*',;:@&=-]|%[0-9a-f]{2})*)*(?:\?(?:[a-z0-9$_\.\+!\*',;:@&=-]|%[0-9a-f]{2})*)?)?(?:#(?:[a-z0-9$_\.\+!\*',;:@&=/?-]|%[0-9a-f]{2})*)?)?(?:[^\.,:\s])))/ig

  bottomPage: ->
    osu.bottomPageDistance() == 0


  bottomPageDistance: ->
    body = document.documentElement ? document.body.parent ? document.body
    (body.scrollHeight - body.scrollTop) - body.clientHeight


  classWithModifiers: (className, modifiers) ->
    ret = className

    if modifiers?
      ret += " #{className}--#{modifier}" for modifier in modifiers when modifier?

    ret


  currentUserIsFriendsWith: (user_id) ->
    _.find currentUser.friends, target_id: user_id


  diffColour: (difficulty) ->
    stops = [
      { offset: 1.5, red: 79, green: 192, blue: 255 },
      { offset: 2, red: 79, green: 255, blue: 213 },
      { offset: 2.5, red: 124, green: 255, blue: 79 },
      { offset: 3.375, red: 246, green: 240, blue: 92 },
      { offset: 4.625, red: 255, green: 128, blue: 104 },
      { offset: 5.875, red: 255, green: 60, blue: 113 },
      { offset: 7, red: 101, green: 99, blue: 222 },
      { offset: 8, red: 24, green: 21, blue: 142 }
    ]

    interpolate = (value, sourceStart, sourceEnd, destStart, destEnd) ->
      destStart + (destEnd - destStart) * ((value - sourceStart) / (sourceEnd - sourceStart))

    colour = {}

    if (difficulty? || difficulty > 8)
      colour = { red: 0, green: 0, blue: 0 }
    else
      i = stops.findIndex((stop) -> starRating <= stop.starRating)

      if (i == -1)
        colour = { red: 0, green: 0, blue: 0 }
      else if (i - 1 < 0)
        colour = {
          red: stops[i].red,
          green: stops[i].green,
          blue: stops[i].blue
        }<commit_msg>Fix diffColour coloring everything black<commit_after># Copyright (c) ppy Pty Ltd <<EMAIL>>. Licensed under the GNU Affero General Public License v3.0.
# See the LICENCE file in the repository root for full licence text.

@osu =
  isIos: /iPad|iPhone|iPod/.test(navigator.platform)
  urlRegex: /(https?:\/\/((?:(?:[a-z0-9]\.|[a-z0-9][a-z0-9-]*[a-z0-9]\.)*[a-z][a-z0-9-]*[a-z0-9](?::\d+)?)(?:(?:(?:\/+(?:[a-z0-9$_\.\+!\*',;:@&=-]|%[0-9a-f]{2})*)*(?:\?(?:[a-z0-9$_\.\+!\*',;:@&=-]|%[0-9a-f]{2})*)?)?(?:#(?:[a-z0-9$_\.\+!\*',;:@&=/?-]|%[0-9a-f]{2})*)?)?(?:[^\.,:\s])))/ig

  bottomPage: ->
    osu.bottomPageDistance() == 0


  bottomPageDistance: ->
    body = document.documentElement ? document.body.parent ? document.body
    (body.scrollHeight - body.scrollTop) - body.clientHeight


  classWithModifiers: (className, modifiers) ->
    ret = className

    if modifiers?
      ret += " #{className}--#{modifier}" for modifier in modifiers when modifier?

    ret


  currentUserIsFriendsWith: (user_id) ->
    _.find currentUser.friends, target_id: user_id


  diffColour: (difficulty) ->
    stops = [
      { offset: 1.5, red: 79, green: 192, blue: 255 },
      { offset: 2, red: 79, green: 255, blue: 213 },
      { offset: 2.5, red: 124, green: 255, blue: 79 },
      { offset: 3.375, red: 246, green: 240, blue: 92 },
      { offset: 4.625, red: 255, green: 128, blue: 104 },
      { offset: 5.875, red: 255, green: 60, blue: 113 },
      { offset: 7, red: 101, green: 99, blue: 222 },
      { offset: 8, red: 24, green: 21, blue: 142 }
    ]

    interpolate = (value, sourceStart, sourceEnd, destStart, destEnd) ->
      destStart + (destEnd - destStart) * ((value - sourceStart) / (sourceEnd - sourceStart))

    colour = {}

    if (difficulty == null || difficulty > 8)
      colour = { red: 0, green: 0, blue: 0 }
    else
      i = stops.findIndex((stop) -> difficulty <= stop.offset)

      if (i == -1)
        colour = { red: 0, green: 0, blue: 0 }
      else if (i - 1 < 0)
        colour = {
          red: stops[i].red,
          green: stops[i].green,
          blue: stops[i].blue
        }
{'fraction_non_alphanumeric': 0.22341440152598951, 'fraction_numerical': 0.058655221745350504, 'mean_word_length': 2.651000870322019, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 23, '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': '3421195', 'n_tokens_mistral': 1809, 'n_tokens_neox': 1590, 'n_words': 375}