Commit 003d7f67 authored by Dave Lane's avatar Dave Lane
Browse files

tidy up merge with a bunch of new issues within the responsive youtube and vimeo code

parents 1a4265a3 f6e91dd1
......@@ -2,7 +2,7 @@
/* jshint node: true, multistr: true, trailing: true, esnext: true */
"use strict";
const VERSION = "1.3.0",
const VERSION = "1.4.1",
JQUERY = "http://code.jquery.com/jquery-2.1.1.min.js",
FILEPATH = "/home/data/wikieducator/course-snapshot/src",
GENERATOR_URL = "https://git.oeru.org/wikieducator/course-snapshot",
......@@ -35,6 +35,7 @@ var pages = [], // list of page URLs to be processed
pi = 0, // process index
wp,
base_url = "",
numstr = '/[^\d.]/g',
opt,
options = {};
......@@ -470,9 +471,59 @@ function processPage(pi) {
}
});
$('.weVimeo-wrapper').each(function(i, e) {
console.log("******* Checking for Vimeo video! ********");
var wrapper = $(this),
wrapper_classes = wrapper.attr("class"),
align = 'none', align_class = 'none', url, id, args = '', width, w_unit, height, h_unit,
start = 0, vimeoinvocation = '';
// find the alignment
if (wrapper.hasClass('right')) {
align = 'right';
align_class = 'floatright';
} else if (wrapper.hasClass('left')) {
align = 'left';
align_class = 'floatleft';
} else if (wrapper.hasClass('center')) {
align = 'center';
align_class = 'center';
}
console.log('align=' + align + ', align_class=' + align_class + '...');
wrapper.find('iframe').each(function(i, e) {
var $this = $(this);
url = $this.attr('src'),
// get the number only
width = $this.attr('width').replace(numstr, '') || 560,
// get the units, if any
w_unit = $this.attr('width').replace(width, '') || 'px',
// get the number only
height = $this.attr("height").replace(numstr, '') || 315,
// get the units, if any
h_unit = $this.attr('height').replace(height, '') || 'px',
id = url.split('?')[0].split('video/')[1],
args = url.split('?')[1].replace('&', '&');
start = args.split('#t=')[1].replace('s','');
console.log('++++++++++++++++++++++++start = ', start);
args = args.split('#t=')[0] + '&#t=' + start + 's';
console.log('url = ', url);
console.log('id = ', id);
console.log('width = ' + width + ' units = ' + w_unit + ', height = ' + height + ' units = ' + h_unit + '...');
});
vimeoinvocation = '[arve class="weVimeo-responsive" url="https://vimeo.com/' + id + '" parameters="' + args + '" align="' + align + '" maxwidth="' + width + '"]';
// disabling for the time being
/*wrapper.find('.caption').each(function(i, e) {
vimeoinvocation += '<div class="caption">' + $(this).html() + '</div>';
});
wrapper.find('.author').each(function(i, e) {
vimeoinvocation += '<div class="author">' + $(this).html() + '</div>';
});
vimeoinvocation = '<div class="weVimeo-wrapper" style="max-width: ' + width + w_unit + ';">' + vimeoinvocation + '</div>'; */
wrapper.replaceWith(vimeoinvocation);
});
// embed YouTube videos
$('.weYouTube-wrapper').each(function(i, e) {
console.log("******* Checking for video! ********");
var wrapper = $(this),
wrapper_classes = wrapper.attr("class"),
align = 'none',
......@@ -487,48 +538,56 @@ function processPage(pi) {
} else if (wrapper.hasClass('center')) {
align = 'center';
} else {
align = 'none';
align = 'none';
}
console.log('align ', align);
//console.log('align ', align);
// get the title if any
if (wrapper.find('.weYouTubeTitleContainer')) {
yttitle = wrapper.find('.weYouTubeTitleContainer').text();
console.log("title = ", yttitle);
//console.log("title = ", yttitle);
}
// get the video details
wrapper.find(".weYouTube").each(function(i, e) {
var $this = $(this),
var $this = $(this), width, w_unit, height, h_unit,
id = $this.attr("data-ytid"),
width = $this.css("width") || 560,
height = $this.css("height") || 315,
origwidth = $this.css('width') || '560px',
origheight = $this.css("height") || '315px',
start = 0,
list = $this.attr("data-list"),
index = $this.attr("data-index");
index = $this.attr("data-index");
// get the number only
width = origwidth.replace(numstr, '');
// get the units, if any
w_unit = origwidth.replace(width, '') || 'px';
// get the number only
height = origheight.replace(numstr, '') || 315;
// get the units, if any
h_unit = origheight.replace(height, '') || 'px';
// get video details
if (wrapper.find("a").attr("href").includes("youtube.com")) {
url = wrapper.find("a").attr("href");
url = wrapper.find("a").attr("href");
console.log('checking for start in url = ', url);
var qstring = url.split("?")[1],
qvars = qstring.split('&'),
qparam, i;
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 {
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 + '"'; }
}
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);
......@@ -566,11 +625,11 @@ function processPage(pi) {
});
// add our header stuff
var header = $("head");
//setAppMeta(header);
var page_header = $("head");
//setAppMeta(page_header);
// make stylesheet & Javascript references point to WikiEducator
header.find('link[rel="stylesheet"]').each(function() {
page_header.find('link[rel="stylesheet"]').each(function() {
var href = $(this).attr("href");
if (
href &&
......@@ -626,6 +685,11 @@ function processPage(pi) {
}());
</script>`);
/* if (opt['--h5p']) {
console.log('!!!!!!!!!!!!!!!!!!!!!!!!!! adding H5P Resize script!!!!');
page_header.append(getH5PResizer());
}*/
theme.header($, opt);
var iconsrc = $("#footer-copyrightico img").attr("src").replace("/icons/", "/buttons/");
......@@ -643,6 +707,7 @@ function processPage(pi) {
if (opt["--h5p"]) {
console.log("+++++");
h5p.process($, opt);
//addH5PResizer(page_header);
console.log("+++++");
}
......@@ -658,8 +723,8 @@ function processPage(pi) {
nl = urls[pages[np]];
}
if (opt["--previous"] && opt["--next"]) {
pt = opt["--previous"];
nt = opt["--next"];
pt = opt["--previous"];
nt = opt["--next"];
}
theme.prevnext($, pl, nl, pt, nt);
}
......
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