<commit_before>import i18n from 'i18next';

const $app = document.getElementById('app');

class StoreSettings {
	
	data = {}
	
	defaultData = {
		lang: i18n.languages[0] || 'en',
		theme: 'light',
		view: 'map',
		debug: 0
	}
	
	// Update setting, optionally save to localStorage.
	update(key, value, save) {
		if (save) {
			this.data[key] = value;
			localStorage.setItem('settings', JSON.stringify(this.data));
		}
		
		// Handle setting side effects.
		switch (key) {
			case 'lang':
				i18n.changeLanguage(value);
				document.body.parentElement.setAttribute('lang', value);
				break;
			case 'theme':
				$app.setAttribute('data-theme', value);
				break;
			case 'debug':
				$app.className = 'is-debug-' + value;
				break;
		}
	}
	
	// Load and apply settings.
	constructor() {
		this.data = { ...this.defaultData, ...JSON.parse(localStorage.getItem('settings') || '{}') };
		for (const key of Object.keys(this.data)) this.update(key, this.data[key]);
	}
	
}

export default new StoreSettings();<commit_msg>Add default case for switch (web)<commit_after>import i18n from 'i18next';

const $app = document.getElementById('app');

class StoreSettings {
	
	data = {}
	
	defaultData = {
		lang: i18n.languages[0] || 'en',
		theme: 'light',
		view: 'map',
		debug: 0
	}
	
	// Update setting, optionally save to localStorage.
	update(key, value, save) {
		if (save) {
			this.data[key] = value;
			localStorage.setItem('settings', JSON.stringify(this.data));
		}
		
		// Handle setting side effects.
		switch (key) {
			case 'lang':
				i18n.changeLanguage(value);
				document.body.parentElement.setAttribute('lang', value);
				break;
			case 'theme':
				$app.setAttribute('data-theme', value);
				break;
			case 'debug':
				$app.className = 'is-debug-' + value;
				break;
			default: break;
		}
	}
	
	// Load and apply settings.
	constructor() {
		this.data = { ...this.defaultData, ...JSON.parse(localStorage.getItem('settings') || '{}') };
		for (const key of Object.keys(this.data)) this.update(key, this.data[key]);
	}
	
}

export default new StoreSettings();
{'fraction_non_alphanumeric': 0.16674698795180723, 'fraction_numerical': 0.00963855421686747, 'mean_word_length': 3.3705263157894736, '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': '894530', 'n_tokens_mistral': 812, 'n_tokens_neox': 692, 'n_words': 160}