<?php if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
<!DOCTYPE HTML>
<html>
<head>
     <meta charset="<?php $this->options->charset(); ?>">
    <meta name="renderer" content="webkit">
    <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black" />
    <meta name="apple-touch-fullscreen" content="yes"/>
    <meta name="format-detection" content="email=no" />
    <meta name="wap-font-scale"  content="no" />
    <meta name="viewport" content="user-scalable=no, width=device-width" />
    <meta content="telephone=no" name="format-detection" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <?php if(!empty(General::Options('favicon'))): ?>
 <link rel="shortcut icon" href="<?php echo General::Options('favicon') ?>" />
 <?php endif; ?>
    <title><?php $this->archiveTitle([
            'category'  =>  _t('Articles under the category "%s"'),
            'search'    =>  _t('Articles containing the keyword "%s"'),
            'tag'       =>  _t('Articles under the tag "%s"'),
            'author'    =>  _t('Profile of the author "%s"')
        ], '', ' - '); ?><?php $this->options->title(); ?></title>
    <link rel="stylesheet" href="<?php $this->options->themeUrl('assets/css/beardocs.css?v='); ?><?php echo themeVersion();?>">
    <link rel="stylesheet" href="<?php $this->options->themeUrl('assets/plugins/remixicon/remixicon.css'); ?>">
    <link rel="stylesheet" href="<?php $this->options->themeUrl('assets/plugins/element-ui/index.min.css'); ?>">
    <link href="<?php $this->options->themeUrl('assets/plugins/lazyload/transition.min.css'); ?>" rel="stylesheet">
    <link rel="stylesheet" href="<?php $this->options->themeUrl('assets/plugins/fancybox/fancybox.min.css'); ?>">
    <link rel="stylesheet" href="<?php $this->options->themeUrl('assets/plugins/menutree/menutree.min.css?v=1'); ?>">
    <script src="<?php $this->options->themeUrl('assets/plugins/jquery/jquery.min.js'); ?>"></script>
    <script src="<?php $this->options->themeUrl('assets/js/uikit.js'); ?>"></script>
    <?php $this->header('commentReply=1&description=&pingback=0&xmlrpc=0&wlw=0&generator=&template=&atom='); ?>
    <script>
        window.searchApi = "";
    </script>
    <?php if(General::Options('headerColorChoose') == true):?>
    <style>
    header{
        background: linear-gradient(60deg, <?php echo General::Options('headerColor1'); ?> 0%, <?php echo General::Options('headerColor2'); ?> 100%);
    }
    
    </style>
    <?php endif;?>
    <?php echo General::Options('CustomizationCode'); ?>
    <script>
(function () {
    window.TypechoComment = {
        dom : function (id) {
            return document.getElementById(id);
        },
    
        create : function (tag, attr) {
            var el = document.createElement(tag);
        
            for (var key in attr) {
                el.setAttribute(key, attr[key]);
            }
        
            return el;
        },

        reply : function (cid, coid) {
            var comment = this.dom(cid), parent = comment.parentNode,
                response = this.dom('respond-post-<?php echo $this->cid;?>'), input = this.dom('comment-parent'),
                form = 'form' == response.tagName ? response : response.getElementsByTagName('form')[0],
                textarea = response.getElementsByTagName('textarea')[0];
            if (null == input) {
                input = this.create('input', {
                    'type' : 'hidden',
                    'name' : 'parent',
                    'id'   : 'comment-parent'
                });

                form.appendChild(input);
            }

            input.setAttribute('value', coid);

            if (null == this.dom('comment-form-place-holder')) {
                var holder = this.create('div', {
                    'id' : 'comment-form-place-holder'
                });

                response.parentNode.insertBefore(holder, response);
            }
            //comment.appendChild(response);
            comment.insertAdjacentElement("afterend",response);
            this.dom('cancel-comment-reply-link').style.display = '';

            if (null != textarea && 'text' == textarea.name) {
                textarea.focus();
            }

            return false;
        },

        cancelReply : function () {
            var response = this.dom('respond-post-<?php echo $this->cid;?>'),
            holder = this.dom('comment-form-place-holder'), input = this.dom('comment-parent');

            if (null != input) {
                input.parentNode.removeChild(input);
            }

            if (null == holder) {
                return true;
            }

            this.dom('cancel-comment-reply-link').style.display = 'none';
            holder.parentNode.insertBefore(response, holder);
            return false;
        }
    };
})();

    </script>
</head>
<body>
<header class="uk-background-secondary uk-background-norepeat uk-background-cover uk-background-center-center uk-light" <?php if (General::Options('headerBackground') !== '' && (General::Options('headerColorChoose') == false || General::Options('headerColorChoose') == '')): ?>
	style="background-image: url(<?php echo General::Options('headerBackground'); ?>);"<?php endif; ?>>
