Pen Settings

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm 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. We'll also process your JavaScript with Babel.

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

Code Indentation

     

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.

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.

            
              <!-- The length of this demonstration is commented, in order to help you properly understand how it was built. In the following code you will be mostly concerned with the JS references to Vimeo's Froogaloop API for JavaScript. For the sake of expedience, however, I will also be using bits of Zurb Foundation, whose files are referenced as external sources along with Froogaloop. --> 

<!-- Background image art is by http://zy0rg.deviantart.com/art/Mobia-220866072 -->

<div id="wrap" class="center">
  <!-- Ignore the header stuff, it's necessary for page display but not functionality -->
  <header class="row">
    <h1>HTML chapter markers for a Vimeo video </h1>
    <p>The following pen is a commented demo of how to simplify Vimeo's <a href="https://developer.vimeo.com/player/js-api" target="_blank">Froogaloop API</a> for quick creation of chapter markers in a project. In this pen we capture a chapter marker on click, pass it to an external JS file, then control the on-page video through the provided API. The follow up pen will deal with live transcriptions. I'll restore the original Steampunk video in a bit - I made a mistake and edited a live pen. The functionality is still intact.</p>
  </header>

  <div class="main-content row">

    <!-- The important stuff starts here -->

    <div class="large-9 columns entry-video">
      <!-- We're usign Foundation's flex-video class to make this responsive (not important but perhaps interesting to some of you) -->
      <div class="flex-video widescreen vimeo">
        <!-- This is the element that Froogaloop grabs by ID in the JS. Note that we put ?api=1 on the end. This is SUPER IMPORTANT. You can't control a video without an active API flag. -->
        <iframe id="thevideo" src="//player.vimeo.com/video/98067863?api=1" width="500" height="281" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
      </div>
    </div>

    <div class="large-3 columns toc">
      <!-- For simple linked timestamps, we're going to use HTML5's data element in order to place a second marker. In pratice, you'll probably have to use a bit of math to convert minutes & seconds into base ten. The JavaScript then references the link object on click, finds the seconds value, and jumps to that point in the video. -->
      <dl>
        <dt>00:09</dt>
        <dd>
          <!-- Note that we put the seconds in data-seek and give the link a class of timecode. Also notice that we give it a blank HREF using #. The JS uses a preventdefault() to stop the URL from being updated on click. Instead, the click is captured and sent to the external JS for processing. -->
          <a href="#" data-seek="8.2" class="timecode">Skip the credits</a>
        </dd>
        <dt>00:54</dt>
        <dd>
          <a href="#" data-seek="53.6" class="timecode">Welcome to your life</a>
        </dd>
        <dt>01.02</dt>
        <dd>
          <a href="#" data-seek="62.3" class="timecode">There's no turning back</a>
        </dd>
        <dt>01.11</dt>
        <dd>
          <a href="#" data-seek="71" class="timecode">Even while we sing</a>
        </dd>
        <dt>01.17</dt>
        <dd>
          <a href="#" data-seek="77.5" class="timecode">We will find you</a>
        </dd>
        <dt>01.19</dt>
        <dd>
          <a href="#" data-seek="79.8" class="timecode">Acting on your best behavior</a>
        </dd>
        <dt>01.24</dt>
        <dd>
          <a href="#" data-seek="83.95" class="timecode">Turn your back on mother...</a>
        </dd>
        <dt>01.28</dt>
        <dd>
          <a href="#" data-seek="88.4" class="timecode">Everybody wants to rule...</a>
        </dd>
        <dt>01.39</dt>
        <dd>
          <a href="#" data-seek="99.1" class="timecode">Help me to decide</a>
        </dd>
        <dt>01.43</dt>
        <dd>
          <a href="#" data-seek="103.4" class="timecode">Help me make the</a>
        </dd>
        <dt>01.45</dt>
        <dd>
          <a href="#" data-seek="105.62" class="timecode">Most of freedom</a>
        </dd>
        <dt>01.50</dt>
        <dd>
          <a href="#" data-seek="110" class="timecode">And of pleasure</a>
        </dd>
        <dt>01.54</dt>
        <dd>
          <a href="#" data-seek="114.25" class="timecode">Nothing ever lasts forever</a>
        </dd>
        <dt>02.00</dt>
        <dd>
          <a href="#" data-seek="120.7" class="timecode">Everybody wants to rule...</a>
        </dd>
        <dt>02.07</dt>
        <dd>
          <a href="#" data-seek="127.4" class="timecode">There's a room where...</a>
        </dd>
        <dt>02.12</dt>
        <dd>
          <a href="#" data-seek="132.05" class="timecode">Holding hands while the...</a>
        </dd>
        <dt>02.16</dt>
        <dd>
          <a href="#" data-seek="136.42" class="timecode">When they do I'll be...</a>
        </dd>
        <dt>02.20</dt>
        <dd>
          <a href="#" data-seek="140.4" class="timecode">So glad we've almost...</a>
        </dd>
        <dt>02.24</dt>
        <dd>
          <a href="#" data-seek="144.7" class="timecode">So sad we had to fade...</a>
        </dd>
      </dl>
    </div>
  </div>

  <!-- The important stuff ends here -->

  <footer class="row">
    
    <!-- Wait, no, my Twitter is important! -->
    
    <a href="https://twitter.com/ImperativeIdeas" class="twitter-follow-button" data-show-count="false" data-size="large">Follow @ImperativeIdeas</a>
    <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
  </footer>
</div>
            
          
!
            
              @import "compass/css3";

/*!
 * The SCSS stuff isn't really part of the tutorial, although using definition lists to line up your time stamp and description for SEO is a trick I'd recommend learning.
 */

@import url(https://fonts.googleapis.com/css?family=Dosis:600,400|Playfair+Display:400,700);

html, body { // useful to define these in many cases
  height: 100%;
  width: 100%;
}

body { // Just fixing a background in place to make the view interesting
  background: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/72900/steampunk-blue.jpg) center center;
  background-attachment: fixed;
  background-size: cover;
  padding-top: 5%;
}

header, footer { // Some quick styles so your eyes don't bleed
  background: rgb(36, 38, 39);
  padding: 15px;
  h1 {
    font-family: 'Playfair Display', serif;
    color: silver;
    font-size: 32px;
  }
  p {
    font-family: 'Dosis', sans-serif;
    font-size: 1.1em;
    text-align: justify;
    color: silver;
  }
}

.main-content {
  background: rgba(0,0,0,.85);
  padding: 10px;
  .toc { // This styles our defintion list so the timecode & name are related
    dt, dd {
      float: left;
      margin: 0;
      color: white;
      font-size: 12px
    }
    dt { 
      clear:both;
      margin-right: 1em;
    }
  }
}

footer { // Nothing to see here, move along
  text-align: right;
}
            
          
!
            
              jQuery(function ($) { // Document Ready (important!)
  
  // Get the video element that we wish to control
  var iframe = document.getElementById('thevideo');
  
  // Initialize Froogaloop (linked .js.min file) on the captured video
  var player = $f(iframe);

  // When a link with a class of "timecode" is clicked, capture the event
  $('.timecode').on('click', function (e) {
    // Prevent the default link (typically a hash) from executing
    e.preventDefault();
    // Get the location value from the HTML5 data parameter
    var seekVal = $(this).attr('data-seek');
    // Using Froogaloop, trigger the SeekTo method using the captured value
    player.api('seekTo', seekVal);
  });

});
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.

Console