Autolink spotify links with the Spotify Play button
This commit is contained in:
parent
cf1111dc5a
commit
342faddd00
7 changed files with 27 additions and 17 deletions
|
@ -1,2 +1,2 @@
|
|||
for(var autolinker=new Autolinker,ytidregex=/watch\?v=([A-Za-z0-9\-_]+)/,notes=document.querySelectorAll(".e-content"),i=0;i<notes.length;i++){var ytid=notes[i].textContent.match(ytidregex);if(null!==ytid){var id=ytid[1],iframe=document.createElement("iframe");iframe.classList.add("youtube"),iframe.setAttribute("src","//www.youtube.com/embed/"+id),iframe.setAttribute("frameborder",0),iframe.setAttribute("allowfullscreen","true"),notes[i].appendChild(iframe)}var orig=notes[i].innerHTML,linked=autolinker.link(orig);notes[i].innerHTML=linked}
|
||||
for(var autolinker=new Autolinker,ytidregex=/watch\?v=([A-Za-z0-9\-_]+)/,spotifyregex=/https\:\/\/play\.spotify\.com\/(.*)\b/,notes=document.querySelectorAll(".e-content"),i=0;i<notes.length;i++){var ytid=notes[i].textContent.match(ytidregex);if(null!==ytid){var yid=ytid[1],yiframe=document.createElement("iframe");yiframe.classList.add("youtube"),yiframe.setAttribute("src","//www.youtube.com/embed/"+yid),yiframe.setAttribute("frameborder",0),yiframe.setAttribute("allowfullscreen","true"),notes[i].appendChild(yiframe)}var spotifyid=notes[i].textContent.match(spotifyregex);if(null!==spotifyid){var sid=spotifyid[1].replace("/",":"),siframe=document.createElement("iframe");siframe.classList.add("spotify"),siframe.setAttribute("src","https://embed.spotify.com/?uri=spotify:"+sid),siframe.setAttribute("frameborder",0),siframe.setAttribute("allowtransparency","true"),notes[i].appendChild(siframe)}var orig=notes[i].innerHTML,linked=autolinker.link(orig);notes[i].innerHTML=linked}
|
||||
//# sourceMappingURL=maps/links.js.map
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue