<commit_before>//globals (kinda?)
var total = ['links', 'apps', 'bookmarks', 'themes'];
var units = ['fahrenheit', 'celsius'];
var link_page = '';
var wrench = false;

var defaultTheme = {
	'options-color': '#ff0000',
	'main-color': '#ffffff',
	'title-color': '#4a4a4a',
	'background-color': '#000000'
};
	
$(function() {	
	//set defaults
	if(!localStorage.getItem('hide_weather')) {
		localStorage.setItem('hide_weather', false);
	}

	if(localStorage.getItem('active')) {
		var active = localStorage.getItem('active');
		//If the last page we were at  was the gallery, show the last page before that.
		if (active == 3) {
			if (localStorage.getItem('previous')) {
				active = localStorage.getItem('previous');
				localStorage.setItem('active', active);
			} else {
				active = 1;
			}
		}
		$('#menu').prop('selectedIndex', active);
	} else {
		localStorage.setItem('active', 1);
	}
	
	if(!localStorage.getItem('locat')) {
		localStorage.setItem('locat', '95123'); 
	}

	if(!localStorage.getItem('unit')) {
		localStorage.setItem('unit', 'fahrenheit');
	}

	if(!localStorage.getItem('themes')) {
		localStorage.setItem('themes', '[]');
	}

	if(localStorage.getItem('font')) {
		$('#font-chooser').prop('selectedIndex', localStorage.getItem('font'));
	} else {
		localStorage.setItem('font', 0);
	}

	$('#select-box').val(localStorage.getItem('unit'));
	
	//laod cached results for weather or set default locat
	$('#where').html(localStorage.getItem('where'));
	$('#temp').html(localStorage.getItem('temp'));
	$('#condition').html(localStorage.getItem('condition'));
	$('#locat').val(localStorage.getItem('locat'));

	//attach color pickers
	$.each(defaultTheme, function(key, value) {
		$('#' + key).farbtastic(function(theme) {
			localStorage.setItem(key, theme);
			$('#' + key + '-display').text(theme);
			updateStyle(false);
		});

		//If you press enter in the text box, set it a the new color.
		$('#' + key + '-display').on('keydown', function(e) {
			if(e.keyCode == 13) {
				$.farbtastic('#' + key).setColor($(this).text());
				return false;
			}
		});

		$('#' + key + '-display').on('blur', function(e) {
			$.farbtastic('#' + key).setColor($(this).text());
		});

		if(localStorage.getItem(key)) {
			$.farbtastic('#' + key).setColor(localStorage.getItem(key));
		} else {
			$.farbtastic('#' + key).setColor(value);
		}
	});

	//attach the menu selectbox
	$('#menu').metroSelect({
		'onchange': function() {
			changeView($('#menu').attr('selectedIndex'));
		}
	});

	//attach the weather selectbox
	$('#select-box').metroSelect({
		'onchange': function() {
			localStorage.setItem('unit', units[$('#select-box').attr('selectedIndex')]);
			updateWeather(true);
		}
	});

	$('#font-chooser').metroSelect({
		'onchange': function() {
			localStorage.setItem('font', $('#font-chooser').attr('selectedIndex'));	
			updateStyle();
		}
	});

	//Attaching event handlers
	//show all options on the page.
	$('#wrench').on('click', function() {		
		_gaq.push(['_trackEvent', 'Page Action', 'wrench clicked']);
		if (wrench){
			$('.option').hide('fast');
			if(localStorage.getItem('active') == 3) {
				$('#menu-sel-' + localStorage.getItem('previous')).click();
			}
		} else {
			$('.option').show('fast');
		}
		wrench = !wrench;
		//handle guys that have states that can be activated AFTER wrench.
		$('.picker').fadeOut('fast');
		doneEditingTheme();

		$('#where').prop('contentEditable', 'false');
		if($('#url').length) $('#url').remove();
	});

	//Called when addding a new link to the links pages
	$('#add').on('click', function() {
		_gaq.push(['_trackEvent', 'Page Action', 'add clicked']);
		if ($('#url').length) {
			saveNewLink();
		} else {
			$('#add').text('done');
			var element = $('<span class="url" id="url" contentEditable="true">http://</span>');
			element.hide();
			$(this).parent().append(element);<commit_msg>Fixed the leftover options bug<commit_after>//globals (kinda?)
var total = ['links', 'apps', 'bookmarks', 'themes'];
var units = ['fahrenheit', 'celsius'];
var link_page = '';
var wrench = false;

var defaultTheme = {
	'options-color': '#ff0000',
	'main-color': '#ffffff',
	'title-color': '#4a4a4a',
	'background-color': '#000000'
};
	
$(function() {	
	//set defaults
	if(!localStorage.getItem('hide_weather')) {
		localStorage.setItem('hide_weather', false);
	}

	if(localStorage.getItem('active')) {
		var active = localStorage.getItem('active');
		//If the last page we were at  was the gallery, show the last page before that.
		if (active == 3) {
			if (localStorage.getItem('previous')) {
				active = localStorage.getItem('previous');
				localStorage.setItem('active', active);
			} else {
				active = 1;
			}
		}
		$('#menu').prop('selectedIndex', active);
	} else {
		localStorage.setItem('active', 1);
	}
	
	if(!localStorage.getItem('locat')) {
		localStorage.setItem('locat', '95123'); 
	}

	if(!localStorage.getItem('unit')) {
		localStorage.setItem('unit', 'fahrenheit');
	}

	if(!localStorage.getItem('themes')) {
		localStorage.setItem('themes', '[]');
	}

	if(localStorage.getItem('font')) {
		$('#font-chooser').prop('selectedIndex', localStorage.getItem('font'));
	} else {
		localStorage.setItem('font', 0);
	}

	$('#select-box').val(localStorage.getItem('unit'));
	
	//laod cached results for weather or set default locat
	$('#where').html(localStorage.getItem('where'));
	$('#temp').html(localStorage.getItem('temp'));
	$('#condition').html(localStorage.getItem('condition'));
	$('#locat').val(localStorage.getItem('locat'));

	//attach color pickers
	$.each(defaultTheme, function(key, value) {
		$('#' + key).farbtastic(function(theme) {
			localStorage.setItem(key, theme);
			$('#' + key + '-display').text(theme);
			updateStyle(false);
		});

		//If you press enter in the text box, set it a the new color.
		$('#' + key + '-display').on('keydown', function(e) {
			if(e.keyCode == 13) {
				$.farbtastic('#' + key).setColor($(this).text());
				return false;
			}
		});

		$('#' + key + '-display').on('blur', function(e) {
			$.farbtastic('#' + key).setColor($(this).text());
		});

		if(localStorage.getItem(key)) {
			$.farbtastic('#' + key).setColor(localStorage.getItem(key));
		} else {
			$.farbtastic('#' + key).setColor(value);
		}
	});

	//attach the menu selectbox
	$('#menu').metroSelect({
		'onchange': function() {
			changeView($('#menu').attr('selectedIndex'));
		}
	});

	//attach the weather selectbox
	$('#select-box').metroSelect({
		'onchange': function() {
			localStorage.setItem('unit', units[$('#select-box').attr('selectedIndex')]);
			updateWeather(true);
		}
	});

	$('#font-chooser').metroSelect({
		'onchange': function() {
			localStorage.setItem('font', $('#font-chooser').attr('selectedIndex'));	
			updateStyle();
		}
	});

	//Attaching event handlers
	//show all options on the page.
	$('#wrench').on('click', function() {		
		_gaq.push(['_trackEvent', 'Page Action', 'wrench clicked']);
		if (wrench){
			$('.option').hide('fast', function() {
				$(this).hide();
			});
			if(localStorage.getItem('active') == 3) {
				$('#menu-sel-' + localStorage.getItem('previous')).click();
			}
		} else {
			$('.option').show('fast');
		}
		wrench = !wrench;
		//handle guys that have states that can be activated AFTER wrench.
		$('.picker').fadeOut('fast');
		doneEditingTheme();

		$('#where').prop('contentEditable', 'false');
		if($('#url').length) $('#url').remove();
	});

	//Called when addding a new link to the links pages
	$('#add').on('click', function() {
		_gaq.push(['_trackEvent', 'Page Action', 'add clicked']);
		if ($('#url').length) {
			saveNewLink();
		} else {
			$('#add').text('done');
			var element = $('<span class="url" id="url" contentEditable="true">http://</span>');
			element.hide();
			$(this).parent().append(element);
{'fraction_non_alphanumeric': 0.23152201905742983, 'fraction_numerical': 0.006438320885912954, 'mean_word_length': 4.442887175893483, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '4761890', 'n_tokens_mistral': 2872, 'n_tokens_neox': 2622, 'n_words': 489}