<commit_before>var CONSTANTS = window.CONSTANTS
var ActionTypes = CONSTANTS.ActionTypes
// var Dispatcher = require('../dispatcher');
var Store = require('./es6_store')

var parsedUri = parseUri(window.location) || {};
var query = parsedUri.query || {};
var currentPage = query.page || 1
var totalPages = 1

class PaginationStore extends Store {
  constructor() {
    super()

    this.dispatchToken = Dispatcher.register((action) => {
      switch (action.type) {
        case ActionTypes.PAGINATION_PAGE_CHANGED:
          _setPage(action)
          this.emitChange()
          break
        case ActionTypes.PAGINATION_TOTAL_PAGES_RECEIVE:
          _setTotalPages(action)
          this.emitChange()
          break
      }
    })
  }

  getCurrentPage() {
    return currentPage
  }

  getTotalPages() {
    return totalPages
  }
}

var store = new PaginationStore()

var dataTag = document.getElementById('PaginationStore')
if (dataTag) {
  var data = JSON.parse(dataTag.innerHTML);

  Dispatcher.dispatch({
    type: ActionTypes.PAGINATION_TOTAL_PAGES_RECEIVE,
    currentPage: data.current_page,
    totalPages: data.total_pages
  })
}

module.exports = store

function _setPage(action) {
  currentPage = action.page
}<commit_msg>Fix pagination initialization<commit_after>var CONSTANTS = window.CONSTANTS
var ActionTypes = CONSTANTS.ActionTypes
// var Dispatcher = require('../dispatcher')
var Store = require('./es6_store')
var url = require('url')
var qs = require('qs')

var parsedUri = url.parse(window.location.toString())
var query = qs.parse(parsedUri.query || {})
var currentPage = parseInt(query.page || 1, 10)
var totalPages = 1

class PaginationStore extends Store {
  constructor() {
    super()

    this.dispatchToken = Dispatcher.register((action) => {
      switch (action.type) {
        case ActionTypes.PAGINATION_PAGE_CHANGED:
          _setPage(action)
          this.emitChange()
          break
        case ActionTypes.PAGINATION_TOTAL_PAGES_RECEIVE:
          _setTotalPages(action)
          this.emitChange()
          break
      }
    })
  }

  getCurrentPage() {
    return currentPage
  }

  getTotalPages() {
    return totalPages
  }
}

var store = new PaginationStore()

var dataTag = document.getElementById('PaginationStore')
if (dataTag) {
  var data = JSON.parse(dataTag.innerHTML)

  Dispatcher.dispatch({
    type: ActionTypes.PAGINATION_TOTAL_PAGES_RECEIVE,
    currentPage: data.current_page,
    totalPages: data.total_pages
  })
}

module.exports = store

function _setPage(action) {
  currentPage = action.page
}
{'fraction_non_alphanumeric': 0.10756040530007795, 'fraction_numerical': 0.003117692907248636, 'mean_word_length': 3.3142857142857145, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '3100726', 'n_tokens_mistral': 826, 'n_tokens_neox': 795, 'n_words': 161}