<commit_before>var Settings;

function SaveSettings() {
		$('input[type=radio]:checked').each(function (index) {
			var key = $(this).attr('name');
			Settings[key] = $(this).attr('value');
		});

		$('input[type=checkbox][name]').each(function(i) {
			var key = $(this).attr('name');
			if (key.indexOf('provide_') == -1) {
				Settings[key] = $(this).is(':checked');
			} else {
				Settings["providers"][key.replace('provide_','')] = $(this).is(':checked');
			}
		});

		chrome.storage.sync.set({"BTDSettings": Settings}, function () {
			console.log('Options saved!');
		});
	}

$(function() {

	function CGetMessage(message) {
		return chrome.i18n.getMessage(message);
	}

	// Localisation and stuff
	document.title = CGetMessage("optionsPageTitle");
	$('.version-number').text(chrome.app.getDetails().version);
	$('.user-agent').text(navigator.userAgent);

	$('.i18n').each(function (index) {
		var message = $(this).attr('data-message');
		$(this).text(CGetMessage(message));
	});

	chrome.storage.sync.get("BTDSettings", function (obj) {
		Settings = obj.BTDSettings;

		for (var setting in Settings) {
			if (Settings[setting] === true || Settings[setting] === false) {
				$('[name="'+setting+'"]').prop('checked', Settings[setting]);
			} else {
				$('[name="'+setting+'"][value="'+Settings[setting]+'"]').prop('checked', true);
			}
		}

		for (var provider in Settings["providers"]) {
			$('[name="provide_'+provider+'"]').prop('checked', Settings["providers"][provider]);
		}

		tweetPreviewClasses();
		$('#apparence input[type=checkbox]').each(contentPreview);
	});

	// Taken from the Chrome Bootstrap styleguide http://roykolak.github.io/chrome-bootstrap/
	$('.menu a').click(function(ev) {
		ev.preventDefault();
		var selected = 'selected';

		$('.mainview > *').removeClass(selected);
		$('.menu li').removeClass(selected);
		setTimeout(function() {
			$('.mainview > *:not(.selected)').css('display', 'none');
		}, 100);

		$(ev.currentTarget).parent().addClass(selected);
		var currentView = $($(ev.currentTarget).attr('href'));
		currentView.css('display', 'block');
		setTimeout(function() {
			currentView.addClass(selected);
		}, 0);

		setTimeout(function() {
			$('body')[0].scrollTop = 0;
		}, 200);
	});
	$('.mainview > *:not(.selected)').css('display', 'none');

	$('.checkbox img').each(function (index) {
		var linkToImg = $(this).attr('src');
		$(this).parent().css('background-image','url('+linkToImg+')').addClass('favicon');
		$(this).remove();
	});

	$('input').on('change', SaveSettings);

	$('input[name="timestamp"], input[name="name_display"], input[name="circled_avatars"]').on('change', function () {
		tweetPreviewClasses();
	});

	$('#apparence input[type=checkbox]').on('change', contentPreview);


    function tweetPreviewClasses() {
        var timestampVal = document.querySelector("input[name='timestamp']:checked").value;
        var nameVal = document.querySelector("input[name='name_display']:checked").value;
        var avatarVal = document.querySelector("input[name='circled_avatars']").checked;
        document.querySelector(".tweet-preview .name").className = "name "+nameVal;
        document.querySelector(".tweet-preview .timestamp").className = "timestamp "+timestampVal;
        document.querySelector(".tweet-preview .picture").className = "picture "+avatarVal;
    }

    function contentPreview() {
		if ($(this).is(':checked')) {
			$('#content_preview').addClass($(this).attr('name'));
		} else {
			$('#content_preview').removeClass($(this).attr('name'));
		}
    }

});<commit_msg>Cleaned SaveSettings()<commit_after>var Settings;

