<commit_before>//$Id$

jQuery.fn.extend({
	flexibleSyntaxHighlighter: function(s) {
		s = jQuery.extend({
			mode: "tiki",
			lineNumbers: false,
			readOnly: false,
			force: false,
			l: "lib/codemirror/mode/"
		}, s);
		
		var l = s.l;
		
		var modeLocs = {
			clike: 		{js: l + "clike/clike.js"},
			css: 		{js: l + "css/css.js"},
			diff: 		{
							js: l + "diff/diff.js",
							css: l + "diff/diff.css"
						},
			haskell: 	{js: l + "haskell/haskell.js"},
			htmlmixed: 	{js: l + "htmlmixed/htmlmixed.js"},
			javascript: {js: l + "javascript/javascript.js"},
			lua: 		{js: l + "lua/lua.js"},
			php: 		{js: l + "php/php.js"},
			plsql: 		{js: l + "plsql/plsql.js"},
			python: 	{js: l + "python/python.js"},
			rst: 		{
							js: l + "rst/rst.js",
							css: l + "rst/rst.css"
						},
			r: 			{js: "lib/codemirror_tiki/mode/r/r.js"},
			scheme: 	{js: l + "scheme/scheme.js"},
			smalltalk: 	{js: l + "smalltalk/smalltalk.js"},
			stex: 		{js: l + "stex/stex.js"},
			tiki:	{
							js: 'lib/codemirror_tiki/mode/tiki/tiki.js',
							css: 'lib/codemirror_tiki/mode/tiki/tiki.css'
						},
			xml: 		{js: l + "xml/xml.js"},
			yaml:		{js: l + "yaml/yaml.js"}
		};
		
		jQuery(this).each(function() {
			jQuery(this).hide();
		});
		
		jQuery(this).each(function() {
			var settings = jQuery.extend({}, s);
			settings.parent = jQuery(this).parent();
			var o = jQuery(this);
			
			if (!settings.force && !o.is('pre')) {
				if (!o.data('codemirror') || o.data("nocodemirror")) return;
			}
			
			var textarea;
			
			if (!o.is(':input')) {
				var syntax = o.data('syntax');
				var lineNumbers = o.data('line-numbers');
				
				textarea =  $('<textarea class="preCodeMirror"></textarea>')
					.val(o.text())
					.insertAfter(o);
				
				if (syntax) textarea.data('syntax', syntax);
				if (lineNumbers) textarea.data('line-numbers', lineNumbers);
			} else {
				textarea = o;
			}
			
			//-->Width fix
			settings.width = settings.parent.width();
			settings.height = o.height();
			
			o.hide();

			//prevent the bottom scrollbar from popping up if not enough height
			settings.height = (settings.height < 50 ? 50 : settings.height);
			settings.width = (settings.width < 50 ? 50 : settings.width);
			//-->End Width fix
			if (textarea.attr('codeMirrorRelationshipFullscreen')) return false;
			
			if (!textarea.length) return false;
			if (!window.CodeMirror) return false;
			
			function applyOverride(override, setting) {
				var attr = textarea.data(override);
				if (!settings[setting]) {
					settings[setting] = attr;
				} else if (!attr) {
					attr = settings[setting];
				}
				settings[setting] = attr;
				return settings[setting];
			}
			
			var mode = applyOverride('syntax', 'mode');
			var lineNumbers = applyOverride('line-numbers', 'lineNumbers');
			
			var modeDef = syntaxHighlighter.modes[mode];
			if (!modeDef) {
				syntaxHighlighter.remove(textarea);
				syntaxHighlighter.ready(textarea, settings);
			} else {
				if (!modeDef.modeSpec) return;
				if (!modeDef.mime) return;
				var modeLoc = modeLocs[modeDef.modeSpec];
				if (!modeLoc) return;
				
				if (modeLoc.css) {
					jQuery('head').append('<link rel="stylesheet" class="tiki-codemirror-style" href="' + modeLoc.css + '" />');
				}
				
				
				settings.parent.visible(function() {
					settings.parent.modal(tr("Loading..."));
					if (modeLoc.js) {
						jQuery.getScript(modeLoc.js, function(e) {
							syntaxHighlighter.remove(textarea);
							syntaxHighlighter.ready(textarea, settings, modeDef, mode);
							settings.parent.modal();
						});
					}
				});
			}
		});
		
		return this;
	}
});

