<commit_before>this.GobiertoParticipation.ContributionContainersController = (function() {
  function ContributionContainersController() {}

  ContributionContainersController.prototype.index = function(url){
    _initContributionContainer();
  };

  function _initContributionContainer(){
    var format_date = d3.timeFormat("%Y-%m-%d");

    var page = 1

    var viewdata = data.slice((page-1)*cardnumber,page*cardnumber);

    var now = new Date;
    var px, py, vx, vy, offsetX, offsetY, maxVelocity = 8;

    var width = d3.select('.contributions_content').node().clientWidth,
        height = d3.select('.contributions_content').node().clientHeight,
        cardWidth = 330,
        cardHeight = 130;

    var x = d3.scaleLinear()
      .range([0, width])
      .domain([0, data.length]);

    var y = d3.scaleLinear()
      .range(0, height)
      .domain([0, data.length]);

    var z = d3.scaleLinear()
      .range([-5, 5])
      .domain([0, data.length]);

    var nodes = createNodes(viewdata);

    for (i = 1; i <= page_max; i++) {
      if (i === 1) {
        $(".circles_progress").append('<li data-page=' + i + ' class="active"><a href=""><span></span></a></li>');
      } else {
        $(".circles_progress").append('<li data-page=' + i + '><a href=""><span></span></a></li>');
      }
    }

    var collisionForce = rectCollide()
      .size(function (d) { return [d.width, d.height] });

    var boxForce = boundedBox()
      .bounds([[0, 0], [width, height]])
      .size(function (d) { return [d.width, d.height] });

    var simulation = d3.forceSimulation(nodes)
      .velocityDecay(0.6) // Speed of the simulation: https://github.com/d3/d3-force/blob/master/README.md#simulation_velocityDecay
      .alphaTarget(1)
      .force('box', boxForce)
      .force('collision', collisionForce);

    var drag = d3.drag()
      .on('start', started)
      .on('drag', dragged)
      .on('end', ended);

    var contributions = d3.select('.contributions_container');

    contributions.select('.contributions_content')
      .append('div')
      .attr('class', 'contribution_legend')
      .attr('id', 'contribution_legend')
      .text(users_ideas);

    contributions.select('.contributions_content')
      .append('i')
      .attr('id', 'next')
      .attr('data-toggle', 'next')
      .attr('class', 'fa fa-angle-right fa-3x arrow next_contribution')
      .on('click', updateContributions);

    contributions.select('.contributions_content')
      .append('i')
      .attr('id', 'previous')
      .attr('data-toggle', 'previous')
      .attr('class', 'fa fa-angle-left fa-3x arrow previous_contribution disabled')
      .on('click', updateContributions);

      createCards(nodes);

    $('#next').click(function() {
        page++;
        viewdata = data.slice((page-1)*cardnumber,page*cardnumber);
        var nodes = createNodes(viewdata);
        createCards(nodes);
        if (page === page_max ) {
          d3.select('.next_contribution')
            .classed('disabled', true);
        }

        var simulation = d3.forceSimulation(nodes)
          .velocityDecay(0.6) // Speed of the simulation: https://github.com/d3/d3-force/blob/master/README.md#simulation_velocityDecay
          .alphaTarget(1)
          .force('box', boxForce)
          .force('collision', collisionForce);
    });

    $('#previous').click(function() {
        page--;
        viewdata = data.slice((page-1)*cardnumber,page*cardnumber);
        var nodes = createNodes(viewdata);
        createCards(nodes);
        if (page === 1 ) {
          d3.select('.previous_contribution')
            .classed('disabled', true);
        }

        if (page <= page_max ) {
          d3.select('.next_contribution')
            .classed('disabled', false);
        }

        var simulation = d3.forceSimulation(nodes)
          .velocityDecay(0.6) // Speed of the simulation: https://github.com/d3/d3-force/blob/master/README.md#simulation_velocityDecay
          .alphaTarget(1)
          .force('box', boxForce)
          .force('collision', collisionForce);
    });

    /* Pagination links */
    $('li[data-page]').click(function(e) {
      e.preventDefault();
      page = $(this).data('page');
      viewdata = data.slice((page-1)*cardnumber,page*cardnumber);
      var nodes = createNodes(viewdata);
      createCards(nodes);
      if (page === page_max ) {
        d3.select('.next_contribution')
          .classed('disabled', true);
      }
      $('li[data-page]').removeClass('active');
      $(this).addClass('active');

      if (page === 1 ) {
        d3.select('.previous_contribution')
          .classed('disabled', true);
      }

      if (page <= page_max ) {
        d3.select('.next_contribution')
          .classed('disabled', false);
      }

      if (page === page_max ) {
        d3.select('.next_contribution')
          .classed('disabled', true);
      }

      var simulation = d3.forceSimulation(nodes)
        .velocityDecay(0.6) // Speed of the simulation: https://github.com/d3/d3-force/blob/master/README.md#simulation_velocityDecay
        .alphaTarget(1)
        .force('box', boxForce)
        .force('collision', collisionForce);
    });<commit_msg>Fix previous contribution when click pagination<commit_after>this.GobiertoParticipation.ContributionContainersController = (function() {
  function ContributionContainersController() {}

  ContributionContainersController.prototype.index = function(url){
    _initContributionContainer();
  };

  function _initContributionContainer(){
    var format_date = d3.timeFormat("%Y-%m-%d");

    var page = 1

    var viewdata = data.slice((page-1)*cardnumber,page*cardnumber);

    var now = new Date;
    var px, py, vx, vy, offsetX, offsetY, maxVelocity = 8;

    var width = d3.select('.contributions_content').node().clientWidth,
        height = d3.select('.contributions_content').node().clientHeight,
        cardWidth = 330,
        cardHeight = 130;

    var x = d3.scaleLinear()
      .range([0, width])
      .domain([0, data.length]);

    var y = d3.scaleLinear()
      .range(0, height)
      .domain([0, data.length]);

    var z = d3.scaleLinear()
      .range([-5, 5])
      .domain([0, data.length]);

    var nodes = createNodes(viewdata);

    for (i = 1; i <= page_max; i++) {
      if (i === 1) {
        $(".circles_progress").append('<li data-page=' + i + ' class="active"><a href=""><span></span></a></li>');
      } else {
        $(".circles_progress").append('<li data-page=' + i + '><a href=""><span></span></a></li>');
      }
    }

    var collisionForce = rectCollide()
      .size(function (d) { return [d.width, d.height] });

    var boxForce = boundedBox()
      .bounds([[0, 0], [width, height]])
      .size(function (d) { return [d.width, d.height] });

    var simulation = d3.forceSimulation(nodes)
      .velocityDecay(0.6) // Speed of the simulation: https://github.com/d3/d3-force/blob/master/README.md#simulation_velocityDecay
      .alphaTarget(1)
      .force('box', boxForce)
      .force('collision', collisionForce);

    var drag = d3.drag()
      .on('start', started)
      .on('drag', dragged)
      .on('end', ended);

    var contributions = d3.select('.contributions_container');

    contributions.select('.contributions_content')
      .append('div')
      .attr('class', 'contribution_legend')
      .attr('id', 'contribution_legend')
      .text(users_ideas);

    contributions.select('.contributions_content')
      .append('i')
      .attr('id', 'next')
      .attr('data-toggle', 'next')
      .attr('class', 'fa fa-angle-right fa-3x arrow next_contribution')
      .on('click', updateContributions);

    contributions.select('.contributions_content')
      .append('i')
      .attr('id', 'previous')
      .attr('data-toggle', 'previous')
      .attr('class', 'fa fa-angle-left fa-3x arrow previous_contribution disabled')
      .on('click', updateContributions);

      createCards(nodes);

    $('#next').click(function() {
        page++;
        viewdata = data.slice((page-1)*cardnumber,page*cardnumber);
        var nodes = createNodes(viewdata);
        createCards(nodes);
        if (page === page_max ) {
          d3.select('.next_contribution')
            .classed('disabled', true);
        }

        var simulation = d3.forceSimulation(nodes)
          .velocityDecay(0.6) // Speed of the simulation: https://github.com/d3/d3-force/blob/master/README.md#simulation_velocityDecay
          .alphaTarget(1)
          .force('box', boxForce)
          .force('collision', collisionForce);
    });

    $('#previous').click(function() {
        page--;
        viewdata = data.slice((page-1)*cardnumber,page*cardnumber);
        var nodes = createNodes(viewdata);
        createCards(nodes);
        if (page === 1 ) {
          d3.select('.previous_contribution')
            .classed('disabled', true);
        }

        if (page <= page_max ) {
          d3.select('.next_contribution')
            .classed('disabled', false);
        }

        var simulation = d3.forceSimulation(nodes)
          .velocityDecay(0.6) // Speed of the simulation: https://github.com/d3/d3-force/blob/master/README.md#simulation_velocityDecay
          .alphaTarget(1)
          .force('box', boxForce)
          .force('collision', collisionForce);
    });

    /* Pagination links */
    $('li[data-page]').click(function(e) {
      e.preventDefault();
      page = $(this).data('page');
      viewdata = data.slice((page-1)*cardnumber,page*cardnumber);
      var nodes = createNodes(viewdata);
      createCards(nodes);
      if (page === page_max ) {
        d3.select('.next_contribution')
          .classed('disabled', true);
      }
      $('li[data-page]').removeClass('active');
      $(this).addClass('active');

      if (page === 1 ) {
        d3.select('.previous_contribution')
          .classed('disabled', true);
      }

      if (page < page_max ) {
        d3.select('.next_contribution')
          .classed('disabled', false);
        d3.select('.previous_contribution')
          .classed('disabled', false);
      }

      if (page === page_max ) {
        d3.select('.next_contribution')
          .classed('disabled', true);
      }

      var simulation = d3.forceSimulation(nodes)
        .velocityDecay(0.6) // Speed of the simulation: https://github.com/d3/d3-force/blob/master/README.md#simulation_velocityDecay
        .alphaTarget(1)
        .force('box', boxForce)
        .force('collision', collisionForce);
    });
{'fraction_non_alphanumeric': 0.16898192197906756, 'fraction_numerical': 0.012654614652711704, 'mean_word_length': 2.626984126984127, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 27, 'https://': 8, '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': '4503917', 'n_tokens_mistral': 3356, 'n_tokens_neox': 3216, 'n_words': 570}