Created
February 16, 2012 23:59
-
-
Save EspadaV8/1848992 to your computer and use it in GitHub Desktop.
TuxRadar create HTML audio tag
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:(function()%7Bfunction%20getScript(url%2Csuccess)%7B%20var%20script%3Ddocument.createElement('script')%3B%20script.src%3Durl%3B%20var%20head%3Ddocument.getElementsByTagName('head')%5B0%5D%2Cdone%3Dfalse%3Bscript.onload%3Dscript.onreadystatechange%3Dfunction()%7Bif(!done%26%26(!this.readyState%7C%7Cthis.readyState%3D%3D'loaded'%7C%7Cthis.readyState%3D%3D'complete'))%7Bdone%3Dtrue%3Bsuccess()%3Bscript.onload%3Dscript.onreadystatechange%3Dnull%3Bhead.removeChild(script)%3B%7D%7D%3Bhead.appendChild(script)%3B%7DgetScript('%2F%2Fajax.googleapis.com%2Fajax%2Flibs%2Fjquery%2F1.7.1%2Fjquery.min.js'%2Cfunction()%7Bif(typeof%20jQuery%3D%3D'undefined')%7Balert('There%20was%20an%20error%20loading%20the%20jQuery%20JS%20file.%20Sorry.')%3B%7Delse%7B%24jq%3DjQuery.noConflict()%3Bvar%20l%3D%24jq('.podcastdownload')%3Bvar%20ogg%3Dl.find('a%5Bhref%24%3D%22ogg%22%5D')%3Bvar%20mp3%3Dl.find('a%5Bhref%24%3D%22mp3%22%5D')%3Bl.empty().html('%3Cdiv%20style%3D%22margin%3A0%200%2015px%200%3B%22%3E%3Caudio%20autobuffer%3D%22autobuffer%22%20preload%3D%22auto%22%20controls%3D%22controls%22%20tabindex%3D%220%22%3E%3Csource%20src%3D%22'%2Bogg.attr('href')%2B'%22%20%2F%3E%3Csource%20src%3D%22'%2Bmp3.attr('href')%2B'%22%20%2F%3E%3C%2Faudio%3E%3C%2Fdiv%3E%3Cp%3E%3Cstrong%3E%3Ca%20href%3D%22'%2Bogg%2B'%22%3E'%2Bogg.text()%2B'%3C%2Fa%3E%3C%2Fp%3E%3Cp%3E%3Ca%20href%3D%22'%2Bmp3%2B'%22%3E'%2Bmp3.text()%2B'%3C%2Fa%3E%3C%2Fstrong%3E%3C%2Fdiv%3E')%3B%7D%7D)%3B%7D)()%3B |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
function getScript(url,success){ | |
var script=document.createElement('script'); | |
script.src=url; | |
var head=document.getElementsByTagName('head')[0], | |
done=false; | |
// Attach handlers for all browsers | |
script.onload = script.onreadystatechange = function() { | |
if ( !done && (!this.readyState | |
|| this.readyState == 'loaded' | |
|| this.readyState == 'complete') ) { | |
done=true; | |
success(); | |
script.onload = script.onreadystatechange = null; | |
head.removeChild(script); | |
} | |
}; | |
head.appendChild(script); | |
} | |
getScript('//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js',function() { | |
if (typeof jQuery=='undefined') { | |
alert('There was an error loading the jQuery JS file. Sorry.'); | |
} else { | |
$jq=jQuery.noConflict(); | |
var links = $('.podcastdownload'); | |
var ogg = links.find('a[href$="ogg"]'); | |
var mp3 = links.find('a[href$="mp3"]'); | |
links.empty().html('<div style="margin:0 0 15px 0;"><audio autobuffer="autobuffer" preload="auto" controls="controls" tabindex="0"><source src="'+ogg.attr('href')+'" /><source src="'+mp3.attr('href')+'" /></audio></div><p><strong><a href="'+ogg+'">'+ogg.text()+'</a></p><p><a href="'+mp3+'">'+mp3.text()+'</a></strong></div>'); | |
} | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment