Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import or require. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <p>Work in Progress. Press <strong>Play</strong> first.</p>

<iframe width="100%" height="166" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/72199688&amp;color=ff5500&amp;auto_play=false&amp;hide_related=false&amp;show_comments=true&amp;show_user=true&amp;show_reposts=false"></iframe>

<div class="wavesurfer-transcript">
  <p><span class="wavesurfer-marker" data-start="0" data-end="5">Alien 2347</span></p>
    <p><span class="wavesurfer-marker" data-start="5" data-end="8">Episode numero 1</span></p>
  <p><span class="wavesurfer-marker" data-start="8" data-end="11.5">Dans le vaisseau A2347,</span> <span class="wavesurfer-marker" data-start="11.5" data-end="15.5">d'étranges extraterrestres complotent secrètement.</span></p>
</div>
            
          
!
            
              .wavesurfer-marker:hover {
  cursor: pointer;
  text-decoration: underline;
}

.wavesurfer-marker-current {
  background: rgba(126, 126, 126, 0.4);
}
            
          
!
            
              // Sample Markers on Page
var MarkersInit = function(markers) {
  var elements = document.querySelectorAll('.wavesurfer-marker');
  Array.prototype.forEach.call(elements, function(el, i) {
    var time_start = el.dataset.start;
    var time_end = el.dataset.end;
    var id = el.dataset.id;;
    if (id >= 1) {
      id = id - 1;
    } else {
      id = 0;
    }
    marker = {};
    marker.time_start = time_start;
    marker.time_end = time_end;
    marker.dom = el;
    if (typeof(markers[id]) === 'undefined') {
      markers[id] = [];
    }
    markers[id].push(marker);
  });
}

// On Ready
document.onreadystatechange = () => {
  if (document.readyState === 'complete') {

    // Init Markers
    var markers = [];
    MarkersInit(markers);

    // Create SoundCloud Player Object ( TODO: all loop)
    var iframeElement = document.querySelector("iframe");
    var widget = SC.Widget(iframeElement);

    // Register On Click Event Handler
    var elements = document.querySelectorAll('.wavesurfer-marker');
    Array.prototype.forEach.call(elements, function(el, i) {
      el.onclick = function() {
        // Get Data Attribute
        var pos = el.dataset.start * 1000;
        // Seek
        widget.seekTo(pos);
      }
    });

    // Bind Continuous Play
    widget.bind(SC.Widget.Events.PLAY_PROGRESS, function() {
      widget.getPosition(function(current_time) {
        current_time = current_time / 1000;
        var j = 0; // NOTE: to extend for several players
        markers[j].forEach(function(marker, i) {
          if (current_time >= marker.time_start && current_time <= marker.time_end) {
            marker.dom.classList.add("wavesurfer-marker-current");
          } else {
            marker.dom.classList.remove("wavesurfer-marker-current");
          }
        });
      });
    });

  } // Document Complete
}; // Document Ready State Change
            
          
!
999px

Console