<commit_before>
/**
var running;
function runningAnimate(num) {
  num = num || 0;
  if (num > 9) num = 0;
  setFavicon('loading-' + num);
  running = setTimeout(function () {
    runningAnimate(num + 1);
  }, 100);
}
**/

function setFavicon(status) {
  $('link[rel*="icon"]').attr('href', '/images/icons/favicon-' + status + '.png');
}

function animateFav() {
  var alt = false;
  function switchit() {
    setFavicon('running' + (alt ? '-alt' : ''));
    alt = !alt;
  }
  return setInterval(switchit, 500);
}

angular.module('JobStatus', [], function ($interpolateProvider) {
  $interpolateProvider.startSymbol('[[');
  $interpolateProvider.endSymbol(']]');
})
  .controller('JobCtrl', ['$scope', '$element', function ($scope, $element) {
    // TODO get this via ajax.
    $scope.$watch('job.status', function (value) {
      var runtime = null;
      if (value === 'running') {
        if (runtime === null) {
          runtime = animateFav();
        }
      } else {
        if (runtime !== null) {
          clearInterval(runtime);
        }
        setFavicon(value);
      }
    });
    $scope.job = window.job;
    $scope.repo = window.repo;
    $scope.startTest = function () {
      if ($scope.job.status === 'running' ||
          $scope.job.status === 'submitted') return;
      startJob($scope.job.repo_url, 'TEST_ONLY');
      $scope.job = {
        repo_url: $scope.job.repo_url,
        status: 'submitted',
        output: ''
      };
    };
    $scope.startDeploy = function () {
      if ($scope.job.status === 'running' ||
          $scope.job.status === 'submitted') return;
      startJob($scope.job.repo_url, 'TEST_AND_DEPLOY');
      $scope.job = {
        repo_url: $scope.job.repo_url,
        status: 'submitted',
        output: ''
      };
    };
    $('[data-toggle="tooltip"]', $element[0]).tooltip();

    // Socket update stuff
    var console = document.querySelector('pre.console-output');
    io.connect().on('start', function (data) {
      if (data.repo_url != $scope.job.repo_url) return;
      $scope.job = {
        repo_url: $scope.job.repo_url,
        status: 'running',
        output: ''
      };
      $scope.$digest();
    }).on('update', function (data) {
      if (data.repo_url != $scope.job.repo_url) return;
      if ($scope.job.status !== 'running') {
        $scope.job = {
          repo_url: $scope.job.repo_url,
          status: 'running',<commit_msg>console scrolls to bottom on page load. fixes #128<commit_after>
/**
var running;
function runningAnimate(num) {
  num = num || 0;
  if (num > 9) num = 0;
  setFavicon('loading-' + num);
  running = setTimeout(function () {
    runningAnimate(num + 1);
  }, 100);
}
**/

function setFavicon(status) {
  $('link[rel*="icon"]').attr('href', '/images/icons/favicon-' + status + '.png');
}

function animateFav() {
  var alt = false;
  function switchit() {
    setFavicon('running' + (alt ? '-alt' : ''));
    alt = !alt;
  }
  return setInterval(switchit, 500);
}

angular.module('JobStatus', [], function ($interpolateProvider) {
  $interpolateProvider.startSymbol('[[');
  $interpolateProvider.endSymbol(']]');
})
  .controller('JobCtrl', ['$scope', '$element', function ($scope, $element) {
    // TODO get this via ajax.
    $scope.$watch('job.status', function (value) {
      var runtime = null;
      if (value === 'running') {
        if (runtime === null) {
          runtime = animateFav();
        }
      } else {
        if (runtime !== null) {
          clearInterval(runtime);
        }
        setFavicon(value);
      }
    });
    $scope.job = window.job;
    $scope.repo = window.repo;
    $scope.startTest = function () {
      if ($scope.job.status === 'running' ||
          $scope.job.status === 'submitted') return;
      startJob($scope.job.repo_url, 'TEST_ONLY');
      $scope.job = {
        repo_url: $scope.job.repo_url,
        status: 'submitted',
        output: ''
      };
    };
    $scope.startDeploy = function () {
      if ($scope.job.status === 'running' ||
          $scope.job.status === 'submitted') return;
      startJob($scope.job.repo_url, 'TEST_AND_DEPLOY');
      $scope.job = {
        repo_url: $scope.job.repo_url,
        status: 'submitted',
        output: ''
      };
    };
    $('[data-toggle="tooltip"]', $element[0]).tooltip();

    // Socket update stuff
    var console = document.querySelector('pre.console-output');

    setTimeout(function () {
      console.scrollTop = console.scrollHeight;
    }, 10);

    io.connect().on('start', function (data) {
      if (data.repo_url != $scope.job.repo_url) return;
      $scope.job = {
        repo_url: $scope.job.repo_url,
        status: 'running',
        output: ''
      };
      $scope.$digest();
    }).on('update', function (data) {
      if (data.repo_url != $scope.job.repo_url) return;
      if ($scope.job.status !== 'running') {
        $scope.job = {
          repo_url: $scope.job.repo_url,
          status: 'running',
{'fraction_non_alphanumeric': 0.18563357546408393, 'fraction_numerical': 0.005447941888619854, 'mean_word_length': 2.505657708628006, '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': '4020158', 'n_tokens_mistral': 1655, 'n_tokens_neox': 1616, 'n_words': 311}