<!doctype html>

<title>直播源修改插件-HFtalk</title>
<meta charset="utf-8" />
<link rel="stylesheet" href="/code/doc/docs.css">
<link rel="stylesheet" href="/code/doc/ziyong.css">
<link rel="stylesheet" href="/code/lib/codemirror.css">
<link rel="stylesheet" href="/code/addon/dialog/dialog.css">


<article>
    <h1 id=top>KODI直播源修改插件</h1>

    <div>
        <p>插件主要目的是让大家在本地局域网内，也可以简单修改直播源</p>
    </div>

    <body class='git-project'>
        <div class='twelve wide column'>
            <div class='git-project-content' id='git-project-content'>
                <div class='row column tree-holder' id='tree-holder'>
                    <div class='tree-content-holder' id='tree-content-holder'>
                        <div class='ui flat nopadding segment tree-content'>
                            <div class='git-project-recent-commit' id='git-project-info'>
                                <div class='recent-commit' >
                                    <h2 id="mulu" style="width: 50%">
                                        <img class="avatar circular ui image 20 mini" width="20" alt="" />
                                        本地直播源地址
                                    </h2>
                                   <button onclick="editNew()" style="margin-left: 30px;">新建直播源文件</button>
                                   <button onclick="Epg()" style="margin-left: 30px;">映射电子节目单</button>
                                </div>
                                
                            </div>
%for file in files:
                            <div class='recent-commit'>
                                <div class='row tree-item'>
                                    <div class='five wide column tree-item-file-name tree-list-item' style="width: 50%;float: left">
                                        <i class="iconfont icon-file"></i>
                                        <a class="intro" title="{{file}}"
                                            href="/{{file}}">{{file}}</a>

                                    </div>
                                    <div  style="width: 35%;float: left">
                                    <button onclick="MapY('{{file}}')" style="width: 30%">
                                            映射
                                        </button>
                                    </div>
                                    	<button onclick="Delete('{{file}}')">
                                            删除
                                        </button>
                                    
                                        
                                        <a href="/edit/{{file}}"><i
                                                class='iconfont icon-commit'></i>
                                            修改
                                        </a>
                                    
                                </div>
                            </div>
%end
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <br>
        <form action="/upload" method="post" enctype="multipart/form-data" accept-charset="utf-8" style="width:300px;height:30px;margin-right:50%;">

            <input type="submit" name="upload" />
            <input type="file" name="m3uFile" accept=".m3u,.m3u8" multiple="multiple" required/>
        </form>
    </body>
    <br><br>
    <body class='git-project'>
        <div class='twelve wide column'>
            <div class='git-project-content' id='git-project-content'>
                <div class='row column tree-holder' id='tree-holder'>
                    <div class='tree-content-holder' id='tree-content-holder'>
                        <div class='ui flat nopadding segment tree-content'>
                            <div class='git-project-recent-commit' id='git-project-info'>
                                <div class='recent-commit'>
                                    <h2 id="mulu">
                                        <img class="avatar circular ui image 20 mini" width="20" alt="" />
                                        <span>本地频道logo地址</span>

                                    </h2>
                                </div>
                            </div>
%for dir in dirs:                            
                            <div class='recent-commit'>
                                <div class='row tree-item'>
                                    <div class='five wide column tree-item-file-name tree-list-item' style="width: 50%;float: left">
                                        <i class="iconfont icon-file"></i>
                                        <a class="intro" title="/{{dir}}" href="/{{dir}}" >{{dir}}</a>
                                    </div>
                                    <div  style="width: 35%;float: left">
                                    <button onclick="MapY('{{dir}}')" style="width: 30%">
                                            映射
                                        </button>
                                    </div>                            
                                    	<button onclick="Delete('{{dir}}')">
                                            删除
                                        </button>
                                        <a href="/{{dir}}"><i
                                                class='iconfont icon-commit'></i>
                                            修改
                                        </a>                                       
                                </div>
                            </div>
