var browser = getBrowser();
function getBrowser() {
if (navigator==null)
{
return null;
}
return navigator.appName;
}
//if( isIE() ) {
// document.write( "" );
//}
//else {
// document.write( "" );
//}
function isIE5up() {
if( browser == "Microsoft Internet Explorer" ) {
return( true );
}
return( false );
}
var AJAXDebug=0;
///////////
// Function to generate progress image. This would probably be replace
// with server side include.
//
function formatProgressPanel()
{
var txt = '
'+ top.formatProgressMsg + ' |

|
';
document.write( txt );
}
var requestCtxt = new Object();
requestCtxt.m_fieldMapping = null;
requestCtxt.updateComplete = null;
//
var FieldMapping;
FieldMapping.TYPE_HTML = 0;
FieldMapping.TYPE_TEXT = 1;
FieldMapping.TYPE_CHECKBOX = 2;
FieldMapping.TYPE_SELECT = 3;
FieldMapping.TYPE_RADIO = 4;
FieldMapping.TYPE_CALLBACK = 5;
var xmlRequestObject;
var Cell;
Cell.ICON = 0;
Cell.CONTENT = 1;
Cell.BLANK = 2;
Cell.HIDDEN = 3;
function Cell(type, value, align)
{
this.m_type = type;
this.m_value = value;
this.m_align = align;
}
///////////////////////////////////////////////////////////////
//
//Each field has a fieldName and a dataName.
// The fieldName is used to map the field to the display value on a page,
// if there is no field name then the field is only accessed on
// edits. In this way a page can iterate through all values returned by
// the server to populate data for the page, but still skip element that
// have no display value that would otherwise cause a "field xxxx not found"
// message to be displayed.
function FieldMapping( n, d, type, encoder, decoder )
{
//fieldName used for displaying data
this.m_fieldName = n;
//dataName used for updating data
this.m_dataName = d == null ? n : d;
this.m_type = type == null ? FieldMapping.TYPE_HTML : type;
this.m_encoder = encoder == null ? encodeText : encoder;
this.m_decoder = decoder == null ? decodeText : decoder;
}
//Convenience object that "extends" FieldMapping with specific checkbox behaviors pre-defined.
function CheckboxMapping( n, d )
{
return new FieldMapping(n, d, FieldMapping.TYPE_CHECKBOX, encodeCheckbox, decodeBoolean);
}
//Convenience object that "extends" FieldMapping with specific radio button behaviors pre-defined.
function RadioMapping( n, d )
{
return new FieldMapping(n, d, FieldMapping.TYPE_RADIO, encodeRadio, decodeRadio);
}
/////////////////////////////////////
//
function encodeSetValue( text )
{
if( text == null )
return "";
else
{
var newUrl = text.replace(/\\/g, "\\\\" );
newUrl = newUrl.replace(/:/g, "\\:" );
// ConnectionHandler's tokenizer uses: (),=&?
newUrl = newUrl.replace(/,/g, "\\," );
newUrl = newUrl.replace(/\(/g, "\\(" );
newUrl = newUrl.replace(/\)/g, "\\)" );
newUrl = newUrl.replace(/\=/g, "\\=" );
newUrl = newUrl.replace(/&/g, "\\&" );
newUrl = newUrl.replace(/\?/g, "\\?" );
return encodeURIComponent(newUrl);
}
}
////////////////////////////////////
// Function to encode text fields.
function encodeText( formElement )
{
return encodeSetValue( formElement.value );
}
////////////////////////////////////
// Function to encode checkbox's as 1=true or 0=false.
function encodeCheckbox( formElement )
{
return formElement.checked ? "1" : "0";
}
////////////////////////////////////
// Function to encode checkbox's as 1=true or 0=false.
function encodeSelect( formElement )
{
if( formElement.selectedIndex >= 0 )
{
//alert("call to encodeSelect: " + formElement.options[ formElement.selectedIndex ].value);
return formElement.options[ formElement.selectedIndex ].value;
}
else
return '';
}
////////////////////////////////////
// Function to encode checkbox's as 1=true or 0=false.
function encodeRadio( formElement )
{
for( var i=0 ; i 1 )
{
var elem = formElement.elements[0];
req = elem.name + ":" + encodeSetValue( elem.value );
//
for( var i=1 ; i 0 && elements[0].childNodes != null )
{
if( elements[0].childNodes.length == 0 )
return null;
else if( elements[0].childNodes[0].nodeType == 3){
var j = elements[0].childNodes.length;
for (i = 0; i < j; i++){
rtn = rtn + elements[0].childNodes[i].nodeValue;
}
//Fix for FireFox. Long returns are broken up into 4096 byte child nodes. IE is all in one.
//alert("rtn len=" + rtn.length + "ChildNode count=" + j + "\n" );
}
else {
rtn = elements[0];
}
}
}
return rtn
}
/****************************************************************
This version was changed by Adam G. and is commented out for now
because it doesn't work for a list of nodes, e.g. tempSensorList.
The version above is the old one.
////////////////////////////////////////////////////////////////////
//
//TODO: there is something not quite right here. If you have a node
// with only one value then the data doesn't get returned correctly.
function getXMLValue( xmlDoc, elementName )
{
//alert("getXMLValue( xmlDoc, " + elementName + ");");
var rtn = null;
//
if( xmlDoc == null || xmlDoc.childNodes.length == 0 )
{
alert("Received bad XML document.");
}
else
{
var elements = xmlDoc.getElementsByTagName( elementName );
//
if( elements != null && elements.length > 0 && elements[0].childNodes != null && elements[0].childNodes.length > 0 )
{
//if( elements[0].hasChildNodes )
// alert(" Found(" + elements[0].tagName + "): " + elements[0] + ", with childCount: " + elements[0].childNodes.length + ", " + elements[0] );
//else
// alert(" Element: " + elements[0].tagName + " does not have children.");
//
//The logic here wasn't quite right, at least not for returning XML
// snippets. Changed it so that if the requested element has a child
// node that is text (e.g. my text would be an element
// with a child that is text) return the text value, otherwise return
// the element
if (elements[0].hasChildNodes)
{
if (elements[0].childNodes[0].nodeType==3)
{
rtn = elements[0].childNodes[0].nodeValue;
}
else
{
rtn = elements[0]
}
}
//Otherwise return the node itself...
else //if (elements[0].hasChildNodes())
{
//alert(" getXMLValue: " + elements[0].childNodes[0].childNodes.length );
rtn = elements[0];
}
//else
//{
//alert(" getXMLValue: " + elements[0].childNodes[0].nodeValue );
// rtn = elements[0].childNodes[0].nodeValue;
//}
}
}
//
return rtn;
}
***********************************************************************/
/////////////////////////////////////////////////////////////////////////
//
// Requests the XML document.
//
//Lets load the WebPage defined by url ( output should be xml )r
//If we are using IE then we will use microsoft ActiveX Object, there are
//two microsoft objects we can try. If the first fails, move to second one.
//if not IE then we will use the defined JS object XMLHttpRequest().
//
function loadXMLDocument( url, callback, postData )
{
var xDoc;
//
if( window.XMLHttpRequest )
{
xmlRequestObject = new XMLHttpRequest();
}
else if( window.ActiveXObject )
// if( window.ActiveXObject )
{
try
{
xmlRequestObject = new ActiveXObject("Msxml2.XMLHTTP");
// alert("XMLHttpRequest is executed");
}
catch ( e )
{
try
{
xmlRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
}
catch ( E )
{
}
}
}
//
if( xmlRequestObject )
{
xmlRequestObject.onreadystatechange = callback;
xmlRequestObject.open("POST", url, true );
if( postData == null )
postData = '';
xmlRequestObject.setRequestHeader("Content-Type", "application/x-www-form-urlencoded" );
xmlRequestObject.send( postData );
}
}
function getXMLTagByName( xmlDoc, name )
{
var tagList = xmlDoc.getElementsByTagName( name );
var rtn = null;
//
if( tagList.length > 0 )
rtn = tagList[0];
return rtn;
}
function setTextField( fieldId, value )
{
var elem = document.getElementById( fieldId );
if( elem != null && elem.value != undefined )
{
if (value == null)
elem.value = '';
else
elem.value = value;
}
// else
// showErrorMessage(" text field (" + fieldId + ") not found.");
}
function setDiv( fieldId, value )
{
//alert( "setDiv(" + fieldId + ", value=" + value + ")" );
var elem = document.getElementById(fieldId);
//this is the element in the HTML page
if (elem != null)
{
//if ("outerHTML" == elem)
if ("innerText" in elem && "outerHTML" in elem)
//if (elem.tagName == "PRE" && "outerHTML" in elem)
{
//if (elem.parentNode.tagName == "PRE")
//{
//elem.outerHTML = ((value == null) ? "" : "" + value + "
");
// elem.outerHTML = "" + value + "
";
elem.innerText= value;
elem.textContent=value;
//}
//else
//{
//elem["outerHTML"] = ((value == null) ? "" : value);
//elem.outerHTML ="";
//}
}
//else if (elem.innerHTML != null)
else
{
//elem.innerHTML = ((value == null) ? "" : value);
elem.innerHTML = value;
}
}
// if( elem != null && elem.value != undefined )
// elem.innerHTML = value;
// else
// showErrorMessage(" div (" + fieldId + ") not found.");
//return elem.value;
}
function setCheckbox( fieldId, value ) {
var val = false;
if( value != undefined )
val = trim(value) == "0" ? false : true;
//
var elem = document.getElementById( fieldId );
if( elem != null && elem.checked != undefined )
elem.checked = val == "0" ? false : true;
}
function setRadio( formElement, fieldName, value ) {
var val = false;
if( value != null )
{
for( var i=0 ; i
|
";
elem.style.display = 'block';
}
function validateHostName( name ) {
var hostPattern = /([a-zA-Z0-9][a-zA-Z0-9-]{0,64})/;
var result = name.match( hostPattern );
//
if( result == null || result[1].length != name.length )
return 1;
else
return 0;
}
function validateIP( address ) {
var isValid = 0;
//
if( address == null | address == "0.0.0.0" || address == "255.255.255.255" ||
address.indexOf( "127." ) == 0 )
isValid = 1;
else {
var ipPattern = /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/;
var segArray = address.match(ipPattern);
//
if( segArray == null || segArray.length != 5 )
isValid = 2;
else {
var length = 0;
for( i=1; i 255 ) {
isValid = 3;
break;
}
}
//=
if( length + 3 != address.length )
return 4;
}
}
//
return isValid;
}
function isValidatePort( elemId )
{
var elem = document.getElementById( elemId );
if( elem == null ) {
alert('Element (' + elemId + ') not found.');
return 1;
}
else
{
var portNum = elem.value;
return portNum > 0 && portNum <= 65535 ? 0 : 1;
}
}
////////////////////////////////////////////////////////////////////
//
function ipmiPrivToName( type )
{
var name = "Unknown";
if( type == 15 )
name = top.noneRole;//None
if( type == 2 )
name = top.userRole;//User
else if( type == 3 )
name = top.operatorRole//"Operator";
else if( type == 4 )
name = top.adminRole//"Administrator"; //bug 28907 (shows "Admin". want "Administrator")
return name;
}
function detectOS()
{
var agt = navigator.userAgent.toLowerCase();
bWindows = false;
bLinux = false;
if ((agt.indexOf("win95")!=-1) ||(agt.indexOf("windows 95")!=-1)) bWindows=true;
if ((agt.indexOf("win98")!=-1) ||(agt.indexOf("windows 98")!=-1)) bWindows=true;
if ((agt.indexOf("winnt")!=-1) ||(agt.indexOf("windows nt")!=-1)) bWindows=true;
if ((agt.indexOf("linux")!=-1)) bLinux = true;
}
function showUpdateArea()
{
hideElement( 'contentArea' );
hideElement('progressScreen');
showInlineElement('updateArea');
}
function appendTableRow(logData)
{
var aTable = document.getElementById('tempTable');
var newRowIndex = aTable.rows.length;
//doesn't seem to be a way to set style="height: 1px;" for blank.gif rows...
// but it also doesn't seem to affect table layout.
var tr = aTable.insertRow(newRowIndex);
insertBlankCell(tr, 0);
insertBlankCell(tr, 1);
var cell = tr.insertCell(2);
populateCell(cell, newRowIndex, logData.name, 'left');
insertBlankCell(tr, 3);
cell = tr.insertCell(4);
populateCell(cell, newRowIndex, logData.reading, 'center');
insertBlankCell(tr, 5);
cell = tr.insertCell(6);
populateCell(cell, newRowIndex, logData.minWarning, 'center');
insertBlankCell(tr, 7);
cell = tr.insertCell(8);
populateCell(cell, newRowIndex, logData.maxWarning, 'center');
insertBlankCell(tr, 9);
cell = tr.insertCell(10);
populateCell(cell, newRowIndex, logData.minFailure, 'center');
insertBlankCell(tr, 11);
cell = tr.insertCell(12);
populateCell(cell, newRowIndex, logData.maxFailure, 'center');
}
/**
* Callback used with loadXMLDocument. This function will
* be called each time the xmlRequestObject's readyState changes.
* When the readyState is 4, indicating that processing is
* complete, the status is checked. If the status is ok then
* the method document.chainedCallback will be called. document.chainedCallback
* should be defined at the page level prior to calling loadXMLDocument.
*/
function waitWithCallback()
{
//Only execute for state "loaded", all other states have
// no processing.
if (xmlRequestObject.readyState == 4)
{
// only if "OK"
if (xmlRequestObject.status == 200 )
{
var xmlDoc = xmlRequestObject.responseXML;
var reqStatus = getXMLValue( xmlDoc, 'status' );
if( reqStatus != 'ok' )
{
var message = getXMLValue( xmlDoc, 'message' );
//alert(" Request failed: " + message );
//If we fail perform the callback with a null doc
// to signal the chainedCallback that the server'
// did not recognize the request
document.chainedCallback(null);
}
else
{
//It might be wise at somepoint to implement
// chainedCallback as a stack to avoid accidentally
// stepping on a callback by overwriting it with
// a value that hasn't been called back yet. This
// would introduce substantial complexity though...
document.chainedCallback(xmlDoc);
if( requestCtxt.updateComplete != null)
{
requestCtxt.updateComplete( requestCtxt, xmlDoc );
}
}
}
else if( xmlRequestObject.status == 401 )
{
document.location = "/login.html";
}
else
{
//showErrorMessage(" Could not retrieve data from server ( status=" +
// xmlRequestObject.status + ", " + xmlRequestObject.statusText + ")" );
showContentPanel();
}
}
} //end of waitWithCallback
/**
* Rows alternate styles, this method provides a mechanism
* for changing the style based on the row index.
*/
function getStyleForRow(tableRowIndex) {
return (tableRowIndex % 2 == 0) ? 'data-area-canvas-odd' : 'data-area-canvas-even';
}
function insertBlankCell(tr, cellIndex)
{
var cell = tr.insertCell(cellIndex);
cell.className=getStyleForRow(tr.rowIndex);
cell.innerHTML='
';
}
/********************************************************************
function populateCell(cell, tableRowIndex, innerHTML, align)
{
cell.className=getStyleForRow(tableRowIndex);
cell.vAlign='middle';
//cell.align='align';
cell.innerHTML = (innerHTML == ' ') ? '[N/A]' : innerHTML;
}
*********************************************************************/
function populateCell(cell, tableRowIndex, innerHTML, align, cellType)
{
cell.className=getStyleForRow(tableRowIndex);
cell.vAlign='middle';
if (align !=null)
{
cell.align=align;
}
if (cellType == null)
{
//Don't interpret no type as unknown, default to content.
cellType = Cell.CONTENT;
}
switch (cellType)
{
case Cell.ICON:
cell.innerHTML="
";
break;
case Cell.CONTENT:
cell.innerHTML = (innerHTML == ' ') ? '[N/A]' : innerHTML;
break
case Cell.BLANK :
cell.innerHTML='
';
break;
case Cell.HIDDEN :
cell.innerHTML='' + innerHTML + ''
break;
default:
showErrorMessage("Unknown type for cell, cell - " + celltype);
break;
}
}
/**
* Submit a request for data to the server and call
* refreshDataCallback when the response arrives.
*/
function refreshData(data)
{
document.chainedCallback = refreshDataCallback;
loadXMLDocument('data?get=' + data, waitWithCallback);
}
/**********************************************************************************
function appendTableRow(table,row)
{
var aTable = document.getElementById(table);
var newRowIndex = aTable.rows.length;
//doesn't seem to be a way to set style="height: 1px;" for blank.gif rows...
// but it also doesn't seem to affect table layout.
var tr = aTable.insertRow(newRowIndex);
for (i = 0; i < row.length; i++)
{
switch (row[i].m_type)
{
case Cell.ICON:
cell = tr.insertCell(i);
cell.innerHTML="
";
break;
case Cell.CONTENT:appendTableRow
cell = tr.insertCell(i);
populateCell(cell, newRowIndex, row[i].m_value, row[i].m_align);
break;
case Cell.BLANK:
insertBlankCell(tr, i);
break;
default:
showErrorMessage("undefined value in row's cell " + i);
break;
}
}
}
************************************************************************************/
function appendTableRow(table,row)
{
var aTable = document.getElementById(table);
if (null == aTable)
return;
var newRowIndex = aTable.rows.length;
//doesn't seem to be a way to set style="height: 1px;" for blank.gif rows...
// but it also doesn't seem to affect table layout.
var tr = aTable.insertRow(newRowIndex);
for (i = 0; i < row.length; i++)
{
cell = tr.insertCell(i);
populateCell(cell, newRowIndex, row[i].m_value, row[i].m_align, row[i].m_type);
}
}
function clearTableRows(tableName, startRow, endRow)
{
aTable = document.getElementById(tableName);
if (aTable == null || aTable.rows.length==0)
{
//Nothing to do.
return;
}
if (startRow == null)
{
startRow = 0;
}
if (endRow == null || endRow > aTable.rows.length)
{
endRow = aTable.rows.length;
}
//Delete at the starting point until
// the number of rows between start and end
// are gone.
for (var x=startRow; x < endRow; x++)
{
aTable.deleteRow(startRow);
}
}
function trim(str)
{
if (str == null || str==undefined )
{
return str;
}
str = str.replace(/^\s*/gi, "");
str = str.replace(/\s*$/gi, "");
return str;
}
function isEmpty( str )
{
return trim(str).length == 0;
}
var IPV6_ALLOWED_COLONS = 7;
var IPV6_IPV4_ALLOWED_COLONS = 5;
/* This function will verify IPV6 address in the following format
* x:x:x:x:x:x:x:x or compressed format
* x - represents valid ipv6
*/
var ipV6Pattern = new RegExp("^([0-9,A-F,a-f]{0,4})\:([0-9,A-F,a-f]{0,4})\:([0-9,A-F,a-f]{0,4})\:([0-9,A-F,a-f]{0,4})\:([0-9,A-F,a-f]{0,4})\:([0-9,A-F,a-f]{0,4})\:([0-9,A-F,a-f]{0,4})\:([0-9,A-F,a-f]{1,4})$");
var ipV6Pattern2 = new RegExp("^([0-9,A-F,a-f]{0,4})\:([0-9,A-F,a-f]{0,4})\:([0-9,A-F,a-f]{0,4})\:([0-9,A-F,a-f]{0,4})\:([0-9,A-F,a-f]{0,4})\:([0-9,A-F,a-f]{0,4})\:([0-9,A-F,a-f]{0,4})\:([0-9,A-F,a-f]{1,4})$");
function isIPV6(str)
{
var tStr = trim(str);
var validIPv6 = true;
if (tStr.length > 60 || tStr.length < 2 ) { return false; }
var bCompressedFormat = false;
if (tStr.indexOf("::")>-1)
{
bCompressedFormat = true;
if (tStr == "::") return true; //Valid unspecified ipv6 address
}
if (validIPv6 && bCompressedFormat)
validIPv6 = isIPV6Format(str,IPV6_ALLOWED_COLONS);
// IPv6 prefrerred format check x:x:x:x:x:x:x:x
// Check this if ipv6 is not in compressed format
if (validIPv6 && !bCompressedFormat && !ipV6Pattern.test(str))
{
//alert("invalid format");
validIPv6 = false;
}
return validIPv6;
}
/*
*mixed environment of IPv4 and IPv6 nodes is
x:x:x:x:x:x:d.d.d.d, where the 'x's are the hexadecimal values of
the six high-order 16-bit pieces of the address, and the 'd's are
the decimal values of the four low-order 8-bit pieces of the
address (standard IPv4 representation). Examples:
0:0:0:0:0:0:13.1.68.3
0:0:0:0:0:FFFF:129.144.52.38
or in compressed form:
::13.1.68.3
::FFFF:129.144.52.38
*
*/
/* This function will verify IPV6 address in the following format
* x:x:x:x:x:x:y.y.y.y
* x - represents valid ipv6
* y - represents valid ipv4
*/
var ipV6PatternWithIPV4 = new RegExp("^([0-9,A-F,a-f]{0,4})\:([0-9,A-F,a-f]{0,4})\:([0-9,A-F,a-f]{0,4})\:([0-9,A-F,a-f]{0,4})\:([0-9,A-F,a-f]{0,4})\:([0-9,A-F,a-f]{1,4})$");
function isIPV6WithIPV4(str)
{
var validIP = true;
var tStr = str;
//Mixed IPv6 and IPV4 str length should be less than 45 and greater than 8
if (tStr.length > 45 || tStr.length<8)
{
validIP = false;
}
if (validIP && tStr.indexOf(".")==-1)
{
validIP = false;
}
//Split ipv6 and ipv4
if (validIP)
{
var dotPos = tStr.indexOf(".");
var ipv4Str = tStr.substring(tStr.lastIndexOf(":",dotPos)+1);
if (isIPV4(ipv4Str))
{
var tempStr = tStr.substring(0,tStr.lastIndexOf(":",dotPos)+1);
var ipv6Str = "";
if (tempStr.lastIndexOf("::")==tempStr.length-2)
{
ipv6Str = tempStr;
}
else
{
ipv6Str = tempStr.substring(0,tempStr.lastIndexOf(":"));
}
//ipv6 validation.
if (ipv6Str.length > 29 || ipv6Str.length < 2)
{
validIP = false;
}
var bCompressedFormat = false;
if (tStr.indexOf("::")>-1)
{
bCompressedFormat = true; //Valid unspecified ipv6 address
if (tStr == "::")
validIP = true;
}
if (validIP && bCompressedFormat)
validIP = isIPV6Format(ipv6Str,IPV6_IPV4_ALLOWED_COLONS);
// IPv6 prefrerred format check x:x:x:x:x:x:x:x
// Check this if ipv6 is not in compressed format
if (validIP && !bCompressedFormat && !ipV6PatternWithIPV4.test(ipv6Str))
{
//alert("invalid format");
validIP = false;
}
}
else
{
validIP = false;
}
}
return validIP;
}
/* This function will verify IPV6 address in the following format
* x:x:x:x:x:x/z
* x - represents valid ipv6
* z - represents prefix
*/
function isIPV6WithPrefix(str)
{
tStr = str;
validIP = true;
if (tStr.indexOf("/")==-1)
{
validIP = false;
}
if (validIP)
{
var prefixStr = tStr.substring(tStr.indexOf("/")+1);
if (isNumeric(prefixStr))
{
var ipv6Str = tStr.substring(0,tStr.indexOf("/")) ;
if (!isIPV6(ipv6Str))
validIP = false;
}
else
{
validIP = false;
}
}
return validIP;
}
/* This function will verify IPV6 address in the following format
* x:x:x:x:x:x:y.y.y.y/z
* x - represents valid ipv6
* y - represents valid ipv4
* z - represents prefix
*/
function isIPV6WithIPV4AndPrefix(str)
{
tStr = str;
validIP = true;
if (tStr.indexOf("/")==-1 || tStr.indexOf(".")==-1)
{
validIP = false;
}
if (validIP && tStr.length > 47 || tStr.length<11)
{
validIP = false;
}
if (validIP)
{
var ipv6AndIPV4Str = tStr.substring(0,tStr.indexOf("/"));
validIP = isIPV6WithIPV4(ipv6AndIPV4Str);
}
if (validIP)
{
var prefixStr = tStr.substring(tStr.indexOf("/")+1)
validIP = isNumeric(prefixStr);
}
return validIP;
}
//This function should not be call from outside of function.js
function isIPV6Format(str,allowedColons)
{
var tStr = str;
var ipv6Format = true;
var bCompressedFormat = false;
//Double colons may be used only once in an IP address
var dColonStr = tStr.split("::");
if (dColonStr.length > 2 )
{
ipv6Format = false;
}
var colonCount = countSingleColonOccurance(str);
if(colonCount > allowedColons-2)
{
ipv6Format = false;
}
if (ipv6Format)
{
for(var i=0;i -1)
{
var sColonStr = dColonStr[i].split(":");
for(var j=0;j-1)
{
if (strVal.indexOf("::")>-1)
{
var dColonStr = strVal.split("::");
for(var i=0;i-1)
{
ipv6Addr = ipv6Addr.substring(0,ipv6Addr.indexOf(".")); //Removing ipv4 if exist
ipv6Addr = ipv6Addr.substring(0,ipv6Addr.lastIndexOf(":"))//Removing ipv4 if exist
if (ipv6Addr == loopBackAddr)
return true;
}
var str = ipv6Addr.substring(0,ipv6Addr.lastIndexOf(":"));
str = str.replace(/:/g, "" );
if (!validchars.test(str))
return false;
var tempStr = ipv6Addr.substring(ipv6Addr.lastIndexOf(":")+1)//Taking last position of ipv6
if (parseInt(tempStr) == 1)
return true;
else
return false;
}
//This function is used to test Ipv6 address is multicast address Starting with(FFxx::) or not
//This function should be called after validating ipv6
function isMulticastAddr(ipv6Addr)
{
var multicastAddr = ipv6Addr.substring(0,ipv6Addr.indexOf(":"));
multicastAddr = multicastAddr.toUpperCase();
if (multicastAddr.indexOf("FF")==0)
return true;
else
return false;
}
function isIpv6AsDoubleColon(ip6Addr)
{
var notValidchars = /^[0-0]*$/;
var str = ip6Addr.replace(/:/g, "" );
if (notValidchars.test(str))
return true;
else
return false;
}
var ipV4Pattern = new RegExp("^([0-9]{1,3}).([0-9]{1,3}).([0-9]{1,3}).([0-9]{1,3})$");
function isIPV4(str)
{
var match = str.match(ipV4Pattern);
return match != null
&& match[1] < 256
&& match[2] < 256
&& match[3] < 256
&& match[4] < 256;
}
function isHexWithColonPeriod(text)
{
var validchars = /^[a-fA-F0-9\:\.]*$/;
if (text == null) return false;
if( validchars.test(text))
{
return true;
}
return false;
}
/**
* Returns the value of the node if it exists.
* If strict is passed and the node does not exist throws "NoSuchNode" exception,
* otherwise returns null
*/
function getXmlNodeValue(xmlSnippet, nodeName, strict)
{
if (xmlSnippet == null)
{
return null;
}
element = xmlSnippet.getElementsByTagName(nodeName)[0];
if (element == null )
{
//if (strict==null || strict==undefined || !strict)
//{
// return "";
//}
//else
//{
// var error = new Error();
// throw "getXmlNodeValue error: no node for " + nodeName;
//}
return null;
}
return element.childNodes[0].nodeValue;
}
//var Status;
//Status.OK = 0;
//Status.ALERT = 1;
//Status.FAILED = 2;
//see http://www.netlobo.com/url_query_string_javascript.html, which was the
// basis for this script. If server side scripting is available form values
// are available as
function getParameterFromURL(parameterName, aURL)
{
//I'm not sure why we're replacing [ and ] with escaped versions (\[ and \]), but
// left this for now. The [] probably do something bad to the regexp
// evaluation, although it shouldn't...
parameterName = parameterName.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
//regex to search for parameter name preceded by & or ? followed by
//any character except end of line, & or #, capturing everything after the = a
//and before the eol, & or #.
var regexS = "[\\?&]"+parameterName+"=([^]*)";
//build and execute the regex against the search term
var regex = new RegExp( regexS );
var results = regex.exec( aURL );
//return null if no match, or first match.
if( results == null )
{
return null;
}
else
{
return results[1];
}
}
//Given a select control and a comma delimitted string convert the string into
//options for the select control.
function delimValueToOptions(selectControl, value, delim)
{
//Clear any existing options
while (selectControl.options.length > 0)
{
selectControl.remove(0);
}
if (value == null)
{
return;
}
var valueArray = value.split(delim);
for (var optionIndex=0; optionIndex0)
ipAddr = hostAddr.substring(1,hostAddr.indexOf("]"))
else
ipAddr = hostAddr.substring(1);
}
else
{
if (hostAddr.indexOf(":")>0) //checking it is IPv4 ,checking contains host addr
{
ipAddr = hostAddr.substring(0,hostAddr.indexOf(":"))
}
}
ipAddr = ipAddr+"@"+ipv6Format;
return ipAddr;
}
function clearFileInput( id ){
var elem = document.getElementById( id );
elem.parentNode.innerHTML = elem.parentNode.innerHTML;
}
// constants to define the title of the alert and button text.
var ALERT_TITLE = "System Alert";
var ALERT_BUTTON_TEXT = "OK";
function createCustomAlert(txt,titleTxt,alertType,bReloadPage) {
// shortcut reference to the document object
d = document;
// if the modalContainer object already exists in the DOM, bail out.
if(d.getElementById("modalContainer")) return;
// create the modalContainer div as a child of the BODY element
mObj = d.getElementsByTagName("body")[0].appendChild(d.createElement("div"));
mObj.id = "modalContainer";
// make sure its as tall as it needs to be to overlay all the content on the page
mObj.style.height = document.documentElement.scrollHeight + "px";
// create the DIV that will be the alert
alertObj = mObj.appendChild(d.createElement("div"));
alertObj.id = "alertBox";
// MSIE doesnt treat position:fixed correctly, so this compensates for positioning the alert
if(d.all && !window.opera) alertObj.style.top = document.documentElement.scrollTop + 100 + "px";
// center the alert box
alertObj.style.left = (d.documentElement.scrollWidth - alertObj.offsetWidth)/2 + "px";
// create an H1 element as the title bar
span1 = alertObj.appendChild(d.createElement("span"));
spanTxt = "";
span1.innerHTML = spanTxt;
// create an anchor element to use as the confirmation button.
span1 = alertObj.appendChild(d.createElement("span"));
spanTxt = "";
span1.innerHTML = spanTxt;
// set up the onclick event to remove the alert when the anchor is clicked
//btn.onclick = function() { removeCustomAlert();return false; }
}
// removes the custom alert from the DOM
// Reload page afterward
function removeCustomAlert() {
document.getElementsByTagName("body")[0].removeChild(document.getElementById("modalContainer"));
hideElement('contentArea');
document.location.reload(true);
}
// removes the custom alert from the DOM
// DON'T Reload page afterward
function removeCustomAlert2() {
document.getElementsByTagName("body")[0].removeChild(document.getElementById("modalContainer"));
}
function HTMLEncode( text )
{
if ( typeof( text ) != "string" ) text = text.toString();
text = text.replace(/&/g, "&");
text = text.replace( //g, ">");
return text ;
}
// check Unique Port
var gl_portIdx = new Object();
gl_portIdx.webHTTPPort = 0;
gl_portIdx.webHTTPSPort = 1;
gl_portIdx.sshPort = 2;
gl_portIdx.telnetPort = 3;
gl_portIdx.kvmPort = 4;
gl_portIdx.remoteSyslogPort = 5;
gl_portIdx.GLServerPort = 6;
var gl_port_array = new Array();
var enterUniqPortMsg = "Please enter unique port numbers."; //Please enter unique port numbers.
function InitUniquePort(val)
{
fieldList[val++] = new FieldMapping( "kvmPort" , null, FieldMapping.TYPE_TEXT );
fieldList[val++] = new FieldMapping( "webHTTPPort" , null, FieldMapping.TYPE_TEXT );
fieldList[val++] = new FieldMapping( "webHTTPSPort" , null, FieldMapping.TYPE_TEXT );
fieldList[val++] = new FieldMapping( "sshPort" , null, FieldMapping.TYPE_TEXT );
fieldList[val++] = new FieldMapping( "telnetPort" , null, FieldMapping.TYPE_TEXT );
fieldList[val++] = new FieldMapping( "remoteSyslogPort", "remoteSyslogPort", FieldMapping.TYPE_TEXT );
fieldList[val++] = new FieldMapping( "GLServerPort" , "xGLServerPort", FieldMapping.TYPE_TEXT );
}
function LoadUniquePort(xmlDoc)
{
gl_port_array[gl_portIdx.webHTTPPort] = getXMLValue(xmlDoc,"webHTTPPort");
gl_port_array[gl_portIdx.webHTTPSPort] = getXMLValue(xmlDoc,"webHTTPSPort");
gl_port_array[gl_portIdx.sshPort] = getXMLValue(xmlDoc,"sshPort");
gl_port_array[gl_portIdx.telnetPort] = getXMLValue(xmlDoc,"telnetPort");
gl_port_array[gl_portIdx.kvmPort] = getXMLValue(xmlDoc,"kvmPort");
gl_port_array[gl_portIdx.remoteSyslogPort] = getXMLValue(xmlDoc,"remoteSyslogPort");
gl_port_array[gl_portIdx.GLServerPort] = getXMLValue(xmlDoc,"xGLServerPort");
}
function ChkUniquePort()
{
var match = false;
var j = 0;
if (gl_port_array.length > 1) {
while (j < gl_port_array.length){
for ( var i = j + 1; i < gl_port_array.length; i++){
if (gl_port_array[j] == gl_port_array[i]) { match = true; }
}
j++;
}
}
return match;
}
function escapeStr(str) {
var tmp = new Array();
var i;
var escstr="";
var dec;
str = str.replace(/\\/g, "\\\\");
tmp = str.split("");
for(i=0; i