<commit_before>var _AJAX_LOADING = false;

/**
 * Code for the separator bar between the two panes
 */
function DraggableSeparator() {
	this.onmousedown = this.onmousedown.bindAsEventListener(this);
	// this.onselectstart = this.onselectstart.bindAsEventListener(this);
}
DraggableSeparator.prototype = {
	onmousedown : function(event) {
		this.leftBase = $('left').offsetWidth - Event.pointerX(event);
		this.separatorBase = getDimension($('separator'),'left') - Event.pointerX(event);
		this.rightBase = getDimension($('right'),'left') - Event.pointerX(event);

		document.onmousemove = this.document_mousemove.bindAsEventListener(this);
		document.onmouseup = this.document_mouseup.bindAsEventListener(this);
		
		document.body.onselectstart = this.body_selectstart.bindAsEventListener(this);
	},
	document_mousemove : function(event) {
		$('left').style.width = (this.leftBase + Event.pointerX(event)) + 'px';
		fixRightWidth();
	},
	document_mouseup : function(e) {
		document.onmousemove = null;
	},
	
	body_selectstart : function(event) {
		Event.stop(event);
		return false;
	}
}

function fixRightWidth() {
	if( !$('right') )
		return;
	
	// Absolutely position all the elements
	var sep = getDimension($('left'),'width') + getDimension($('left'),'left');
	$('separator').style.left = (sep + 2) + 'px';
	$('right').style.left = (sep + 6) + 'px';		

	// Give the remaining space to right
	var rightWidth = parseInt(document.body.offsetWidth) - parseInt($('left').offsetWidth) - $('separator').offsetWidth - 8;
	
	if( rightWidth >= 0 )
		$('right').style.width = rightWidth + 'px';
	
	var rb;
	if(rb = $('rightbottom')) {
		rb.style.left = $('right').style.left;
		rb.style.width = $('right').style.width;
	}
}

Behaviour.register({
	'#separator' : DraggableSeparator,
	
	'#left' : {
		hide : function() {
			if(!this.hidden) {
				this.hidden = true;
				this.style.width = null;
				Element.addClassName(this,'hidden');
				Element.addClassName('separator','hidden');
				fixRightWidth();
			}
		},
		show : function() {
			if(this.hidden) {
				this.hidden = false;
				Element.removeClassName(this,'hidden');
				Element.removeClassName('separator','hidden');
				fixRightWidth();
			}			
		}		
	},
	
	'#MainMenu li' : {
		onclick : function(event) { 
			window.location.href = this.getElementsByTagName('a')[0].href; 
			Event.stop(event);
		}
	},
	
	'#Menu-help' : {
		onclick : function() {
			var w = window.open(this.getElementsByTagName('a')[0].href, 'help');
			w.focus();
			return false;
		}
	}

})



window.ontabschanged = function() {
	var formEl = $('Form_EditForm');
	
	if( !formEl )
		return;
	
	var fs = formEl.getElementsByTagName('fieldset')[0];
	if(fs) fs.style.height = formEl.style.height;

	// var divs = document.getElementsBySelector('#Form_EditForm div');
	/*for(i=0;i<divs.length;i++) {
		if( ( Element.hasClassName(divs[i],'tab') || Element.hasClassName(divs[i],'tabset') ) && isVisible(divs[i]) ) {
			if(navigator.appName == "Microsoft Internet Explorer")
				fitToParent(divs[i], i == 0 ? 18 : 0);
			else
				fitToParent(divs[i], 3);
		}
	}*/
	
	if( _TAB_DIVS_ON_PAGE ) {
		for(i = 0; i < _TAB_DIVS_ON_PAGE.length; i++ ) {
			// console.log(_TAB_DIVS_ON_PAGE[i].id);
			if(navigator.appName == "Microsoft Internet Explorer")
				fitToParent(_TAB_DIVS_ON_PAGE[i], i == 0 ? 18 : 30);
			else
				fitToParent(_TAB_DIVS_ON_PAGE[i], /*3*/ 30);
		}
	}
}