//An effective way of interacting with a codemirror editor
var syntaxHighlighter = {
	modes: {
		"c": {
			modeSpec: "clike",
			mime: "text/x-csrc"
		},
		"c++": {<commit_msg>[FIX] In edit mode, parent had no height, moved height to parent and kept height inherit on scroll object<commit_after>//$Id$

jQuery.fn.extend({
	flexibleSyntaxHighlighter: function(s) {
		s = jQuery.extend({
			mode: "tiki",
			lineNumbers: false,
			readOnly: false,
			force: false,
			l: "lib/codemirror/mode/"
		}, s);
		
		var l = s.l;
		
		var modeLocs = {
			clike: 		{js: l + "clike/clike.js"},
			css: 		{js: l + "css/css.js"},
			diff: 		{
							js: l + "diff/diff.js",
							css: l + "diff/diff.css"
						},
			haskell: 	{js: l + "haskell/haskell.js"},
			htmlmixed: 	{js: l + "htmlmixed/htmlmixed.js"},
			javascript: {js: l + "javascript/javascript.js"},
			lua: 		{js: l + "lua/lua.js"},
			php: 		{js: l + "php/php.js"},
			plsql: 		{js: l + "plsql/plsql.js"},
			python: 	{js: l + "python/python.js"},
			rst: 		{
							js: l + "rst/rst.js",
							css: l + "rst/rst.css"
						},
			r: 			{js: "lib/codemirror_tiki/mode/r/r.js"},
			scheme: 	{js: l + "scheme/scheme.js"},
			smalltalk: 	{js: l + "smalltalk/smalltalk.js"},
			stex: 		{js: l + "stex/stex.js"},
			tiki:	{
							js: 'lib/codemirror_tiki/mode/tiki/tiki.js',
							css: 'lib/codemirror_tiki/mode/tiki/tiki.css'
						},
			xml: 		{js: l + "xml/xml.js"},
			yaml:		{js: l + "yaml/yaml.js"}
		};
		
		jQuery(this).each(function() {
			jQuery(this).hide();
		});
		
		jQuery(this).each(function() {
			var settings = jQuery.extend({}, s);
			settings.parent = jQuery(this).parent();
			var o = jQuery(this);
			
			if (!settings.force && !o.is('pre')) {
				if (!o.data('codemirror') || o.data("nocodemirror")) return;
			}
			
			var textarea;
			
			if (!o.is(':input')) {
				var syntax = o.data('syntax');
				var lineNumbers = o.data('line-numbers');
				
				textarea =  $('<textarea class="preCodeMirror"></textarea>')
					.val(o.text())
					.insertAfter(o);
				
				if (syntax) textarea.data('syntax', syntax);
				if (lineNumbers) textarea.data('line-numbers', lineNumbers);
			} else {
				textarea = o;
			}
			
			//-->Width fix
			settings.width = settings.parent.width();
			settings.height = o.height();
			
			o.hide();

			//prevent the bottom scrollbar from popping up if not enough height
			settings.height = (settings.height < 50 ? 50 : settings.height);
			settings.width = (settings.width < 50 ? 50 : settings.width);
			//-->End Width fix
			if (textarea.attr('codeMirrorRelationshipFullscreen')) return false;
			
			if (!textarea.length) return false;
			if (!window.CodeMirror) return false;
			
			function applyOverride(override, setting) {
				var attr = textarea.data(override);
				if (!settings[setting]) {
					settings[setting] = attr;
				} else if (!attr) {
					attr = settings[setting];
				}
				settings[setting] = attr;
				return settings[setting];
			}
			
			var mode = applyOverride('syntax', 'mode');
			var lineNumbers = applyOverride('line-numbers', 'lineNumbers');
			
			var modeDef = syntaxHighlighter.modes[mode];
			if (!modeDef) {
				syntaxHighlighter.remove(textarea);
				syntaxHighlighter.ready(textarea, settings);
			} else {
				if (!modeDef.modeSpec) return;
				if (!modeDef.mime) return;
				var modeLoc = modeLocs[modeDef.modeSpec];
				if (!modeLoc) return;
				
				if (modeLoc.css) {
					jQuery('head').append('<link rel="stylesheet" class="tiki-codemirror-style" href="' + modeLoc.css + '" />');
				}
				
				
				settings.parent.visible(function() {
					settings.parent.modal(tr("Loading..."));
					if (modeLoc.js) {
						jQuery.getScript(modeLoc.js, function(e) {
							syntaxHighlighter.remove(textarea);
							syntaxHighlighter.ready(textarea, settings, modeDef, mode);
							settings.parent.modal();
							settings.parent.find('.CodeMirror').height(settings.height);
						});
					}
				});
			}
		});
		
		return this;
	}
});

//An effective way of interacting with a codemirror editor
var syntaxHighlighter = {
	modes: {
		"c": {
			modeSpec: "clike",
			mime: "text/x-csrc"
		},
		"c++": {
{'fraction_non_alphanumeric': 0.17781780751415338, 'fraction_numerical': 0.002058672156459084, 'mean_word_length': 2.7049571020019068, 'pattern_counts': {'":': 4, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4724489', 'n_tokens_mistral': 3629, 'n_tokens_neox': 2758, 'n_words': 569}