<commit_before>const 	React 			= require('react'),
		Link			= require('react-router').Link,
		RouteHandler 	= require('react-router').RouteHandler,
		Pager 			= require('react-paginate'),
		Movie 			= require('./Movie.jsx'),
		// DatePicker 		= require('react-datepicker'),
		// moment 			= require('moment'),
		optionsBO 		= require('./options.js')


// const DatePickerWrapper = React.createClass({
// 	// getInitialState: function() {
// 	// 	return {
// 	// 		date: moment()
// 	// 	}
// 	// },

// 	render: function() {
// 		<span>
// 			<DatePicker
// 				key="example1"
// 				selected={movie.last_watched}
// 				onChange={handleWatched}
// 			/>

// 		</span>
// 	}
// })

module.exports = React.createClass({
	// componentWillUpdate: function() {
	// 	console.log('this.selected', this.selected)
	// 	console.log('selected', this.state.selected)
	// 	this.forced = 0
	// 	if (this.selected) {
	// 		this.forced = this.selected
	// 	}		
	// },
	handlePageClick: function(data) {
		this.shouldScroll = true
		this.selected = data.selected
		const offset = Math.ceil(this.selected * this.props.options.limit);
		optionsBO.setOffset(offset)		
	},

	componentDidUpdate: function() {
		if (this.shouldScroll) {
			window.scrollTo(0, 0)
		}

		this.shouldScroll = false

		// console.log('didUdpate')
	},	

	render: function() {
		const movies = this.props.movies
		const options = this.props.options

		var pagination;
		if (movies.total > options.limit) {
			// console.log('moviesPage.total('+movies.total+')>limit('+options.limit+'); selected='+this.selected)

			pagination = (
		        <Pager previousLabel={<i className="icon-chevron-left"></i>}
		                       nextLabel={<i className="icon-chevron-right"></i>}
		                       breakLabel={<li className="break"><a href="">...</a></li>}
		                       pageNum={Math.ceil(movies.total / options.limit)}
		                       marginPagesDisplayed={3}
		                       pageRangeDisplayed={5}
		                       forceSelected={this.selected}
		                       clickCallback={this.handlePageClick}
		                       containerClassName={"pagination col-xs-12"}
		                       subContainerClassName={"pages"}
		                       activeClass={"active"} />				
			)
		}

		var items = movies.items.map(function(movie) {
			return (
				<Movie movie={movie} key={movie.title+movie.modified} />
			)
		})

		return (
			<section className="row moviep">
				{pagination}

				{items}

				{pagination}
			</section>
		)
	}
})<commit_msg>- Fix bug where pagination wouldn't reset to the first page when changing query term<commit_after>const 	React 			= require('react'),
		Link			= require('react-router').Link,
		RouteHandler 	= require('react-router').RouteHandler,
		Pager 			= require('react-paginate'),
		Movie 			= require('./Movie.jsx'),
		// DatePicker 		= require('react-datepicker'),
		// moment 			= require('moment'),
		optionsBO 		= require('./options.js')


// const DatePickerWrapper = React.createClass({
// 	// getInitialState: function() {
// 	// 	return {
// 	// 		date: moment()
// 	// 	}
// 	// },

// 	render: function() {
// 		<span>
// 			<DatePicker
// 				key="example1"
// 				selected={movie.last_watched}
// 				onChange={handleWatched}
// 			/>

// 		</span>
// 	}
// })

module.exports = React.createClass({
	// componentWillUpdate: function() {
	// 	console.log('this.selected', this.selected)
	// 	console.log('selected', this.state.selected)
	// 	this.forced = 0
	// 	if (this.selected) {
	// 		this.forced = this.selected
	// 	}		
	// },
	handlePageClick: function(data) {
		this.shouldScroll = true
		// this.selected = data.selected
		// const offset = Math.ceil(this.selected * this.props.options.limit);
		const offset = Math.ceil(data.selected * this.props.options.limit);
		optionsBO.setOffset(offset)		
	},

	componentDidUpdate: function() {
		if (this.shouldScroll) {
			window.scrollTo(0, 0)
		}

		this.shouldScroll = false

		// console.log('didUdpate')
	},	

	render: function() {
		const movies = this.props.movies
		const options = this.props.options

		const selected = options.offset / options.limit

		console.log('offset: ' + options.offset + ' limit: ' + options.limit)
		console.log('selected: ' + selected)

		var pagination;
		if (movies.total > options.limit) {
			// console.log('moviesPage.total('+movies.total+')>limit('+options.limit+'); selected='+this.selected)

			pagination = (
		        <Pager previousLabel={<i className="icon-chevron-left"></i>}
		                       nextLabel={<i className="icon-chevron-right"></i>}
		                       breakLabel={<li className="break"><a href="">...</a></li>}
		                       pageNum={Math.ceil(movies.total / options.limit)}
		                       marginPagesDisplayed={3}
		                       pageRangeDisplayed={5}
		                       forceSelected={selected}
		                       clickCallback={this.handlePageClick}
		                       containerClassName={"pagination col-xs-12"}
		                       subContainerClassName={"pages"}
		                       activeClass={"active"} />				
			)
		}

		var items = movies.items.map(function(movie) {
			return (
				<Movie movie={movie} key={movie.title+movie.modified} />
			)
		})

		return (
			<section className="row moviep">
				{pagination}

				{items}

				{pagination}
			</section>
		)
	}
})
{'fraction_non_alphanumeric': 0.16583747927031509, 'fraction_numerical': 0.0029482218536944905, 'mean_word_length': 2.275799637899819, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 37, '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': '737697', 'n_tokens_mistral': 1990, 'n_tokens_neox': 1717, 'n_words': 260}