<!doctype html>
<html>
<head>
    <!-- Global site tag (gtag.js) - Google Analytics -->
    <script async src="https://www.googletagmanager.com/gtag/js?id=G-K76PSKSSGX"></script>
    <script>
        window.dataLayer = window.dataLayer || [];

        function gtag() {
            dataLayer.push(arguments);
        }

        gtag('js', new Date());

        gtag('config', 'G-K76PSKSSGX');
    </script>
    <meta charset="utf-8">
    <title>人人影视下载分享</title>
    <link rel="icon" type="image/x-icon" href="favicon.ico">
    <link href="https://fonts.googleapis.com/css?family=Pacifico&display=swap" rel="stylesheet">
    <link href="/css/normalize.min.css" rel="stylesheet">
    <style>
        h1 {
            font-family: Pacifico, sans-serif;
            font-size: 4em;
            color: #3eb5f1;
            margin: 0;
        }

        h2 {
            font-weight: 300;
            font-family: sans-serif;
        }

        .centered {
            /*position: fixed;*/
            top: 50%;
            left: 50%;
            /*transform: translate(-50%, -50%);*/
            text-align: center;
        }

        a {
            text-decoration: none;
        }

    </style>
</head>
<body>
<div class="centered">
    <h1>人人影视下载分享 By Benny</h1>
    <h2>
        <a href="https://www.buymeacoffee.com/bennythink" target="_blank"><img src="/img/default-green.png"
                                                                               alt="Buy Me A Coffee"
                                                                               style="height: 55px !important;width: 200px !important;"></a>
        <a href="https://afdian.net/@BennyThink" target="_blank"><img src="/img/afdian.png" alt="爱发电"
                                                                      style="height: 55px !important;width: 200px !important;"></a>
    </h2>
    <h2>本站数据库<b><a style="color: skyblue" href="/help.html">永久开源免费</a></b>，<abbr
            style="text-decoration: none" title="你也爬不下来啊">请不要做无意义的爬虫。</abbr>
        <a href="help.html" style="color: deepskyblue">使用帮助？</a>
    </h2>
    <form action="search.html">
        <label>
            <input name="keyword" id="keyword" type="text">
        </label>
        <input type="submit" value="搜索">
    </form>

    <hr>
    <div id="tv">
    </div>
    <hr>

    <h3>
        联系我 <a style="text-decoration: none;color: green" href="https://t.me/BennyThink">Benny 小可爱</a>・
        YYeTs 机器人<a style="text-decoration: none;color: green" href="https://t.me/yyets_bot">Telegram Bot</a>・
        开源 <a style="text-decoration: none;color: green" href="https://github.com/tgbot-collection/YYeTsBot">GitHub</a>・
        Telegram <a style="text-decoration: none;color: green" href="https://t.me/mikuri520">Channel</a>・
        我的博客 <a style="text-decoration: none;color: green" href="https://dmesg.app/">土豆不好吃</a>
    </h3>
</div>
</body>
<script src="js/axios.min.js"></script>
<script src="js/common.js"></script>

<script>
    let kwe = document.URL.split("keyword=")[1];
    if (kwe === undefined) {
        kwe = document.URL.split("kw=")[1];
    }
    let kw = decodeURI(kwe).toLowerCase().replace(" ", "");
    // const axios = require('axios');

    // Make a request for a user with a given ID
    axios.get('/api/resource?keyword=' + kw)
        .then(function (response) {
            // handle success
            doSearch(response.data.data)
            // console.log(response.data);
        })
        .catch(function (error) {
            // handle error
            console.log(error);
        })
        .then(function () {
            // always executed
        });


    function doSearch(data) {
        let search = document.getElementById("keyword");
        if (kw !== "undefined") {
            search.value = kw;
        }
        let div = document.getElementById("tv");
        for (let i = 0; i < data.length; i++) {
            let info = data[i].data.info
            let name = `${info.cnname} ${info.enname} ${info.aliasname}`;
            let html = `<h3><a style="text-decoration: none;color: cornflowerblue" href="/resource.html?id=${info.id}">${name}</a></h3>`;
            let backup = div.innerHTML;
            div.innerHTML = backup + html;

        }
        if (data.length === 0) {
            let issueLink = `https://github.com/tgbot-collection/YYeTsBot/issues/new?assignees=BennyThink&labels=new&title=增加新资源【xxx】&body=请准确填写新资源的下载地址和大小，最好能够上传类似[如下格式的json文件](https://github.com/tgbot-collection/YYeTsBot/blob/master/management/format.json)。若不遵守此规则，issue将被关闭。谢谢。`;
            div.innerHTML = `<h2>没有搜索到结果 (ノへ￣、)</h2><a style="text-decoration: none;color: cornflowerblue" target="_blank" href="${issueLink}">点我去补充信息</a>`
        }
    }

    accessMetrics("search");
</script>
</html>
