<commit_before># ROUTER

class window.AppRouter extends Backbone.Router
  
  routes:
    "": "electionsList"
    ":namespace/:candidacies/:tag": "compare"
    ":namespace/:candidacies": "tagsList"
    ":namespace": "candidatesList"
  
  electionsList: ->
    unless @electionsListView
      @electionsListView = new ElectionsListView(el: "#elections-list", collection: app.collections.elections, model: app.models.election)
      @electionsListView.render()
    
    # get elections
    if _.isEmpty app.collections.elections.models
      app.collections.elections.fetch()
    
    app.views.navigation.push 'elections-list'
  
  candidatesList: (namespace)->
    unless @candidaciesListView
      @candidaciesListView = new CandidaciesListView(el: "#candidacies-list", model: app.models.election)
      @candidaciesListView.render()
    
    unless _.isEmpty app.collections.elections.models
      election = _.find app.collections.elections.models, (election) ->
        election.namespace() == namespace
      app.models.election.set id: election.id
    
    app.views.navigation.push 'candidacies-list'
    
  tagsList: (namespace, names)->
    # redirect if /
    unless names
      return @navigate namespace, true
    
    unless @tagsListView
      @tagsListView = new TagsListView(el: "#tags")
      @tagsListView.render()
      
    # set candidacies using url
    app.models.election.bind 'change', (election)=>
      namespaces = names.split ','
      candidacies = _.filter election.candidacies.models, (candidacy)->
        _.include namespaces, candidacy.namespace()
      app.collections.selectedCandidacies.reset candidacies
    
    app.views.navigation.push 'tags'
    
  compare: (namespace, candidacies, tagNamespace)->
    # redirect if /
    unless tagNamespace
      return @navigate "#{namespace}/#{candidacies}", true
      
    unless @compareView
      @compareView = new CompareView(el: "#compare")
      @compareView.render()
      view = new PropositionsView(el: "#compare .table-view")
      view.render()
      
    # set candidacies, tag using url
    app.models.election.bind 'change', (election)=>
      # candidacies
      namespaces = candidacies.split ','
      candidacies = _.filter election.candidacies.models, (candidacy)->
        _.include namespaces, candidacy.namespace()
      app.collections.selectedCandidacies.reset candidacies
      # tag
      tag = _.find election.tags.models, (_tag) ->
        _tag.namespace() == tagNamespace
      app.models.tag.set tag.toJSON()
    
    app.views.navigation.push 'compare'
    
  share: ->
    unless @shareView
      @shareView = new ShareView(el: "#share")
      @shareView.render()
    app.views.application.presentModalView 'share'<commit_msg>TOUCH: fix bug (propositions were not loaded because loadPropositions was not called)<commit_after># ROUTER

class window.AppRouter extends Backbone.Router
  
  routes:
    "": "electionsList"
    ":namespace/:candidacies/:tag": "compare"
    ":namespace/:candidacies": "tagsList"
    ":namespace": "candidatesList"
  
  electionsList: ->
    unless @electionsListView
      @electionsListView = new ElectionsListView(el: "#elections-list", collection: app.collections.elections, model: app.models.election)
      @electionsListView.render()
    
    # get elections
    if _.isEmpty app.collections.elections.models
      app.collections.elections.fetch()
    
    app.views.navigation.push 'elections-list'
  
  candidatesList: (namespace)->
    unless @candidaciesListView
      @candidaciesListView = new CandidaciesListView(el: "#candidacies-list", model: app.models.election)
      @candidaciesListView.render()
    
    unless _.isEmpty app.collections.elections.models
      election = _.find app.collections.elections.models, (election) ->
        election.namespace() == namespace
      app.models.election.set id: election.id
    
    app.views.navigation.push 'candidacies-list'
    
  tagsList: (namespace, names)->
    # redirect if /
    unless names
      return @navigate namespace, true
    
    unless @tagsListView
      @tagsListView = new TagsListView(el: "#tags")
      @tagsListView.render()
      
    # set candidacies using url
    app.models.election.bind 'change', (election)=>
      namespaces = names.split ','
      candidacies = _.filter election.candidacies.models, (candidacy)->
        _.include namespaces, candidacy.namespace()
      app.collections.selectedCandidacies.reset candidacies
    
    app.views.navigation.push 'tags'
    
  compare: (namespace, candidacies, tagNamespace)->
    # redirect if /
    unless tagNamespace
      return @navigate "#{namespace}/#{candidacies}", true
      
    unless @compareView
      @compareView = new CompareView(el: "#compare")
      @compareView.render()
      view = new PropositionsView(el: "#compare .table-view")
      view.loadPropositions()
      view.render()
      
    # set candidacies, tag using url
    app.models.election.bind 'change', (election)=>
      # candidacies
      namespaces = candidacies.split ','
      candidacies = _.filter election.candidacies.models, (candidacy)->
        _.include namespaces, candidacy.namespace()
      app.collections.selectedCandidacies.reset candidacies
      # tag
      tag = _.find election.tags.models, (_tag) ->
        _tag.namespace() == tagNamespace
      app.models.tag.set tag.toJSON()
    
    app.views.navigation.push 'compare'
    
  share: ->
    unless @shareView
      @shareView = new ShareView(el: "#share")
      @shareView.render()
    app.views.application.presentModalView 'share'
{'fraction_non_alphanumeric': 0.11501254030813328, 'fraction_numerical': 0.0, 'mean_word_length': 3.039797395079595, 'pattern_counts': {'":': 14, '<': 3, '<?xml version=': 0, '>': 25, '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': '2357996', 'n_tokens_mistral': 1619, 'n_tokens_neox': 1602, 'n_words': 337}