<commit_before><html>
	<head>
		<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>

		<script type="text/javascript">
			"use strict";

			var mainSchema = "CSLEDIT.mainSchema",
				subSchemas = "CSLEDIT.subSchemas";

			var updateView = function () {
				var mainList = $('#mainSchemaList'),
					subList = $('#subSchemasList'),
					mainSchemaData = JSON.parse(localStorage.getItem(mainSchema)),
					subSchemasData = JSON.parse(localStorage.getItem(subSchemas));

				mainList.children().remove();
				subList.children().remove();

				if (mainSchemaData === null) {
					mainList.append("<li>Main schema file not specified</li>");
				} else {
					$.each(mainSchemaData, function (name, data) {
						mainList.append("<li>" + name + "</li>");
					});
				}

				if (subSchemasData === null) {
					subList.append("<li>No sub schemas specified</li>");
				} else {
					$.each(subSchemasData, function (name, data) {
						subList.append("<li>" + name + "</li>");
					});
				}
			}

			var readSchemaFiles = function (schemaKey, files) {
				var schemaData = {};

				$.each(files, function (i, file) {
					var reader = new FileReader();

					reader.onload = function (event) {
						schemaData[file.name] = event.target.result;
					
						localStorage.setItem(schemaKey, JSON.stringify(schemaData));
						updateView();
					};
					reader.readAsText(file);
				});

				return schemaData;
			};

			$(document).ready(function () {
				if (typeof(localStorage) === "undefined" || localStorage === null) {
					$('body').html("localStorage not available in this environment");
				}

				$("#mainSchemaFile").change(function (event) {
					readSchemaFiles(mainSchema, event.target.files);
				});
				$("#subSchemasFiles").change(function (event) {
					readSchemaFiles(subSchemas, event.target.files);
				});

				$("#deleteSchema").click(function () {
					localStorage.removeItem(mainSchema);
					localStorage.removeItem(subSchemas);

					updateView();
				});
				
				$("#resetEverything").click(function () {
					localStorage.clear();
					alert("All local settings removed");
				});

				updateView();
			});

		</script>
		
	</head>
	<body>
		<h3>Current CSL schema files</h3>

		<label for="mainSchemaFile">Main CSL Schema RNG File:</label><input id="mainSchemaFile" type="file"></input><br />
		<ul id="mainSchemaList"></ul>

		<label for="subSchemasFiles">Other CSL Schema RNG Files:</label><input id="subSchemasFiles" type="file" multiple="multiple"></input><br />
		<ul id="subSchemasList"></ul>

		<button id="deleteSchema">Delete All Files (reset schema to default)</button>

		<h3>Reset everything</h3>
		<button id="resetEverything">Reset all local settings to default (your style will be lost)</button>

		<p>

		<h3>CSL Editor</h3>
		<a href="../visualEditor">
			Go to Visual Editor page
		</a> (these settings will be remembered, return back to this page is you want to change them)
		</p>
	</body>