window.onresize = function(init) {
	var right = $('right');
	var rightbottom = $('rightbottom');
	if(rightbottom) rightbottom.style.display = 'none';

	if(typeof fitToParent == 'function') fitToParent('right', 12);

	if( $('left') && $('separator') && right )
		$('left').style.height = $('separator').style.height = right.style.height;

	if(rightbottom) {
		var newHeight = (parseInt(right.style.height) / 3);
		right.style.height = (newHeight*2) + 'px';
		rightbottom.style.height = newHeight + 'px';
		rightbottom.style.display = '';
		rightbottom.style.top = getDimension(right,'top') + (newHeight*2) + 'px';
	}
	
	if(typeof fitToParent == 'function') fitToParent('Form_EditForm');
	if(typeof fixHeight_left == 'function') fixHeight_left();
	if(typeof fixRightWidth == 'function') fixRightWidth();
	
	window.ontabschanged();
}

appendLoader(function() { 
	document.body.style.overflow = 'hidden';
	window.onresize(true);
});

function isVisible(el) {
	// if(typeof el.isVisible != 'undefined') return el.isVisible;
	if(el.tagName == "body" || el.tagName == "BODY") return (el.isVisible = true);
	else if(el.style.display == 'none') return (el.isVisible = false);
	else return (el.isVisible = isVisible(el.parentNode));
}


LeftAndMain_window_unload = function() {
	window.exiting = true; // this is used by prototype
	if(typeof autoSave == 'function')
	autoSave(navigator.appName == "Microsoft Internet Explorer");
}

Event.observe(window, 'beforeunload', LeftAndMain_window_unload);

/**
 * Unlock the locked status message.
 * Show a queued message, if one exists
 */
function unlockStatusMessage() {
	statusMessage.locked = false; 
	if(statusMessage.queued) {
		statusMessage(
			statusMessage.queued.msg,
			statusMessage.queued.type,
			statusMessage.queued.showNetworkActivity); 
	
		statusMessage.queued = null;
	}
}

/**
 * Move form actions to the top and make them ajax
 */
function ajaxActionsAtTop(formName, actionHolderName, tabName) {
	var actions = document.getElementsBySelector('#' + formName + ' .Actions')[0];
	var holder;

	if(actions) {
		if((holder = $(actionHolderName)) && holder != actions) {
			holder.parentNode.removeChild(holder);
		}
		
		actions.id = actionHolderName;
		actions.className = 'ajaxActions';

		$(tabName).appendChild(actions);
		prepareAjaxActions(actions, formName, tabName);
	}
}

/**
 * Prepare the ajax actions so that the buttons actually do something
 */
function prepareAjaxActions(actions, formName, tabName) {
	var i, button, list = actions.getElementsByTagName('input')
	for (i=0;button=list[i];i++) {
		button.ownerForm = $(formName);
	
		button.onclick = function(e) {
			// tries to call a custom method of the format "action_<youraction>_right"
			if(window[this.name + '_' + tabName]) {
				window[this.name + '_' + tabName](e);
			} else {
				statusMessage(ingize(this.value));
				Ajax.SubmitForm(this.ownerForm, this.name, {
					onSuccess: Ajax.Evaluator,
					onFailure: ajaxErrorHandler
				});
			}
			return false;
		}
		behaveAs(button, StatusTitle);
	}
}

function ingize(val) {
	if(!val) val = "process";
	if(val.substr(val.length-1) == 'e') return val.substr(0, val.length-1) + 'ing...';
	else return val + 'ing...';
}<commit_msg>Improved ingize() support so that it works on multi-word verbs<commit_after>var _AJAX_LOADING = false;

/**
 * Code for the separator bar between the two panes
 */
