<commit_before>;(function(window) {
  'use strict';

  var angular = window.angular;

  angular
    .module('tuchong-daily')
    .controller('home', [
      '$scope',
      'Store',
      '$ionicLoading',
      '$timeout',
      'imageLoader',
      'share',
      '$ionicModal',
      '$rootScope',
      '$cordovaDialogs',
      home
    ]);

  function home(scope, Store, $ionicLoading, $timeout, imageLoader, share, $ionicModal, $rootScope, $cordovaDialogs) {
    // When Push Received,
    // Render this notified post as first post.
    $rootScope.$on('pushNotificationReceived', pushNotificationReceived);

    scope.share = share.popup;
    scope.makeCssUri = makeCssUri;
    scope.openZoom = openZoom;
    scope.hideZoom = hideZoom;

    var slides = null;
    var childrenSlides = {};

    var backgrounds = scope.backgrounds = [];
    var childrens = scope.childrens = {};

    // Show loading
    $ionicLoading.show();

    // Read local cache from localStorage
    if (Store.cache.collections)
      return setup(Store.cache.collections);

    // Open a request
    fetch();

    // Fetch fresh data from API server
    function fetch(id) {
      var query = {};
      
      if (id)
        query.postId = id;

      Store[id ? 'post' : 'hot'].get(query, success, fail);

      function success(data) {
        if (id) {
          data.postId = id;
          return setup([data]);
        }

        if (!data.collections)
          return fail();

        // Setup a few slides
        setup(data.collections);

        // Save all data to cache
        Store.save('collections', data);
      }

      function fail(err) {
        $ionicLoading.show({
          template: '<i class="icon ion-ios-close-outline"></i> 网络连接失败...请稍后再试'
        });
        return false;
      }
    }

    // Setup slides view
    function setup(data) {
      var rendered = scope.collections && scope.collections.length > 0;

      scope.collections = rendered ?
        scope.collections.concat(data) : 
        data;

      // Show befor init slides
      if (!scope.slidesReady)
        scope.slidesReady = true;

      // Hide loading
      $ionicLoading.hide();

      var targetIndex = rendered && data.length === 1 ? 
        findIndex(data[0].postId, scope.collections) :
        0;

      // Load cover image
      loadCover(targetIndex, { 
        setupChildrenSwiper: true 
      });

      if (targetIndex === 0)
        loadCover(1);

      // Init the slides on next tick
      $timeout(function() {
        // When Push Received
        if (rendered && slides) {
          slides.updateSlidesSize();

          if (targetIndex !== 0)
            slides.slideTo(targetIndex);

          return;
        }

        slides = new Swiper('.swiper-container-collection', {
          onSlideChangeStart: function() {
            loadCover(slides.activeIndex + 1, { 
              setupChildrenSwiper: true,
              loadFirstChild: true
            });
          }
        });
      }, 10);
    }
<commit_msg>Fix a params typo<commit_after>;(function(window) {
  'use strict';

  var angular = window.angular;

  angular
    .module('tuchong-daily')
    .controller('home', [
      '$scope',
      'Store',
      '$ionicLoading',
      '$timeout',
      'imageLoader',
      'share',
      '$ionicModal',
      '$rootScope',
      '$cordovaDialogs',
      home
    ]);

  function home(scope, Store, $ionicLoading, $timeout, imageLoader, share, $ionicModal, $rootScope, $cordovaDialogs) {
    // When Push Received,
    // Render this notified post as first post.
    $rootScope.$on('pushNotificationReceived', pushNotificationReceived);

    scope.share = share.popup;
    scope.makeCssUri = makeCssUri;
    scope.openZoom = openZoom;
    scope.hideZoom = hideZoom;

    var slides = null;
    var childrenSlides = {};

    var backgrounds = scope.backgrounds = [];
    var childrens = scope.childrens = {};

    // Show loading
    $ionicLoading.show();

    // Read local cache from localStorage
    if (Store.cache.collections)
      return setup(Store.cache.collections);

    // Open a request
    fetch();

    // Fetch fresh data from API server
    function fetch(id) {
      var query = {};
      
      if (id)
        query.postId = id;

      Store[id ? 'post' : 'hot'].get(query, success, fail);

      function success(data) {
        if (id) {
          data.postId = id;
          return setup([data]);
        }

        if (!data.collections)
          return fail();

        // Setup a few slides
        setup(data.collections);

        // Save all data to cache
        Store.save('collections', data);
      }

      function fail(err) {
        $ionicLoading.show({
          template: '<i class="icon ion-ios-close-outline"></i> 网络连接失败...请稍后再试'
        });
        return false;
      }
    }

    // Setup slides view
    function setup(data) {
      var rendered = scope.collections && scope.collections.length > 0;

      scope.collections = rendered ?
        scope.collections.concat(data) : 
        data;

      // Show befor init slides
      if (!scope.slidesReady)
        scope.slidesReady = true;

      // Hide loading
      $ionicLoading.hide();

      var targetIndex = rendered && data.length === 1 ? 
        findIndex(data[0].postId, scope.collections) :
        0;

      // Load cover image
      loadCover(targetIndex, { 
        setupChildrenSwiper: true,
        loadFirstChild: true
      });

      if (targetIndex === 0)
        loadCover(1);

      // Init the slides on next tick
      $timeout(function() {
        // When Push Received
        if (rendered && slides) {
          slides.updateSlidesSize();

          if (targetIndex !== 0)
            slides.slideTo(targetIndex);

          return;
        }

        slides = new Swiper('.swiper-container-collection', {
          onSlideChangeStart: function() {
            loadCover(slides.activeIndex + 1, { 
              setupChildrenSwiper: true,
              loadFirstChild: true
            });
          }
        });
      }, 10);
    }

{'fraction_non_alphanumeric': 0.124608537992418, 'fraction_numerical': 0.0032965221691115872, 'mean_word_length': 1.8991877687529861, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, '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': '3292109', 'n_tokens_mistral': 1826, 'n_tokens_neox': 1734, 'n_words': 411}