1
0
mirror of https://github.com/DigitalDevices/octonet.git synced 2023-10-10 13:36:52 +02:00
octonet/octoserve/var/www/channellists.html

492 lines
17 KiB
HTML

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>OctopusNet</title>
<link rel="stylesheet" type="text/css" href="/style.css">
<script type="text/javascript" src="/menu.js"></script>
<!-- Add included scripts here -->
<script type="text/javascript" src="/systeminfo.lua"></script>
<script type="text/javascript">Octoserve = false;</script>
<script type="text/javascript" src="/octoserve/serverinfo.js"></script>
<!-- Add page scripts here -->
<script type="text/javascript">
var hasCable = false;
var hasSat = false;
var hasTer = false;
var StartTime = null;
var xmlhttp = new XMLHttpRequest();
var url = "/channelscan.lua?select=keys";
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState == 4 )
{
if( xmlhttp.status == 200 )
myFunction(xmlhttp.responseText);
}
}
function myFunction(response)
{
var kl = JSON.parse(response);
document.Cable.Select.length = 0;
document.Satellite1.Select.length = 0;
document.Satellite2.Select.length = 0;
document.Satellite3.Select.length = 0;
document.Satellite4.Select.length = 0;
document.Cable.Select.options[0] = (new Option("-", null, false, true) );
document.Satellite1.Select.options[0] = (new Option("-", null, false, true) );
document.Satellite2.Select.options[0] = (new Option("-", null, false, true) );
document.Satellite3.Select.options[0] = (new Option("-", null, false, true) );
document.Satellite4.Select.options[0] = (new Option("-", null, false, true) );
var iCable = 1;
var iSat = 1;
for(var i = 0; i < kl.KeyList.length; i++)
{
if( (hasCable && kl.KeyList[i].DVBType.indexOf("C") >= 0) ||
(hasTer && kl.KeyList[i].DVBType.indexOf("T") >= 0) )
{
var Select = (kl.KeyList[i].Key == "UM");
document.Cable.Select.options[iCable] = (new Option(kl.KeyList[i].Title, kl.KeyList[i].Key, false, Select) );
iCable += 1;
}
if( (hasSat && kl.KeyList[i].DVBType.indexOf("S") >= 0) )
{
var Select = (kl.KeyList[i].Key == "0192");
document.Satellite1.Select.options[iSat] = (new Option(kl.KeyList[i].Title, kl.KeyList[i].Key, false, Select) );
document.Satellite2.Select.options[iSat] = (new Option(kl.KeyList[i].Title, kl.KeyList[i].Key, false, false) );
document.Satellite3.Select.options[iSat] = (new Option(kl.KeyList[i].Title, kl.KeyList[i].Key, false, false) );
document.Satellite4.Select.options[iSat] = (new Option(kl.KeyList[i].Title, kl.KeyList[i].Key, false, false) );
iSat += 1;
}
}
if( iCable > 1 )
document.getElementById("trCable").style.display = "table-row";
if( iSat > 1 )
{
document.getElementById("trSat1").style.display = "table-row";
document.getElementById("trSat2").style.display = "table-row";
document.getElementById("trSat3").style.display = "table-row";
document.getElementById("trSat4").style.display = "table-row";
}
}
function SetSource(Src,SourceIndex)
{
}
function OnLoad()
{
for(var i = 0; i < Octoserve.TunerList.length; i++ )
{
if( Octoserve.TunerList[i] )
{
if( Octoserve.TunerList[i].Desc.indexOf("C/T") >= 0 ) hasCable = true;
if( Octoserve.TunerList[i].Desc.indexOf("C/C2") >= 0 ) hasCable = true;
if( Octoserve.TunerList[i].Desc.indexOf("S/S2") >= 0 ) hasSat = true;
}
}
// TODO: differentiate between dvbc and dvbt
hasTer = hasCable;
xmlhttp.open("GET", url, true);
xmlhttp.send();
}
function DisableButtons(disabled)
{
document.getElementById("EpgButton").disabled = disabled;
document.getElementById("ScanButton").disabled = disabled;
document.getElementById("StatusButton").disabled = disabled;
document.getElementById("DeleteButton").disabled = disabled;
document.getElementById("DeleteAllButton").disabled = disabled;
document.getElementById("RestoreButton").disabled = disabled;
document.getElementById("UploadButton").disabled = disabled;
}
var ScanReq = new XMLHttpRequest();
ScanReq.onreadystatechange=function()
{
if (ScanReq.readyState == 4 )
{
if( ScanReq.status == 200 )
ScanStatus(ScanReq.responseText);
else
{
document.getElementById("scancount").firstChild.nodeValue = "\u00A0";
document.getElementById("scantext").firstChild.nodeValue = "Error " + ScanReq.status;
DisableButtons(false);
}
}
}
function GetStatus()
{
ScanReq.open("GET", "/channelscan.lua?select=status&t=" + Math.random(), true);
ScanReq.send();
}
function ScanStatus(response)
{
var s = JSON.parse(response);
var done = true;
if( s.status )
{
if( s.status == "active" )
{
document.getElementById("scancount").firstChild.nodeValue = s.count;
document.getElementById("scantext").firstChild.nodeValue = s.msg;
done = false;
}
else if( s.status == "busy" )
{
document.getElementById("scancount").firstChild.nodeValue = "\u00A0";
document.getElementById("scantext").firstChild.nodeValue = "BUSY";
}
else if( s.status == "done" )
{
var sec = "";
if( StartTime )
{
var t = new Date() - StartTime;
sec = ", time: " + Math.floor(t/1000) + " seconds";
StartTime = null;
}
document.getElementById("scancount").firstChild.nodeValue = s.count;
document.getElementById("scantext").firstChild.nodeValue = s.msg + sec;
}
else if( s.status == "deleted" )
{
document.getElementById("scancount").firstChild.nodeValue = "\u00A0";
document.getElementById("scantext").firstChild.nodeValue = "Channel list deleted";
}
else if( s.status == "restored" )
{
document.getElementById("scancount").firstChild.nodeValue = "\u00A0";
if( s.count == 0 )
document.getElementById("scantext").firstChild.nodeValue = "Nothing restored";
else
document.getElementById("scantext").firstChild.nodeValue = "Previous channel list restored";
}
else if( s.status == "error" )
{
document.getElementById("scancount").firstChild.nodeValue = "Error";
document.getElementById("scantext").firstChild.nodeValue = s.msg;
}
else if( s.status == "updated" )
{
document.getElementById("scancount").firstChild.nodeValue = "\u00A0";
document.getElementById("scantext").firstChild.nodeValue = s.msg + " updated";
}
else if( s.status == "retry" )
{
done = false;
}
}
if( done )
{
DisableButtons(false);
}
else
window.setTimeout(GetStatus,500);
}
function InitiateScan()
{
DisableButtons(true);
var param = "";
for(var i = 1; i < document.Cable.Select.options.length; i += 1)
{
if( document.Cable.Select.options[i].selected )
param = param + "&key=" + document.Cable.Select.options[i].value;
}
for(var i = 1; i < document.Satellite1.Select.options.length; i += 1)
{
if( document.Satellite1.Select.options[i].selected )
param = param + "&key=" + document.Satellite1.Select.options[i].value + ".1";
}
for(var i = 1; i < document.Satellite2.Select.options.length; i += 1)
{
if( document.Satellite2.Select.options[i].selected )
param = param + "&key=" + document.Satellite2.Select.options[i].value + ".2";
}
for(var i = 1; i < document.Satellite3.Select.options.length; i += 1)
{
if( document.Satellite3.Select.options[i].selected )
param = param + "&key=" + document.Satellite3.Select.options[i].value + ".3";
}
for(var i = 1; i < document.Satellite4.Select.options.length; i += 1)
{
if( document.Satellite4.Select.options[i].selected )
param = param + "&key=" + document.Satellite4.Select.options[i].value + ".4";
}
if( param != "" )
{
ScanReq.open("POST", "/channelscan.lua", true);
ScanReq.setRequestHeader("Content-type","application/x-www-form-urlencoded");
ScanReq.send("select=scan" + param + "&sitables=1&sort=1&restartdms=1");
document.getElementById("scancount").firstChild.nodeValue = "\u00A0";
document.getElementById("scantext").firstChild.nodeValue = "Scanning...";
StartTime = new Date();
}
else
{
document.getElementById("scancount").firstChild.nodeValue = "\u00A0";
document.getElementById("scantext").firstChild.nodeValue = "\u00A0";
}
}
function InitiateEPGScan()
{
DisableButtons(true);
ScanReq.open("POST", "/channelscan.lua", true);
ScanReq.setRequestHeader("Content-type","application/x-www-form-urlencoded");
ScanReq.send("select=epg");
document.getElementById("scancount").firstChild.nodeValue = "\u00A0";
document.getElementById("scantext").firstChild.nodeValue = "Scanning...";
StartTime = new Date();
}
function PollStatus()
{
DisableButtons(true);
GetStatus();
}
function DeleteScan(all)
{
DisableButtons(true);
ScanReq.open("POST", "/channelscan.lua", true);
ScanReq.setRequestHeader("Content-type","application/x-www-form-urlencoded");
ScanReq.send("select=delete" + (all ? "&all=true" : ""));
}
function RestoreScan()
{
DisableButtons(true);
ScanReq.open("POST", "/channelscan.lua", true);
ScanReq.setRequestHeader("Content-type","application/x-www-form-urlencoded");
ScanReq.send("select=restore");
}
function Uploader(event)
{
event.preventDefault();
document.getElementById("scancount").firstChild.nodeValue = "\u00A0";
document.getElementById("scantext").firstChild.nodeValue = "\u00A0";
var fileSelect = document.getElementById("UploadList");
if( fileSelect.files.length > 0 )
{
var formData = new FormData();
formData.append('filename', fileSelect.files[0], fileSelect.files[0].name)
DisableButtons(true);
ScanReq.open("POST", "/channelscan.lua", true);
ScanReq.send(formData);
}
}
</script>
</head>
<body onload="OnLoad()">
<table class="maintable">
<colgroup>
<col style="width: 182px"/>
<col style="width: 728px"/>
</colgroup>
<tr><td class="maintd" colspan="2">
<a href="http://www.digitaldevices.de"><img src="/BannerDD.jpg" alt="DD" width="910" height="130" /></a>
</td></tr>
<tr><td class="maintd" colspan="2">&nbsp;</td></tr>
<tr>
<td class="maintd"><script type="text/javascript">CreateMenu();</script></td>
<td class="content">
<div>
<!-- Begin Content -->
<table cellpadding="2px" class="center-div">
<tr id="trCable" style="display:none">
<td>Cable</td>
<td style="text-align:right">
<form name="Cable" action="">
<select name="Select" size="1" style="width: 300px" onchange="SetSource(0,document.Cable.Select.selectedIndex)" >
</select>
</form>
</td>
</tr>
<tr id="trSat1" style="display:none">
<td>Satellite 1</td>
<td style="text-align:right">
<form name="Satellite1" action="">
<select name="Select" size="1" style="width: 300px" onchange="SetSource(1,document.Satellite1.Select.selectedIndex)" >
</select>
</form>
</td>
</tr>
<tr id="trSat2" style="display:none">
<td>Satellite 2</td>
<td style="text-align:right">
<form name="Satellite2" action="">
<select name="Select" size="1" style="width: 300px" onchange="SetSource(2,document.Satellite2.Select.selectedIndex)" >
</select>
</form>
</td>
</tr>
<tr id="trSat3" style="display:none">
<td>Satellite 3</td>
<td style="text-align:right">
<form name="Satellite3" action="">
<select name="Select" size="1" style="width: 300px" onchange="SetSource(3,document.Satellite3.Select.selectedIndex)" >
</select>
</form>
</td>
</tr>
<tr id="trSat4" style="display:none">
<td>Satellite 4</td>
<td style="text-align:right">
<form name="Satellite4" action="">
<select name="Select" size="1" style="width: 300px" onchange="SetSource(4,document.Satellite4.Select.selectedIndex)" >
</select>
</form>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td style="text-align:right">
<form action="">
<input id="StatusButton" type="Button" value="Get Status" onclick="PollStatus()" >
<input id="ScanButton" type="Button" value="Start Channel Scan" onclick="InitiateScan()" >
<input id="EpgButton" type="Button" value="Start EPG Scan" onclick="InitiateEPGScan()" >
</form>
</td>
</tr>
<tr>
<td>
<div id="scancount" style="text-align:right">&nbsp;</div>
</td>
<td>
<div id="scantext" style="text-align:left">&nbsp;</div>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td style="text-align:right">
<form action="">
<input id="DeleteButton" type="Button" value="Delete Channel List" onclick="DeleteScan()" >
<input id="RestoreButton" type="Button" value="Restore Previous Channel List" onclick="RestoreScan()" >
</form>
</td>
</tr>
<tr>
<td colspan="2" style="text-align:right">
<form action="" method="post" enctype="multipart/form-data" onsubmit="Uploader(event)">
<input id="UploadList" type="file" name="filename" value="*.json" size="30" accept=".json">
<input id="UploadButton" type="submit" value="Upload">
</form>
</td>
</tr>
</table>
<hr/>
<div style="text-align: center">
<h4>Downloads</h4>
Channel List:
&nbsp;<a href="/channellist.lua?select=json">JSON</a>
&nbsp;<a href="/channellist.lua?select=m3u">M3U</a>
<br/>
Transponder List:
&nbsp;<a href="/channellist.lua?select=tl">Current</a>
&nbsp;<a href="/channellist.lua?select=stl">Default</a>
<br/>
<form action="">
<input id="DeleteAllButton" type="Button" value="Delete All" onclick="DeleteScan(true)" >
</form>
</div>
<hr/>
<h4 style="text-align: center">Old Format Lists</h4>
<table cellpadding="2px" class="center-div">
<tr>
<td>System Channel Database</td>
<td>
<table>
<tr>
<td>
<form action="dlchannels.lua" method="get">
<input type="submit" value="Download tar.gz" >
<input type="hidden" name="select" value="system" >
</form>
</td>
<td>
<form action="dlchannels.lua" method="get">
<input type="submit" value="Download zip" disabled >
<input type="hidden" name="select" value="system" >
</form>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>User Channel Database</td>
<td>
<table>
<tr>
<td>
<form action="dlchannels.lua" method="get">
<input type="submit" value="Download tar.gz">
<input type="hidden" name="select" value="user" >
</form>
</td>
<td>
<form action="dlchannels.lua" method="get">
<input type="submit" value="Download zip" disabled >
<input type="hidden" name="select" value="user" >
</form>
</td>
<td>
<form action="delchannels.lua" method="get">
<input type="submit" value="Delete">
</form>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan="2">
<form action="uplchannels.lua" method="post" enctype="multipart/form-data">
<input type="file" name="filename" value="*.gz" size="30" accept="application/zip,application/gzip">
<input type="submit" value="Upload">
</form>
</td>
</tr>
</table>
<!-- End Content -->
</div>
</td>
</tr>
<tr><td colspan="2">&nbsp;</td></tr>
</table>
</body>
</html>