function DraggableSeparator() {
	this.onmousedown = this.onmousedown.bindAsEventListener(this);
	// this.onselectstart = this.onselectstart.bindAsEventListener(this);
}
DraggableSeparator.prototype = {
	onmousedown : function(event) {
		this.leftBase = $('left').offsetWidth - Event.pointerX(event);
		this.separatorBase = getDimension($('separator'),'left') - Event.pointerX(event);
		this.rightBase = getDimension($('right'),'left') - Event.pointerX(event);

		document.onmousemove = this.document_mousemove.bindAsEventListener(this);
		document.onmouseup = this.document_mouseup.bindAsEventListener(this);
		
		document.body.onselectstart = this.body_selectstart.bindAsEventListener(this);
	},
	document_mousemove : function(event) {
		$('left').style.width = (this.leftBase + Event.pointerX(event)) + 'px';
		fixRightWidth();
	},
	document_mouseup : function(e) {
		document.onmousemove = null;
	},
	
	body_selectstart : function(event) {
		Event.stop(event);
		return false;
	}
}

function fixRightWidth() {
	if( !$('right') )
		return;
	
	// Absolutely position all the elements
	var sep = getDimension($('left'),'width') + getDimension($('left'),'left');
	$('separator').style.left = (sep + 2) + 'px';
	$('right').style.left = (sep + 6) + 'px';		

	// Give the remaining space to right
	var rightWidth = parseInt(document.body.offsetWidth) - parseInt($('left').offsetWidth) - $('separator').offsetWidth - 8;
	
	if( rightWidth >= 0 )
		$('right').style.width = rightWidth + 'px';
	
	var rb;
	if(rb = $('rightbottom')) {
		rb.style.left = $('right').style.left;
		rb.style.width = $('right').style.width;
	}
}

Behaviour.register({
	'#separator' : DraggableSeparator,
	
	'#left' : {
		hide : function() {
			if(!this.hidden) {
				this.hidden = true;
				this.style.width = null;
				Element.addClassName(this,'hidden');
				Element.addClassName('separator','hidden');
				fixRightWidth();
			}
		},
		show : function() {
			if(this.hidden) {
				this.hidden = false;
				Element.removeClassName(this,'hidden');
				Element.removeClassName('separator','hidden');
				fixRightWidth();
			}			
		}		
	},
	
	'#MainMenu li' : {
		onclick : function(event) { 
			window.location.href = this.getElementsByTagName('a')[0].href; 
			Event.stop(event);
		}
	},
	
	'#Menu-help' : {
		onclick : function() {
			var w = window.open(this.getElementsByTagName('a')[0].href, 'help');
			w.focus();
			return false;
		}
	}

})



window.ontabschanged = function() {
	var formEl = $('Form_EditForm');
	
	if( !formEl )
		return;
	
	var fs = formEl.getElementsByTagName('fieldset')[0];
	if(fs) fs.style.height = formEl.style.height;

	// var divs = document.getElementsBySelector('#Form_EditForm div');
	/*for(i=0;i<divs.length;i++) {
		if( ( Element.hasClassName(divs[i],'tab') || Element.hasClassName(divs[i],'tabset') ) && isVisible(divs[i]) ) {
			if(navigator.appName == "Microsoft Internet Explorer")
				fitToParent(divs[i], i == 0 ? 18 : 0);
			else
				fitToParent(divs[i], 3);
		}
	}*/
	
	if( _TAB_DIVS_ON_PAGE ) {
		for(i = 0; i < _TAB_DIVS_ON_PAGE.length; i++ ) {
			// console.log(_TAB_DIVS_ON_PAGE[i].id);
			if(navigator.appName == "Microsoft Internet Explorer")
				fitToParent(_TAB_DIVS_ON_PAGE[i], i == 0 ? 18 : 30);
			else
				fitToParent(_TAB_DIVS_ON_PAGE[i], /*3*/ 30);
		}
	}
}

