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

initial code copy for h5p - doesn't run yet

parent 043c6aab
Loading
Loading
Loading
Loading
+57 −2
Original line number Diff line number Diff line
console.log('in h5p.js!');

module.exports = {
    version: "0.0.1",
    version: "0.0.2",
    process: function($, opt) {
        console.log('in h5p.js module!');
        
        var count = 0,
            h5pid,
            host,
            subdir,
            subsite,
            height,
            width,
            style,
            style_string,
            classes,
            id;
        // find the nodes in the Dom...
        $(".WEH5P").each(function() {
            h5pid = host = subdir = subsite = height = width = style = style_string = classes = id = "";
            code = "";
            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+'"';
                }
            });
            if (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);
            $(this).replaceWith(code);
        });
    }
}