2012-03-12 22:38:09 +01:00
|
|
|
// let's fetch us some goddamn API
|
|
|
|
var apiEmbed = document.createElement('script');
|
|
|
|
apiEmbed.src = 'http://www.youtube.com/player_api';
|
|
|
|
document.getElementsByTagName('script')[0].parentNode.insertBefore(apiEmbed, document.getElementsByTagName('script')[0]);
|
|
|
|
|
|
|
|
// this will be called by the player API when it's finished downloading
|
|
|
|
function onYouTubePlayerAPIReady() {
|
|
|
|
var youTubePlaceholders = document.getElementsByClassName('ytplaceholder');
|
|
|
|
for(var i = 0; i < youTubePlaceholders.length; i++) {
|
2012-03-12 23:07:08 +01:00
|
|
|
var videoURL = youTubePlaceholders[i].innerHTML;
|
2012-03-12 22:38:09 +01:00
|
|
|
var videoIDMaybe = videoURL.match(/[?&]v=([A-Za-z0-9\-_]+)(?:[?&]|$)/);
|
|
|
|
youTubePlaceholders[i].innerText = '';
|
|
|
|
if(videoIDMaybe) {
|
|
|
|
var ytVideoID = videoIDMaybe[1];
|
|
|
|
var player = new YT.Player(youTubePlaceholders[i], {
|
2012-03-12 22:57:55 +01:00
|
|
|
height: '203',
|
|
|
|
width: '336',
|
2012-03-12 22:38:09 +01:00
|
|
|
videoId: ytVideoID
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|