Commit 36896105 authored by Dave Lane's avatar Dave Lane
Browse files

working responsive youtube vids with the ARVE plugin

parent e69e7684
......@@ -416,36 +416,69 @@ function processPage(pi) {
// embed YouTube videos
$('.weYouTube-wrapper').each(function(i, e) {
console.log("******* Checking for video! ********");
var wrapper = $(this),
align = wrapper.attr("align"),
wrapper_classes = wrapper.attr("class"),
style,
align = 'none',
style, url,
yttitle = "",
ytinvocation;
// find the alignment
if (wrapper.hasClass('floatright')) {
align = 'right';
} else if (wrapper.hasClass('floatleft')) {
align = 'left';
} else if (wrapper.hasClass('center')) {
align = 'center';
} else {
align = 'none';
}
console.log('align ', align);
// get the title if any
if (wrapper.find('.weYouTubeTitleContainer')) {
yttitle = wrapper.find('.weYouTubeTitleContainer').text();
console.log("title = ", yttitle);
}
// get the video details
wrapper.find(".weYouTube").each(function(i, e) {
var $this = $(this),
id = $this.attr("data-ytid"),
width = $this.css("width") || 560,
height = $this.css("height") || 315,
start = $this.css("t") || 0,
start = 0,
list = $this.attr("data-list"),
index = $this.attr("data-index");
var opts = ' class="weYouTube-responsive" controls="yes" allowfullscreen="yes"';
opts += ' maxwidth="' + width + '" start=' + start;
ytinvocation = '[youtube v="' + id + '" ' + opts + ']';
if (width) { style = ' style="width: ' + width + '"';}
else style = "";
index = $this.attr("data-index");
// get video details
if (wrapper.find("a").attr("href").includes("youtube.com")) {
url = wrapper.find("a").attr("href");
console.log('checking for start in url = ', url);
var qstring = url.split("?")[1],
qvars = qstring.split('&'),
qparam, i;
url = url.split("?")[0] + '?v=' + id;
for (i = 0; i < qvars.length; i++) {
qparam = qvars[i].split('=');
if (qparam[0] === 't') {
start = qparam[1];
console.log('found start! = ', start);
}
}
console.log('qstring = ', qstring);
} else {
url = 'https://youtube.com/watch?v=' + id;
}
console.log('url = ', url);
var opts = ' class="weYouTube-responsive" controls="yes" disable_links="true" allowfullscreen="yes"';
opts += ' url="' + url + '"';
opts += ' maxwidth=' + width;
if (start != 0) { opts += ' parameters="start=' + start + '"'; }
if (yttitle != "") { opts += ' title="' + yttitle + '"'; }
if (align != "none") { opts += ' align="' + align + '"'; }
ytinvocation = '[arve' + opts + ']';
console.log('initial ytinvocation = ', ytinvocation);
console.log("******* Checking for video title! ********");
if (wrapper.find('.weYouTubeTitleContainer')) {
var yttitle = wrapper.find('.weYouTubeTitleContainer').text();
console.log("title = ", yttitle);
//ytinvocation = '<span class="weYouTubeTitle" style="padding-left: 0.5em;">' + yttitle + '</span>' + ytinvocation;
// ytinvocation = '<div class="weYouTubeTitleContainer" style="color: white; background: rgba(69,69,69,75); position: absolute; top: 0px; width: 100%; height: 18px; font: 14px sans-serif; padding-top: 4px;"><span class="weYouTubeTitle" style="padding-left: 0.5em;">' + yttitle + '</span>' + ytinvocation + '</div>';
}
console.log("******* After check for video title! ********");
});
// assign the new content...
ytinvocation = '<div class="' + wrapper_classes + '"' + style + '>' + ytinvocation + '</div>';
//ytinvocation = '<div class="' + wrapper_classes + '"' + style + '>' + ytinvocation + '</div>';
wrapper.replaceWith(ytinvocation); //Testing YouTube
});
// embed SoundCloud clips
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment