zoukankan      html  css  js  c++  java
  • ueditor 插入视频代码解析

     /*
         * 创建插入视频字符窜
         * @param url 视频地址
         * @param width 视频宽度
         * @param height 视频高度
         * @param align 视频对齐
         * @param toEmbed 是否以flash代替显示
         * @param addParagraph  是否需要添加P 标签
         
         */
        function creatInsertStr(url,width,height,id,align,classname,type){
            var str;
            switch (type){
                case 'image':
                    str = '<img ' + (id ? 'id="' + id+'"' : '') + ' width="'+ width +'" height="' + height + '" _url="'+url+'" class="' + classname + '"'  +
                        ' src="' + me.options.UEDITOR_HOME_URL+'themes/default/images/spacer.gif" style="background:url('+me.options.UEDITOR_HOME_URL+'themes/default/images/videologo.gif) no-repeat center center; border:1px solid gray;'+(align ? 'float:' + align + ';': '')+'" />'
                    break;
                case 'embed':
                    str = '<embed type="application/x-shockwave-flash" class="' + classname + '" pluginspage="http://www.macromedia.com/go/getflashplayer"' +
                        ' src="' +  utils.html(url) + '" width="' + width  + '" height="' + height  + '"'  + (align ? ' style="float:' + align + '"': '') +
                        ' wmode="transparent" play="true" loop="false" menu="false" allowscriptaccess="never" allowfullscreen="true" >';
                    break;
                case 'video':
                    var ext = url.substr(url.lastIndexOf('.') + 1);
                    if(ext == 'ogv') ext = 'ogg';
                    str = '<video' + (id ? ' id="' + id + '"' : '') + ' class="' + classname + '" ' + (align ? ' style="float:' + align + '"': '') +
                        ' controls preload="none" width="' + width + '" height="' + height + '" src="' + url + '" data-setup="{}">' +
                        '<source src="' + url + '" type="video/' + ext + '" /></video>';
                    break;
            }
            return str;
        }
        //插入在线视频传入的类名是edui-faked-video  插入上传的视频类名是edui-upload-video
        function switchImgAndVideo(root,img2video){ 
            utils.each(root.getNodesByTagName(img2video ? 'img' : 'embed video'),function(node){
                var className = node.getAttr('class');
                if(className && className.indexOf('edui-faked-video') != -1){
                    var html = creatInsertStr( img2video ? node.getAttr('_url') : node.getAttr('src'),node.getAttr('width'),node.getAttr('height'),null,node.getStyle('float') || '',className,img2video ? 'embed':'image');
                    node.parentNode.replaceChild(UE.uNode.createElement(html),node);
                }
                if(className && className.indexOf('edui-upload-video') != -1){
                    var html = creatInsertStr( img2video ? node.getAttr('_url') : node.getAttr('src'),node.getAttr('width'),node.getAttr('height'),null,node.getStyle('float') || '',className,img2video ? 'video':'image');
                    node.parentNode.replaceChild(UE.uNode.createElement(html),node);
                }
            })
        }
    
        me.addOutputRule(function(root){   //可能是代码与设计模式切换时html的转换,img站位标签和实际标签转换
            switchImgAndVideo(root,true)
        });
        me.addInputRule(function(root){
            switchImgAndVideo(root)
        });
  • 相关阅读:
    园子一周年
    HTML5本地存储之Web Storage实例篇,最有用的是localStorage
    解析H5本地储存Web Storage
    response.sendRedirect传递参数和转向
    html文件form表单action调用servlet连接mysql数据库实例
    容器List之ArrayList详解
    PageHelper的使用
    可迭代对象、迭代器、生成器
    伪随机数生成器——random模块的用法
    python中的单例设计模式
  • 原文地址:https://www.cnblogs.com/djiz/p/13965181.html
Copyright © 2011-2022 走看看