var UpStreamColour = "#87ab8f" ;
var DownStreamColour = "#beb574" ;
var UpDownStreamOverlapColour = "#d95963" ;
var NegativeValueColour = "#7b7bc1" ;
function DisableEnableTable( TableId, CheckStatus)
{
if(CheckStatus == true)
{
document.getElementById(TableId).bgColor = "lightgrey";
}
else
{
document.getElementById(TableId).bgColor = "";
}
}
var offset = 1;
var BandNumber = 1;
var USBandNumber = 1;
var DSBandNumber = 1;
function InsertRow( Direction, StartVal , EndVal )
{
var CreateNewRow = 1;
var Number = 0;
var UStd = "";
var DStd = "";
if( Direction == "UpStream")
{
if( BandNumber > USBandNumber)
{
Number = USBandNumber;
}
else
{
Number = BandNumber;
USBandNumber++;
}
UStd = "
" ;
DStd = " ";
if( BandNumber > USBandNumber)
{
CreateNewRow = 0;
document.getElementById("USBand" + Number).innerHTML = UStd ;
USBandNumber++;
}
}
else
{
if( BandNumber > DSBandNumber)
{
Number = DSBandNumber;
}
else
{
Number = BandNumber;
DSBandNumber++;
}
DStd = " " ;
UStd = " ";
if( BandNumber > DSBandNumber)
{
CreateNewRow = 0;
document.getElementById("DSBand" + Number).innerHTML = DStd ;
DSBandNumber++;
}
}
if (CreateNewRow == 1)
{
var xx=document.getElementById('BandInfoTable');
var x=xx.insertRow(Number + offset);
var y=x.insertCell(0);
var z=x.insertCell(1);
y.innerHTML=""
z.innerHTML=""
var td = " " ;
y.id = "USBand" + Number;
z.id = "DSBand" + Number;
y.width = "50%";
z.width = "50%";
y.innerHTML = UStd ;
z.innerHTML = DStd ;
BandNumber++;
}
}
function ShowRawValuesInTable(doc, Title, UpSize, UpValueList , DownSize, DownValueList , base )
{
var MaxSize = 0;
if( UpSize > DownSize)
{
MaxSize = UpSize;
}
else
{
MaxSize = DownSize;
}
var table = "" ;
table += "";
table += " | " ;
table += " UpStream " + Title + " | ";
table += " DownStream " + Title + " | ";
table += "
" ;
table += "Tones | " ;
table += " | " ;
table += " | " ;
table += "
" ;
var tr="";
doc.write(table);
for (i = 0; i < MaxSize; i +=10 )
{
tr = "" ;
tr += "" + i + " | " ;
tr += "" ;
for (j = 0; j < 10; j++ )
{
UpValue = parseInt(UpValueList[i+j], base);
DownValue = parseInt(DownValueList[i+j], base);
if( ( UpValue > 0) && ( ( DownValue > 0) || ( DownValue < 0) ) )
{
tr += " " + UpValue + " | " ;
}
else if( UpValue < 0)
{
tr += " " + UpValue + " | " ;
}
else
{
tr += " " + UpValue + " | " ;
}
}
tr += "
| " ;
tr += "" ;
for (j = 0; j < 10; j++ )
{
UpValue = parseInt(UpValueList[i+j], base);
DownValue = parseInt(DownValueList[i+j], base);
if( ( DownValue > 0) && ( ( UpValue > 0) || ( UpValue < 0) ) )
{
tr += " " + DownValue + " | " ;
}
else if( DownValue < 0)
{
tr += " " + DownValue + " | " ;
}
else
{
tr += " " + DownValue + " | " ;
}
}
tr += "
| " ;
tr += "
" ;
doc.write(tr);
}
doc.write("
");
}
function doCompleteBarGraph( doc, yTitle, xTitle, yDiff, xDiff, yFactor, xFactor, yMaxSize, UpSize, UpValueList , DownSize, DownValueList , base )
{
var xMaxSize = 0;
if( UpSize > DownSize)
{
xMaxSize = UpSize ;
}
else
{
xMaxSize = DownSize;
}
xFactorSize = xMaxSize* xFactor ;
yFactorSize = yMaxSize* yFactor ;
doBarGraphTop(doc, yTitle, xFactorSize);
doBarGraphTableStart(doc, yTitle, xFactorSize , yFactorSize);
doLeftBar(doc, "black", yMaxSize, yDiff, yFactor);
doAllBarsWrite(doc, yFactor, xFactor, yMaxSize, UpSize, UpValueList , DownSize, DownValueList , base );
doBarGraphTableEnd(doc );
doHorizantalBar(doc, "black", (xFactorSize+ xDiff),3 );
doAxisWrite(doc, xTitle, xDiff, xMaxSize, xFactor );
}
function doBarGraphColorInfo(doc, color,Title)
{
var table = " ";
table = " " ;
table += " " ;
table += " " + Title + " | ";
table += "
" ;
table += "
" ;
doc.write(table);
}
function doBGColorInfoStart(doc )
{
var table = " ";
table = " " ;
table += " " ;
table += " | ";
doc.write(table);
}
function doBGColorInfo(doc, color,Title,width)
{
var td = " ";
td += " " + Title + " | ";
td += " | ";
doc.write(td);
}
function doBGColorInfoEnd(doc, color,Title)
{
var table = " ";
table += "
" ;
table += "
" ;
doc.write(table);
}
function doBarGraphTableStart(doc, yTitle, xFactorSize , yFactorSize)
{
var table = " ";
table = "";
doc.write(table);
}
function doBarGraphTableEnd(doc)
{
doc.write("
");
}
function doBarGraphTop(doc, Title, Size)
{
var table = " ";
var TmpSize = 0;
TmpSize = Size +45;
table = " " ;
table += " " ;
table += " | ";
table += " " + Title+ " | ";
table += "
" ;
table += "
" ;
doc.write(table);
}
function doLeftBar(doc, color, height, diff, mulfactor)
{
var td = " ";
var difffactor = 0 ;
var initheight = 0 ;
var barheight = 0 ;
var loop = 0 ;
difffactor = (diff / mulfactor);
ActualBarHeight = ( mulfactor * height);
initheight = (diff/ 2);
loop = ( height / diff ) * mulfactor ;
barheight = ActualBarHeight + initheight;
td = " " ;
for (i=loop; i>=1; i--)
{
td += "" +(i* difffactor )+"- | ";
}
td += " | ";
td += " ";
td += " | ";
doc.write(td);
td = "";
td +="";
td += " | ";
doc.write(td);
}
function doAllBarsWrite(doc, yFactor, xFactor, yMaxSize, UpSize, UpValueList , DownSize, DownValueList , base )
{
var UpValue = 0;
var DownValue = 0;
var xMaxSize = 0;
var xFactorSize = 0;
var yFactorSize = 0;
if( UpSize > DownSize)
{
xMaxSize = UpSize ;
}
else
{
xMaxSize = DownSize;
}
xFactorSize = xMaxSize* xFactor ;
yFactorSize = yMaxSize* yFactor ;
var width = 1;
if ( xFactor > 1)
{
width *= xFactor;
}
var Colour = " ";
var Value = 0;
for (i = 0; i < xMaxSize; i++)
{
if ( xFactor < 1)
{
if( ( i % (1/xFactor) ) != 0)
{
continue;
}
}
if((UpSize > i) && (DownSize> i) )
{
UpValue = parseInt(UpValueList[i], base);
DownValue = parseInt(DownValueList[i], base);
if( (UpValue < 0) || (DownValue < 0) )
{
if(UpValue < DownValue)
{
Colour = NegativeValueColour;
Value = UpValue * -1;
}
else
{
Colour = NegativeValueColour;
Value = DownValue * -1 ;
}
}
else if( (UpValue != 0) && (DownValue == 0) )
{
Colour = UpStreamColour;
Value = UpValue ;
}
else if( (UpValue == 0) && (DownValue != 0) )
{
Colour = DownStreamColour;
Value = DownValue ;
}
else if( UpValue > DownValue )
{
Colour = UpDownStreamOverlapColour;
Value = UpValue ;
}
else
{
Colour = UpDownStreamOverlapColour;
Value = DownValue ;
}
}
else if(UpSize > i)
{
UpValue = parseInt(UpValueList[i], base);
if( UpValue < 0 )
{
Colour = NegativeValueColour;
Value = UpValue * -1;
}
else
{
Colour = UpStreamColour;
Value = UpValue ;
}
}
else
{
DownValue = parseInt(DownValueList[i], base);
if( DownValue < 0 )
{
Colour = NegativeValueColour;
Value = DownValue * -1;
}
else
{
Colour = DownStreamColour ;
Value = DownValue ;
}
}
doBarGraphWrite(doc, Colour, ((Value *yFactor) % (yFactorSize +1)), width);
}
}
function doBarGraphWrite(doc, color,height,width)
{
var td = " ";
td += " | ";
doc.write(td);
}
function doHorizantalBar(doc, color,width,height)
{
var table = " ";
var TmpWidth;
TmpWidth = width +45;
table += " ";
doc.write(table);
}
function doAxisWrite(doc, xTitle, Gap, Size, xFactor )
{
var td = " ";
var table = " ";
var i;
var xFactorSize = Size * xFactor ;
var TmpSize = xFactorSize +45 + Gap ;
var FactorGap = Gap *(1/xFactor);
var loop = Size / FactorGap ;
var r_loop = Math.round( loop ) ;
if(loop >= r_loop )
{
loop = r_loop ;
}
else
{
loop = r_loop -1;
}
var RemainGap = ( (Size - (loop*FactorGap))* xFactor);
var MiddlePosition = Math.round(loop/2);
table += ""
doc.write(table);
doc.write("");
td = "";
td += "";
td += " | " ;
doc.write(td);
for (i=0; i< loop ;i++)
{
td = "";
td += (i * FactorGap ) ;
td += " | " ;
doc.write(td);
}
if( (loop*FactorGap) < Size)
{
td = "";
td += " ";
td += " | " ;
doc.write(td);
}
td = "";
td += Size ;
td += " | " ;
doc.write(td);
doc.write("
");
doc.write("");
td = "";
td += "";
td += " | " ;
doc.write(td);
for (i=0; i< loop ;i++)
{
if( i == MiddlePosition )
{
td = "";
td += xTitle ;
td += " | " ;
doc.write(td);
}
else
{
td = "";
td += " | " ;
doc.write(td);
}
}
if( (loop*FactorGap) < Size)
{
td = "";
td += " | " ;
doc.write(td);
}
td = "";
td += " | " ;
doc.write(td);
doc.write("
");
doc.write("
");
}