<commit_before>$(document).ready(function() {
  setInterval(updateCurrentTime, 100);
  captionTime(0.0);
});

var transcript = {};

// function onApiChange(event) {
// video name headline onStateChange
function onStateChange(event) {
  // if (event['playerState'] === 3) {
  if (event) {
    // throw (event['playerState']);
  }
  if (player.getVideoData().title) {
    $('.vidNameNav').html(player.getVideoData().title); // replace vid headline ID with vid title
    $('title').append((' &#47; ') + (player.getVideoData().title)); // append video title to page title
    // window.location = ('/' + player.getVideoData()['video_id']); // TODO: stop this from switching on playback. TODO: stop flash of error message.
    // throw 'state'
  }
}

// video name headline onPlayerReady
function onPlayerReady(event) {
  if (player.getVideoData().title) {
    $('.vidNameNav').html(player.getVideoData().title); // replace vid headline ID with vid title
    $('title').append((' &#47; ') + (player.getVideoData().title)); // append video title to page title
    // throw 'ready'
  }
}

// TODO: test for videos that cannot be embeded
// function onError(event) {
//   throw event
// }


// link timer to timestamp and display caption function
// TODO: time on user side, check API time as failsafe near user next caption time.
$('#timeStamp').html('&nbsp;');
function updateCurrentTime() {
  if (player.getPlayerState() === 1) { // if player playing
    // v2 why round? why not just match nonround to last transcript event?
    var rounded = (Math.round(((player.getCurrentTime()) * 2)) / 2);
    $('#timeStamp').html('Timestamp: ' + 'rounded: ' + rounded + ' fixed: ' + player.getCurrentTime().toFixed(1));
    captionTime(rounded);
  }
}

// display captions to page and clear after six seconds
var captionTime;
captionTime = function(currentTime) {
  var endAndStartTimer;
  if (transcript[currentTime] !== undefined) {
    endAndStartTimer = function() {
      var displayFade;
      displayFade = function() {
        $("#captions").fadeOut("fast");
      };
      clearTimeout(window.hider);
      $("#captions").html(transcript[currentTime]).show();
      window.hider = window.setTimeout(function() {
        displayFade();
      }, 6000);
    };
    window.hider;
    endAndStartTimer();
  }
};

// TESTING: jump timer vid to field time
$('.transcript_input').on('focus', function() {
  // TODO: seekTo auto starts the video. needs to auto start / not auto start based on context. Example: not autostart if timestamp empty.
  // TODO: make auto start work for dynamicly generated rows.
  // if (player.seekTo(($(this).closest('tr').find('input.timestamp_input').val()))) {
    // alert('yo');
  // }
});


// load captions on click
// $('.transcriptDisplaySelect').click(function() {
//   if (player.getPlayerState() === 1) {
//     player.playVideo();
//   }
//   $('#captions').html(''); // clear current transcript display
//   transcript = $.parseJSON($(this).html());
//   // autostart vid
//   alert(player);
// });

// start / stop video control
// $('#starp').click(function() {
//   if (player.getPlayerState() === 1) {
//     player.pauseVideo();
//   } else {
//     player.playVideo();
//   }
// });

// // skip back control
// $('#skipBack').click(function() {
//   player.pauseVideo();
//   player.seekTo((player.getCurrentTime() - 3), true);
//   player.playVideo();
//   // console.log(player.getCurrentTime());
// });<commit_msg>switch URL with related link embed click<commit_after>$(document).ready(function() {
  // TODO: start function on playerReady
  setInterval(updateCurrentTime, 100);
  captionTime(0.0);
});

var transcript = {};

// function onApiChange(event) {
// video name headline onStateChange
function onStateChange(event) {
  // if (event['playerState'] === 3) {
  if (event) {
    // throw (event['playerState']);
  }
  if (player.getVideoData().title) {
    $('.vidNameNav').html(player.getVideoData().title); // replace vid headline ID with vid title
    $('title').append((' &#47; ') + (player.getVideoData().title)); // append video title to page title
    // window.location = ('/' + player.getVideoData()['video_id']); // TODO: stop this from switching on playback. TODO: stop flash of error message.
    // throw 'state'
  }
}

// switch URL with related link embed click
function onStateChange(event) {
 if (window.yovid !== player.getVideoUrl()) {
  if (window.yovid !== undefined) {
    window.location = '/' + player.getVideoData()['video_id'];
  }
}
window.yovid = player.getVideoUrl();
}

// video name headline onPlayerReady
function onPlayerReady(event) {
  if (player.getVideoData().title) {
    $('.vidNameNav').html(player.getVideoData().title); // replace vid headline ID with vid title
    $('title').append((' &#47; ') + (player.getVideoData().title)); // append video title to page title
  }
}

// TODO: test for videos that cannot be embeded
// function onError(event) {
//   throw event
// }


// link timer to timestamp and display caption function
// TODO: time on user side, check API time as failsafe near user next caption time.
$('#timeStamp').html('&nbsp;');
function updateCurrentTime() {
  if (player.getPlayerState() === 1) { // if player playing
    // v2 why round? why not just match nonround to last transcript event?
    var rounded = (Math.round(((player.getCurrentTime()) * 2)) / 2);
    $('#timeStamp').html('Timestamp: ' + 'rounded: ' + rounded + ' fixed: ' + player.getCurrentTime().toFixed(1));
    captionTime(rounded);
  }
}

// display captions to page and clear after six seconds
var captionTime;
captionTime = function(currentTime) {
  var endAndStartTimer;
  if (transcript[currentTime] !== undefined) {
    endAndStartTimer = function() {
      var displayFade;
      displayFade = function() {
        $("#captions").fadeOut("fast");
      };
      clearTimeout(window.hider);
      $("#captions").html(transcript[currentTime]).show();
      window.hider = window.setTimeout(function() {
        displayFade();
      }, 6000);
    };
    window.hider;
    endAndStartTimer();
  }
};

// TESTING: jump timer vid to field time
$('.transcript_input').on('focus', function() {
  // TODO: seekTo auto starts the video. needs to auto start / not auto start based on context. Example: not autostart if timestamp empty.
  // TODO: make auto start work for dynamicly generated rows.
  // if (player.seekTo(($(this).closest('tr').find('input.timestamp_input').val()))) {
    // alert('yo');
  // }
});

// load captions on click
// $('.transcriptDisplaySelect').click(function() {
//   if (player.getPlayerState() === 1) {
//     player.playVideo();
//   }
//   $('#captions').html(''); // clear current transcript display
//   transcript = $.parseJSON($(this).html());
//   // autostart vid
//   alert(player);
// });

// start / stop video control
// $('#starp').click(function() {
//   if (player.getPlayerState() === 1) {
//     player.pauseVideo();
//   } else {
//     player.playVideo();
//   }
// });

// // skip back control
// $('#skipBack').click(function() {
//   player.pauseVideo();
//   player.seekTo((player.getCurrentTime() - 3), true);
//   player.playVideo();
//   // console.log(player.getCurrentTime());
// });
{'fraction_non_alphanumeric': 0.18317860606900374, 'fraction_numerical': 0.006096716087016766, 'mean_word_length': 3.3351351351351353, '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': '4649608', 'n_tokens_mistral': 2219, 'n_tokens_neox': 2151, 'n_words': 564}