function SaveSettings() {
	$('input[type=radio]:checked').each(function(index) {
		var key = $(this).attr('name');
		Settings[key] = $(this).attr('value');
	});

	$('input[type=checkbox][name]').each(function(i) {
		var key = $(this).attr('name');
		if (key.indexOf('provide_') == -1) {
			Settings[key] = $(this).is(':checked');
		} else {
			Settings["providers"][key.replace('provide_', '')] = $(this).is(':checked');
		}
	});

	chrome.storage.sync.set({
		"BTDSettings": Settings
	}, function() {
		console.log('Options saved!');
	});
}

$(function() {

	function CGetMessage(message) {
		return chrome.i18n.getMessage(message);
	}

	// Localisation and stuff
	document.title = CGetMessage("optionsPageTitle");
	$('.version-number').text(chrome.app.getDetails().version);
	$('.user-agent').text(navigator.userAgent);

	$('.i18n').each(function(index) {
		var message = $(this).attr('data-message');
		$(this).text(CGetMessage(message));
	});

	chrome.storage.sync.get("BTDSettings", function(obj) {
		Settings = obj.BTDSettings;

		for (var setting in Settings) {
			if (Settings[setting] === true || Settings[setting] === false) {
				$('[name="' + setting + '"]').prop('checked', Settings[setting]);
			} else {
				$('[name="' + setting + '"][value="' + Settings[setting] + '"]').prop('checked', true);
			}
		}

		for (var provider in Settings["providers"]) {
			$('[name="provide_' + provider + '"]').prop('checked', Settings["providers"][provider]);
		}

		tweetPreviewClasses();
		$('#apparence input[type=checkbox]').each(contentPreview);
	});

	// Taken from the Chrome Bootstrap styleguide http://roykolak.github.io/chrome-bootstrap/
	$('.menu a').click(function(ev) {
		ev.preventDefault();
		var selected = 'selected';

		$('.mainview > *').removeClass(selected);
		$('.menu li').removeClass(selected);
		setTimeout(function() {
			$('.mainview > *:not(.selected)').css('display', 'none');
		}, 100);

		$(ev.currentTarget).parent().addClass(selected);
		var currentView = $($(ev.currentTarget).attr('href'));
		currentView.css('display', 'block');
		setTimeout(function() {
			currentView.addClass(selected);
		}, 0);

		setTimeout(function() {
			$('body')[0].scrollTop = 0;
		}, 200);
	});
	$('.mainview > *:not(.selected)').css('display', 'none');

	$('.checkbox img').each(function(index) {
		var linkToImg = $(this).attr('src');
		$(this).parent().css('background-image', 'url(' + linkToImg + ')').addClass('favicon');
		$(this).remove();
	});

	$('input').on('change', SaveSettings);

	$('input[name="timestamp"], input[name="name_display"], input[name="circled_avatars"]').on('change', function() {
		tweetPreviewClasses();
	});

	$('#apparence input[type=checkbox]').on('change', contentPreview);


	function tweetPreviewClasses() {
		var timestampVal = document.querySelector("input[name='timestamp']:checked").value;
		var nameVal = document.querySelector("input[name='name_display']:checked").value;
		var avatarVal = document.querySelector("input[name='circled_avatars']").checked;
		document.querySelector(".tweet-preview .name").className = "name " + nameVal;
		document.querySelector(".tweet-preview .timestamp").className = "timestamp " + timestampVal;
		document.querySelector(".tweet-preview .picture").className = "picture " + avatarVal;
	}

	function contentPreview() {
		if ($(this).is(':checked')) {
			$('#content_preview').addClass($(this).attr('name'));
		} else {
			$('#content_preview').removeClass($(this).attr('name'));
		}
	}

});
{'fraction_non_alphanumeric': 0.23003104713519615, 'fraction_numerical': 0.003951453570420547, 'mean_word_length': 5.178727114210985, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 9, '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': '3276322', 'n_tokens_mistral': 2466, 'n_tokens_neox': 2246, 'n_words': 333}