<commit_before>(function() {
	"use strict";

	var template = new sprinkles.Template("/settings/settings.html");
	var Config = custom.main.Config;
	var Settings = custom.settings.Settings;

	function SettingsController(router) {
		this.router = router;
		this.settingsListElement = null;
		this.checkboxOnlyShowPostsWithImages = null;
		this.checkboxOpenExternalLinksInNewTab = null;
		this.checkboxShowInfo = null;
		this.checkboxShowPostTitles = null;
	};

	SettingsController.prototype.init = function() {
		// If it is the user’s first visit, make the default settings the user’s
		// settings.
		if (Settings.get("version") === null) {
			Settings.set("version", "2015-07-02");
			Settings.setOnlyShowPostsWithImages(Config.threadList.onlyShowPostsWithImages);
			Settings.setOpenExternalLinksInNewTab(Config.threadList.openExternalLinksInNewTab);
			Settings.setShowInfo(Config.threadList.showInfo);
			Settings.setShowPostTitles(Config.threadList.showPostTitles);
		}

		this.router.registerRoute("/settings", this.loadPage.bind(this));
	};

	SettingsController.prototype.loadPage = function() {
		var page = new sprinkles.Page(document.getElementById("content"), template);
		page.load(this.handleRequest.bind(this, page));
	};

	SettingsController.prototype.handleRequest = function(page) {
		this.settingsListElement = document.getElementById("settings-list");
		this.checkboxOnlyShowPostsWithImages = document.getElementById("setting-only-show-posts-with-images");
		this.checkboxOpenExternalLinksInNewTab = document.getElementById("setting-open-external-links-in-new-tab");
		this.checkboxShowInfo = document.getElementById("setting-show-info");
		this.checkboxShowPostTitles = document.getElementById("setting-show-post-titles");

		if (!this.settingsListElement
				|| !this.checkboxOnlyShowPostsWithImages
				|| !this.checkboxOpenExternalLinksInNewTab
				|| !this.checkboxShowInfo
				|| !this.checkboxShowPostTitles) {
			app.logger.error("SettingsController: A required element is missing.");
			return;
		}

		this.checkboxOnlyShowPostsWithImages.checked = Settings.getOnlyShowPostsWithImages();
		this.checkboxOpenExternalLinksInNewTab.checked = Settings.getOpenExternalLinksInNewTab();
		this.checkboxShowInfo.checked = Settings.getShowInfo();
		this.checkboxShowPostTitles.checked = Settings.getShowPostTitles();
		this.checkboxShowPostTitles.disabled = !this.checkboxOnlyShowPostsWithImages.checked;

		this.settingsListElement.addEventListener("click", this.onListClick.bind(this));

		if (!app.storage.localStorageIsAvailable) {
			var message = "Your settings can’t be saved permanently because your browser doesn’t allow storing data. This can happen if you disabled local storage in your browser’s settings or if you browse in privacy mode.";
			app.session.addFlashWarningMessage(message);
		}
	};

	SettingsController.prototype.onListClick = function(event) {
		Settings.setOnlyShowPostsWithImages(this.checkboxOnlyShowPostsWithImages.checked);
		Settings.setOpenExternalLinksInNewTab(this.checkboxOpenExternalLinksInNewTab.checked);
		Settings.setShowInfo(this.checkboxShowInfo.checked);
		Settings.setShowPostTitles(this.checkboxShowPostTitles.checked);

		this.checkboxShowPostTitles.disabled = !this.checkboxOnlyShowPostsWithImages.checked;
		if (this.checkboxShowPostTitles.disabled) {
			this.checkboxShowPostTitles.checked = true;
			Settings.setShowPostTitles(true);
		}
	};

	sprinkles.provide("custom.settings.SettingsController", SettingsController);
})();
<commit_msg>Fixed incorrect usage of sprinkles.Logger.error.<commit_after>(function() {
	"use strict";

	var template = new sprinkles.Template("/settings/settings.html");
	var Config = custom.main.Config;
	var Settings = custom.settings.Settings;

	function SettingsController(router) {
		this.router = router;
		this.settingsListElement = null;
		this.checkboxOnlyShowPostsWithImages = null;
		this.checkboxOpenExternalLinksInNewTab = null;
		this.checkboxShowInfo = null;
		this.checkboxShowPostTitles = null;
	};

	SettingsController.prototype.init = function() {
		// If it is the user’s first visit, make the default settings the user’s
		// settings.
		if (Settings.get("version") === null) {
			Settings.set("version", "2015-07-02");
			Settings.setOnlyShowPostsWithImages(Config.threadList.onlyShowPostsWithImages);
			Settings.setOpenExternalLinksInNewTab(Config.threadList.openExternalLinksInNewTab);
			Settings.setShowInfo(Config.threadList.showInfo);
			Settings.setShowPostTitles(Config.threadList.showPostTitles);
		}

		this.router.registerRoute("/settings", this.loadPage.bind(this));
	};

	SettingsController.prototype.loadPage = function() {
		var page = new sprinkles.Page(document.getElementById("content"), template);
		page.load(this.handleRequest.bind(this, page));
	};

	SettingsController.prototype.handleRequest = function(page) {
		this.settingsListElement = document.getElementById("settings-list");
		this.checkboxOnlyShowPostsWithImages = document.getElementById("setting-only-show-posts-with-images");
		this.checkboxOpenExternalLinksInNewTab = document.getElementById("setting-open-external-links-in-new-tab");
		this.checkboxShowInfo = document.getElementById("setting-show-info");
		this.checkboxShowPostTitles = document.getElementById("setting-show-post-titles");

		if (!this.settingsListElement
				|| !this.checkboxOnlyShowPostsWithImages
				|| !this.checkboxOpenExternalLinksInNewTab
				|| !this.checkboxShowInfo
				|| !this.checkboxShowPostTitles) {
			app.logger.error(["SettingsController: Element is missing."]);
			return;
		}

		this.checkboxOnlyShowPostsWithImages.checked = Settings.getOnlyShowPostsWithImages();
		this.checkboxOpenExternalLinksInNewTab.checked = Settings.getOpenExternalLinksInNewTab();
		this.checkboxShowInfo.checked = Settings.getShowInfo();
		this.checkboxShowPostTitles.checked = Settings.getShowPostTitles();
		this.checkboxShowPostTitles.disabled = !this.checkboxOnlyShowPostsWithImages.checked;

		this.settingsListElement.addEventListener("click", this.onListClick.bind(this));

		if (!app.storage.localStorageIsAvailable) {
			var message = "Your settings can’t be saved permanently because your browser doesn’t allow storing data. This can happen if you disabled local storage in your browser’s settings or if you browse in privacy mode.";
			app.session.addFlashWarningMessage(message);
		}
	};

	SettingsController.prototype.onListClick = function(event) {
		Settings.setOnlyShowPostsWithImages(this.checkboxOnlyShowPostsWithImages.checked);
		Settings.setOpenExternalLinksInNewTab(this.checkboxOpenExternalLinksInNewTab.checked);
		Settings.setShowInfo(this.checkboxShowInfo.checked);
		Settings.setShowPostTitles(this.checkboxShowPostTitles.checked);

		this.checkboxShowPostTitles.disabled = !this.checkboxOnlyShowPostsWithImages.checked;
		if (this.checkboxShowPostTitles.disabled) {
			this.checkboxShowPostTitles.checked = true;
			Settings.setShowPostTitles(true);
		}
	};

	sprinkles.provide("custom.settings.SettingsController", SettingsController);
})();

{'fraction_non_alphanumeric': 0.11055918251490207, 'fraction_numerical': 0.0022707919386886176, 'mean_word_length': 6.132591093117409, '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': '2884686', 'n_tokens_mistral': 2169, 'n_tokens_neox': 1979, 'n_words': 306}