%end
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <br>
        <form action="/upload" method="post" name="uploadDir" enctype="multipart/form-data" accept-charset="utf-8" style="width:300px;height:30px;">
            <input type="submit" name="upload" />
            <input type="file" webkitdirectory name="uploadDir"  required/>
        </form>
    </body>
    
</article>

<div id="footer" style="text-align:center;">
    技术小白 BUG难免 介意勿用 ——韩风Talk <br><br>
    <a href="https://space.bilibili.com/472755599" target="_blank">
<img border="0" src="/code/doc/logos/Bilibili_logo.png" style="height: 20px;" />
</a>&emsp;&emsp;&emsp;
<a href="https://www.ixigua.com/home/106895204214" target="_blank">
<img border="0" src="/code/doc/logos/xigua.png" style="height: 20px;" />
</a>&emsp;&emsp;&emsp;
<a href="https://www.youtube.com/channel/UCNvrWFnraM8H1Zh8ASKyiqg" target="_blank">
<img border="0" src="/code/doc/logos/YouTube_Logo.png" style="height: 20px;" />
</a>
</div>
<br>
<script>
var z = location.href;
var y = document.getElementsByClassName("intro");
var hostName =  "http://" + location.hostname + ":" + location.port + "/";
for (let x in y) {
  y[x].innerHTML = z + y[x].title;
};

function Delete(x) {
	del = "/delete/" + x
	x = confirm("确定删除？")
	if (x){
		var xhttp = new XMLHttpRequest();
		xhttp.onreadystatechange = function() {
 			if (this.readyState == 4 && xhttp.status == 200) {
 				alert("删除成功");
 				location.replace(hostName);
 				}
			};
	 	xhttp.open("POST", del, true);
		xhttp.send();
    }else{
	 }; 
}


function MapY(x) {
	Mapdir = hostName + x
	Yin = confirm("确定映射到 PRV IPTV Simple Client插件么？")
	if (Yin){
		var xhttp = new XMLHttpRequest();
		xhttp.onreadystatechange = function () {
			if (this.readyState == 4 && this.status == 200) {
				if (this.responseText == "error") {
					alert("映射出错，请手动设置")
				} else {
					alert(x+'设置成功\n请对"PRV IPTV Simple Client"插件禁用后再启用\n即可使用')
				}

			}
		};
        xhttp.open("POST", "/yingshe", true);
		xhttp.send("hostName=" + encodeURI(encodeURI(hostName)) + "&Yfile=" + encodeURI(encodeURI(x)));
	 }; 
}

function editNew() {
	var Word = prompt("请输入新建文件名称(不需带扩展名.m3u)：", "hanfeng");
	if (Word == null || Word == "") {
		alert("未输入，已取消");
	} else {
		x = "/new/" + Word
		New = hostName + "edit/" + Word + ".m3u"
		var xhttp = new XMLHttpRequest();
		xhttp.onreadystatechange = function () {
			if (this.readyState == 4 && this.status == 200) {
				if (this.responseText == "exists") {
					Doc = "已存在同名文件，是否转到" + Word + ".m3u 编辑"
					if (confirm(Doc)) {
						location.replace(New)
					}
				} else {
					alert("新建文件成功，现转到编辑界面")
					location.replace(New)
				}

			}
		};
		xhttp.open("POST", x, true);
		xhttp.send();
	}
}

function Epg() {
	var Word = prompt("请输入电子节目单网址(一般默认输入即可)：", "http://epg.51zmt.top:8000/e.xml");
	if (Word == null || Word == "") {
		alert("未输入，已取消");
	} else {
		var xhttp = new XMLHttpRequest();
		xhttp.onreadystatechange = function () {
			if (this.readyState == 4 && this.status == 200) {
				if (this.responseText == "error") {
					alert("映射出错，请手动设置")
				} else {
					alert('电子节目单设置成功\n请对"PRV IPTV Simple Client"插件禁用后再启用\n即可使用')
				}

			}
		};
		xhttp.open("POST", "/epg", true);
		xhttp.send("epg=" + encodeURI(encodeURI(Word)));
	}
}
</script>



