{% INCLUDE 'overall_header.html' %}
{% INCLUDECSS '@primehalo_primepostrevisions/ppr_acp.css' %}
<h1>{{ lang('ACP_PRIMEPOSTREVISIONS_TITLE') }}</h1>

<form id="acp_board" method="post" action="{{ U_ACTION }}">
	<fieldset>
		<legend>{{ lang('ACP_PRIMEPOSTREVISIONS_BASIC_SETTINGS') }}</legend>
		<dl>
			<dt><label for="primepostrev_enable_general">{{ lang('ACP_PRIMEPOSTREVISIONS_ENABLE_GENERAL') ~ lang('COLON') }}</label><br /><span>{{ lang('ACP_PRIMEPOSTREVISIONS_ENABLE_GENERAL_EXPLAIN') }}</span></dt>
			<dd><label><input type="radio" class="radio" name="primepostrev_enable_general" id="primepostrev_enable_general" value="1" {% if PRIMEPOSTREVISIONS_ENABLE_GENERAL %}checked="checked" {% endif %} /> {{ lang('YES') }}</label>
				<label><input type="radio" class="radio" name="primepostrev_enable_general" value="0" {% if not PRIMEPOSTREVISIONS_ENABLE_GENERAL %}checked="checked" {% endif %}/> {{ lang('NO') }}</label></dd>
		</dl>
		<dl>
			<dt><label for="primepostrev_enable_autoprune">{{ lang('ACP_PRIMEPOSTREVISIONS_ENABLE_AUTOPRUNE') ~ lang('COLON') }}</label><br /><span>{{ lang('ACP_PRIMEPOSTREVISIONS_ENABLE_AUTOPRUNE_EXPLAIN') }}</span></dt>
			<dd><label><input type="radio" class="radio" name="primepostrev_enable_autoprune" value="1" {% if PRIMEPOSTREVISIONS_ENABLE_AUTOPRUNE %}checked="checked" {% endif %}id="primepostrev_enable_autoprune" /> {{ lang('YES') }}</label>
				<label><input type="radio" class="radio" name="primepostrev_enable_autoprune" value="0" {% if not PRIMEPOSTREVISIONS_ENABLE_AUTOPRUNE %}checked="checked" {% endif %}/> {{ lang('NO') }}</label></dd>
		</dl>
	</fieldset>

	<fieldset id="primepostrevisions_enable_section">
		<legend>{{ lang('ACP_PRIMEPOSTREVISIONS_FORUM_SETTINGS') }}</legend>
		<p>{{ lang('ACP_PRIMEPOSTREVISIONS_FORUM_SETTINGS_EXPLAIN') }}</p>
		<br>
		<table class="table1 responsive">
			<thead>
				<tr>
					<th>{{ lang('ACP_PRIMEPOSTREVISIONS_FORUM_NAME') }}</th>
					<th>{{ lang('ACP_PRIMEPOSTREVISIONS_FORUM_ENABLE') }}</th>
					<th>{{ lang('ACP_PRIMEPOSTREVISIONS_FORUM_SETTINGS_AUTOPRUNE') }}</th>
				</tr>
			</thead>
			<tbody>
				{% if loops.forumrow|length %}
					{% for forumrow in loops.forumrow %}
						{% if forumrow.S_IS_CAT %}
							<tr>
								<td class="row3" colspan="3"><label><span class="responsive-hide">{{ forumrow.FORUM_PAD }}</span>{{ forumrow.FORUM_NAME }}</label></td>
							</tr>
						{% else %}
							<tr class="forum-row" title="{{ forumrow.FORUM_NAME }}">
								<td class="row1"><label for="primepostrev_enable_{{ forumrow.FORUM_ID }}"><span class="responsive-hide">{{ forumrow.FORUM_PAD }}</span><a href="{{ forumrow.U_EDIT }}" class="edit">{{ ICON_EDIT }}</a> {{ forumrow.FORUM_NAME }}</label></td>
								<td class="row1">
									<label class="forum-enable-area"><input type="radio" class="radio" name="primepostrev_enable[{{ forumrow.FORUM_ID }}]" id="primepostrev_enable_{{ forumrow.FORUM_ID }}" value="1" {% if forumrow.S_PRIMEPOSTREV_ENABLE %} id="primepostrev_enable" checked="checked"{% endif %} /> {{ lang('YES') }}</label>
									<label class="forum-enable-area"><input type="radio" class="radio" name="primepostrev_enable[{{ forumrow.FORUM_ID }}]" value="0" {% if not forumrow.S_PRIMEPOSTREV_ENABLE %} id="primepostrev_enable" checked="checked"{% endif %} /> {{ lang('NO') }}</label>
								</td>
								<td class="row1">
									<label class="forum-autoprune-area"><input type="number" id="primepostrev_autoprune_{{ forumrow.FORUM_ID }}" name="primepostrev_autoprune[{{ forumrow.FORUM_ID }}]" value="{{ forumrow.PRIMEPOSTREV_AUTOPRUNE }}" min="0" max="9999" /> {{ lang('DAYS') }}</label>
								</td>
							</tr>
						{% endif %}
					{% endfor %}
				{% else %}
					<tr><td colspan="3"><strong>{{ lang('NO_FORUMS') }}</strong></td></tr>
				{% endif %}
			</tbody>
		</table>
	</fieldset>

	<fieldset>
		<legend>{{ lang('ACP_SUBMIT_CHANGES') }}</legend>
		<p class="submit-buttons">
			<input class="button1" type="submit" id="submit" name="submit" value="{{ lang('SUBMIT') }}" />&nbsp;
			<input class="button2" type="reset" id="reset" name="reset" value="{{ lang('RESET') }}" />
		</p>
		{{ S_FORM_TOKEN }}
	</fieldset>
</form>
<script>
// Dim the sections that that aren't used based on the general settings.
// Don't actually disable because we still want to allow the user to make changes
// even though the changes won't have any effect until the setting is enabled.

function updateEnableSection() {
	let enabled = document.getElementById('primepostrev_enable_general').checked;
	let elements = document.getElementsByClassName('forum-enable-area');
	for (let element of elements) {
		element.style.opacity = enabled ? 1 : 0.5;
	}
}

function updateAutopruneeSection() {
	let enabled = document.getElementById('primepostrev_enable_autoprune').checked;
	let elements = document.getElementsByClassName('forum-autoprune-area');
	for (let element of elements) {
		element.style.opacity = enabled ? 1 : 0.5;
	}
}

const enableGeneralInputs = document.querySelectorAll('input[name="primepostrev_enable_general"]');
for (let input of enableGeneralInputs) {
	input.addEventListener('change', function(event) {
		updateEnableSection();
	});
}

const enableAutopruneInputs = document.querySelectorAll('input[name="primepostrev_enable_autoprune"]');
for (let input of enableAutopruneInputs) {
	input.addEventListener('change', function(event) {
		updateAutopruneeSection();
	});
}

updateEnableSection();
updateAutopruneeSection();
</script>
{% INCLUDE 'overall_footer.html' %}
