<commit_before>$(function() {
  var idClock, options, template;

  var state = {
    startedAt: null,
    stoppedAt: null,
    positions: []
  };

  $('body').css('opacity', 1);
   
  $.get('gpx.mst', function(t) {
    template = t;
    Mustache.parse(template);
  });

  function updateStatus() {
    var accuracy;
    var n = state.positions.length;

    if (n == 0) {
      $('#status').html('Accuracy: none');
      $('#start').addClass('disabled');
    } else {
      accuracy = Math.round(state.positions[n - 1].accuracy);
      $('#status').html('Accuracy: ' + accuracy + ' m');
      $('#start').removeClass('disabled');

      if (accuracy > 50) {
        // TODO
      }
    }
  }

  function success(pos) {
    var position = {
      date: new Date(pos.timestamp).toISOString()
    };

    for (k in pos.coords) {
      position[k] = pos.coords[k] || 0;
    }
    state.positions.push(position)
    updateStatus();
  };

  function error(err) {
    console.warn('ERROR(' + err.code + '): ' + err.message);
  };

  options = {
    enableHighAccuracy: true,
    maximumAge: 0
  };

  navigator.geolocation.watchPosition(success, error, options);

  $('#start').click(function() {
    $('#start').hide();
    $('#stop').show();
    $('#stop').attr('href', '');

    state.startedAt = new Date();
    state.stoppedAt = null;
    state.duration = 0;
    state.positions = [];
    
    idClock = setInterval(function() {
      var clock = moment.unix(++state.duration - 3600);
      $('#clock').text(clock.format('HH:mm:ss'));<commit_msg>Add updateClock()<commit_after>$(function() {
  var idClock, options, template;

  var state = {
    startedAt: null,
    stoppedAt: null,
    positions: []
  };

  $('body').css('opacity', 1);
   
  $.get('gpx.mst', function(t) {
    template = t;
    Mustache.parse(template);
  });

  function updateClock() {
    var clock = moment.unix(state.duration - 3600);

    $('#clock').text(clock.format('HH:mm:ss'));
  }

  function updateStatus() {
    var accuracy;
    var n = state.positions.length;

    if (n == 0) {
      $('#status').html('Accuracy: none');
      $('#start').addClass('disabled');
    } else {
      accuracy = Math.round(state.positions[n - 1].accuracy);
      $('#status').html('Accuracy: ' + accuracy + ' m');
      $('#start').removeClass('disabled');

      if (accuracy > 50) {
        // TODO
      }
    }
  }

  function success(pos) {
    var position = {
      date: new Date(pos.timestamp).toISOString()
    };

    for (k in pos.coords) {
      position[k] = pos.coords[k] || 0;
    }
    state.positions.push(position)
    updateStatus();
  };

  function error(err) {
    console.warn('ERROR(' + err.code + '): ' + err.message);
  };

  options = {
    enableHighAccuracy: true,
    maximumAge: 0
  };

  navigator.geolocation.watchPosition(success, error, options);

  $('#start').click(function() {
    $('#start').hide();
    $('#stop').show();
    $('#stop').attr('href', '');

    state.startedAt = new Date();
    state.stoppedAt = null;
    state.duration = 0;
    state.positions = [];
    
    updateClock();
    idClock = setInterval(function() {
      state.duration++;
      updateClock();
{'fraction_non_alphanumeric': 0.1967934611757309, 'fraction_numerical': 0.007544797233574348, 'mean_word_length': 2.6490825688073394, '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': '163518', 'n_tokens_mistral': 1089, 'n_tokens_neox': 1046, 'n_words': 189}