⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bipad.js

📁 ajax 框价.是个好工具.javascript 矿家.可以用在任何平台.
💻 JS
字号:
var biPad;function BiPad(){	var source = application.getComponentById("source");	var preview = application.getComponentById("preview");	var mb = application.getComponentById( "menu-bar" );	var hmb = application.getComponentById( "help-menu-button" );	var b = new BiMenuButton( "Snippets" );	b.setMnemonic( "S" );	b.setSubMenu( this.getSnippetsMenu( application.getResourceById("snippets") ) );	mb.add( b, hmb );	source.setFocused( true );	// If Mozilla we hide the clipboard ui elements	if ( BiBrowserCheck.moz )	{		var item;		var items = ["clipboard-tbs", "cut-tbb", "copy-tbb", "paste-tbb",					 "cut-mi", "copy-mi", "paste-mi", "clipboard-ms"];		for ( var i = 0; i < items.length; i++ )		{			item = application.getComponentById( items[i] );			item.getParent().remove( item );		}	}	if ( BiBrowserCheck.ie )	{		var t = new BiTimer( 500 );		t.addEventListener( "tick", this.syncClipBoardCommands, this );		t.start();	}}_p = BiPad.prototype;_p._autoPreview = true;_p.getAutoPreview = function (){	return this._autoPreview;};_p.setAutoPreview = function ( b ){	this._autoPreview = b;	if ( b )		this.preview();};_p.preview = function () {	var source = application.getComponentById("source");	var preview = application.getComponentById("preview");	var errorLabel = application.getComponentById("errorLabel");	this.error = false;	var d = new BiXmlDocument;	d.loadXML("<root>" + source.getText() + "</root>");	if (d.parseError.errorCode != 0) {		this.showError("Reason: " + d.parseError.reason + "\nLine: " + d.parseError.line);	} else {		try {			// we need to remove all so that we are not reusing components from			// the preview that has an id			preview.removeAll();			var de = d.documentElement;			var cs = de.childNodes;			var rp = application.getAdf().getXmlResourceParser();			for (var i = 0; i < cs.length; i++) {				preview.addXmlNode(cs[i], rp)			}			if (!this.error) {				this.hideError();			}		} catch (ex) {			preview.removeAll();			this.showError(ex.message);		} finally {			d = null;		}	}};_p.timedPreview = function ( n ){	if ( n == undefined )		n = 100;	if ( this._previewTimer )	{		this._previewTimer.stop();	}	else	{		this._previewTimer = new BiTimer;		this._previewTimer.addEventListener( "tick", function ()		{			this.preview();			this._previewTimer.stop();		}, this );	}	this._previewTimer.setInterval( n );	this._previewTimer.start();};_p.showError = function ( s ){	var infoBox = application.getComponentById("infoBox");	var errorLabel = application.getComponentById("errorLabel");	errorLabel.setText( s );	infoBox.setVisible( true );	infoBox.invalidateParentLayout();	if ( !this._firstHandled )	{		this._firstHandled = true;		BiTimer.callOnce(infoBox.invalidateParentLayout, 1, infoBox);	}	this.error = true;};_p.hideError = function (){	var infoBox = application.getComponentById("infoBox");	infoBox.setVisible( false );	infoBox.invalidateParentLayout();	this.error = false;};_p.insertText = function ( s, collapseToEnd ){	var source = application.getComponentById( "source" );	source.setFocused( true );	source.setSelectionText( s );	if ( collapseToEnd )		source.setSelectionStart( source.getSelectionStart() + s.length );};_p.increaseNumber = function (e){	var source = application.getComponentById( "source" );	var info = this.findNumber();	if ( info )	{		e.preventDefault();		source.setSelectionStart( info.start );		source.setSelectionLength( info.end - info.start );		var n = String(Number(info.num) + 5);		source.setSelectionText( n );		//source.setSelectionStart( info.start );		//source.setSelectionLength( n.length );	}};_p.decreaseNumber = function (e){	var source = application.getComponentById( "source" );	var info = this.findNumber();	if ( info )	{		e.preventDefault();		source.setSelectionStart( info.start );		source.setSelectionLength( info.end - info.start );		var n = String(info.num - 5);		source.setSelectionText( n );		source.setSelectionStart( info.start );		source.setSelectionLength( n.length );	}};_p.findNumber = function (){	var source = application.getComponentById( "source" );	var s = source.getText();	var n = source.getSelectionStart();	var start = n;	var end = n;	while ( /\d|\-/.test( s.charAt(start - 1) ) )		start--;	while ( /\d|\-/.test( s.charAt(end) ) )		end++;	var num = s.substring( start, end );	if ( num != "" && !isNaN(num) )		return { num: num, start: start, end: end };	return null;};BiPad.main = function (){	biPad = new BiPad;};/* Snippets */_p.getSnippetsMenu = function ( s ){	var m = new BiMenu;	var cs = s.getChildren();	var l = cs.length;	var mi;	for ( var i = 0; i < l; i++ )	{		mi = new BiMenuItem( cs[i].getName() );		if ( cs[i] instanceof Snippet )		{			mi._snippet = cs[i];			mi.addEventListener( "action", BiPad.onSnippet );		}		else	// Snippets		{			mi.setSubMenu( this.getSnippetsMenu( cs[i] ) );		}		m.add( mi );	}	return m;};BiPad.onSnippet = function ( e ){	var snippet = e.getTarget()._snippet;	biPad.insertText( snippet.getText() );};/* Clip board */_p.copy = function ( e ){	try	{		document.execCommand( "copy" );	}	catch ( ex ) {}};_p.cut = function ( e ){	try	{		document.execCommand( "cut" );	}	catch ( ex ) {}};_p.paste = function ( e ){	try	{		document.execCommand( "paste" );		e.preventDefault();	}	catch ( ex ) {}};_p.syncClipBoardCommands = function (){	var c = application.getComponentById("cut-command");	c.setEnabled( document.queryCommandEnabled("cut") );	c = application.getComponentById("copy-command");	c.setEnabled( document.queryCommandEnabled("copy") );	c = application.getComponentById("paste-command");	c.setEnabled( document.queryCommandEnabled("paste") );};/* Color picker */_p.showColorPicker = function (){	var cp = new BiColorPicker;	cp.addEventListener( "dialogresult", function ( e )	{		var res = cp.getDialogResult();		if ( res != null )			this.insertText( res );	}, this );	cp.setVisible( true );};_p.showAbout = function (){	var d = application.getComponentById( "about-dialog" );	d.setVisible( true );	d.getContentPane().getFirstChild().invalidateLayout();};_p.showHelp = function (){	window.open( new BiUri(application.getAdfPath(), "help.html" ).toString() );};_p.onSourceTextChanged = function ( e ){	if ( this.getAutoPreview() )	{		this.timedPreview( 50 );	}};// syntax errors are not thrown when using execScript// This cannot be handled in BiScriptLoaderQueue becuase it breaks the debuggerif (BiBrowserCheck.ie) {	window.onerror = function (msg, url, ln) {		biPad.showError(msg);		return true;	};}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -