<commit_before>/* global UndoStack */

const cme = chrome.management;
const getI18N = chrome.i18n.getMessage;
const myid = getI18N('@@extension_id');

// Handle undo/redo events
const undoStack = new UndoStack(document.body);

const escapeCssId = id => id.replace(/[@.]/g, '\\$0');

/**
 * GENERATE PAGE
 */
const $searchField = $(`<input placeholder="${getI18N('searchTxt')}">`);
const eul = $('<ul id="extList">');
const $options = $('<div class="options">');
const $disableAllButton = $(`<button>${getI18N('disAll')}</button>`);
const $extensionPageButton = $(`<a href="chrome://extensions">${getI18N('extensionPage')}</a>`);

if (!localStorage.getItem('undo-info-message')) {
	const $undoInfoMessage = $(`<p>${getI18N('undoInfoMsg')} </p>`);
	const $hideInfoMessage = $(`<a href="#hide">${getI18N('hideInfoMsg')}</a>`);
	$undoInfoMessage.append($hideInfoMessage);
	$('body').append($undoInfoMessage);
	$hideInfoMessage.click(() => {
		localStorage.setItem('undo-info-message', 1);
		$undoInfoMessage.slideUp(300);
	});
}

$options
	.append($disableAllButton)
	.append($extensionPageButton);

$('body')
	.append($searchField)
	.append($options)
	.append(eul);

$searchField.focus();
window.scrollTo(0, 0); // Fix overscroll caused by autofocus

// Generate extension list
getExtensions(extensions => {
	const listHTML = extensions
	.sort((a, b) => {
		if (a.enabled === b.enabled) {
			return a.name.localeCompare(b.name); // Sort by name
		}
		return a.enabled < b.enabled ? 1 : -1; // Sort by state
	})
	.map(createList);
	$(listHTML.join('')).appendTo(eul);
});

/**
 * EVENT LISTENERS<commit_msg>Fix hiding of Undo information<commit_after>/* global UndoStack */

const cme = chrome.management;
const getI18N = chrome.i18n.getMessage;
const myid = getI18N('@@extension_id');

// Handle undo/redo events
const undoStack = new UndoStack(document.body);

const escapeCssId = id => id.replace(/[@.]/g, '\\$0');

/**
 * GENERATE PAGE
 */
const $searchField = $(`<input placeholder="${getI18N('searchTxt')}">`);
const eul = $('<ul id="extList">');
const $options = $('<div class="options">');
const $disableAllButton = $(`<button>${getI18N('disAll')}</button>`);
const $extensionPageButton = $(`<a href="chrome://extensions">${getI18N('extensionPage')}</a>`);

if (!localStorage.getItem('undo-info-message')) {
	const $undoInfoMessage = $(`<p>${getI18N('undoInfoMsg')} </p>`);
	const $hideInfoMessage = $(`<a href="#hide">${getI18N('hideInfoMsg')}</a>`);
	$undoInfoMessage.append($hideInfoMessage);
	$('body').append($undoInfoMessage);
	$hideInfoMessage.click(() => {
		localStorage.setItem('undo-info-message', 1);
		$undoInfoMessage.hide();
	});
}

$options
	.append($disableAllButton)
	.append($extensionPageButton);

$('body')
	.append($searchField)
	.append($options)
	.append(eul);

$searchField.focus();
window.scrollTo(0, 0); // Fix overscroll caused by autofocus

// Generate extension list
getExtensions(extensions => {
	const listHTML = extensions
	.sort((a, b) => {
		if (a.enabled === b.enabled) {
			return a.name.localeCompare(b.name); // Sort by name
		}
		return a.enabled < b.enabled ? 1 : -1; // Sort by state
	})
	.map(createList);
	$(listHTML.join('')).appendTo(eul);
});

/**
 * EVENT LISTENERS
{'fraction_non_alphanumeric': 0.21635063723966427, 'fraction_numerical': 0.014609884986011812, 'mean_word_length': 5.397614314115308, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 33, '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': '5765250', 'n_tokens_mistral': 1175, 'n_tokens_neox': 1138, 'n_words': 213}