<!--#set global $pane="Switches"#-->
<!--#set global $help_uri = $confighelpuri + "switches"#-->
<!--#include $webdir + "/_inc_header_uc.tmpl"#-->

<div class="colmask">
    <div class="padding alt section">
        <label for="advanced-settings-button" class="form-control advanced-button ">
            <input type="checkbox" id="advanced-settings-button" name="advanced-settings-button"> $T('button-advanced')
        </label>
    </div>
    <form action="saveSwitches" method="post" name="fullform" class="fullform" autocomplete="off">
        <input type="hidden" id="apikey" name="apikey" value="$apikey" />
        <input type="hidden" id="ajax" name="ajax" value="1" />
        <input type="hidden" name="output" value="json" />
        <div class="section advanced-settings">
            <div class="col2">
                <h3>$T('swtag-server') <a href="$help_uri#toc1" target="_blank"><span class="glyphicon glyphicon-question-sign"></span></a></h3>
            </div><!-- /col2 -->
            <div class="col1">
                <fieldset>
                    <div class="field-pair">
                        <label class="config" for="max_art_tries">$T('opt-max_art_tries')</label>
                        <input type="number" name="max_art_tries" id="max_art_tries" value="$max_art_tries" min="2" max="2000" />
                        <span class="desc">$T('explain-max_art_tries')</span>
                    </div>
                    <div class="field-pair">
                        <label class="config" for="auto_disconnect">$T('opt-auto_disconnect')</label>
                        <input type="checkbox" name="auto_disconnect" id="auto_disconnect" value="1" <!--#if int($auto_disconnect) > 0 then 'checked="checked"' else ""#--> />
                        <span class="desc">$T('explain-auto_disconnect')</span>
                    </div>
                    <div class="field-pair">
                        <button class="btn btn-default saveButton"><span class="glyphicon glyphicon-ok"></span> $T('button-saveChanges')</button>
                        <button class="btn btn-default restoreDefaults"><span class="glyphicon glyphicon-asterisk"></span> $T('button-restoreDefaults')</button>
                    </div>
                </fieldset>
            </div><!-- /col1 -->
        </div><!-- /section -->
        <div class="section">
            <div class="col2">
                <h3>$T('swtag-queue') <a href="$help_uri#toc2" target="_blank"><span class="glyphicon glyphicon-question-sign"></span></a></h3>
            </div><!-- /col2 -->
            <div class="col1">
                <fieldset>
                    <div class="field-pair advanced-settings">
                        <label class="config" for="pre_script">$T('opt-pre_script')</label>
                        <select name="pre_script" id="pre_script">
                        <!--#for $sc in $scripts#-->
                            <!--#if $sc.lower() == $pre_script.lower()#-->
                                <option value="$sc" selected="selected">$Tspec($sc)</option>
                            <!--#else#-->
                                <option value="$sc">$Tspec($sc)</option>
                            <!--#end if#-->
                        <!--#end for#-->
                        </select>
                        <span class="desc">$T('explain-pre_script')</span>
                    </div>
                    <div class="field-pair advanced-settings">
                        <label class="config" for="end_queue_script">$T('opt-end_queue_script')</label>
                        <select name="end_queue_script" id="end_queue_script">
                        <!--#for $sc in $scripts#-->
                            <!--#if $sc.lower() == $end_queue_script.lower()#-->
                                <option value="$sc" selected="selected">$Tspec($sc)</option>
                            <!--#else#-->
                                <option value="$sc">$Tspec($sc)</option>
                            <!--#end if#-->
                        <!--#end for#-->
                        </select>
                        <span class="desc">$T('explain-end_queue_script')</span>
                    </div>
                    <div class="field-pair">
                        <label class="config" for="propagation_delay">$T('opt-propagation_delay')</label>
                        <input type="number" name="propagation_delay" id="propagation_delay" value="$propagation_delay" min="0" /> <i>$T('minutes')</i>
                        <span class="desc">$T('explain-propagation_delay')</span>
                    </div>
                    <div class="field-pair advanced-settings">
                        <label class="config" for="top_only">$T('opt-top_only')</label>
                        <input type="checkbox" name="top_only" id="top_only" value="1" <!--#if int($top_only) > 0 then 'checked="checked"' else ""#--> />
                        <span class="desc">$T('explain-top_only')</span>
                    </div>
                    <div class="field-pair advanced-settings">
                        <label class="config" for="pre_check">$T('opt-pre_check')</label>
                        <input type="checkbox" name="pre_check" id="pre_check" value="1" <!--#if int($pre_check) > 0 then 'checked="checked"' else ""#--> />
                        <span class="desc">$T('explain-pre_check')</span>
                    </div>
                    <div class="field-pair">
                        <label class="config" for="fail_hopeless_jobs">$T('opt-fail_hopeless_jobs')</label>
                        <input type="checkbox" name="fail_hopeless_jobs" id="fail_hopeless_jobs" value="1" <!--#if int($fail_hopeless_jobs) > 0 then 'checked="checked"' else ""#--> />
                        <span class="desc">$T('explain-fail_hopeless_jobs')</span>
                    </div>
                    <div class="field-pair">
                        <label class="config" for="no_dupes">$T('opt-no_dupes')</label>
                        <select name="no_dupes" id="no_dupes">
                            <option value="0" <!--#if int($no_dupes) == 0 then 'selected="selected"' else ""#--> >$T('nodupes-off')</option>
                            <option value="4" <!--#if int($no_dupes) == 4 then 'selected="selected"' else ""#--> >$T('nodupes-tag')</option>
                            <option value="2" <!--#if int($no_dupes) == 2 then 'selected="selected"' else ""#--> >$T('nodupes-pause')</option>
                            <option value="3" <!--#if int($no_dupes) == 3 then 'selected="selected"' else ""#--> >$T('fail-to-history')</option>
                            <option value="1" <!--#if int($no_dupes) == 1 then 'selected="selected"' else ""#--> >$T('nodupes-ignore')</option>
                        </select>
                        <span class="desc">
                            $T('explain-no_dupes')<br>
                            <a href="https://sabnzbd.org/wiki/duplicate-detection" target="_blank">https://sabnzbd.org/wiki/duplicate-detection</a>
                        </span>
                    </div>
                    <div class="field-pair">
                        <label class="config" for="no_smart_dupes">$T('opt-no_smart_dupes')</label>
                        <select name="no_smart_dupes" id="no_smart_dupes">
                            <option value="0" <!--#if int($no_smart_dupes) == 0 then 'selected="selected"' else ""#--> >$T('nodupes-off')</option>
                            <option value="4" <!--#if int($no_smart_dupes) == 4 then 'selected="selected"' else ""#--> >$T('nodupes-tag')</option>
                            <option value="2" <!--#if int($no_smart_dupes) == 2 then 'selected="selected"' else ""#--> >$T('nodupes-pause')</option>
                            <option value="3" <!--#if int($no_smart_dupes) == 3 then 'selected="selected"' else ""#--> >$T('fail-to-history')</option>
                            <option value="1" <!--#if int($no_smart_dupes) == 1 then 'selected="selected"' else ""#--> >$T('nodupes-ignore')</option>
                        </select>
                        <span class="desc">
                            $T('explain-no_smart_dupes')<br>
                            <a href="https://sabnzbd.org/wiki/duplicate-detection" target="_blank">https://sabnzbd.org/wiki/duplicate-detection</a>
                        </span>
                    </div>
                    <div class="field-pair advanced-settings">
                        <label class="config" for="dupes_propercheck">$T('opt-dupes_propercheck')</label>
                        <input type="checkbox" name="dupes_propercheck" id="dupes_propercheck" value="1" <!--#if int($dupes_propercheck) > 0 then 'checked="checked"' else ""#--> />
                        <span class="desc">$T('explain-dupes_propercheck')</span>
                    </div>
                    <div class="field-pair">
                        <label class="config" for="pause_on_pwrar">$T('opt-pause_on_pwrar')</label>
                        <select name="pause_on_pwrar" id="pause_on_pwrar">
                            <option value="0" <!--#if int($pause_on_pwrar) == 0 then 'selected="selected"' else ""#--> >$T('nodupes-off')</option>
                            <option value="1" <!--#if int($pause_on_pwrar) == 1 then 'selected="selected"' else ""#--> >$T('nodupes-pause')</option>
                            <option value="2" <!--#if int($pause_on_pwrar) == 2 then 'selected="selected"' else ""#--> >$T('fail-to-history')</option>
                        </select>
                        <span class="desc">$T('explain-pause_on_pwrar')</span>
                    </div>
                    <div class="field-pair">
                        <label class="config" for="unwanted_extensions">$T('opt-unwanted_extensions')</label>
                        <select name="unwanted_extensions_mode" id="unwanted_extensions_mode">
                            <option value="0" <!--#if int($unwanted_extensions_mode) == 0 then 'selected="selected"' else ""#--> >$T('unwanted_extensions_blacklist')</option>
                            <option value="1" <!--#if int($unwanted_extensions_mode) == 1 then 'selected="selected"' else ""#--> >$T('unwanted_extensions_whitelist')</option>
                        </select>
                        <input type="text" name="unwanted_extensions" id="unwanted_extensions" value="$unwanted_extensions"/>
                        <span class="desc">$T('explain-unwanted_extensions')</span>
                    </div>
                    <div class="field-pair">
                        <label class="config" for="action_on_unwanted_extensions">$T('opt-action_on_unwanted_extensions')</label>
                        <select name="action_on_unwanted_extensions" id="action_on_unwanted_extensions">
                            <option value="0" <!--#if int($action_on_unwanted_extensions) == 0 then 'selected="selected"' else ""#--> >$T('nodupes-off')</option>
                            <option value="1" <!--#if int($action_on_unwanted_extensions) == 1 then 'selected="selected"' else ""#--> >$T('nodupes-pause')</option>
                            <option value="2" <!--#if int($action_on_unwanted_extensions) == 2 then 'selected="selected"' else ""#--> >$T('fail-to-history')</option>
                        </select>
                        <span class="desc">$T('explain-action_on_unwanted_extensions')</span>
                    </div>
                    <div class="field-pair advanced-settings">
                        <label class="config" for="auto_sort">$T('opt-auto_sort')</label>
                        <select name="auto_sort" id="auto_sort">
                            <option value="">$T('default')</option>
                            <option value="remaining asc" <!--#if $auto_sort == "remaining asc" then 'selected="selected"' else ""#--> >$T('Glitter-sortRemaining')</option>
                            <option value="avg_age desc" <!--#if $auto_sort == "avg_age desc" then 'selected="selected"' else ""#--> >$T('Glitter-sortAgeAsc')</option>
                            <option value="avg_age asc" <!--#if $auto_sort == "avg_age asc" then 'selected="selected"' else ""#--> >$T('Glitter-sortAgeDesc')</option>
                            <option value="name asc" <!--#if $auto_sort == "name asc" then 'selected="selected"' else ""#--> >$T('Glitter-sortNameAsc')</option>
                            <option value="name desc" <!--#if $auto_sort == "name desc" then 'selected="selected"' else ""#--> >$T('Glitter-sortNameDesc')</option>
                            <option value="size asc" <!--#if $auto_sort == "size asc" then 'selected="selected"' else ""#--> >$T('Glitter-sortSizeAsc')</option>
                            <option value="size desc" <!--#if $auto_sort == "size desc" then 'selected="selected"' else ""#--> >$T('Glitter-sortSizeDesc')</option>
                        </select>
                        <span class="desc">$T('explain-auto_sort') $T('explain-auto_sort_remaining')</span>
                    </div>
                    <div class="field-pair">
                        <label class="config" for="direct_unpack">$T('opt-direct_unpack')</label>
                        <input type="checkbox" name="direct_unpack" id="direct_unpack" value="1" <!--#if int($direct_unpack) > 0 then 'checked="checked"' else ""#--> />
                        <span class="desc">$T('explain-direct_unpack').replace('. ', '.<br/>')</span>
                    </div>
                    <div class="field-pair">
                        <button class="btn btn-default saveButton"><span class="glyphicon glyphicon-ok"></span> $T('button-saveChanges')</button>
                        <button class="btn btn-default restoreDefaults"><span class="glyphicon glyphicon-asterisk"></span> $T('button-restoreDefaults')</button>
                    </div>
                </fieldset>
            </div><!-- /col1 -->
        </div><!-- /section -->
        <div class="section">
            <div class="col2">
                <h3>$T('swtag-pp') <a href="$help_uri#toc3" target="_blank"><span class="glyphicon glyphicon-question-sign"></span></a></h3>
            </div><!-- /col2 -->
            <div class="col1">
                <fieldset>
                    <div class="field-pair">
                        <label class="config" for="pause_on_post_processing">$T('opt-pause_on_post_processing')</label>
                        <input type="checkbox" name="pause_on_post_processing" id="pause_on_post_processing" value="1" <!--#if int($pause_on_post_processing) > 0 then 'checked="checked"' else ""#--> />
                        <span class="desc">$T('explain-pause_on_post_processing')</span>
                    </div>
                    <div class="field-pair advanced-settings">
                        <label class="config" for="enable_all_par">$T('opt-enable_all_par')</label>
                        <input type="checkbox" name="enable_all_par" id="enable_all_par" value="1" <!--#if int($enable_all_par) > 0 then 'checked="checked"' else ""#--> />
                        <span class="desc">$T('explain-enable_all_par').replace('. ', '.<br/>')</span>
                    </div>
                    <!--#if not $windows#-->
                    <div class="field-pair advanced-settings <!--#if not $have_nice then "disabled" else "" #-->">
                        <label class="config" for="nice">$T('opt-nice')</label>
                        <input type="text" name="nice" id="nice" value="$nice" <!--#if not $have_nice then 'readonly="readonly" disabled="disabled"' else "" #--> />
                        <span class="desc">$T('readwiki')</span>
                    </div>
                    <div class="field-pair advanced-settings <!--#if not $have_ionice then "disabled" else "" #-->">
                        <label class="config" for="ionice">$T('opt-ionice')</label>
                        <input type="text" name="ionice" id="ionice" value="$ionice" <!--#if not $have_ionice then 'readonly="readonly" disabled="disabled"' else "" #--> />
                        <span class="desc">$T('readwiki')</span>
                    </div>
                    <!--#else#-->
                    <div class="field-pair advanced-settings">

                        <label class="config" for="win_process_prio">$T('opt-win_process_prio')</label>
                        <select name="win_process_prio" id="win_process_prio">
                            <option value="4" <!--#if int($win_process_prio) == 4 then 'selected="selected"' else ""#-->>$T('win_process_prio-high')</option>
                            <option value="3" <!--#if int($win_process_prio) == 3 then 'selected="selected"' else ""#-->>$T('win_process_prio-normal')</option>
                            <option value="2" <!--#if int($win_process_prio) == 2 then 'selected="selected"' else ""#-->>$T('win_process_prio-low')</option>
                            <option value="1" <!--#if int($win_process_prio) == 1 then 'selected="selected"' else ""#-->>$T('win_process_prio-idle')</option>
                        </select>
                        <span class="desc">$T('readwiki')</span>
                    </div>
                    <!--#end if#-->
                    <div class="field-pair advanced-settings">
                        <label class="config" for="par_option">$T('opt-par_option')</label>
                        <input type="text" name="par_option" id="par_option" value="$par_option" />
                        <span class="desc">$T('readwiki')</span>
                    </div>
                    <div class="field-pair advanced-settings">
                        <label class="config" for="sfv_check">$T('opt-sfv_check')</label>
                        <input type="checkbox" name="sfv_check" id="sfv_check" value="1" <!--#if int($sfv_check) > 0 then 'checked="checked"' else ""#--> />
                        <span class="desc">$T('explain-sfv_check')</span>
                    </div>
                    <div class="field-pair advanced-settings">
                        <label class="config" for="safe_postproc">$T('opt-safe_postproc')</label>
                        <input type="checkbox" name="safe_postproc" id="safe_postproc" value="1" <!--#if int($safe_postproc) > 0 then 'checked="checked"' else ""#--> />
                        <span class="desc">$T('explain-safe_postproc')</span>
                    </div>
                    <div class="field-pair advanced-settings">
                        <label class="config" for="enable_recursive">$T('opt-enable_recursive')</label>
                        <input type="checkbox" name="enable_recursive" id="enable_recursive" value="1" <!--#if int($enable_recursive) > 0 then 'checked="checked"' else ""#--> />
                        <span class="desc">$T('explain-enable_recursive')</span>
                    </div>
                    <div class="field-pair advanced-settings">
                        <label class="config" for="flat_unpack">$T('opt-flat_unpack')</label>
                        <input type="checkbox" name="flat_unpack" id="flat_unpack" value="1" <!--#if int($flat_unpack) > 0 then 'checked="checked"' else ""#--> />
                        <span class="desc">$T('explain-flat_unpack')</span>
                    </div>
                    <div class="field-pair advanced-settings">
                        <label class="config" for="script_can_fail">$T('opt-script_can_fail')</label>
                        <input type="checkbox" name="script_can_fail" id="script_can_fail" value="1" <!--#if int($script_can_fail) > 0 then 'checked="checked"' else ""#--> />
                        <span class="desc">$T('explain-script_can_fail')</span>
                    </div>
                    <div class="field-pair">
                        <label class="config" for="ignore_samples">$T('opt-ignore_samples')</label>
                        <input type="checkbox" name="ignore_samples" id="ignore_samples" value="1" <!--#if int($ignore_samples) > 0 then 'checked="checked"' else ""#--> />
                        <span class="desc">$T('explain-ignore_samples') $T('igsam-del').</span>
                    </div>
                    <div class="field-pair">
                        <label class="config" for="deobfuscate_final_filenames">$T('opt-deobfuscate_final_filenames')</label>
                        <input type="checkbox" name="deobfuscate_final_filenames" id="deobfuscate_final_filenames" value="1" <!--#if int($deobfuscate_final_filenames) > 0 then 'checked="checked"' else ""#--> />
                        <span class="desc">$T('explain-deobfuscate_final_filenames') $T('explain-deobfuscate_final_filenames-ext')</span>
                    </div>
                    <div class="field-pair">
                        <label class="config" for="cleanup_list">$T('opt-cleanup_list')</label>
                        <input type="text" name="cleanup_list" id="cleanup_list" value="$cleanup_list"/>
                        <span class="desc">$T('explain-cleanup_list')</span>
                    </div>
                    <div class="field-pair">
                        <label class="config" for="history_retention_option">$T('opt-history_retention')</label>
                        <select name="history_retention_option" id="history_retention_option">
                            <option value="all" <!--#if $auto_sort == "all" then 'selected="selected"' else ""#-->>$T('history_retention-all')</option>
                            <option value="number-archive" <!--#if $history_retention_option == "number-archive" then 'selected="selected"' else ""#-->>$T('history_retention-number-archive')</option>
                            <option value="number-delete" <!--#if $history_retention_option == "number-delete" then 'selected="selected"' else ""#-->>$T('history_retention-number-delete')</option>
                            <option value="days-archive" <!--#if $history_retention_option == "days-archive" then 'selected="selected"' else ""#-->>$T('history_retention-days-archive')</option>
                            <option value="days-delete" <!--#if $history_retention_option == "days-delete" then 'selected="selected"' else ""#-->>$T('history_retention-days-delete')</option>
                            <option value="all-archive" <!--#if $history_retention_option == "all-archive" then 'selected="selected"' else ""#-->>$T('history_retention-archive')</option>
                            <option value="all-delete" <!--#if $history_retention_option == "all-delete" then 'selected="selected"' else ""#-->>$T('history_retention-none')</option>
                        </select>
                        <input type="number" id="history_retention_number" name="history_retention_number" min="1" value="$history_retention_number">
                    </div>
                    <div class="field-pair">
                        <button class="btn btn-default saveButton"><span class="glyphicon glyphicon-ok"></span> $T('button-saveChanges')</button>
                        <button class="btn btn-default restoreDefaults"><span class="glyphicon glyphicon-asterisk"></span> $T('button-restoreDefaults')</button>
                    </div>
                </fieldset>
            </div><!-- /col1 -->
        </div><!-- /section -->
        <div class="section advanced-settings">
            <div class="col2">
                <h3>$T('swtag-naming') <a href="$help_uri#toc4" target="_blank"><span class="glyphicon glyphicon-question-sign"></span></a></h3>
            </div><!-- /col2 -->
            <div class="col1">
                <fieldset>
                    <div class="field-pair">
                        <label class="config" for="folder_rename">$T('opt-folder_rename')</label>
                        <input type="checkbox" name="folder_rename" id="folder_rename" value="1" <!--#if int($folder_rename) > 0 then 'checked="checked"' else ""#--> />
                        <span class="desc">$T('explain-folder_rename').replace('. ', '.<br/>')</span>
                    </div>
                    <div class="field-pair">
                        <label class="config" for="replace_spaces">$T('opt-replace_spaces')</label>
                        <input type="checkbox" name="replace_spaces" id="replace_spaces" value="1" <!--#if int($replace_spaces) > 0 then 'checked="checked"' else ""#--> />
                        <span class="desc">$T('explain-replace_spaces')</span>
                    </div>
                    <div class="field-pair">
                        <label class="config" for="replace_underscores">$T('opt-replace_underscores')</label>
                        <input type="checkbox" name="replace_underscores" id="replace_underscores" value="1" <!--#if int($replace_underscores) > 0 then 'checked="checked"' else ""#--> />
                        <span class="desc">$T('explain-replace_underscores')</span>
                    </div>
                    <div class="field-pair">
                        <label class="config" for="replace_dots">$T('opt-replace_dots')</label>
                        <input type="checkbox" name="replace_dots" id="replace_dots" value="1" <!--#if int($replace_dots) > 0 then 'checked="checked"' else ""#--> />
                        <span class="desc">$T('explain-replace_dots')</span>
                    </div>
                    <!--#if not $windows#-->
                    <div class="field-pair">
                        <label class="config" for="sanitize_safe">$T('opt-sanitize_safe')</label>
                        <input type="checkbox" name="sanitize_safe" id="sanitize_safe" value="1" <!--#if int($sanitize_safe) > 0 then 'checked="checked"' else ""#--> />
                        <span class="desc">$T('explain-sanitize_safe')</span>
                    </div>
                    <!--#end if#-->
                    <div class="field-pair">
                        <button class="btn btn-default saveButton"><span class="glyphicon glyphicon-ok"></span> $T('button-saveChanges')</button>
                        <button class="btn btn-default restoreDefaults"><span class="glyphicon glyphicon-asterisk"></span> $T('button-restoreDefaults')</button>
                    </div>
                </fieldset>
            </div><!-- /col1 -->
        </div><!-- /section -->
        <div class="section">
            <div class="col2">
                <h3>$T('swtag-quota') <a href="$help_uri#toc5" target="_blank"><span class="glyphicon glyphicon-question-sign"></span></a></h3>
            </div><!-- /col2 -->
            <div class="col1">
                <fieldset>
                    <div class="field-pair">
                        <label class="config" for="quota_size">$T('opt-quota_size')</label>
                        <input type="text" name="quota_size" id="quota_size" value="$quota_size" class="smaller_input" />
                        <span class="desc">$T('explain-quota_size')</span>
                    </div>
                    <div class="field-pair">
                        <label class="config" for="quota_period">$T('opt-quota_period')</label>
                        <select name="quota_period" id="quota_period">
                            <option value="d" <!--#if $quota_period == "d" then 'selected="selected"' else ""#--> >$T('day').capitalize()</option>
                            <option value="w" <!--#if $quota_period == "w" then 'selected="selected"' else ""#--> >$T('week').capitalize()</option>
                            <option value="m" <!--#if $quota_period == "m" then 'selected="selected"' else ""#--> >$T('month').capitalize()</option>
                            <option value="x" <!--#if $quota_period == "x" then 'selected="selected"' else ""#--> >$T('manual').capitalize()</option>
                        </select>
                        <span class="desc">$T('explain-quota_period')</span>
                    </div>
                    <div class="field-pair">
                        <label class="config" for="quota_day">$T('opt-quota_day')</label>
                        <input type="text" name="quota_day" id="quota_day" value="$quota_day" class="smaller_input" />
                        <span class="desc">$T('explain-quota_day')</span>
                    </div>
                    <div class="field-pair">
                        <label class="config" for="quota_resume">$T('opt-quota_resume')</label>
                        <input type="checkbox" name="quota_resume" id="quota_resume" value="1" <!--#if int($quota_resume) > 0 then 'checked="checked"' else ""#--> />
                        <span class="desc">$T('explain-quota_resume')</span>
                    </div>
                    <div class="field-pair">
                        <button class="btn btn-default saveButton"><span class="glyphicon glyphicon-ok"></span> $T('button-saveChanges')</button>
                    </div>
                </fieldset>
            </div><!-- /col1 -->
        </div><!-- /section -->
    </form>
