<commit_before>var streams=${ streams }
var params = { allowScriptAccess: "always", bgcolor: "#cccccc", wmode: "transparent", allowFullScreen: "true" };
var atts = { id: "myytplayer" };

// If the user doesn't have flash, use the HTML5 Video instead. YouTube's
// iFrame API which supports HTML5 is still developmental so it is not default
if (swfobject.hasFlashPlayerVersion("10.1")){
  swfobject.embedSWF(document.location.protocol +  "//www.youtube.com/apiplayer?enablejsapi=1&playerapiid=ytplayer?wmode=transparent",
        "ytapiplayer", "640", "385", "8", null, null, params, atts);
} else {

  //end of this URL may need &origin=http://..... once pushed to production to prevent XSS
  $("#html5_player").attr("src", document.location.protocol +  "//www.youtube.com/embed/" + streams["1.0"] + "?enablejsapi=1&controls=0");
  $("#html5_player").show();

  var tag = document.createElement('script');
  tag.src = document.location.protocol +  "//www.youtube.com/player_api";
  var firstScriptTag = document.getElementsByTagName('script')[0];
  firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
  // Make sure the callback is called once API ready, YT seems to be buggy
  loadHTML5Video();
}
var captions=0;
$("#slider").slider({slide:function(event,ui){seek_slide('slide',event.originalEvent,ui.value);},
                     stop:function(event,ui){seek_slide('stop',event.originalEvent,ui.value);}});

function good() {
    window['console'].log(ytplayer.getCurrentTime());
}

ajax_video=good;

// load the same video speed your last video was at in a sequence
// if the last speed played on video doesn't exist on another video just use 1.0 as default

function add_speed(key, stream) {
  var id = 'speed_' + stream;

  if (key == video_speed) {
    $("#video_speeds").append(' <li class=active id="'+id+'">'+key+'x</li>');
  } else {
    $("#video_speeds").append(' <li id="'+id+'">'+key+'x</li>');
  }

  $("#"+id).click(function(){
    change_video_speed(key, stream);
    $(this).siblings().removeClass("active");
    $(this).addClass("active");
  });
}

var l=[]
for (var key in streams) {
    l.push(key);
}

function sort_by_value(a,b) {
    var x=parseFloat(a);
    var y=parseFloat(b);
    var r=((x < y) ? -1 : ((x > y) ? 1 : 0));
    return r;
}

l.sort(sort_by_value);

$(document).ready(function() {
    video_speed = $.cookie("video_speed");
    console.log("ready");
    console.log(video_speed);

    if (( !video_speed ) || ( !streams[video_speed] )) {
	video_speed = "1.0";
    }
    console.log(video_speed);
    loadNewVideo(streams["1.0"], streams[video_speed], ${ position });

    for(var i=0; i<l.length; i++) {
	add_speed(l[i], streams[l[i]])
    }

});



function toggleVideo(){
  if ($("#video_control").hasClass("play")){
    play();
    $("#video_control").removeClass().addClass("pause");
  } else {
    pause();
    $("#video_control").removeClass().addClass("play");
  }
}

$("#video_control").click(toggleVideo);

// space bar to pause video
$(".video-wrapper").keyup(function(e){
  active = document.activeElement;
  if (e.which == 32) {
    e.preventDefault();
    $("#video_control").click();
  }<commit_msg>fix issue with saving video speed when video speeds are stored in different formats (with or without leading/trailing zeros)<commit_after>var streams=${ streams }
var params = { allowScriptAccess: "always", bgcolor: "#cccccc", wmode: "transparent", allowFullScreen: "true" };
var atts = { id: "myytplayer" };

// If the user doesn't have flash, use the HTML5 Video instead. YouTube's
// iFrame API which supports HTML5 is still developmental so it is not default
if (swfobject.hasFlashPlayerVersion("10.1")){
  swfobject.embedSWF(document.location.protocol +  "//www.youtube.com/apiplayer?enablejsapi=1&playerapiid=ytplayer?wmode=transparent",
        "ytapiplayer", "640", "385", "8", null, null, params, atts);
} else {

  //end of this URL may need &origin=http://..... once pushed to production to prevent XSS
  $("#html5_player").attr("src", document.location.protocol +  "//www.youtube.com/embed/" + streams["1.0"] + "?enablejsapi=1&controls=0");
  $("#html5_player").show();

  var tag = document.createElement('script');
  tag.src = document.location.protocol +  "//www.youtube.com/player_api";
  var firstScriptTag = document.getElementsByTagName('script')[0];
  firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
  // Make sure the callback is called once API ready, YT seems to be buggy
  loadHTML5Video();
}
var captions=0;
$("#slider").slider({slide:function(event,ui){seek_slide('slide',event.originalEvent,ui.value);},
                     stop:function(event,ui){seek_slide('stop',event.originalEvent,ui.value);}});

function good() {
    window['console'].log(ytplayer.getCurrentTime());
}

ajax_video=good;

// load the same video speed your last video was at in a sequence
// if the last speed played on video doesn't exist on another video just use 1.0 as default

function add_speed(key, stream) {
  var id = 'speed_' + stream;

  if (key == video_speed) {
    $("#video_speeds").append(' <li class=active id="'+id+'">'+key+'x</li>');
  } else {
    $("#video_speeds").append(' <li id="'+id+'">'+key+'x</li>');
  }

  $("#"+id).click(function(){
    change_video_speed(key, stream);
    $(this).siblings().removeClass("active");
    $(this).addClass("active");
  });
}

var l=[]
for (var key in streams) {
    l.push(key);
}

function sort_by_value(a,b) {
    var x=parseFloat(a);
    var y=parseFloat(b);
    var r=((x < y) ? -1 : ((x > y) ? 1 : 0));
    return r;
}

l.sort(sort_by_value);

$(document).ready(function() {
    video_speed = $.cookie("video_speed");

    //ugly hack to account for different formats in vid speed in the XML (.75 vs 0.75, 1.5 vs 1.50);
    if (( !video_speed ) || ( !streams[video_speed] && !streams[video_speed + "0"]) && !streams[video_speed.slice(0,-1)] && !streams[video_speed.slice(1)] && !streams["0" + video_speed]) {
      video_speed = "1.0";
    }

    if (streams[video_speed + "0"]){
      video_speed = video_speed + "0";
    } else if (streams[video_speed.slice(0, -1)]){
      video_speed = video_speed.slice(0, -1);
    } else if (streams[video_speed.slice(1)]) {
      video_speed = video_speed.slice(1);
    } else if (streams["0" + video_speed]) {
      video_speed = "0" + video_speed;
    }

    loadNewVideo(streams["1.0"], streams[video_speed], ${ position });

    for(var i=0; i<l.length; i++) {
      add_speed(l[i], streams[l[i]])
    }

});



function toggleVideo(){
  if ($("#video_control").hasClass("play")){
    play();
    $("#video_control").removeClass().addClass("pause");
  } else {
    pause();
    $("#video_control").removeClass().addClass("play");
  }
}

$("#video_control").click(toggleVideo);

// space bar to pause video
$(".video-wrapper").keyup(function(e){
  active = document.activeElement;
  if (e.which == 32) {
    e.preventDefault();
    $("#video_control").click();
  }
{'fraction_non_alphanumeric': 0.18918141274636743, 'fraction_numerical': 0.013379369874838154, 'mean_word_length': 4.1958146487294465, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 6, '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': '6835364', 'n_tokens_mistral': 2353, 'n_tokens_neox': 2327, 'n_words': 525}