///import core ///import plugins/inserthtml.js ///commands 百度应用 ///commandsName webapp ///commandsTitle 百度应用 ///commandsDialog dialogs\webapp UE.plugins['webapp'] = function () { var me = this; function createInsertStr( obj, toIframe, addParagraph ) { return !toIframe ? (addParagraph ? '

' : '') + '' + (addParagraph ? '

' : '') : ''; } function switchImgAndIframe( img2frame ) { var tmpdiv, nodes = domUtils.getElementsByTagName( me.document, !img2frame ? "iframe" : "img" ); for ( var i = 0, node; node = nodes[i++]; ) { if ( node.className != "edui-faked-webapp" ){ continue; } tmpdiv = me.document.createElement( "div" ); tmpdiv.innerHTML = createInsertStr( img2frame ? {url:node.getAttribute( "_url" ), width:node.width, height:node.height,title:node.title,logo:node.style.backgroundImage.replace("url(","").replace(")","")} : {url:node.getAttribute( "src", 2 ),title:node.title, width:node.width, height:node.height,logo:node.getAttribute("logo_url")}, img2frame ? true : false,false ); node.parentNode.replaceChild( tmpdiv.firstChild, node ); } } me.addListener( "beforegetcontent", function () { switchImgAndIframe( true ); } ); me.addListener( 'aftersetcontent', function () { switchImgAndIframe( false ); } ); me.addListener( 'aftergetcontent', function ( cmdName ) { if ( cmdName == 'aftergetcontent' && me.queryCommandState( 'source' ) ){ return; } switchImgAndIframe( false ); } ); me.commands['webapp'] = { execCommand:function ( cmd, obj ) { me.execCommand( "inserthtml", createInsertStr( obj, false,true ) ); } }; };