SOURCE

console 命令行工具 X clear

                    
>
console
<!doctype html>
<html>

<head>
    <meta http-equiv="content-type" content="txt/html; charset=utf-8" />
    <meta name="viewport"
        content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.4.1/dist/css/bootstrap.min.css"
        integrity="sha256-L/W5Wfqfa0sdBNIKN9cG6QA5F2qx4qICmU2VgLruv9Y=" crossorigin="anonymous">
    <title>短网址生成</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            cursor: default;
        }

        html,
        body {
            height: 100%;
        }

        body {
            display: -webkit-box;
            display: flex;
            -webkit-box-align: center;
            align-items: center;
            -webkit-box-pack: center;
            justify-content: center;
            vertical-align: center;
            flex-wrap: wrap;
            align-content: center;

            color: #2a2b2c;
            background-color: #ebedee;
            overflow: hidden;
        }

        .card {
            background-color: transparent;
            width: 768px;
        }

        .card-text {
            text-align: center;
        }

        .card-text>a {
            text-decoration: none;
            color: #007bff;
        }

        .card-text>a {
            cursor: pointer;
        }

        .form-control {
            cursor: auto;
        }

        .modal-content {
            background-color: #252d38;
        }

        .modal-header {
            border-bottom: 1px solid #1F262F;
        }

        .modal-footer {
            border-top: 1px solid #1F262F;
        }

        @media (max-width: 769px) {
            .card {
                width: 80%;
            }
        }

        @media (max-width: 420px) {
            .card {
                width: 95%;
            }
        }

        @media (prefers-color-scheme: dark) {
            body {
                color: #d9d9d9;
                background: #1b1b1b;
            }

            .card {
                background-color: #252d38;
            }
        }
    </style>
</head>

<body>
    <div class="card">
        <h5 class="card-header">�� 缩短你的网址!</h5>
        <div class="card-body">
            <h5 class="card-title">请输入要缩短的长网址:</h5>
            <div class="input-group mb-3">
                <input type="text" class="form-control" placeholder="输入一个网址" id="text">
                <div class="input-group-append">
                    <button class="btn btn-primary" type="button" onclick='shorturl()' id="searchbtn">缩短它</button>
                </div>
            </div>
            <p id="notice"></p>
        </div>
    </div>
    <div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel"
        aria-hidden="true">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="exampleModalLabel">结果</h5>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                </div>
                <div class="modal-body" id="result">没有结果</div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-primary" onclick='copyurl("result")' data-toggle="popover"
                        data-placement="bottom" data-content="Copied!">复制</button>
                    <button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
                </div>
            </div>
        </div>
    </div>
    <div style="width:100%;text-align:center">
        <p data-toggle="modal" data-target="#myModal" style="color:#007BFF">API接口文档</p>
        <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
            aria-hidden="true">
            <div class="modal-dialog" role="document" style="height:100%;min-width:700px">
                <div class="modal-content" style="height:90%">
                    <div class="modal-header">
                        <h5 class="modal-title" id="exampleModalLabel">API接口文档</h5>
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                            <span aria-hidden="true">&times;</span>
                        </button>
                    </div>
                        <iframe style="width: 100%;height:100%;" src="https://www.wulihub.com.cn/gc/qDv3Yb/index.html" frameborder="0"></iframe>
                </div>
            </div>
        </div>
    </div>
    <script src="https://cdn.jsdelivr.net/npm/jquery@3.4.1/dist/jquery.slim.min.js"
        integrity="sha256-pasqAKBDmFT4eHoN2ndd6lN370kFiGUFyTiUHWhU7k8=" crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js"
        integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo"
        crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.4.1/dist/js/bootstrap.min.js"
        integrity="sha256-WqU1JavFxSAMcLP2WIOI+GB2zWmShMI82mTpLDcqFUg=" crossorigin="anonymous"></script>
    <script>
        let res
        function shorturl() {
            if (document.querySelector("#text").value == "") {
                alert("网址不能为空!")
                return
            }

            document.getElementById("searchbtn").disabled = true;
            document.getElementById("searchbtn").innerHTML = '<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>请等待...';
            fetch(window.location.pathname, {
                method: 'POST',
                headers: { 'Content-Type': 'application/json' },
                body: JSON.stringify({ url: document.querySelector("#text").value })
            }).then(function (response) {
                return response.json();
            })
                .then(function (myJson) {
                    res = myJson;
                    document.getElementById("searchbtn").disabled = false;
                    document.getElementById("searchbtn").innerHTML = '缩短它';
                    if (res.key !== "" && res.status == "200")
                        document.getElementById("result").innerHTML = window.location.protocol + "//" + window.location.host + "/" + res.key;
                    else if (res.key !== "")
                        document.getElementById("result").innerHTML = res.key;
                    $('#exampleModal').modal('show')
                })
                .catch(function (err) {
                    alert("未知错误,请重试!");
                    document.getElementById("searchbtn").disabled = false;
                    document.getElementById("searchbtn").innerHTML = '缩短它';
                })
        }
        function copyurl(id, attr) {
            let target = null;

            if (attr) {
                target = document.createElement('div');
                target.id = 'tempTarget';
                target.style.opacity = '0';
                if (id) {
                    let curNode = document.querySelector('#' + id);
                    target.innerText = curNode[attr];
                } else {
                    target.innerText = attr;
                }
                document.body.appendChild(target);
            } else {
                target = document.querySelector('#' + id);
            }

            try {
                let range = document.createRange();
                range.selectNode(target);
                window.getSelection().removeAllRanges();
                window.getSelection().addRange(range);
                document.execCommand('copy');
                window.getSelection().removeAllRanges();
                console.log('复制成功')
            } catch (e) {
                console.log('复制失败')
            }

            if (attr) {
                // remove temp target
                target.parentElement.removeChild(target);
            }
        }
    </script>
</body>

</html>