<commit_before>/**
 * -----------------------------------------
 *  ____  _           _          _    _
 * |  _ \(_) ___ ___ | |__   ___| |  (_)___ 
 * | |_) | |/ __/ _ \| '_ \ / _ \ |  | / __|
 * |  __/| | (_| (_) | |_) |  __/ |_ | \__ \
 * |_|   |_|\___\___/|_.__/ \___|_(_)| |___/
 * Picobel.js                       _/ |    
 * tomhazledine.com/audio          |__/    
 *
 * =========================================
 * 
 * Replace any native <audio> instances with
 * standard elements (spans, buttons & divs)
 * that we can style however we like.
 *
 * Functionality powered by Web Audio API.
 * -----------------------------------------
 */
function Picobel( options ) {

    /**
     * -----------------------
     * PARSE OPTIONS
     *
     * Make sure we have valid
     * options. If we don't we
     * should provide sensible
     * fallbacks.
     * -----------------------
     */
    options = typeof options !== 'undefined' ? options : {};
    // options.prefix = options.prefix || '';
    options.theme = options.theme || 'defaultPlayerTheme';

    /**
     * ---------------------------------------------
     * MAKE STUFF HAPPEN
     *
     * The following lines initialize functions we
     * declare further down the file. We need to
     * call them in a specific order (so things like
     * element-selection work properly).
     * ---------------------------------------------
     */

    // Find all the elements and store them
    // in an array (for easy access).
    var audioElements = findAudio();

    // Get our data from those elements.
    var data = getRawData( audioElements );

    // Replace those elements with our own custom markup.
    buildMarkup( audioElements );

    // Now we've placed our elements in the DOM, we can select them.
    var wrappers = document.getElementsByClassName( 'customAudioPlayer' );
    var playPauseButtons = document.getElementsByClassName( 'playerTrigger' );
    var muteButtons = document.getElementsByClassName( 'songMuteButton' );
    var playPauseButtonsText = document.getElementsByClassName( 'buttonText' );
    var playTimer = document.getElementsByClassName( 'songPlayTimer' );
    var songLengthBox = document.getElementsByClassName( 'songDuration' );
    var titleDisplay = document.getElementsByClassName( 'titleDisplay' );
    var artistDisplay = document.getElementsByClassName( 'artistDisplay' );
    var progressBar = document.getElementsByClassName( 'songProgressSlider' );
    var playhead = document.getElementsByClassName( 'pseudoProgressPlayhead' );
    var indicator = document.getElementsByClassName( 'pseudoProgressIndicator' );
    var volumeControl = document.getElementsByClassName( 'songVolumeSlider' );
    var volumeDisplay = document.getElementsByClassName( 'songVolumeValue' );
    var volumeIndicator = document.getElementsByClassName( 'pseudoVolumeIndicator' );
    var volumePlayhead = document.getElementsByClassName( 'pseudoVolumePlayhead' );

    // Initialize the audio.
    var myAudio = initAudio( data );

    // Create a var to store the index of the file currently
    // being played (defaulting to the first track in the DOM)
    var currentSongIndex = 0;

    /**
     * ---------------------------------
     * SETUP
     *
     * These functions find our targets,
     * generate our elements, and set up
     * our environment.
     * ---------------------------------
     */

    // Return an array of all the <audio> elements found on the page.
    function findAudio() {
        // Get all the <audio> occurrences in the page.
        var audioElements = document.getElementsByTagName( 'audio' );
        // Save our audioElements as an array (so
        // we can manipulate the DOM but still
        // access our items).
        var items = [].slice.call( audioElements );
        return items;
    }

    // Get the url for each audio file
    // we want to load [using elements
    // found by findAudio()]
    function getRawData( data ) {
        output = [];
        for ( var i = 0; i < data.length; i++ ) {
            item = {};
            // Get the file's URL
            item.url = data[i].src;
            item.preload = data[i].preload;
            output.push( item );
        }
        return output;
    }

    // Create our own markup in place of the native <audio> elements.
    function buildMarkup( data ) {
        for ( var i = 0; i < data.length; i++ ) {

            // Create a container for our new player
            var newPlayer = document.createElement( 'div' );<commit_msg>Allow an option to override preload attribute<commit_after>/**
 * -----------------------------------------
 *  ____  _           _          _    _
 * |  _ \(_) ___ ___ | |__   ___| |  (_)___ 
 * | |_) | |/ __/ _ \| '_ \ / _ \ |  | / __|
 * |  __/| | (_| (_) | |_) |  __/ |_ | \__ \
 * |_|   |_|\___\___/|_.__/ \___|_(_)| |___/
 * Picobel.js                       _/ |    
 * tomhazledine.com/audio          |__/    
 *
 * =========================================
 * 
 * Replace any native <audio> instances with
 * standard elements (spans, buttons & divs)
 * that we can style however we like.
 *
 * Functionality powered by Web Audio API.
 * -----------------------------------------
 */
function Picobel( options ) {

    /**
     * -----------------------
     * PARSE OPTIONS
     *
     * Make sure we have valid
     * options. If we don't we
     * should provide sensible
     * fallbacks.
     * -----------------------
     */
    options = typeof options !== 'undefined' ? options : {};
    // options.prefix = options.prefix || '';
    options.theme = options.theme || 'defaultPlayerTheme';

    /**
     * ---------------------------------------------
     * MAKE STUFF HAPPEN
     *
     * The following lines initialize functions we
     * declare further down the file. We need to
     * call them in a specific order (so things like
     * element-selection work properly).
     * ---------------------------------------------
     */

    // Find all the elements and store them
    // in an array (for easy access).
    var audioElements = findAudio();

    // Get our data from those elements.
    var data = getRawData( audioElements );

    // Replace those elements with our own custom markup.
    buildMarkup( audioElements );

    // Now we've placed our elements in the DOM, we can select them.
    var wrappers = document.getElementsByClassName( 'customAudioPlayer' );
    var playPauseButtons = document.getElementsByClassName( 'playerTrigger' );
    var muteButtons = document.getElementsByClassName( 'songMuteButton' );
    var playPauseButtonsText = document.getElementsByClassName( 'buttonText' );
    var playTimer = document.getElementsByClassName( 'songPlayTimer' );
    var songLengthBox = document.getElementsByClassName( 'songDuration' );
    var titleDisplay = document.getElementsByClassName( 'titleDisplay' );
    var artistDisplay = document.getElementsByClassName( 'artistDisplay' );
    var progressBar = document.getElementsByClassName( 'songProgressSlider' );
    var playhead = document.getElementsByClassName( 'pseudoProgressPlayhead' );
    var indicator = document.getElementsByClassName( 'pseudoProgressIndicator' );
    var volumeControl = document.getElementsByClassName( 'songVolumeSlider' );
    var volumeDisplay = document.getElementsByClassName( 'songVolumeValue' );
    var volumeIndicator = document.getElementsByClassName( 'pseudoVolumeIndicator' );
    var volumePlayhead = document.getElementsByClassName( 'pseudoVolumePlayhead' );

    // Initialize the audio.
    var myAudio = initAudio( data );

    // Create a var to store the index of the file currently
    // being played (defaulting to the first track in the DOM)
    var currentSongIndex = 0;

    /**
     * ---------------------------------
     * SETUP
     *
     * These functions find our targets,
     * generate our elements, and set up
     * our environment.
     * ---------------------------------
     */

    // Return an array of all the <audio> elements found on the page.
    function findAudio() {
        // Get all the <audio> occurrences in the page.
        var audioElements = document.getElementsByTagName( 'audio' );
        // Save our audioElements as an array (so
        // we can manipulate the DOM but still
        // access our items).
        var items = [].slice.call( audioElements );
        return items;
    }

    // Get the url for each audio file
    // we want to load [using elements
    // found by findAudio()]
    function getRawData( data ) {
        output = [];
        for ( var i = 0; i < data.length; i++ ) {
            item = {};
            // Get the file's URL
            item.url = data[i].src;
            item.preload = options.preload ? options.preload : data[i].preload;
            output.push( item );
        }
        return output;
    }

    // Create our own markup in place of the native <audio> elements.
    function buildMarkup( data ) {
        for ( var i = 0; i < data.length; i++ ) {

            // Create a container for our new player
            var newPlayer = document.createElement( 'div' );
{'fraction_non_alphanumeric': 0.1700218818380744, 'fraction_numerical': 0.0006564551422319475, 'mean_word_length': 1.9176508139163742, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 11, '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': '2909812', 'n_tokens_mistral': 2434, 'n_tokens_neox': 2365, 'n_words': 726}