</html>
<commit_msg>show all local storage data in settings page and add CSS so it looks nicer<commit_after><!DOCTYPE html>
<html>
	<head>
		<link rel="stylesheet" type="text/css" href="../cslEditorLib/css/base.css?bust=$GIT_COMMIT" />
		<style>
			td {
				background-color: #eeeeee;
			}
		</style>

		<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>

		<script type="text/javascript">
			"use strict";

			var mainSchema = "CSLEDIT.mainSchema",
				subSchemas = "CSLEDIT.subSchemas";

			var updateView = function () {
				var mainList = $('#mainSchemaList'),
					subList = $('#subSchemasList'),
					mainSchemaData = JSON.parse(localStorage.getItem(mainSchema)),
					subSchemasData = JSON.parse(localStorage.getItem(subSchemas));

				mainList.children().remove();
				subList.children().remove();

				if (mainSchemaData === null) {
					mainList.append("<li>Main schema file not specified</li>");
				} else {
					$.each(mainSchemaData, function (name, data) {
						mainList.append("<li>" + name + "</li>");
					});
				}

				if (subSchemasData === null) {
					subList.append("<li>No sub schemas specified</li>");
				} else {
					$.each(subSchemasData, function (name, data) {
						subList.append("<li>" + name + "</li>");
					});
				}

				displayLocalStorage();
			}

			var displayLocalStorage = function () {
				var table = $('<table>'),
					key,
					value,
					totalCharacters = 0;

				if (localStorage.length > 0) {
					table.append(
						$('<tr>')
							.append($('<td>').append("<strong>key</strong>"))
							.append($('<td>').append("<strong>value</strong>"))
					);
				}

				// list local storage contents
				for (var i = 0; i < localStorage.length; i++) {
					key = localStorage.key(i);
					value = localStorage.getItem(key);

					totalCharacters += value.length + key.length;

					// elide value
					if (value.length > 400) {
						value = value.substring(0, 400) + "...";
					}

					console.log(sanitize(value));

					table.append(
						$('<tr>')
							.append($('<td>').append(key))
							.append($('<td>').append(sanitize(value)))
					);
				}

				console.log("total = " + totalCharacters);
				var thousandsOfCharacters = Math.round(totalCharacters / 1000);

				$('#localStorage')
					.html("")
					.append("<p>Using " + thousandsOfCharacters + "k characters out of a possible 2500k (see " +
							"<a href=http://dev-test.nemikor.com/web-storage/support-test>reference</a>)</p>")
					.append(table);

			};

			var sanitize = function (input) {
				return input
					.replace(/&/g, "&amp;")
					.replace(/</g, "&lt")
					.replace(/>/g, "&gt;")
					.replace(/"/g, "&quot;");
			};

			var readSchemaFiles = function (schemaKey, files) {
				var schemaData = {};

				$.each(files, function (i, file) {
					var reader = new FileReader();

					reader.onload = function (event) {
						schemaData[file.name] = event.target.result;
					
						localStorage.setItem(schemaKey, JSON.stringify(schemaData));
						updateView();
					};
					reader.readAsText(file);
				});

				return schemaData;
			};

			$(document).ready(function () {
				if (typeof(localStorage) === "undefined" || localStorage === null) {
					$('body').html("localStorage not available in this environment");
				}

				$("#mainSchemaFile").change(function (event) {
					readSchemaFiles(mainSchema, event.target.files);
				});
				$("#subSchemasFiles").change(function (event) {
					readSchemaFiles(subSchemas, event.target.files);
				});

				$("#deleteSchema").click(function () {
					localStorage.removeItem(mainSchema);
					localStorage.removeItem(subSchemas);

					updateView();
				});
				
				$("#resetEverything").click(function () {
					localStorage.clear();
					updateView();
				});

				updateView();
			});

		</script>
		
	</head>
	<body>
		<h3>Current CSL schema files</h3>

		<label for="mainSchemaFile">Main CSL Schema RNG File:</label><input id="mainSchemaFile" type="file"></input><br />
		<ul id="mainSchemaList"></ul>

		<label for="subSchemasFiles">Other CSL Schema RNG Files:</label><input id="subSchemasFiles" type="file" multiple="multiple"></input><br />
		<ul id="subSchemasList"></ul>

		<button id="deleteSchema">Delete All Files (reset schema to default)</button>

		<h3>Current local storage</h3>
		<div id=localStorage>
		</div>
		<button id="resetEverything">Delete all local settings (your style will be lost)</button>
		<p>

		<h3>CSL Editor</h3>
		<a href="../visualEditor">Go to Visual Editor page</a> (these settings will be remembered, return back to this page if you want to change them)
		</p>
	</body>
</html>

{'fraction_non_alphanumeric': 0.17631613496127085, 'fraction_numerical': 0.003938558487593541, 'mean_word_length': 3.2630106323447117, 'pattern_counts': {'":': 0, '<': 118, '<?xml version=': 0, '>': 119, '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': '2087435', 'n_tokens_mistral': 3076, 'n_tokens_neox': 2370, 'n_words': 498}