</div><!-- /colmask -->

<script type="text/javascript">
jQuery(document).ready(function() {
    jQuery('#history_retention_option').on('change', updateHistoryRetention)
    function updateHistoryRetention() {
        var retention_option = jQuery('#history_retention_option').val()
        var retention_number = jQuery('#history_retention_number')

        if(retention_option === "number-archive" || retention_option === "number-delete") {
            retention_number.show()
            retention_number.attr('placeholder', '$T('history_retention-limit')')
        } else if(retention_option === "days-archive" || retention_option === "days-delete") {
            retention_number.show()
            retention_number.attr('placeholder', '$T('days').capitalize()')
        } else {
            retention_number.hide()
            retention_number.val('')
            retention_number.attr('placeholder', '')
        }
    }
    updateHistoryRetention()

    jQuery('.restoreDefaults').click(function(e) {
        // Get section name
        var sectionName = jQuery(this).parents('.section').find('.col2 h3').text().trim()

        // Confirm?
        if(!confirm("$T('explain-restoreDefaults') \""+sectionName+"\"\n$T('confirm')")) return false
        e.preventDefault()

        // Need to get all the input values, so same way as saving normally
        var key_container = {}
        jQuery(this).parents('.section').extractFormDataTo(key_container);
        key_container = Object.keys(key_container)

        // Send request
        jQuery.ajax({
            type: "GET",
            url: "../../api",
            data: "mode=set_config_default&apikey=${apikey}&output=json&keyword=" + key_container.join('&keyword=')
        }).then(function(data) {
            // Reload page
            document.location = document.location
        })
    })
});
</script>

<!--#include $webdir + "/_inc_footer_uc.tmpl"#-->
