<?php

namespace GriffinForms\Admin\Js\Local;

final class Compliance extends \GriffinForms\Admin\Js\Local\Settings
{
    public function getOptionsDataJs(): string
    {
        $js = 'function getOptionsData() {' . PHP_EOL .
              '    getComplianceDefaultsEnabledOption();' . PHP_EOL .
              '    getComplianceDefaultProfileOption();' . PHP_EOL .
              '    getComplianceDefaultStoreIpOption();' . PHP_EOL .
              '    getComplianceDefaultStoreUserAgentOption();' . PHP_EOL .
              '    getComplianceDefaultRetentionDaysOption();' . PHP_EOL .
              '    getComplianceTrustProxyHeadersOption();' . PHP_EOL .
              '    getComplianceShowIpNoticeOption();' . PHP_EOL .
              '}' . PHP_EOL;

        $js .= $this->getComplianceDefaultsEnabledOptionJs();
        $js .= $this->getComplianceDefaultProfileOptionJs();
        $js .= $this->getComplianceDefaultStoreIpOptionJs();
        $js .= $this->getComplianceDefaultStoreUserAgentOptionJs();
        $js .= $this->getComplianceDefaultRetentionDaysOptionJs();
        $js .= $this->getComplianceTrustProxyHeadersOptionJs();
        $js .= $this->getComplianceShowIpNoticeOptionJs();

        return $js;
    }

    public function getComplianceDefaultProfileOptionJs(): string
    {
        return 'function getComplianceDefaultProfileOption() {' . PHP_EOL .
               '    optionsData["compliance_default_profile"] = jQuery("#griffinforms-settings-compliance-compliancedefaultprofile").val();' . PHP_EOL .
               '}' . PHP_EOL;
    }

    public function getComplianceDefaultsEnabledOptionJs(): string
    {
        return 'function getComplianceDefaultsEnabledOption() {' . PHP_EOL .
               '    optionsData["compliance_defaults_enabled"] = jQuery("#griffinforms-settings-compliance-compliancedefaultsenabled").prop("checked");' . PHP_EOL .
               '}' . PHP_EOL;
    }

    public function getComplianceDefaultStoreIpOptionJs(): string
    {
        return 'function getComplianceDefaultStoreIpOption() {' . PHP_EOL .
               '    optionsData["compliance_default_store_ip"] = jQuery("#griffinforms-settings-compliance-compliancedefaultstoreip").prop("checked");' . PHP_EOL .
               '}' . PHP_EOL;
    }

    public function getComplianceDefaultStoreUserAgentOptionJs(): string
    {
        return 'function getComplianceDefaultStoreUserAgentOption() {' . PHP_EOL .
               '    optionsData["compliance_default_store_user_agent"] = jQuery("#griffinforms-settings-compliance-compliancedefaultstoreuseragent").prop("checked");' . PHP_EOL .
               '}' . PHP_EOL;
    }

    public function getComplianceDefaultRetentionDaysOptionJs(): string
    {
        return 'function getComplianceDefaultRetentionDaysOption() {' . PHP_EOL .
               '    optionsData["compliance_default_retention_days"] = jQuery("#griffinforms-settings-compliance-compliancedefaultretentiondays").val();' . PHP_EOL .
               '}' . PHP_EOL;
    }

    public function getComplianceTrustProxyHeadersOptionJs(): string
    {
        return 'function getComplianceTrustProxyHeadersOption() {' . PHP_EOL .
               '    optionsData["compliance_trust_proxy_headers"] = jQuery("#griffinforms-settings-compliance-compliancetrustproxyheaders").prop("checked");' . PHP_EOL .
               '}' . PHP_EOL;
    }

    public function getComplianceShowIpNoticeOptionJs(): string
    {
        return 'function getComplianceShowIpNoticeOption() {' . PHP_EOL .
               '    optionsData["compliance_show_ip_notice"] = jQuery("#griffinforms-settings-compliance-complianceshowipnotice").prop("checked");' . PHP_EOL .
               '}' . PHP_EOL;
    }
}
