SCIF settings page extended for 12 Tuner

This commit is contained in:
mvoelkel 2019-07-29 17:19:08 +02:00
parent f1e6470651
commit 82c51267bd
1 changed files with 58 additions and 108 deletions

View File

@ -12,6 +12,29 @@
<!-- Add page scripts here --> <!-- Add page scripts here -->
<script type="text/javascript"> <script type="text/javascript">
var xmlhttp = new XMLHttpRequest();
var url = "/octoserve/tunerstatus.json";
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState == 4 )
{
if( xmlhttp.status == 200 )
myFunction(xmlhttp.responseText);
}
}
function myFunction(response)
{
try
{
var tl = JSON.parse(response);
for(i= 0; i < tl.TunerList.length; i++ )
document.getElementById("trTuner"+i).style.display = "table-row";
}
catch(err) {}
}
SCIFEnabled = false; SCIFEnabled = false;
SelectedManufacturer = 0; SelectedManufacturer = 0;
SelectedUnit = 0; SelectedUnit = 0;
@ -20,13 +43,13 @@ TunerList = new Array();
function SetManufacturer(ManuIndex) function SetManufacturer(ManuIndex)
{ {
if( SCIFEnabled ) document.getElementById("SetButton").disabled = false; if( SCIFEnabled ) document.getElementById("SetButton").disabled = false;
SelectedManufacturer = ManuIndex; SelectedManufacturer = ManuIndex;
document.Unit.Select.length = 0; document.Unit.Select.length = 0;
for( j = 0; j < ManufacturerList[ManuIndex].UnitList.length; j++ ) for( j = 0; j < ManufacturerList[ManuIndex].UnitList.length; j++ )
{ {
document.Unit.Select.options[j] = new Option(ManufacturerList[ManuIndex].UnitList[j].Name,j, false, true); document.Unit.Select.options[j] = new Option(ManufacturerList[ManuIndex].UnitList[j].Name,j, false, true);
} }
SetUnit(ManufacturerList[ManuIndex].UnitList.length-1); SetUnit(ManufacturerList[ManuIndex].UnitList.length-1);
} }
@ -36,7 +59,7 @@ function SetUnit(UnitIndex)
if( SCIFEnabled ) document.getElementById("SetButton").disabled = false; if( SCIFEnabled ) document.getElementById("SetButton").disabled = false;
SelectedUnit = UnitIndex; SelectedUnit = UnitIndex;
for( i = 0; i < TunerList.length; i++ ) for( i = 0; i < TunerList.length; i++ )
{ {
TunerList[i].Select.length = 1; TunerList[i].Select.length = 1;
@ -53,7 +76,7 @@ function SetUnit(UnitIndex)
{ {
TunerList[i].Select.options[0].selected = true; TunerList[i].Select.options[0].selected = true;
} }
} }
} }
function SetSlot(Tuner,SlotIndex) function SetSlot(Tuner,SlotIndex)
@ -66,7 +89,7 @@ function SaveSettings()
if( SCIFEnabled ) if( SCIFEnabled )
{ {
CurUnit = ManufacturerList[SelectedManufacturer].UnitList[SelectedUnit]; CurUnit = ManufacturerList[SelectedManufacturer].UnitList[SelectedUnit];
Protocol = CurUnit.Protocol == "EN50607" ? '2' : '1'; Protocol = CurUnit.Protocol == "EN50607" ? '2' : '1';
param = 'Manufacturer='+SelectedManufacturer+'&Unit='+SelectedUnit+'&Type='+Protocol; param = 'Manufacturer='+SelectedManufacturer+'&Unit='+SelectedUnit+'&Type='+Protocol;
for( i = 0; i < TunerList.length; i++ ) for( i = 0; i < TunerList.length; i++ )
{ {
@ -75,16 +98,16 @@ function SaveSettings()
if( SelectedFrequency > 0 ) if( SelectedFrequency > 0 )
param += SelectedFrequency + ',' + CurUnit.Frequencies[SelectedFrequency-1]; param += SelectedFrequency + ',' + CurUnit.Frequencies[SelectedFrequency-1];
else else
param += '0'; param += '0';
} }
location.replace('/scifsettings.lua?'+param); location.replace('/scifsettings.lua?'+param);
} }
else else
{ {
location.replace('/scifsettings.lua?reset'); location.replace('/scifsettings.lua?reset');
} }
} }
function SetEnable() function SetEnable()
@ -97,23 +120,19 @@ function OnLoad()
{ {
SCIFEnabled = false; SCIFEnabled = false;
TunerList[0] = document.Tuner1; for( i = 0; i < 12 ; i++ )
TunerList[1] = document.Tuner2; {
TunerList[2] = document.Tuner3; TunerList[i] = document.getElementById("formTuner"+i);
TunerList[3] = document.Tuner4; }
TunerList[4] = document.Tuner5;
TunerList[5] = document.Tuner6;
TunerList[6] = document.Tuner7;
TunerList[7] = document.Tuner8;
document.Manufacturer.Select.length = 0; document.Manufacturer.Select.length = 0;
for( i = 0; i < ManufacturerList.length ; i++ ) for( i = 0; i < ManufacturerList.length ; i++ )
{ {
ManuName = ManufacturerList[i].Name; ManuName = ManufacturerList[i].Name;
if( ManuName == '' ) ManuName = "-----------------"; if( ManuName == '' ) ManuName = "-----------------";
document.Manufacturer.Select.options[i] = new Option(ManuName,i, false, true); document.Manufacturer.Select.options[i] = new Option(ManuName,i, false, true);
} }
for( i = 0; i < Tuner.length; i++ ) for( i = 0; i < Tuner.length; i++ )
{ {
if( Tuner[i].Slot > 0 ) SCIFEnabled = true; if( Tuner[i].Slot > 0 ) SCIFEnabled = true;
@ -141,6 +160,8 @@ function OnLoad()
document.getElementById("EnableButton").checked = SCIFEnabled; document.getElementById("EnableButton").checked = SCIFEnabled;
document.getElementById("SetButton").disabled = true; document.getElementById("SetButton").disabled = true;
xmlhttp.open("GET", url, true);
xmlhttp.send();
} }
</script> </script>
@ -169,7 +190,7 @@ function OnLoad()
<td>&nbsp;</td> <td>&nbsp;</td>
<td> <td>
<form action=""> <form action="">
<input id="EnableButton" type="checkbox" value="Check" checked="false" onclick="SetEnable()"> <input id="EnableButton" type="checkbox" value="Check" checked="false" onclick="SetEnable()">
Enable Unicable (EN 50494 / EN 50607) Enable Unicable (EN 50494 / EN 50607)
</form> </form>
</td> </td>
@ -196,93 +217,22 @@ function OnLoad()
</td> </td>
</tr> </tr>
<tr> <script type="text/javascript">
<td>Tuner 1</td> for( var i = 0; i < 12 ; i++ )
<td> {
<form name="Tuner1" action=""> // document.write('<tr id="trTuner'+i+'">');
<select name="Select" size="1" style="width: 300px" onchange="SetSlot(1,document.Tuner1.Select.selectedIndex)"> document.write('<tr id="trTuner'+i+'" style="display:none">');
<option>----</option> document.write('<td>Tuner ' + (i+1) + '</td>');
</select> document.write('<td>');
</form> document.write('<form name="Tuner'+(i+1)+'" id="formTuner'+i+'" action="">');
</td> document.write('<select name="Select" size="1" style="width: 300px" onchange="SetSlot(1,document.Tuner' +(i+1)+'.Select.selectedIndex)">');
</tr> document.write('</option>----</option>');
document.write('</select>');
<tr> document.write('</form>');
<td>Tuner 2</td> document.write('</td>');
<td> document.write('</tr>');
<form name="Tuner2" action=""> }
<select name="Select" size="1" style="width: 300px" onchange="SetSlot(2,document.Tuner2.Select.selectedIndex)"> </script>
<option>----</option>
</select>
</form>
</td>
</tr>
<tr>
<td>Tuner 3</td>
<td>
<form name="Tuner3" action="">
<select name="Select" size="1" style="width: 300px" onchange="SetSlot(3,document.Tuner3.Select.selectedIndex)">
<option>----</option>
</select>
</form>
</td>
</tr>
<tr>
<td>Tuner 4</td>
<td>
<form name="Tuner4" action="">
<select name="Select" size="1" style="width: 300px" onchange="SetSlot(4,document.Tuner4.Select.selectedIndex)">
<option>----</option>
</select>
</form>
</td>
</tr>
<tr>
<td>Tuner 5</td>
<td>
<form name="Tuner5" action="">
<select name="Select" size="1" style="width: 300px" onchange="SetSlot(5,document.Tuner5.Select.selectedIndex)">
<option>----</option>
</select>
</form>
</td>
</tr>
<tr>
<td>Tuner 6</td>
<td>
<form name="Tuner6" action="">
<select name="Select" size="1" style="width: 300px" onchange="SetSlot(6,document.Tuner6.Select.selectedIndex)">
<option>----</option>
</select>
</form>
</td>
</tr>
<tr>
<td>Tuner 7</td>
<td>
<form name="Tuner7" action="">
<select name="Select" size="1" style="width: 300px" onchange="SetSlot(7,document.Tuner7.Select.selectedIndex)">
<option>----</option>
</select>
</form>
</td>
</tr>
<tr>
<td>Tuner 8</td>
<td>
<form name="Tuner8" action="">
<select name="Select" size="1" style="width: 300px" onchange="SetSlot(8,document.Tuner8.Select.selectedIndex)">
<option>----</option>
</select>
</form>
</td>
</tr>
<tr><td colspan="2" align="right"> <tr><td colspan="2" align="right">
<div style="width: 300px"> <div style="width: 300px">
@ -293,7 +243,7 @@ function OnLoad()
</div> </div>
</td></tr> </td></tr>
</table> </table>
<!-- End Content --> <!-- End Content -->
</div> </div>
</td> </td>