<commit_before>/*
  Copyright (c) 2013 <NAME> <<EMAIL>>
  Licensed under the terms of the MIT license.
  See the file LICENSE for copying permissions.
*/


'use strict';

angular.module('SecondhandApp')
  .controller('TimerCtrl', function($scope, SessionTimer) {
    $scope.SessionTimer = SessionTimer;
  });<commit_msg>Added a function to create a WorkSession when timer is stopped.<commit_after>/*
  Copyright (c) 2013 <NAME> <<EMAIL>>
  Licensed under the terms of the MIT license.
  See the file LICENSE for copying permissions.
*/


'use strict';

angular.module('SecondhandApp')
  .controller('TimerCtrl', function($scope, WorkSession, SessionTimer) {
    $scope.SessionTimer = SessionTimer;
    $scope.savingWorkSession = false;

    $scope.endWorkSession = function() {
      $scope.savingWorkSession = true;
      SessionTimer.pauseTimer();

      var session = new WorkSession({
        task: SessionTimer.currentTask.resource_uri,
        start_time: SessionTimer.startTime,
        end_time: SessionTimer.endTime
      });

      session.$save(function(result) {
        SessionTimer.resetTimer();
        $scope.savingWorkSession = false;
      });
    };

    $scope.sidebarActive = function() {
      return SessionTimer.running || $scope.savingWorkSession;
    };
  });
{'fraction_non_alphanumeric': 0.11828793774319066, 'fraction_numerical': 0.0062256809338521405, 'mean_word_length': 3.512280701754386, 'pattern_counts': {'":': 0, '<': 9, '<?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': '7637027', 'n_tokens_mistral': 375, 'n_tokens_neox': 356, 'n_words': 95}