window.onresize = function(init) {
	var right = $('right');
	var rightbottom = $('rightbottom');
	if(rightbottom) rightbottom.style.display = 'none';

	if(typeof fitToParent == 'function') fitToParent('right', 12);

	if( $('left') && $('separator') && right )
		$('left').style.height = $('separator').style.height = right.style.height;

	if(rightbottom) {
		var newHeight = (parseInt(right.style.height) / 3);
		right.style.height = (newHeight*2) + 'px';
		rightbottom.style.height = newHeight + 'px';
		rightbottom.style.display = '';
		rightbottom.style.top = getDimension(right,'top') + (newHeight*2) + 'px';
	}
	
	if(typeof fitToParent == 'function') fitToParent('Form_EditForm');
	if(typeof fixHeight_left == 'function') fixHeight_left();
	if(typeof fixRightWidth == 'function') fixRightWidth();
	
	window.ontabschanged();
}

appendLoader(function() { 
	document.body.style.overflow = 'hidden';
	window.onresize(true);
});

function isVisible(el) {
	// if(typeof el.isVisible != 'undefined') return el.isVisible;
	if(el.tagName == "body" || el.tagName == "BODY") return (el.isVisible = true);
	else if(el.style.display == 'none') return (el.isVisible = false);
	else return (el.isVisible = isVisible(el.parentNode));
}


LeftAndMain_window_unload = function() {
	window.exiting = true; // this is used by prototype
	if(typeof autoSave == 'function')
	autoSave(navigator.appName == "Microsoft Internet Explorer");
}

Event.observe(window, 'beforeunload', LeftAndMain_window_unload);

/**
 * Unlock the locked status message.
 * Show a queued message, if one exists
 */
function unlockStatusMessage() {
	statusMessage.locked = false; 
	if(statusMessage.queued) {
		statusMessage(
			statusMessage.queued.msg,
			statusMessage.queued.type,
			statusMessage.queued.showNetworkActivity); 
	
		statusMessage.queued = null;
	}
}

/**
 * Move form actions to the top and make them ajax
 */
function ajaxActionsAtTop(formName, actionHolderName, tabName) {
	var actions = document.getElementsBySelector('#' + formName + ' .Actions')[0];
	var holder;

	if(actions) {
		if((holder = $(actionHolderName)) && holder != actions) {
			holder.parentNode.removeChild(holder);
		}
		
		actions.id = actionHolderName;
		actions.className = 'ajaxActions';

		$(tabName).appendChild(actions);
		prepareAjaxActions(actions, formName, tabName);
	}
}

/**
 * Prepare the ajax actions so that the buttons actually do something
 */
function prepareAjaxActions(actions, formName, tabName) {
	var i, button, list = actions.getElementsByTagName('input')
	for (i=0;button=list[i];i++) {
		button.ownerForm = $(formName);
	
		button.onclick = function(e) {
			// tries to call a custom method of the format "action_<youraction>_right"
			if(window[this.name + '_' + tabName]) {
				window[this.name + '_' + tabName](e);
			} else {
				statusMessage(ingize(this.value));
				Ajax.SubmitForm(this.ownerForm, this.name, {
					onSuccess: Ajax.Evaluator,
					onFailure: ajaxErrorHandler
				});
			}
			return false;
		}
		behaveAs(button, StatusTitle);
	}
}

function ingize(val) {
	var ingWord, suffix;
	if(!val) val = "process";

	if(val.match(/^([^ ]+) +(.*)$/)) {
		ingWord = RegExp.$1;
		suffix = ' ' + RegExp.$2 + '...';
	} else {
		ingWord = val;
		suffix = '...';
	}
	
	if(ingWord.match(/^(.*)e$/)) return RegExp.$1 + 'ing' + suffix;
	else return ingWord + 'ing' + suffix;
}
{'fraction_non_alphanumeric': 0.1708936297180367, 'fraction_numerical': 0.00477398179919439, 'mean_word_length': 4.278346456692914, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '5254092', 'n_tokens_mistral': 5090, 'n_tokens_neox': 4573, 'n_words': 859}