<!--	<nav class="uk-navbar-container">-->
<!--	  <div class="uk-container">-->
<!--	    <div data-uk-navbar>-->
<!--	      <div class="uk-navbar-center">-->
<!--	          --><?php //if(General::Options('logoPic') == ''):?>
<!--	          <a class="uk-navbar-item uk-logo" href="--><?php //$this->options->siteUrl(); ?><!--">--><?php //if (General::Options('logoText')): ?><!----><?php //echo General::Options('logoText'); ?><!----><?php //else:?><!----><?php //echo $this->options->title;?><!----><?php //endif; ?><!--</a>-->
<!--	          --><?php //else:?>
<!--	        <a class="uk-navbar-item uk-logo" href="--><?php //$this->options->siteUrl(); ?><!--"><img src="--><?php //echo General::Options('logoPic'); ?><!--" style="max-width:100%;"></a>-->
<!--	        --><?php //endif;?>
<!--	      </div>-->
<!--	    </div>-->
<!--	  </div>-->
<!--	</nav>-->
<?php
$currentUrl = $_SERVER['REQUEST_URI'];

?>
    <?php if (strpos($currentUrl, 'category') !== false) { ?>
    <div class="uk-section uk-section-small uk-section-hero uk-position-relative" data-uk-scrollspy="cls: uk-animation-slide-bottom-medium; repeat: false">
        <div class="uk-container">
<!--		    	<h1 class="uk-text-center uk-margin-remove-top">--><?php //if (General::Options('headerText')): ?><!----><?php //echo General::Options('headerText'); ?><!----><?php //else:?><!--How can I help you?--><?php //endif; ?><!--</h1>-->
            <div class="hero-search ">
                <div class="uk-position-relative" >
                    <form class="uk-search uk-search-default " id="searchCompleteForm" name="searchCompleteForm" onsubmit="return false;" style="display: flex; align-items: center; gap: 10px;background-color: ">
                        <div class="uk-inline" style="flex-grow: 1;">
                            <span data-uk-search-icon="ratio: 1.2"></span>
                            <input id="searchComplete" spellcheck=false autocorrect="off" autocomplete="off"
                                   autocapitalize="off" maxlength="2048" tabindex="1" class="uk-search-input uk-form-medium uk-border-rounded" type="search"
                                   placeholder="Input Keywords" autocomplete="off" data-minchars="1" data-maxitems="30" style="width: 100%;">
                        </div>
                        <button class="uk-button uk-button-primary uk-border-rounded" type="submit" aria-label="Search">
                            <span data-uk-icon="icon: search"></span>
                        </button>
                    </form>

                </div>
            </div>
        </div>
    </div>
    <?php
    }
    else if (strpos($currentUrl, 'archives') == true)
    {

        $category_id=General::getCategoryId($this->category);
        $category_info= General::getCategoryInfo($category_id);

        ?>
        <div class="uk-section uk-section-small uk-section-hero uk-position-relative" data-uk-scrollspy="cls: uk-animation-slide-bottom-medium; repeat: false">
            <div class="uk-container">
                <div class="hero-search">
                    <div class="uk-position-relative" style="display: flex; justify-content: center; align-items: center; height: 40px;"> <!-- 设置固定高度 -->
                        <p style="margin: 0;"><?php echo $category_info['name'];?></p>
                    </div>
                </div>
            </div>
        </div>
    <?php
    }
    else
    {
      ?>
        <div class="uk-section uk-section-small uk-section-hero uk-position-relative" data-uk-scrollspy="cls: uk-animation-slide-bottom-medium; repeat: false">
            <div class="uk-container">
                <div class="hero-search">
                    <div class="uk-position-relative" style="display: flex; justify-content: center; align-items: center; height: 40px;"> <!-- 设置固定高度 -->
                        <p style="margin: 0;">Select a category to search.</p>
                    </div>
                </div>
            </div>
        </div>
    <?php
    }
    ?>

</header>

<script>
    $(document).ready(function() {
        // 监听搜索按钮的点击事件
        $('button[type="submit"]').on('click', function(e) {
            e.preventDefault(); // 阻止表单默认提交行为

            // 获取搜索框中的输入值
            var searchQuery = $('#searchComplete').val();


            // 如果 searchQuery 为空，提示用户输入
            if (!searchQuery.trim()) {
                // 移除之前的提示信息（如果存在）
                $('.search-error-message').remove();

                // 插入提示信息
                $('#searchCompleteForm').after(
                    '<div class="search-error-message uk-alert-danger uk-border-rounded uk-margin-small uk-padding-small" style="padding:8px;margin: 0px;">' +
                    'Please enter a search term.' +
                    '</div>'
                );
                return;
            }

            // 获取 category
            var category = '<?php
                $categoryId = General::getCategoryId($this->getArchiveSlug());
                if (empty($categoryId)) {
                    // 如果从 General::getCategoryId 获取不到 category，尝试从 URL 参数中获取
                    $categoryId = isset($_GET['category']) ? $_GET['category'] : '';
                }
                echo $categoryId;
                ?>';

            // 构建目标URL
            var targetUrl = '/search/' + encodeURIComponent(searchQuery) + '/?category=' + category;

            // 跳转到目标URL
            window.location.href = targetUrl;
        });
    });
</script>