All files / src/visual playbackSpeedElements.js

100% Statements 14/14
100% Branches 3/3
100% Functions 2/2
100% Lines 14/14
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66                    31x                       168x               168x       13x 13x 13x           13x   6x 6x   4x 4x   3x 3x               31x            
/**
 * Imports the config module
 * @module config
 */
import config from "../config.js";
 
/**
 * Defines the Playback Speed Visual Elements Handler
 * @module visual/PlaybackSpeedElements
 */
let PlaybackSpeedElements = (function() {
  /**
   * Sets all of the visual playback speed buttons to have the right class
   * to display the background image that represents the current playback
   * speed.
   *
   * @access public
   */
  function sync() {
    /*
			Gets all of the playback speed classes.
		*/
    let playbackSpeedClasses = document.getElementsByClassName(
      "amplitude-playback-speed"
    );
 
    /*
			Iterates over all of the playback speed classes
			applying the right speed class for visual purposes.
		*/
    for (let i = 0; i < playbackSpeedClasses.length; i++) {
      /*
				Removes all of the old playback speed classes.
			*/
      playbackSpeedClasses[i].classList.remove("amplitude-playback-speed-10");
      playbackSpeedClasses[i].classList.remove("amplitude-playback-speed-15");
      playbackSpeedClasses[i].classList.remove("amplitude-playback-speed-20");
 
      /*
				Switch the current playback speed and apply the appropriate
				speed class.
			*/
      switch (config.playback_speed) {
        case 1:
          playbackSpeedClasses[i].classList.add("amplitude-playback-speed-10");
          break;
        case 1.5:
          playbackSpeedClasses[i].classList.add("amplitude-playback-speed-15");
          break;
        case 2:
          playbackSpeedClasses[i].classList.add("amplitude-playback-speed-20");
          break;
      }
    }
  }
 
  /**
   * Returns the public facing methods
   */
  return {
    sync: sync
  };
})();
 
export default PlaybackSpeedElements;