(function($){$.fn.codemirror = function(options) { var result = this; var settings = $.extend( { 'mode' : 'javascript', 'lineNumbers' : false, 'runmode' : false }, options); if (settings.runmode) this.each(function() { var obj = $(this); var accum = [], gutter = [], size = 0; var callback = function(string, style) { if (string == "\n") { accum.push("
"); gutter.push('
'+(++size)+'
'); } else if (style) { accum.push("" + CodeMirror.htmlEscape(string) + ""); } else { accum.push(CodeMirror.htmlEscape(string)); } } CodeMirror.runMode(obj.val(), settings.mode, callback); $('
'+(settings.lineNumbers?('
'+gutter.join('')+'
'):'')+'
'+(settings.lineNumbers?'
':'
')+'
'+accum.join('')+'
').insertAfter(obj); obj.hide(); }); else this.each(function() { result = CodeMirror.fromTextArea(this, settings); }); return result; };})( jQuery );