{% extends "base.html" %}
{% import "utils.html" as utils %}

{% block title %}Libreddit Settings{% endblock %}

{% block search %}
	{% call utils::search("".to_owned(), "", "") %}
{% endblock %}

{% block content %}
	<div id="settings">
	<form action="/settings/" method="POST">
		<div class="prefs">
			<p>Appearance</p>
			<div id="theme">
				<label for="theme">Theme:</label>
				<select name="theme"> 
					{% call utils::options(prefs.theme, ["system", "light", "dark", "black"], "system") %}
				</select>
			</div>
			<p>Interface</p>
			<div id="front_page">
				<label for="front_page">Front page:</label>
				<select name="front_page"> 
					{% call utils::options(prefs.front_page, ["default", "popular", "all"], "default") %}
				</select>
			</div>
			<div id="layout">
				<label for="layout">Layout:</label>
				<select name="layout"> 
					{% call utils::options(prefs.layout, ["card", "clean", "compact"], "card") %}
				</select>
			</div>
			<div id="wide">
				<label for="wide">Wide UI:</label>
				<input type="checkbox" name="wide" {% if prefs.wide == "on" %}checked{% endif %}>
			</div>
			<p>Content</p>
			<div id="comment_sort">
				<label for="comment_sort">Default comment sort:</label>
				<select name="comment_sort"> 
					{% call utils::options(prefs.comment_sort, ["confidence", "top", "new", "controversial", "old"], "confidence") %}
				</select>
			</div>
			<div id="show_nsfw">
				<label for="show_nsfw">Show NSFW posts:</label>
				<input type="checkbox" name="show_nsfw" {% if prefs.show_nsfw == "on" %}checked{% endif %}>
			</div>
		</div>
		<p id="settings_note"><b>Note:</b> settings are saved in browser cookies. Clearing your cookie data will reset them.</p>
		<input id="save" type="submit" value="Save">
	</form>
	{% if prefs.subs.len() > 0 %}
		<aside class="prefs">
			<p>Subscribed Subreddits</p>
			<ul id="settings_subs">
				{% for sub in prefs.subs %}
					<li>
						<span>{{ sub }}</span>
						<form action="/r/{{ sub }}/unsubscribe/?redirect=settings" method="POST">
								<button class="unsubscribe">Unsubscribe</button>
						</form>
					</li>
				{% endfor %}
			</ul>
		</aside>
	{% endif %}
</div>

{% endblock %}