<#-- @ftlvariable name="serp" type="com.serphacker.serposcope.models.google.GoogleSerp" -->
<#import "../admin.ftl.html" as layout>
<@layout.adminLayout i18n("admin.google.title") >

<div class="row" >
    <div class="col-xs-12" >
        <div class="col-xs-12 col-md-offset-3 col-md-6  setting-form" >
            <form class="form" method="post" action="${reverseRoute("admin.GoogleSettingsController","update")}" >
                <@authenticityForm/>
                
                <hr/>
                <h2 class="styled-h2">${i18n("admin.google.scrapOptions")}</h2>
                <hr/>

                <div class="form-group" >
                    <label for="optPages" >${i18n("admin.google.pages")}</label>
                    <input type="number" id="optPages" class="form-control width80" name="pages" value="${options.getPages()}" >
                    <span class="help-block">${i18n("admin.google.pagesHelp")}</span>
                </div>

                <div class="form-group" >
                    <label for="optResultPerPage" >${i18n("admin.google.resultsPerPage")}</label>
                    <input type="number" id="optResultPerPage" class="form-control width80" name="result-per-page"
                           value="${options.getResultPerPage()}" >
                    <span class="help-block">${i18n("admin.google.resultsPerPageHelp")}</span>
                </div>

                <div class="form-group" >
                    <label for="optPauses" >${i18n("label.pause")}</label>
                    <div id="optPauses" class="input-group width260" >
                        <span class="input-group-addon" >${i18n("label.min")}</span>
                        <input type="number" class="form-control" name="min-pause" value="${options.getMinPauseBetweenPageSec()}" >
                        <span class="input-group-addon" >${i18n("label.max")}</span>
                        <input type="number" class="form-control" name="max-pause" value="${options.getMaxPauseBetweenPageSec()}" >
                    </div>
                    <span class="help-block">${i18n("admin.google.pauseHelp")}</span>
                </div>
                
                <div class="form-group" >
                    <label for="maxThreads" >${i18n("admin.google.maxThreads")}</label>
                    <input type="number" id="maxThreads" class="form-control width80" name="maxThreads" value="${options.getMaxThreads()}" >
                    <span class="help-block">${i18n("admin.google.maxThreadsHelp")}</span>
                </div>                
                
                <div class="form-group" >
                    <label for="fetchRetry" >${i18n("admin.google.fetchRetry")}</label>
                    <input type="number" id="fetchRetry" class="form-control width80" name="fetchRetry" value="${options.getFetchRetry()}" >
                    <span class="help-block">${i18n("admin.google.fetchRetryHelp")}</span>
                </div>                

                <hr/>
                <h2 class="styled-h2">${i18n("admin.google.defaultSearchOptions")}</h2>
                <hr/>
                <span class="help-block">${i18n("admin.google.defaultSearchOptionsHelp")}</span>

                <div class="form-group" >
                    <label for="country" >${i18n("label.country")}</label>
                    <#noescape>${fu.countryCombo("country", options.getDefaultCountry())}</#noescape>
                    <span class="help-block">${i18n("admin.google.countryHelp")}</span>
                </div>

                <div class="form-group" >
                    <label for="searchDatacenter" >${i18n("label.datacenter")}</label>
                    <input id="searchDatacenter" class="form-control" name="datacenter" value="${options.getDefaultDatacenter()!""}" >
                    <span class="help-block">${i18n("admin.google.datacenterHelp")}</span>
                </div>

                <div class="form-group" >
                    <label for="searchDevice" >${i18n("label.device")}</label>
                    <div>
                        <div class="btn-group" data-toggle="buttons">
                            <#if options.getDefaultDevice() == "MOBILE" >
                            <label class="btn btn-default">
                                <input type="radio" name="device" value="0"> 
                                <i class="fa fa-desktop fa-bigger fa-lg fa-fw" ></i> ${i18n("label.desktop")}
                            </label>
                            <label class="btn btn-default active">
                                <input type="radio" name="device" value="1" checked="checked" >
                                <i class="fa fa-mobile fa-bigger fa-lg fa-fw" ></i> ${i18n("label.mobile")}
                            </label>                            
                            <#else>
                            <label class="btn btn-default active">
                                <input type="radio"  name="device" value="0" checked="checked" > 
                                <i class="fa fa-desktop fa-bigger fa-lg fa-fw" ></i> ${i18n("label.desktop")}
                            </label>
                            <label class="btn btn-default">
                                <input type="radio" name="device" value="1" >
                                <i class="fa fa-mobile fa-bigger fa-lg fa-fw" ></i> ${i18n("label.mobile")}
                            </label>                            
                            </#if>

                        </div>         
                    </div>
                    <span class="help-block">${i18n("admin.google.deviceHelp")}</span>
                </div>

                <div class="form-group" >
                    <label for="searchLocal" >${i18n("label.local")}</label>
                    <input id="searchLocal" class="form-control search-local" name="local" value="${options.getDefaultLocal()!""}" >
                    <span class="help-block"><#noescape>${i18n("admin.google.localHelp")}</#noescape></span>
                </div>

                <div class="form-group" >
                    <label for="searchCustomParameters" >${i18n("label.customParameters")}</label>
                    <input id="searchCustomParameters" class="form-control" name="custom" 
                           value="${options.getDefaultCustomParameters()!""}"  >
                    <span class="help-block">${i18n("admin.google.customHelp")}</span>
                </div>       

                
                <hr/>
                <input type="button" id="btn-reset-settings" class="btn btn-default" value="${i18n("label.reset")}" 
                    data-action="${reverseRoute("admin.GoogleSettingsController","reset")}" />
                <input type="submit" class="btn btn-primary" value="${i18n("label.save")}" />
            </form>
        </div>
    </div>
</div>
<div class="csp-script" data-src="adminGoogleSettingsController.settings" ></div>
</@>