/* =============================================================================== Chili is the jQuery code highlighter plugin ............................................................................... Copyright 2007 / Andrea Ercolino ------------------------------------------------------------------------------- LICENSE: http://www.opensource.org/licenses/mit-license.php WEBSITE: http://noteslog.com/chili/ =============================================================================== =============================================================================== Metaobjects is the jQuery metadata plugin on steroids ............................................................................... Copyright 2007 / Andrea Ercolino ------------------------------------------------------------------------------- LICENSE: http://www.opensource.org/licenses/mit-license.php WEBSITE: http://noteslog.com/metaobjects/ =============================================================================== */ //----------------------------------------------------------------------------- ( function($) { ChiliBook = { //implied global version: "1.8c" // 2007-07-21 , automatic: true , automaticSelector: "code" , codeLanguage: function( el ) { var recipeName = $( el ).attr( "class" ); return recipeName ? recipeName : ''; } , metadataSelector: "object.chili" // use an empty string for not executing , recipeLoading: true , recipeFolder: "" // used like: recipeFolder + recipeName + '.js' , stylesheetLoading: true , stylesheetFolder: "" // used like: stylesheetFolder + recipeName + '.css' , defaultReplacement: '$$' , replaceSpace: " " // use an empty string for not replacing , replaceTab: "    " // use an empty string for not replacing , replaceNewLine: " 
" // use an empty string for not replacing , recipes: {} //repository , queue: {} //register //fix for IE: copy of PREformatted text strips off all html, losing newlines , preFixCopy: document.selection && document.selection.createRange , preContent: "" , preElement: null }; $.metaobjects = function( options ) { options = $.extend( { context: document , clean: true , selector: 'object.metaobject' }, options ); function jsValue( value ) { eval( 'value = ' + value + ";" ); return value; } return $( options.selector, options.context ) .each( function() { var settings = { target: this.parentNode }; $( '> param[@name=metaparam]', this ) .each( function() { $.extend( settings, jsValue( this.value ) ); } ); $( '> param', this ) .not( '[@name=metaparam]' ) .each( function() { var name = this.name, value = jsValue( this.value ); $( settings.target ) .each( function() { this[ name ] = value; } ); } ); if( options.clean ) { $( this ).remove(); } } ); }; $.fn.chili = function( options ) { var book = $.extend( {}, ChiliBook, options || {} ); function cook( ingredients, recipe ) { function prepareStep( stepName, step ) { var exp = ( typeof step.exp == "string" ) ? step.exp : step.exp.source; steps.push( { stepName: stepName , exp: "(" + exp + ")" , length: 1 // add 1 to account for the newly added parentheses + (exp // count number of submatches in here .replace( /\\./g, "%" ) // disable any escaped character .replace( /\[.*?\]/g, "%" ) // disable any character class .match( /\((?!\?)/g ) // match any open parenthesis, not followed by a ? || [] // make sure it is an empty array if there are no matches ).length // get the number of matches , replacement: (step.replacement) ? step.replacement : book.defaultReplacement } ); } // function prepareStep( stepName, step ) function knowHow() { var prevLength = 0; var exps = new Array; for (var i = 0; i < steps.length; i++) { var exp = steps[ i ].exp; // adjust backreferences exp = exp.replace( /\\\\|\\(\d+)/g, function( m, aNum ) { return !aNum ? m : "\\" + ( prevLength + 1 + parseInt( aNum, 10 ) ); } ); exps.push( exp ); prevLength += steps[ i ].length; } var source = exps.join( "|" ); return new RegExp( source, (recipe.ignoreCase) ? "gi" : "g" ); } // function knowHow() function escapeHTML( str ) { return str.replace( /&/g, "&" ).replace( / -1 ); text = text.replace( /\]*?\>/ig, newline_flag ); var el = document.createElement( '
' );
			el.innerHTML = text;
			text = el.innerText.replace( new RegExp( newline_flag, "g" ), '\r\n' );
			return text;
		}

		$( "body" )
		.bind( "copy", function() {
			if( '' != ChiliBook.preContent ) {
				window.clipboardData.setData( 'Text', preformatted( ChiliBook.preContent ) );
				event.returnValue = false;
			}
		} )
		.bind( "mousedown", function() {
			ChiliBook.preContent = "";
		} )
		.bind( "mouseup", function() {
			ChiliBook.preElement = null;
		} )
		;
	}

} );

} ) ( jQuery );