<commit_before># app/client/utils/layout.coffee

# helpers
UI.registerHelper 'active', (route) ->
  currentRoute = Router.current()
  return '' unless currentRoute

  if currentRoute.route.name == route
    'active'
  else
    ''

notifications = ->

  notifics = []
  challenges = Challenges.find $or: [
    { challengerId: currentPlayerId() }
  , { challengeeId: currentPlayerId() }
  , { challengeeEmail: { $in: currentPlayerEmails() } }
  ]

  challenges.fetch().forEach (c) ->

    challengerGame = Games.findOne c.challengerGameId
    challengeeGame = Games.findOne c.challengeeGameId

    #duel invites
    if c.challengeeId is currentPlayerId() or
    c.challengeeEmail in currentPlayerEmails()

      if challengeeGame.state is 'init' and
      challengerGame.state is 'finished'

        challenger = Meteor.users.findOne c.challengerId

        notifics.push({
          invite: 1
          name: challenger.profile.name
          gameId: c.challengeeGameId
        })

    #duel results
    else if c.challengerId is currentPlayerId() and not c.notified

      if challengeeGame.state is 'finished' and
      challengerGame.state is 'finished'

        challengee = Meteor.users.findOne $or: [
          { _id: c.challengeeId }
        , { emails: { $elemMatch: { address: c.challengeeEmail } } }
        ]

        notifics.push({
          invite: 0
          name: challengee.profile.name
          gameId: c.challengerGameId
        })

  notifics

Template.navbar.helpers

  externallink: -> 'http://www.dr.dk/sporten/fifavm2014'

Template.currentUser.helpers

  name: ->
    Meteor.user().profile.name

Template.notifications.helpers

  count: -> notifications().length

  notifications: -> notifications()


# events

Template.notifications.events

  'click .js-invite-accept': (event) ->
    #data() does not work
    gameId = $(event.target).attr('data-gameId')
    challenge = Challenges.findOne { challengeeGameId: gameId }
    startGame { acceptChallengeId: challenge._id }

  'click .js-invite-decline': (event) ->
    gameId = $(event.target).attr('data-gameId')
    Games.update gameId, $set: { state: 'declined' }
<commit_msg>Changed external link to DR P1<commit_after># app/client/utils/layout.coffee

# helpers
UI.registerHelper 'active', (route) ->
  currentRoute = Router.current()
  return '' unless currentRoute

  if currentRoute.route.name == route
    'active'
  else
    ''

notifications = ->

  notifics = []
  challenges = Challenges.find $or: [
    { challengerId: currentPlayerId() }
  , { challengeeId: currentPlayerId() }
  , { challengeeEmail: { $in: currentPlayerEmails() } }
  ]

  challenges.fetch().forEach (c) ->

    challengerGame = Games.findOne c.challengerGameId
    challengeeGame = Games.findOne c.challengeeGameId

    #duel invites
    if c.challengeeId is currentPlayerId() or
    c.challengeeEmail in currentPlayerEmails()

      if challengeeGame.state is 'init' and
      challengerGame.state is 'finished'

        challenger = Meteor.users.findOne c.challengerId

        notifics.push({
          invite: 1
          name: challenger.profile.name
          gameId: c.challengeeGameId
        })

    #duel results
    else if c.challengerId is currentPlayerId() and not c.notified

      if challengeeGame.state is 'finished' and
      challengerGame.state is 'finished'

        challengee = Meteor.users.findOne $or: [
          { _id: c.challengeeId }
        , { emails: { $elemMatch: { address: c.challengeeEmail } } }
        ]

        notifics.push({
          invite: 0
          name: challengee.profile.name
          gameId: c.challengerGameId
        })

  notifics

Template.navbar.helpers

  externallink: -> 'http://www.dr.dk/p1'

Template.currentUser.helpers

  name: ->
    Meteor.user().profile.name

Template.notifications.helpers

  count: -> notifications().length

  notifications: -> notifications()


# events

Template.notifications.events

  'click .js-invite-accept': (event) ->
    #data() does not work
    gameId = $(event.target).attr('data-gameId')
    challenge = Challenges.findOne { challengeeGameId: gameId }
    startGame { acceptChallengeId: challenge._id }

  'click .js-invite-decline': (event) ->
    gameId = $(event.target).attr('data-gameId')
    Games.update gameId, $set: { state: 'declined' }

{'fraction_non_alphanumeric': 0.11766071014156416, 'fraction_numerical': 0.0023207240659085635, 'mean_word_length': 2.817537643932684, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '3922700', 'n_tokens_mistral': 1430, 'n_tokens_neox': 1364, 'n_words': 281}