<commit_before>'use strict';

define([
  'jquery',
  'underscore',
  'marionette',
  'dust',
  'dust.marionette',
  'controllers/event-bus',
  'archive/posts-template',
  'content/content-template'
], function ($, _, Marionette, dust, dustMarionette, EventBus) {
  var ContentView = Backbone.Marionette.ItemView.extend({
    tagName:  'div id="posts"',
    template: 'content/content-template.dust',

    events: {
      'click .b3-post-title > a': 'selectPost',
      'click .pagination-next':   'renderNextPage',
      'click .pagination-prev':   'renderPrevPage'
    },

    collectionEvents: {
      "reset":  "render"
    },

    initialize: function (options) {
      this.page  = 1;
      this.limit = options.limit || 11;
    },

    serializeData: function () {
      return _.extend(this.getDustTemplate(), {posts: this.getModels()});
    },

    getModels: function () {
      return $.map(this.collection.models, function (post, index) {
        return post.toJSON();
      });
    },

    selectPost: function (ev) {
      var input = $(ev.currentTarget).attr('id');
      EventBus.trigger('router:nav', {route: 'post/' + input, options: {trigger: true}});
      return false;
    },

    renderNextPage: function () {
      if (!this.isLastPage()) {
        this.page++;
        this.collection.fetch(this.getParams());
      }

      return false;
    },

    renderPrevPage: function () {
      if (!this.isFirstPage()) {
        this.page--;
        this.collection.fetch(this.getParams());
      }

      return false;
    },

    getDustTemplate: function () {<commit_msg>To allow window to go back up when refreshing<commit_after>'use strict';

define([
  'jquery',
  'underscore',
  'marionette',
  'dust',
  'dust.marionette',
  'controllers/event-bus',
  'archive/posts-template',
  'content/content-template'
], function ($, _, Marionette, dust, dustMarionette, EventBus) {
  var ContentView = Backbone.Marionette.ItemView.extend({
    tagName:  'div id="posts"',
    template: 'content/content-template.dust',

    events: {
      'click .b3-post-title > a': 'selectPost',
      'click .pagination-next':   'renderNextPage',
      'click .pagination-prev':   'renderPrevPage'
    },

    collectionEvents: {
      "reset":  "render"
    },

    initialize: function (options) {
      this.page  = 1;
      this.limit = options.limit || 11;
    },

    serializeData: function () {
      return _.extend(this.getDustTemplate(), {posts: this.getModels()});
    },

    getModels: function () {
      return $.map(this.collection.models, function (post, index) {
        return post.toJSON();
      });
    },

    selectPost: function (ev) {
      var input = $(ev.currentTarget).attr('id');
      EventBus.trigger('router:nav', {route: 'post/' + input, options: {trigger: true}});
      return false;
    },

    renderNextPage: function () {
      if (!this.isLastPage()) {
        this.page++;
        this.collection.fetch(this.getParams());
      }
    },

    renderPrevPage: function () {
      if (!this.isFirstPage()) {
        this.page--;
        this.collection.fetch(this.getParams());
      }
    },

    getDustTemplate: function () {
{'fraction_non_alphanumeric': 0.16393442622950818, 'fraction_numerical': 0.0025220680958385876, 'mean_word_length': 2.6513233601841195, 'pattern_counts': {'":': 2, '<': 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': '2611105', 'n_tokens_mistral': 1024, 'n_tokens_neox': 988, 'n_words': 192}