<commit_before>/* eslint strict: 0 */
"use strict";

/*
 * This is a separate file for two reasons:
 * 1. CSP policy does not allow inline javascript
 * 2. It has to be a small javascript executed before all other scripts,
 *    so that the timeout can be triggered while slow JS is loading
 */

function displayReload() {
	var loadingReload = document.getElementById("loading-reload");
	if (loadingReload) {
		loadingReload.style.display = "block";
	}
}

var loadingSlowTimeout = setTimeout(function() {
	var loadingSlow = document.getElementById("loading-slow");

	// The parent element, #loading, is being removed when the app is loaded.
	// Since the timer is not cancelled, `loadingSlow` can be not found after
	// 5s. Wrap everything in this block to make sure nothing happens if the
	// element does not exist (i.e. page has loaded).
	if (loadingSlow) {
		loadingSlow.style.display = "block";
		displayReload();
	}
}, 5000);

document.getElementById("loading-reload").addEventListener("click", function() {
	location.reload();
});

window.g_LoungeErrorHandler = function LoungeErrorHandler(e) {
	var title = document.getElementById("loading-title");
	title.textContent = "An error has occured";

	var message = document.getElementById("loading-page-message");
	message.textContent = "An error has occured that prevented the client from loading correctly.";

	var summary = document.createElement("summary");
	summary.textContent = "More details";

	var data = document.createElement("pre");
	data.textContent = e.message; // e is an ErrorEvent

	var info = document.createElement("p");
	info.textContent = "Open the developer tools of your browser for more information.";

	var details = document.createElement("details");
	details.appendChild(summary);
	details.appendChild(data);
	details.appendChild(info);
	message.parentNode.insertBefore(details, message.nextSibling);

	window.clearTimeout(loadingSlowTimeout);
	displayReload();
};

window.addEventListener("error", window.g_LoungeErrorHandler);<commit_msg>Wrap entire error loading script in anonymous function to avoid leaks<commit_after>/* eslint strict: 0 */
"use strict";

/*
 * This is a separate file for two reasons:
 * 1. CSP policy does not allow inline javascript
 * 2. It has to be a small javascript executed before all other scripts,
 *    so that the timeout can be triggered while slow JS is loading
 */

(function() {
	var displayReload = function displayReload() {
		var loadingReload = document.getElementById("loading-reload");
		if (loadingReload) {
			loadingReload.style.display = "block";
		}
	};

	var loadingSlowTimeout = setTimeout(function() {
		var loadingSlow = document.getElementById("loading-slow");

		// The parent element, #loading, is being removed when the app is loaded.
		// Since the timer is not cancelled, `loadingSlow` can be not found after
		// 5s. Wrap everything in this block to make sure nothing happens if the
		// element does not exist (i.e. page has loaded).
		if (loadingSlow) {
			loadingSlow.style.display = "block";
			displayReload();
		}
	}, 5000);

	document.getElementById("loading-reload").addEventListener("click", function() {
		location.reload();
	});

	window.g_LoungeErrorHandler = function LoungeErrorHandler(e) {
		var title = document.getElementById("loading-title");
		title.textContent = "An error has occured";

		var message = document.getElementById("loading-page-message");
		message.textContent = "An error has occured that prevented the client from loading correctly.";

		var summary = document.createElement("summary");
		summary.textContent = "More details";

		var data = document.createElement("pre");
		data.textContent = e.message; // e is an ErrorEvent

		var info = document.createElement("p");
		info.textContent = "Open the developer tools of your browser for more information.";

		var details = document.createElement("details");
		details.appendChild(summary);
		details.appendChild(data);
		details.appendChild(info);
		message.parentNode.insertBefore(details, message.nextSibling);

		window.clearTimeout(loadingSlowTimeout);
		displayReload();
	};

	window.addEventListener("error", window.g_LoungeErrorHandler);
})();
{'fraction_non_alphanumeric': 0.1132391668661719, 'fraction_numerical': 0.0038305003591094086, 'mean_word_length': 4.699863574351978, 'pattern_counts': {'":': 0, '<': 3, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2339190', 'n_tokens_mistral': 1199, 'n_tokens_neox': 1110, 'n_words': 378}