<commit_before>/*
 * speed-control
 * https://github.com/Versal/videojs-speed-control
 *
 * Copyright (c) 2014 Versal Team
 * Licensed under the MIT license.
 */

(function(vjs) {

  /**
   * Construct the speed control
   * @constructor
   * @param {Object} player reference to video player
   * @param {Object} options passed in from plugin initialization
   */
  vjs.SpeedControl = vjs.MenuItem.extend({
    init: function(player, options) {
      var speedSelect = document.createElement('select');

      vjs.MenuItem.call(this, player, options);
      this.player().el().appendChild(speedSelect);
    }
  });

  function speedControl(options) {
    var opts = options || {};

    return new vjs.SpeedControl(this, opts);
  }

  vjs.plugin('speedControl', speedControl);
}(window.videojs));<commit_msg>select works<commit_after>/*
 * speed-control
 * https://github.com/Versal/videojs-speed-control
 *
 * Copyright (c) 2014 Versal Team
 * Licensed under the MIT license.
 */

(function(vjs) {

  /**
   * Construct the speed control
   * @constructor
   * @param {Object} player reference to video player
   * @param {Object} options passed in from plugin initialization
   */
  vjs.SpeedControl = vjs.MenuItem.extend({
    init: function(player, options) {
      vjs.MenuItem.call(this, player, options);
    }
  });

  function createSpeedControl() {
    var props = {
      className: 'vjs-speed-control vjs-control',
      innerHTML: buildSpeeds(),
      role: 'button',
      'aria-live': 'polite',
      tabIndex: 0
    };

    return vjs.Component.prototype.createEl(null, props);
  }

  /**
   * @returns {String} innerHTML string of <option> elements for select
   */
  function buildSpeeds() {
    // speeds are hard-coded for now - could pass in speeds instead
    // from plugin setup, if necessary
    var speeds = [0.25, 0.5, 0.75, 1, 1.25, 1.5, 1.75],
        resultHTML = '<select class="vjs-speed-select">';

    for (var speed in speeds) {
      // make 1.0x the default speed
      if (speeds[speed] === 1) {
        resultHTML += '<option value="' + speeds[speed] + '"' +
          'selected="selected">' +
          speeds[speed] + '.0x</option>';
      } else {
        resultHTML += '<option value="' + speeds[speed] + '"' +
          '>' + speeds[speed] + 'x</option>';
      }
    }

    return resultHTML += '</select>';
  }

  /**
   * hook up events to the speed selector
   * @param {Object} select DOM obj of select element
   * @param {Object} player Reference to videojs player
   */
  function setSpeedEvents(select, player) {
    // setup an onChange listener on the speed select
    // and bind it to the player
    select.onchange = function(e) {
      var index = e.target.selectedIndex,
          newRate = e.target.options[index].value;

      // player.M === direct way to access <video>
      this.M.playbackRate = newRate;
    }.bind(player);
  }

  function speedControl() {
    var options = { 'el': createSpeedControl() },
        speed = new vjs.SpeedControl(this, options),
        select;

    // append the speed select to the videojs control bar
    this.controlBar.el().appendChild(speed.el());
    select = document.getElementsByClassName('vjs-speed-select')[0];

    // pass in select and reference to player to events function
    return setSpeedEvents(select, this);
  }

  vjs.plugin('speedControl', speedControl);
}(window.videojs));
{'fraction_non_alphanumeric': 0.13814432989690723, 'fraction_numerical': 0.009131075110456554, 'mean_word_length': 2.841628959276018, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 2, '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': '4712123', 'n_tokens_mistral': 1041, 'n_tokens_neox': 999, 'n_words': 280}