<commit_before>// Load html file to document
$(window).load(function() {
	// Trigger LoadFile DIV TO Load File
	$('#openload').click(function() {
		$('#loadfile').trigger('click');
	});
	
	// Load File into Editor
	if (window.File && window.FileReader && window.FileList && window.Blob) {
		var LoadFile = function(input) {
			var reader = new FileReader();
				reader.onload = function(e) {
					var content = e.target.result;
					code.val(content);
				};
			reader.readAsText(input[0]);
		};
		
		try {
			$('#loadfile').on('change', function() {
				LoadFile(this.files);
				preview.html(code.val());
			});
		}
		catch(event) {
			alert("Oops there's been an error.");
		}
	} else {
		alert('The File APIs are not fully supported in this browser.');
	}
});

// Save Coded Document
function saveTextAsFile() {
	var textToWrite = document.getElementById("code").value;
	var textFileAsBlob = new Blob([textToWrite], {type:'text/plain'});
	var fileNameToSaveAs = "gen-layout.html";

	var downloadLink = document.createElement("a");
	downloadLink.download = fileNameToSaveAs;
	downloadLink.innerHTML = "Download File";
	if (window.webkitURL != null)
	{
		// Chrome allows the link to be clicked
		// without actually adding it to the DOM.
		downloadLink.href = window.webkitURL.createObjectURL(textFileAsBlob);
	}
	else
	{
		// Firefox requires the link to be added to the DOM
		// before it can be clicked.
		downloadLink.href = window.URL.createObjectURL(textFileAsBlob);
		downloadLink.onclick = destroyClickedElement;
		downloadLink.style.display = "none";
		document.body.appendChild(downloadLink);
	}

	downloadLink.click();
}

function destroyClickedElement(event) {
	document.body.removeChild(event.target);
}

// Horizontal WYSIWYG Menu's Scrollbar
(function() {
    function scrollMenu(e) {
		e = window.event || e;
		var delta = Math.max(-1, Math.min(1, (e.wheelDelta || -e.detail)));
		document.getElementById('idive').scrollLeft -= (delta*40); // Multiplied by 40
		e.preventDefault();
	}
	if (document.getElementById('idive').addEventListener) {
		// IE9, Chrome, Safari, Opera
		document.getElementById('idive').addEventListener("mousewheel", scrollMenu, false);
		// Firefox
		document.getElementById('idive').addEventListener("DOMMouseScroll", scrollMenu, false);
	} else {
		// IE 6/7/8
		document.getElementById('idive').attachEvent("onmousewheel", scrollMenu);
	}
})();
<commit_msg>Update ui.js<commit_after>// Load html file to document
$(window).load(function() {
	// Trigger LoadFile DIV TO Load File
	$('#openload').click(function() {
		$('#loadfile').trigger('click');
	});

	// Load File into Editor
	if (window.File && window.FileReader && window.FileList && window.Blob) {
		var LoadFile = function(input) {
			var reader = new FileReader();
				reader.onload = function(e) {
					var content = e.target.result;
					code.val(content);
				};
			reader.readAsText(input[0]);
		};
		
		try {
			$('#loadfile').on('change', function() {
				LoadFile(this.files);
				preview.html(code.val());
			});
		}
		catch(event) {
			alert("Oops there's been an error.");
		}
	} else {
		alert('The File APIs are not fully supported in this browser.');
	}
  
});

// Insert Button in ExecCommand
function pasteHtmlAtCaret(html) {
	var sel, range;
	if (window.getSelection) {
		// IE9 and non-IE
		sel = window.getSelection();
		if (sel.getRangeAt && sel.rangeCount) {
			range = sel.getRangeAt(0);
			range.deleteContents();

			// Range.createContextualFragment() would be useful here but is
			// non-standard and not supported in all browsers (IE9, for one)
			var el = document.createElement("span");
			el.innerHTML = html;
			var frag = document.createDocumentFragment(), node, lastNode;
			while ( (node = el.firstChild) ) {
				lastNode = frag.appendChild(node);
			}
			range.insertNode(frag);
			
			// Preserve the selection
			if (lastNode) {
				range = range.cloneRange();
				range.setStartAfter(lastNode);
				range.collapse(true);
				sel.removeAllRanges();
				sel.addRange(range);
			}
		}
	} else if (document.selection && document.selection.type != "Control") {
		// IE < 9
		document.selection.createRange().pasteHTML(html);
	}
}

// Save Coded Document
function saveTextAsHTML() {
	var textToWrite = document.getElementById("code").value;
	var textFileAsBlob = new Blob([textToWrite], {type:'text/plain'});
	var fileNameToSaveAs = "gen-layout.html";

	var downloadLink = document.createElement("a");
	downloadLink.download = fileNameToSaveAs;
	downloadLink.innerHTML = "Download File";
	if (window.webkitURL != null)
	{
		// Chrome allows the link to be clicked
		// without actually adding it to the DOM.
		downloadLink.href = window.webkitURL.createObjectURL(textFileAsBlob);
	}
	else
	{
		// Firefox requires the link to be added to the DOM
		// before it can be clicked.
		downloadLink.href = window.URL.createObjectURL(textFileAsBlob);
		downloadLink.onclick = destroyClickedElement;
		downloadLink.style.display = "none";
		document.body.appendChild(downloadLink);
	}

	downloadLink.click();
}
function saveTextAsProject() {
	var textToWrite = document.getElementById("projsavecode").value;
	var textFileAsBlob = new Blob([textToWrite], {type:'text/plain'});
	var fileNameToSaveAs = "mmd-layout.mmd";

	var downloadLink = document.createElement("a");
	downloadLink.download = fileNameToSaveAs;
	downloadLink.innerHTML = "Download File";
	if (window.webkitURL != null)
	{
		// Chrome allows the link to be clicked
		// without actually adding it to the DOM.
		downloadLink.href = window.webkitURL.createObjectURL(textFileAsBlob);
	}
	else
	{
		// Firefox requires the link to be added to the DOM
		// before it can be clicked.
		downloadLink.href = window.URL.createObjectURL(textFileAsBlob);
		downloadLink.onclick = destroyClickedElement;
		downloadLink.style.display = "none";
		document.body.appendChild(downloadLink);
	}

	downloadLink.click();
}
function destroyClickedElement(event) {
	document.body.removeChild(event.target);
}

// Horizontal WYSIWYG Menu's Scrollbar
(function() {
    function scrollMenu(e) {
		e = window.event || e;
		var delta = Math.max(-1, Math.min(1, (e.wheelDelta || -e.detail)));
		document.getElementById('idive').scrollLeft -= (delta*40); // Multiplied by 40
		e.preventDefault();
	}
	if (document.getElementById('idive').addEventListener) {
		// IE9, Chrome, Safari, Opera
		document.getElementById('idive').addEventListener("mousewheel", scrollMenu, false);
		// Firefox
		document.getElementById('idive').addEventListener("DOMMouseScroll", scrollMenu, false);
	} else {
		// IE 6/7/8
		document.getElementById('idive').attachEvent("onmousewheel", scrollMenu);
	}
})();

{'fraction_non_alphanumeric': 0.14517583408476104, 'fraction_numerical': 0.003907424105801022, 'mean_word_length': 4.080152671755725, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 33, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6295256', 'n_tokens_mistral': 2272, 'n_tokens_neox': 2060, 'n_words': 479}