<commit_before>angular.module( 'app', [
  'app.about',
  'app.build',
  'app.language',
  'app.lap',
  'app.play',
  'app.square',
  'app.variant',
  'ngCookies',
  'templates-app',
  'templates-common',
  'ui.router'
])

.config( function myAppConfig ( $stateProvider, $urlRouterProvider ) {
  $urlRouterProvider.otherwise( '/play' );
})

.run( function run () {
})

.controller( 'AppCtrl', function AppCtrl ( $scope, $location ) {
  $scope.$on('$stateChangeSuccess', function(event, toState, toParams, fromState, fromParams){
    if ( angular.isDefined( toState.data.pageTitle ) ) {
      $scope.pageTitle = toState.data.pageTitle + ' | Hub' ;
    }
  });
})

.factory('session', function ($rootScope, $cookies) {
  var game = {
    language: '',
    dialect: '',
    progression: '',
    progressionId: '',
    variant: '',
    variantId: '',
    lap: undefined,
    lapId: '',
  };
  var defaultGame = {
    language: 'Irish',
    dialect: 'Connacht',
    progression: 'Brían\'s Favorite',
    progressionId: 'progressionId',
    variant: 'Connemara-1',
    variantId: 'variantId',
    lap: undefined,
    lapId: '',
  };
  game = defaultGame;

  if ($cookies.game) {
    game = $cookies.game;
  }

  var isValidGame = function() {
    return !_.isEmpty(game.language) &&
      !_.isEmpty(game.dialect) &&
      !_.isEmpty(game.progression) &&
      !_.isEmpty(game.variant);
  };

  var session = {
    setGame: function(_game_) {
      game = _.clone(_game_);
      $cookies.game = game;
      $rootScope.$broadcast('gameChanged');
    },

    getGame: function() {
      return _.clone(game);
    },

    isValidGame: isValidGame,

    isValidLap: function() {
      return isValidGame() && !_.isEmpty(game.lapId);
    },

  };

  return session;
})

;

<commit_msg>Use cookies to keep users' place<commit_after>angular.module( 'app', [
  'app.about',
  'app.build',
  'app.language',
  'app.lap',
  'app.play',
  'app.square',
  'app.variant',
  'ngCookies',
  'templates-app',
  'templates-common',
  'ui.router'
])

.config( function myAppConfig ( $stateProvider, $urlRouterProvider ) {
  $urlRouterProvider.otherwise( '/play' );
})

.run( function run () {
})

.controller( 'AppCtrl', function AppCtrl ( $scope, $location ) {
  $scope.$on('$stateChangeSuccess', function(event, toState, toParams, fromState, fromParams){
    if ( angular.isDefined( toState.data.pageTitle ) ) {
      $scope.pageTitle = toState.data.pageTitle + ' | Hub' ;
    }
  });
})

.factory('session', function ($rootScope, $cookies) {
  var game = {
    language: '',
    dialect: '',
    progression: '',
    progressionId: '',
    variant: '',
    variantId: '',
    lap: undefined,
    lapId: '',
  };

  if ($cookies.game) {
    game = angular.fromJson($cookies.game);
  }

  var isValidGame = function() {
    return !_.isEmpty(game.language) &&
      !_.isEmpty(game.dialect) &&
      !_.isEmpty(game.progression) &&
      !_.isEmpty(game.variant);
  };

  var session = {
    setGame: function(_game_) {
      game = _.clone(_game_);
      $cookies.game = angular.toJson(game);
      $rootScope.$broadcast('gameChanged');
    },

    getGame: function() {
      return _.clone(game);
    },

    isValidGame: isValidGame,

    isValidLap: function() {
      return isValidGame() && !_.isEmpty(game.lapId);
    },

  };

  return session;
})

;


{'fraction_non_alphanumeric': 0.17860353611027868, 'fraction_numerical': 0.00029967036260113877, 'mean_word_length': 3.016847172081829, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2058325', 'n_tokens_mistral': 1159, 'n_tokens_neox': 1141, 'n_words': 205}