<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Code View</title>
    <script src="/static/vue.min.js"></script>
    <script src="/static/axios_min.js"></script>
    <style>
        ul{
            list-style-type: none;
            margin-left:100px;
            margin-right:100px;
        }
         button{
            background-color: #F8F8F8;
            min-height: 40px;
            min-width: 60px;
        }





    </style>
</head>
<body>

<h1 align="center"> {[message]} </h1>
<div align="center">
    <button><a href="/" target="_blank"> Home</a></button>
    <button><a href="/addview" target="_blank"> Add</a></button>
    <button><a href="/about" target="_blank"> About</a></button>
    <button><a href="/help" target="_blank"> Help</a></button>
    <button><a href="https://github.com/425776024/easy_leetcode" target="_blank">Github</a></button>
    <h5>Your Number of open : {[data['count_day']|tojson]} <br/> Your Number of view code :
        {[data['count_view_code']|tojson]}
        <br/> Don't give up! </h5>
</div>
<div id="senetnce" align="center">
    <input align="center" v-model="keyword"/>
    <button style="float:center" @click="find_func()">Find</button>
    <ul v-for="c in code_name_list" align="left">
        <button style="float:center" @click="click_func(c[0])">{{c[1]}}</button>
        <button style="float:right;color:red" @click="del_func(c[0])">Del me</button>
<!--        <button style="float:right"><a href="https://www.youtube.com/">no youtube</a></button>-->
<!--        <button style="float:right"><a href="https://www.bilibili.com/">no bilibili</a></button>-->
        <hr/>
    </ul>
    <br/>
    <H6>Maker：425776024@qq.com</H6>
</div>

<script type="text/javascript">
    var sentence_text = new Vue({
        el: '#senetnce',
        data:{
            code_name_list:{[data['code_name_list']|tojson]},
            keyword:"Leetcode"
        },
        methods: {
            click_func:function (name) {
                host = window.location.host;
                url='http://'+host+'/code/'+name;
                window.open(url);
            },
            find_func:function(){
                host = window.location.host;
                url='http://'+host+'/filter_view/'+sentence_text.keyword;
                window.open(url);
            },
            del_func:function(name) {
                if(confirm("realy delete "+name+" ?")){
                    console.log(name);
                    var info = prompt("input char : Y or y to delete");
                    if (info=="y" || info=="Y"){
                        console.log('delete:'+name);
                        axios.put('/delete', {
                            "name":name,
                          })
                          .then(function (response) {
                            host = window.location.host;
                            url='http://'+host+'/view';
                            window.open(url);
                          })
                          .catch(function (error) {
                            console.log(error);
                          });
                    }
                }
            }
        }
});











</script>
</body>

</html>