Commit 57dfb715 authored by Dave Lane's avatar Dave Lane

working h5p integration, still a bit rough regarding styles and dimensions,...

working h5p integration, still a bit rough regarding styles and dimensions, reimplemented iframe using switch statement
parent c7a31d56
......@@ -22,42 +22,88 @@ module.exports = {
count += 1;
console.log('WEH5P '+count+' ...');
$(this).find("div").each(function() {
case = $(this).attr('class');
//console.log('found '+case+'='+$(this).text());
if (case == 'host') {
host = $(this).text();
console.log('host = '+host);
code += ' src="'+ifurl+'"';
} else if (case == 'height') {
ifheight = $(this).text();
console.log('height = '+ifheight);
ifstyle_string += ' height:'+ifheight+';';
} else if (case == 'width') {
ifwidth = $(this).text();
console.log('width = '+ifwidth);
ifstyle_string += ' width:'+ifwidth+';';
} else if (case == 'style') {
ifstyle = $(this).text();
console.log('style = '+ifstyle);
ifstyle_string += ' '+ifstyle;
} else if (case == 'classes') {
classes = $(this).text();
console.log('classes = '+classes);
iframe += ' class="'+classes+'"';
} else if (case == 'id') {
ifid = $(this).text();
console.log('id = '+ifid);
iframe += ' id="'+ifid+'"';
console.log('found class = '+$(this).attr('class'));
switch($(this).attr('class')) {
case 'h5pid':
h5pid = $(this).text();
console.log('h5pid = '+h5pid);
break;
case 'host':
host = $(this).text();
/*origin = window.location.origin;
if (host === origin) {
host = '';
console.log('same host!');
} else {
console.log('host = '+host);
}*/
break;
case 'subsite':
subsite = $(this).text();
console.log('subsite = '+subsite);
break;
case 'subdir':
subdir = $(this).text();
console.log('subdir = '+subdir);
break;
case 'height':
height = $(this).text();
console.log('height = '+height);
style_string += ' height:'+height+';';
break;
case 'width':
width = $(this).text();
console.log('width = '+width);
style_string += ' width:'+width+';';
break;
case 'style':
style = $(this).text();
console.log('style = '+style);
style_string += ' '+style+';';
break;
case 'classes':
classes = $(this).text();
console.log('classes = '+classes);
break;
case 'id':
id = $(this).text();
console.log('id = '+id);
break;
}
});
script_url = host;
if (subsite != "") {
script_url = subsite+'.'+script_url;
}
if (subdir != "") {
script_url = script_url+'/'+subdir;
}
if (classes != "") {
// add a space...
classes += ' ';
}
classes += 'h5p-iframe h5p-initialized WEH5P';
if (id != "") {
// add a space...
id += ' ';
}
id += "h5p-iframe-'+count+'";
code = '<iframe id="'+id+'" class="'+classes+'"';
code += ' data-content-id="'+h5pid+'" src="'+script_url+'/wp-admin/admin-ajax.php?action=h5p_embed&amp;id='+h5pid+'"';
if (width != "") {
code += ' width="'+width+'"';
}
if (height != "") {
code += ' height="'+height+'"';
}
if (style_string != "") {
code += ' style="'+style_string+'"';
}
code = '<iframe src="'+host+'/wp-admin/admin-ajax.php?action=h5p_embed&id='+h5pid+'"';
if ()
code += ' width="$WIDTH" height="$HEIGHT" frameboarder="0" allowfullscreen="allowfullscreen"></iframe>';
code += '<script src="'+host+'/wp-content/plugins/h5p/h5p-php-library/js/h5p-resizer.js" charset="UTF-8"></script>';
code = '<!-- Escape editor -->'+code+'<!-- Un-Escape editor -->';
console.log(code);
//code += ' width="1108" height="244"';
code += ' frameboarder="0" allowfullscreen="allowfullscreen"></iframe>';
code += '<script class="WEH5P" src="'+script_url+'/wp-content/plugins/h5p/h5p-php-library/js/h5p-resizer.js" charset="UTF-8">&nbsp;</script>';
//code = '<!-- Escape editor -->'+code+'<!-- Un-Escape editor -->';
console.log('code = '+code);
$(this).replaceWith(code);
});
}
......
......@@ -21,30 +21,37 @@ module.exports = {
$(this).find("div").each(function() {
ifclass = $(this).attr('class');
//console.log('found '+ifclass+'='+$(this).text());
if (ifclass == 'url') {
ifurl = $(this).text();
console.log('url = '+ifurl);
iframe += ' src="'+ifurl+'"';
} else if (ifclass == 'height') {
ifheight = $(this).text();
console.log('height = '+ifheight);
ifstyle_string += ' height:'+ifheight+';';
} else if (ifclass == 'width') {
ifwidth = $(this).text();
console.log('width = '+ifwidth);
ifstyle_string += ' width:'+ifwidth+';';
} else if (ifclass == 'style') {
ifstyle = $(this).text();
console.log('style = '+ifstyle);
ifstyle_string += ' '+ifstyle;
} else if (ifclass == 'classes') {
ifclasses = $(this).text();
console.log('classes = '+ifclasses);
iframe += ' class="'+ifclasses+'"';
} else if (ifclass == 'id') {
ifid = $(this).text();
console.log('id = '+ifid);
iframe += ' id="'+ifid+'"';
switch($(this).attr('class')) {
case 'url':
ifurl = $(this).text();
console.log('url = '+ifurl);
iframe += ' src="'+ifurl+'"';
break;
case 'height':
ifheight = $(this).text();
console.log('height = '+ifheight);
ifstyle_string += ' height:'+ifheight+';';
break;
case 'width':
ifwidth = $(this).text();
console.log('width = '+ifwidth);
ifstyle_string += ' width:'+ifwidth+';';
break;
case 'style':
ifstyle = $(this).text();
console.log('style = '+ifstyle);
ifstyle_string += ' '+ifstyle;
break;
case 'classes':
ifclasses = $(this).text();
console.log('classes = '+ifclasses);
iframe += ' class="'+ifclasses+'"';
break;
case 'id':
ifid = $(this).text();
console.log('id = '+ifid);
iframe += ' id="'+ifid+'"';
break;
}
});
if (ifstyle_string != "") {
......
Markdown is supported
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