User:John Vandenberg/switch editor 2.js
mw.hook( 've.activationComplete' ).add( function() {
$('#ca-editsource a').attr('href','#').bind('click', function(){
// if you want a bookmarklet to switch, use the code below
var target = ve.init.mw.targets[0];
var doc = target.surface.getModel().getDocument();
doc = ve.dm.converter.getDomFromData( doc.getFullData(), doc.getStore(), doc.getInternalList() );
target.serializing = false;
target.serialize( doc,
function( content ) {
if ($('#editform').length!=0) $('#editform').remove();
$("body").append('
' );window.onbeforeunload = function (){};
$("textarea#wpTextbox1").val(content).parent().children("#wpDiff").click();
});
// end of bookmarklet
});
});