Skip to content

Commit

Permalink
Modified JS for modal to take any youtube link
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisfrommann committed Jan 17, 2017
1 parent 07bfe5c commit b68f2c4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ <h2>
</section>

<section class="mobile-lede hidden-sm hidden-md hidden-lg">
<img src="/img/experts.jpg" alt="A photo of team members in the Indian Treaty Room (photo credit: Fast Company)">
<iframe width="100%" height="338" src="https://www.youtube.com/embed/aGe5rEDv3g8" frameborder="0" allowfullscreen></iframe>
<h2>
Building a more <span class="everything-is-awesome">awesome</span> government through technology
</h2>
Expand Down
7 changes: 5 additions & 2 deletions js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,17 @@ $( document ).ready(function() {
$( 'a[href^="http"]:not(.target-link)' ).on( "click", function(e) {
var domain = this.href.split('/')[2].replace('www.','');
var tld = domain.substring(domain.length - 3);
console.log(domain);
if (tld != 'gov' && tld != 'mil' && domain != 'facebook.com' && domain != 'github.com' && domain != 'twitter.com') {
$( '#site-alert-overlay' ).show();
$( '#site-alert' ).show();
if (domain == 'youtube.com') {
$( '#site-alert-exit-contents' ).hide();
$( '#site-alert-video' ).show();
$( '#site-alert-video-frame' ).attr('src', 'https://www.youtube.com/embed/aGe5rEDv3g8')
// parse YouTube URL
// https://www.youtube.com/watch?v=aGe5rEDv3g8 -> https://www.youtube.com/embed/aGe5rEDv3g8
var matches = this.href.match(/watch\?v=([a-z0-9]+)/i)
console.log(matches[1]);
$( '#site-alert-video-frame' ).attr('src', 'https://www.youtube.com/embed/' + matches[1])
} else {
$( '#site-alert-exit-contents' ).show();
$( '#site-alert-video' ).hide();
Expand Down

0 comments on commit b68f2c4

Please sign in to comment.