<commit_before>'use strict';

var _        = require("underscore");
var React    = require('react');
var PageView = require("./PageView");


var PaginationListView = React.createClass({
  render: function() {
    if (this.props.pageNum <= this.props.pageRangeDisplayed) {
      items = _.range(1, this.props.pageNum + 1).map(function(page, index) {
        return (
          <PageView
            onClick={this.props.onPageSelected.bind(null, index)}
            selected={this.props.selected === index}
            activeClass={this.props.activeClass}
            key={index}
            page={page} />
        )
      }.bind(this));
    } else {
      var leftSide = (this.props.pageRangeDisplayed / 2),
          rightSide = (this.props.pageRangeDisplayed - leftSide);

      if (this.props.selected > this.props.pageNum - this.props.pageRangeDisplayed / 2) {
        rightSide = this.props.pageNum - this.props.selected;
        leftSide = this.props.pageRangeDisplayed - rightSide;
      }
      else if (this.props.selected < this.props.pageRangeDisplayed / 2) {
        leftSide = this.props.selected;
        rightSide = this.props.pageRangeDisplayed - leftSide;
      }

      var items = [];
      var index;

      for (index = 1; index < this.props.pageNum + 1; index++) {
        var pageView = (
          <PageView
            onClick={this.props.onPageSelected.bind(null, index)}
            selected={this.props.selected === index}
            activeClass={this.props.activeClass}
            key={index}
            page={index} />
        );

        if (index <= this.props.marginPagesDisplayed) {
          items.push(pageView);
          continue;
        }
        if (index > this.props.pageNum - this.props.marginPagesDisplayed) {
          items.push(pageView);
          continue;
        }
        if ((index >= this.props.selected - leftSide) && (index <= this.props.selected + rightSide)) {
          items.push(pageView);
          continue;
        }
        if (items[items.length-1] !== this.props.breakLabel) {
          items.push(this.props.breakLabel);
        }
      }
    }

    return (
      <ul className={this.props.subContainerClassName}>
        {items}
      </ul>
    );
  }
});

module.exports = PaginationListView;<commit_msg>Fix dynamic children bug.<commit_after>'use strict';

var _        = require("underscore");
var React    = require('react');
var PageView = require("./PageView");


var PaginationListView = React.createClass({

  render: function() {

    var items = {};

    if (this.props.pageNum <= this.props.pageRangeDisplayed) {

      var pageViews = _.range(1, this.props.pageNum + 1).map(function(page, index) {
        return (
          <PageView
            onClick={this.props.onPageSelected.bind(null, index)}
            selected={this.props.selected === index}
            activeClass={this.props.activeClass}
            page={page} />
        )
      }.bind(this));

      pageViews.forEach(function(pageView, index) {
        items['item' + index] = pageView;
      });

    } else {

      var leftSide  = (this.props.pageRangeDisplayed / 2);
      var rightSide = (this.props.pageRangeDisplayed - leftSide);

      if (this.props.selected > this.props.pageNum - this.props.pageRangeDisplayed / 2) {
        rightSide = this.props.pageNum - this.props.selected;
        leftSide  = this.props.pageRangeDisplayed - rightSide;
      }

      if (this.props.selected < this.props.pageRangeDisplayed / 2) {
        leftSide  = this.props.selected;
        rightSide = this.props.pageRangeDisplayed - leftSide;
      }

      var index;

      for (index = 1; index < this.props.pageNum + 1; index++) {

        var pageView = (
          <PageView
            onClick={this.props.onPageSelected.bind(null, index)}
            selected={this.props.selected === index}
            activeClass={this.props.activeClass}
            page={index} />
        );

        if (index <= this.props.marginPagesDisplayed) {
          items['item' + index] = pageView;
          continue;
        }

        if (index > this.props.pageNum - this.props.marginPagesDisplayed) {
          items['item' + index] = pageView;
          continue;
        }

        if ((index >= this.props.selected - leftSide) && (index <= this.props.selected + rightSide)) {
          items['item' + index] = pageView;
          continue;
        }

        if (items[items.length-1] !== this.props.breakLabel) {
          items['breaklabel'] = this.props.breakLabel;
        }
      }
    }

    return (
      <ul className={this.props.subContainerClassName}>
        {items}
      </ul>
    );
  }
});

module.exports = PaginationListView;
{'fraction_non_alphanumeric': 0.13444302176696543, 'fraction_numerical': 0.0034144259496372174, 'mean_word_length': 2.065402223675605, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 17, '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': '3938442', 'n_tokens_mistral': 1397, 'n_tokens_neox': 1351, 'n_words': 241}