commit 8e1dd96ad9a3301560a79aa3e6231e5cbc5112a8 Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Sun Feb 5 20:50:50 2017 +0000 Update changelog commit 2d5eae57534f40d6f768ab92e46123d45b85f23d Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Sun Feb 5 20:47:21 2017 +0000 Link to correct js files, also pre-compress js assets commit 281844d09ced2035da05336d6a47399e3cf6a92a Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Sun Feb 5 20:31:12 2017 +0000 Adding a links util
28 lines
1 KiB
JavaScript
28 lines
1 KiB
JavaScript
//links.js
|
|
|
|
let youtubeRegex = /watch\?v=([A-Za-z0-9\-_]+)\b/;
|
|
let spotifyRegex = /https\:\/\/play\.spotify\.com\/(.*)\b/;
|
|
|
|
let notes = document.querySelectorAll('.e-content');
|
|
|
|
for (let note of notes) {
|
|
let ytid = note.textContent.match(youtubeRegex);
|
|
if (ytid) {
|
|
let ytiframe = document.createElement('iframe');
|
|
ytiframe.classList.add('youtube');
|
|
ytiframe.setAttribute('src', 'https://www.youtube.com/embed/' + ytid[1]);
|
|
ytiframe.setAttribute('frameborder', 0);
|
|
ytiframe.setAttribute('allowfullscreen', 'true');
|
|
note.appendChild(ytiframe);
|
|
}
|
|
let spotifyid = note.textContent.match(spotifyRegex);
|
|
if (spotifyid) {
|
|
let sid = spotifyid[1].replace('/', ':');
|
|
let 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');
|
|
note.appendChild(siframe);
|
|
}
|
|
}
|