<commit_before>var socket = io.connect();

var defaultContent;

var show = function(data) {
  var imageRegex = /.+(jpg|jpeg|gif|png)$/;
  var videoRegex = /.+youtube\.com\/watch.+/;

  clear();
  if(data.action === "image" || imageRegex.test(data.url)){
    showImage(data);
  }
  if(data.action === "video" || videoRegex.test(data.url)){
    showVideo(data);
  }
  if(data.action === "iframe"){
    showIFrame(data);
  }
};

var showImage = function(data) {
  $("div.showImage").css({"background-image": "url('"+data.url+"')",
                          "background-size": "contain",
                          "background-repeat": "no-repeat"});
  $("div.showImage").addClass("show");
};

var showIFrame = function(data) {
  $("div.showIFrame").html("<iframe frameborder='0' src='"+data.url+"' />");
  $("div.showIFrame").addClass("show");
};

var showVideo = function(data) {
  // This one is going to be a bit more complex.
  // To start only support youtube, but it would be great to return to the deault 
  // at the end of the video.

  var video_id = data.url.split('v=')[1];<commit_msg>Factor out regex guessing, always take action if provided.<commit_after>var socket = io.connect();

var defaultContent;

var show = function(data) {
  clear();

  if (data.action !== undefined) {
    executeAction(data.action, data);
  } else if(data.url !== undefined) {
    executeAction(guessActionByUrl(data.url), data);
  }
};

var guessActionByUrl = function(url) {
  var imageRegex = /.+(jpg|jpeg|gif|png)$/;
  var videoRegex = /.+youtube\.com\/watch.+/;

  if (imageRegex.test(url)) {
    return "image";
  }
  if (videoRegex.test(url)) {
    return "video";
  }
};

var executeAction = function(action, data) {
  if(action === "image"){
    showImage(data);
  }
  if(action === "video"){
    showVideo(data);
  }
  if(action === "iframe"){
    showIFrame(data);
  }
};

var showImage = function(data) {
  $("div.showImage").css({"background-image": "url('"+data.url+"')",
                          "background-size": "contain",
                          "background-repeat": "no-repeat"});
  $("div.showImage").addClass("show");
};

var showIFrame = function(data) {
  $("div.showIFrame").html("<iframe frameborder='0' src='"+data.url+"' />");
  $("div.showIFrame").addClass("show");
};

var showVideo = function(data) {
  // This one is going to be a bit more complex.
  // To start only support youtube, but it would be great to return to the deault 
  // at the end of the video.

  var video_id = data.url.split('v=')[1];
{'fraction_non_alphanumeric': 0.19390581717451524, 'fraction_numerical': 0.0015829046299960427, 'mean_word_length': 3.2774957698815568, 'pattern_counts': {'":': 6, '<': 5, '<?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': '1291056', 'n_tokens_mistral': 867, 'n_tokens_neox': 836, 'n_words': 190}