<commit_before>/* This Source Code Form is subject to the terms of the MIT license
 * If a copy of the MIT license was not distributed with this file, you can
 * obtain one at http://www.mozillapopcorn.org/butter-license.txt */

function init( window, document ) {

  function requestFullscreen( elem ) {
    // Prefix + case differences.
    if ( elem.requestFullscreen ) {
      elem.requestFullscreen();
    } else if ( elem.mozRequestFullscreen ) {
      elem.mozRequestFullscreen();
    } else if ( elem.mozRequestFullScreen ) {
      elem.mozRequestFullScreen();
    } else if ( elem.webkitRequestFullscreen ) {
      elem.webkitRequestFullscreen();
    }
  }

  function cancelFullscreen() {
    // Prefix + case differences.
    if ( document.exitFullscreen ) {
      document.exitFullscreen();
    } else if ( document.mozCancelFullscreen ) {
      document.mozCancelFullscreen();
    } else if ( document.mozCancelFullScreen ) {
      document.mozCancelFullScreen();
    } else if ( document.webkitCancelFullscreen ) {
      document.webkitCancelFullscreen();
    }
  }

  function $( id ) {
    if( typeof id !== "string" ) {
      return id;
    }
    return document.getElementById( id );
  }

  function isVisible( id ) {
    return $( id ).style.display !== "none";
  }

  function show( elem ) {
    elem = $( elem );
    elem.style.display = "block";
  }

  function hide( elem ) {
    elem = $( elem );
    elem.style.display = "none";
  }

  function setupClickHandlers( popcorn, config ) {
    function replay() {
      popcorn.play();
    }

    function togglePlay() {
      if( isVisible( "post-roll" ) ||
          isVisible( "share" ) ) {
        return;
      }
      popcorn[ popcorn.paused() ? "play" : "pause" ]();
    }
    $( "play-pause" ).addEventListener( "click", togglePlay, false );

    $( "replay-post" ).addEventListener( "click", replay, false );
    $( "replay-share" ).addEventListener( "click", replay, false );

    $( "share-post" ).addEventListener( "click", function() {
      hide( "post-roll" );
      show( "share" );
    }, false );

    $( "share-share" ).addEventListener( "click", function() {
      // Not sure what share in the context of share means...
      Popcorn.nop();
    }, false );

    $( "fullscreen" ).addEventListener( "click", function() {
      if( document.fullscreenElement ) {
        cancelFullscreen();
      } else {
        requestFullscreen( $( "container" ) );
      }
    }, false );
  }

  function buildIFrameHTML() {
    var src = window.location,
      // Sizes are strings: "200x400"
      shareSize = $( "share-size" ).value.split( "x" ),
      width = shareSize[0],
      height = shareSize[1];
    return '<iframe src="' + src + '" width="' + width + '" height="' + height +
           '" frameborder="0" mozallowfullscreen webkitallowfullscreen allowfullscreen></iframe>';
  }

  // We put the embed's cannoncial URL in a <link rel="cannoncial" href="...">
  function getCannonicalURL() {
    var links = document.querySelectorAll( "link" ),
      link;
    for( var i=0; i<links.length; i++ ) {
      link = links[ i ];
      if( link.rel === "cannonical" ) {
        return link.href;
      }
    }
    // Should never happen, but for lint...
    return "";
  }

  function setupEventHandlers( popcorn, config ) {
    $( "share-size" ).onchange = function() {
      $( "share-iframe" ).value = buildIFrameHTML();
    };

    popcorn.on( "ended", function() {
      show( "post-roll" );
    });

    popcorn.on( "pause", function() {
      $( "play-pause" ).innerHTML = "Play";
    });

    popcorn.on( "playing", function() {<commit_msg>[1917] Add simple close handler for share panel close button<commit_after>/* This Source Code Form is subject to the terms of the MIT license
 * If a copy of the MIT license was not distributed with this file, you can
 * obtain one at http://www.mozillapopcorn.org/butter-license.txt */

function init( window, document ) {

  function requestFullscreen( elem ) {
    // Prefix + case differences.
    if ( elem.requestFullscreen ) {
      elem.requestFullscreen();
    } else if ( elem.mozRequestFullscreen ) {
      elem.mozRequestFullscreen();
    } else if ( elem.mozRequestFullScreen ) {
      elem.mozRequestFullScreen();
    } else if ( elem.webkitRequestFullscreen ) {
      elem.webkitRequestFullscreen();
    }
  }

  function cancelFullscreen() {
    // Prefix + case differences.
    if ( document.exitFullscreen ) {
      document.exitFullscreen();
    } else if ( document.mozCancelFullscreen ) {
      document.mozCancelFullscreen();
    } else if ( document.mozCancelFullScreen ) {
      document.mozCancelFullScreen();
    } else if ( document.webkitCancelFullscreen ) {
      document.webkitCancelFullscreen();
    }
  }

  function $( id ) {
    if( typeof id !== "string" ) {
      return id;
    }
    return document.getElementById( id );
  }

  function isVisible( id ) {
    return $( id ).style.display !== "none";
  }

  function show( elem ) {
    elem = $( elem );
    elem.style.display = "block";
  }

  function hide( elem ) {
    elem = $( elem );
    elem.style.display = "none";
  }

  function setupClickHandlers( popcorn, config ) {
    function replay() {
      popcorn.play();
    }

    function togglePlay() {
      if( isVisible( "post-roll" ) ||
          isVisible( "share" ) ) {
        return;
      }
      popcorn[ popcorn.paused() ? "play" : "pause" ]();
    }
    $( "play-pause" ).addEventListener( "click", togglePlay, false );

    $( "replay-post" ).addEventListener( "click", replay, false );
    $( "replay-share" ).addEventListener( "click", replay, false );

    $( "share-post" ).addEventListener( "click", function() {
      hide( "post-roll" );
      show( "share" );
    }, false );

    $( "share-share" ).addEventListener( "click", function() {
      // Not sure what share in the context of share means...
      Popcorn.nop();
    }, false );

    $( "fullscreen" ).addEventListener( "click", function() {
      if( document.fullscreenElement ) {
        cancelFullscreen();
      } else {
        requestFullscreen( $( "container" ) );
      }
    }, false );
  }

  function buildIFrameHTML() {
    var src = window.location,
      // Sizes are strings: "200x400"
      shareSize = $( "share-size" ).value.split( "x" ),
      width = shareSize[0],
      height = shareSize[1];
    return '<iframe src="' + src + '" width="' + width + '" height="' + height +
           '" frameborder="0" mozallowfullscreen webkitallowfullscreen allowfullscreen></iframe>';
  }

  // We put the embed's cannoncial URL in a <link rel="cannoncial" href="...">
  function getCannonicalURL() {
    var links = document.querySelectorAll( "link" ),
      link;
    for( var i=0; i<links.length; i++ ) {
      link = links[ i ];
      if( link.rel === "cannonical" ) {
        return link.href;
      }
    }
    // Should never happen, but for lint...
    return "";
  }

  function setupEventHandlers( popcorn, config ) {
    $( "share-close" ).addEventListener( "click", function() {
      hide( "share" );
    }, false );

    $( "share-size" ).onchange = function() {
      $( "share-iframe" ).value = buildIFrameHTML();
    };

    popcorn.on( "ended", function() {
      show( "post-roll" );
    });

    popcorn.on( "pause", function() {
      $( "play-pause" ).innerHTML = "Play";
    });

    popcorn.on( "playing", function() {
{'fraction_non_alphanumeric': 0.15371120107962213, 'fraction_numerical': 0.0032388663967611335, 'mean_word_length': 2.571566265060241, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '858852', 'n_tokens_mistral': 2298, 'n_tokens_neox': 2195, 'n_words': 558}