Initial commit to new repo
This commit is contained in:
parent
a267f9bfcc
commit
a5173c981b
292 changed files with 17472 additions and 0 deletions
25
public/assets/js/links.js
Normal file
25
public/assets/js/links.js
Normal file
|
@ -0,0 +1,25 @@
|
|||
//the autlinker object
|
||||
var autolinker = new Autolinker();
|
||||
|
||||
//the youtube regex
|
||||
var ytidregex = /watch\?v=([A-Za-z0-9\-_]+)/;
|
||||
|
||||
//grab the notes and loop through them
|
||||
var notes = document.querySelectorAll('.e-content');
|
||||
for(var i = 0; i < notes.length; i++) {
|
||||
//get Youtube ID
|
||||
var ytid = notes[i].textContent.match(ytidregex);
|
||||
if(ytid !== null) {
|
||||
var id = ytid[1];
|
||||
var 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);
|
||||
}
|
||||
//now linkify everything
|
||||
var orig = notes[i].innerHTML;
|
||||
var linked = autolinker.link(orig);
|
||||
notes[i].innerHTML = linked;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue