Last active
March 15, 2019 02:57
-
-
Save Fortyseven/d467c0f378b1ce6b0d29cd2d7b729615 to your computer and use it in GitHub Desktop.
/includes/utilities.js (From WD NetCenter drive)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function clockTick() | |
{ | |
var currentTime = new Date(); | |
var hours = currentTime.getHours(); | |
var minutes = currentTime.getMinutes(); | |
var seconds = currentTime.getSeconds(); | |
var day = currentTime.getDate(); | |
var month = currentTime.getMonth(); | |
var strMonth; | |
var year = currentTime.getFullYear(); | |
var ampm = "am"; | |
strMonth = GetMonth(month); | |
if (hours > 12){ | |
hours = hours - 12; | |
ampm = "pm"; | |
}; | |
if (minutes < 10){ | |
minutes = "0" + minutes; | |
}; | |
if (seconds < 10){ | |
seconds = "0" + seconds; | |
}; | |
if ((navigator.platform.indexOf("MacPPC") > -1) && (navigator.userAgent.indexOf("MSIE") > -1)){ | |
//document.clock_form.clock.size = "1"; | |
document.write(" "+ strMonth + " " + day + ", " + year+ " " + hours + ":" + minutes + " " + ampm);// + ":" + seconds + " " + ampm); | |
} | |
else { | |
document.write(" "+ strMonth + " " + day + ", " + year+ " " + hours + ":" + minutes + " " + ampm);// + ":" + seconds + " " + ampm); | |
//document.clock_form.clock.value = " "+ strMonth + " " + day + ", " + year+ " " + hours + ":" + minutes + " " + ampm;// + ":" + seconds + " " + ampm; | |
//document.clock_form.clock.blur(); | |
//setTimeout("clockTick()", 1000); | |
}; | |
} | |
function Set_nav_DateTime(){ | |
var month; | |
var day; | |
var hourcount; | |
var long_month_name; | |
var current_time; | |
var ampm = "am"; | |
var current_date = ""; | |
current_time = "Thu Mar 14 21:55:20 2019"; | |
fields = current_time.split(/ /); | |
year = fields[fields.length - 1]; | |
short_month_name = fields[1]; | |
if (short_month_name == "Jan") | |
long_month_name = "January"; | |
else if (short_month_name == "Feb") | |
long_month_name = "February"; | |
else if (short_month_name == "Mar") | |
long_month_name = "March"; | |
else if (short_month_name == "Apr") | |
long_month_name = "April"; | |
else if (short_month_name == "May") | |
long_month_name= "May"; | |
else if (short_month_name == "Jun") | |
long_month_name = "June"; | |
else if (short_month_name == "Jul") | |
long_month_name = "July"; | |
else if (short_month_name == "Aug") | |
long_month_name = "August"; | |
else if (short_month_name == "Sep") | |
long_month_name = "September"; | |
else if (short_month_name == "Oct") | |
long_month_name = "October"; | |
else if (short_month_name == "Nov") | |
long_month_name = "November"; | |
else | |
long_month_name = "December"; | |
day = fields[2]; | |
if (day.length == 0) | |
day = "1"; | |
time_fields = fields[3].split(/:/); | |
if (time_fields.length != 3) | |
{ | |
time_fields = fields[4].split(/:/); | |
year = fields[3]; | |
} | |
hour = time_fields[0]; | |
minute = time_fields[1]; | |
second = time_fields[2]; | |
if (hour > 12 ) | |
{ | |
hour = hour- 12; | |
ampm = "pm"; | |
} | |
/* adds an extra 0, minute already has a leading 0 | |
if (minute < 10) | |
{minute = "0" + minute;}; | |
*/ | |
current_date = long_month_name + " " + day + ", " + year + " " + hour + ":" + minute + " " + ampm; | |
document.write(current_date); | |
return true; | |
} | |
function GetDate(datestr) | |
{ | |
var currentTime = new Date(); | |
var hours = currentTime.getHours(); | |
var minutes = currentTime.getMinutes(); | |
var seconds = currentTime.getSeconds(); | |
var day = currentTime.getDate(); | |
var month = currentTime.getMonth(); | |
var strMonth; | |
var year = currentTime.getFullYear(); | |
var ampm = "am"; | |
var strDate = ""; | |
var spacer = ""; | |
strMonth = GetMonth(month); | |
if (hours > 12){ | |
hours = hours - 12; | |
ampm = "pm"; | |
}; | |
if (minutes < 10){ | |
minutes = "0" + minutes; | |
}; | |
if (datestr.toUpperCase() == 'HOUR'){ | |
return hours; | |
}; | |
if (datestr.toUpperCase() == 'MINUTE'){ | |
return minutes; | |
}; | |
if (datestr.toUpperCase() == 'SECOND'){ | |
return seconds; | |
}; | |
if (datestr.toUpperCase() == 'AMPM'){ | |
return ampm; | |
}; | |
if (datestr.toUpperCase() == 'DAY'){ | |
return day; | |
}; | |
if (datestr.toUpperCase() == 'MONTH'){ | |
return strMonth; | |
}; | |
if (datestr.toUpperCase() == 'YEAR'){ | |
return year; | |
}; | |
} | |
function GetMonth(month){ | |
var strMonth; | |
switch(month) | |
{ | |
case 0: | |
strMonth = "January"; | |
break; | |
case 1: | |
strMonth = "February"; | |
break; | |
case 2: | |
strMonth = "March"; | |
break; | |
case 3: | |
strMonth = "April"; | |
break; | |
case 4: | |
strMonth = "May"; | |
break; | |
case 5: | |
strMonth = "June"; | |
break; | |
case 6: | |
strMonth = "July"; | |
break; | |
case 7: | |
strMonth = "August"; | |
break; | |
case 8: | |
strMonth = "September"; | |
break; | |
case 9: | |
strMonth = "October"; | |
break; | |
case 10: | |
strMonth = "November"; | |
break; | |
case 11: | |
strMonth = "December"; | |
break; | |
} | |
return strMonth; | |
} | |
function SetTime(theStr){ | |
var month; | |
var day; | |
var hourcount; | |
var selectstate = ""; | |
if (theStr.toUpperCase() == "YEAR"){ | |
var dayear = GetDate("year") ; | |
document.write('<input name="Year" type="text" id="Year" value="' + dayear + '" size="4" maxlength="4" onChange="time_change();">'); | |
} | |
if (theStr.toUpperCase() == "MONTH"){ | |
for (var i = 1; i <= 12; i++){ | |
month = GetMonth(i - 1) | |
if (month == GetDate('month')) { | |
selectstate = "selected"; | |
} | |
document.write('<option value="' + month + '" ' + selectstate + '>' + month + '</option>') | |
selectstate = ""; | |
} | |
return true; | |
} | |
if (theStr.toUpperCase() == "DAY"){ | |
var dayValue = ""; | |
for (var i = 1; i <= 31; i++){ | |
if (i == GetDate('day')) | |
{selectstate = "selected";}; | |
if (i < 10) | |
{ dayValue = "0"; }; | |
dayValue = dayValue + i; | |
document.write('<option value="' + dayValue+ '" ' + selectstate + '>' + dayValue + '</option>') | |
selectstate = ""; | |
dayValue = ""; | |
} | |
return true; | |
} | |
if (theStr.toUpperCase() == "HOUR"){ | |
var hourValue = ""; | |
for (var i = 1; i <= 12; i++){ | |
hourcount = i; | |
if (hourcount == GetDate('hour')) { | |
selectstate = "selected"; | |
} | |
if (i < 10) { | |
hourValue = "0"; | |
} | |
hourValue = hourValue + i; | |
document.write('<option value="' + hourValue + '" ' + selectstate + '>' + hourValue + '</option>') | |
selectstate = ""; | |
hourValue = ""; | |
} | |
return true; | |
} | |
if (theStr.toUpperCase() == "MINUTE"){ | |
var minuteValue = ""; | |
for (var i = 0; i <= 59; i++) | |
{ | |
if (i == GetDate('minute')) | |
{selectstate = "selected";}; | |
if (i < 10) | |
{minuteValue = "0";}; | |
minuteValue = minuteValue + i; | |
document.write('<option value="' + minuteValue + '" ' + selectstate + '>' + minuteValue + '</option>'); | |
selectstate = ""; | |
minuteValue = ""; | |
} | |
return true; | |
} | |
if (theStr.toUpperCase() == "SECOND"){ | |
var current = GetDate('second'); | |
var secondValue = ""; | |
for (var i = 0; i <= 59; i++){ | |
if (i == current) | |
{selectstate = "selected";}; | |
if (i < 10) | |
{secondValue = "0";}; | |
secondValue = secondValue + i; | |
document.write('<option value="' + secondValue + '" ' + selectstate + '>' + secondValue + '</option>') | |
selectstate = ""; | |
secondValue = ""; | |
} | |
return true; | |
} | |
if (theStr.toUpperCase() == "AMPM"){ | |
var amselectstate = ""; | |
var pmselectstate = ""; | |
if (GetDate('ampm') == 'am') { | |
amselectstate = "selected"; | |
} | |
if (GetDate('ampm') == 'pm') { | |
pmselectstate = "selected"; | |
} | |
document.write('<option value="AM" ' + amselectstate + '>AM</option>'); | |
document.write('<option value="PM" ' + pmselectstate + '>PM</option>'); | |
} | |
return true; | |
} | |
function WriteMenu(section){ | |
document.write('<table width="100%"border="0" cellspacing="0" cellpadding="4">'); | |
document.write('<tr>'); | |
document.write('<td><a href="../systemsummary/index.asp"><img src="../images/icons35_syssummary.gif" width="185" height="35" border="0"></a></td>'); | |
document.write('</tr>'); | |
document.write('<tr>'); | |
document.write('<td><a href="../generalsetup/index.asp"><img src="../images/icons35_generalsetup.gif" width="185" height="35" border="0"></a>'); | |
// General Setup submenu | |
if (section == "General"){ | |
document.write('<br><table width="190" border="0" cellspacing="2" cellpadding="2">'); | |
document.write('<tr>'); | |
document.write('<td width="2" valign="top"><img src="images/spacer.gif" width="2" height="1"></td>'); | |
document.write('<td valign="top"><img src="../images/dot.gif" width="10" height="14"></td>'); | |
document.write('<td valign="top"><a href="login.asp">Update Username and Password </a></td>'); | |
document.write('</tr>'); | |
document.write('<tr>'); | |
document.write('<td valign="top"> </td>'); | |
document.write('<td valign="top"><img src="../images/dot.gif" width="10" height="14"></td>'); | |
document.write('<td valign="top"><a href="datetime.asp">Update Date/Time Settings </a></td>'); | |
document.write('</tr>'); | |
document.write('<tr>'); | |
document.write('<td valign="top"> </td>'); | |
document.write('<td valign="top"><img src="../images/dot.gif" width="10" height="14"></td>'); | |
document.write('<td valign="top"><a href="networkname.asp">Update Device / Workgroup Names </a></td>'); | |
document.write('</tr>'); | |
document.write('<tr>'); | |
document.write('<td valign="top"> </td>'); | |
document.write('<td valign="top"><img src="../images/dot.gif" width="10" height="14"></td>'); | |
document.write('<td valign="top"><a href="networkaddress.asp">Obtain a Network Address </a></td>'); | |
document.write('</tr>'); | |
document.write('<tr>'); | |
document.write('<td valign="top"> </td>'); | |
document.write('<td valign="top"><img src="../images/dot.gif" width="10" height="14"></td>'); | |
document.write('<td valign="top"><a href="firmware.asp">Upgrade Firmware </a></td>'); | |
document.write('</tr></table>'); | |
}; | |
//End of general setup submenu | |
document.write('</td>'); | |
document.write('</tr>'); | |
document.write('<tr>'); | |
document.write('<td><a href="../filesharing/index.asp"><img src="../images/icons35_filesharing.gif" width="185" height="35" border="0"></a>'); | |
//File Sharing submenu | |
if (section == "File"){ | |
document.write('<br><table width="190" border="0" cellspacing="2" cellpadding="2">'); | |
document.write('<tr>'); | |
document.write('<td width="2" valign="top"><img src="images/spacer.gif" width="2" height="1"></td>'); | |
document.write('<td valign="top"><img src="../images/dot.gif" width="10" height="14"></td>'); | |
document.write('<td valign="top"><a href="addshare.asp">Add a Shared Folder</a></td>'); | |
document.write('</tr>'); | |
document.write('<tr>'); | |
document.write('<td valign="top"> </td>'); | |
document.write('<td valign="top"><img src="../images/dot.gif" width="10" height="14"></td>'); | |
document.write('<td valign="top"><a href="renameshare.asp">Rename a Shared Folder</a></td>'); | |
document.write('</tr>'); | |
document.write('<tr>'); | |
document.write('<td valign="top"> </td>'); | |
document.write('<td valign="top"><img src="../images/dot.gif" width="10" height="14"></td>'); | |
document.write('<td valign="top"><a href="removeshare.asp">Remove a Shared Folder</a></td>'); | |
document.write('</tr>'); | |
document.write('<tr>'); | |
document.write('<td valign="top"> </td>'); | |
document.write('<td valign="top"><img src="../images/dot.gif" width="10" height="14"></td>'); | |
document.write('<td valign="top"><a href="updatesecurity.asp">Update Security Settings</a> </td>'); | |
document.write('</tr></table>'); | |
//document.write('<tr>'); | |
//document.write('<td valign="top"> </td>'); | |
//document.write('<td valign="top"><img src="../images/dot.gif" width="10" height="14"></td>'); | |
//document.write('<td valign="top"><a href="prioritywizard.asp">File Transfer Priorities </a></td>'); | |
//document.write('</tr>'); | |
}; | |
//End of File Sharing submenu | |
document.write('</td>'); | |
document.write('</tr>'); | |
document.write('<tr>'); | |
document.write('<td><a href="../printersharing/index.asp"><img src="../images/icons35_printersharing.gif" width="185" height="35" border="0"></a></td>'); | |
document.write('</tr>'); | |
document.write('<tr>'); | |
document.write('<td><a href="../drivemgt/index.asp"><img src="../images/icons35_drivemanagement.gif" width="185" height="35" border="0"></a>'); | |
//Drive Management submenu | |
if (section == "Drive"){ | |
document.write('<br><table width="190" border="0" cellspacing="2" cellpadding="2">'); | |
document.write('<tr>'); | |
document.write('<td width="2" valign="top"><img src="images/spacer.gif" width="2" height="1"></td>'); | |
document.write('<td valign="top"><img src="../images/dot.gif" width="10" height="14"></td>'); | |
document.write('<td valign="top"><a href="diskhealth.asp">View Disk Health </a></td>'); | |
document.write('</tr>'); | |
/* | |
document.write('<tr>'); | |
document.write('<td valign="top"> </td>'); | |
document.write('<td valign="top"><img src="../images/dot.gif" width="10" height="14"></td>'); | |
document.write('<td valign="top"><a href="usb.asp">Change USB Drive Auto-Behavior </a></td>'); | |
document.write('</tr>'); | |
*/ | |
document.write('<tr>'); | |
document.write('<td valign="top"> </td>'); | |
document.write('<td valign="top"><img src="../images/dot.gif" width="10" height="14"></td>'); | |
document.write('<td valign="top"><a href="addpool.asp">Create a New Volume </a></td>'); | |
document.write('</tr>'); | |
document.write('<tr>'); | |
document.write('<td valign="top"> </td>'); | |
document.write('<td valign="top"><img src="../images/dot.gif" width="10" height="14"></td>'); | |
document.write('<td valign="top"><a href="resizepool.asp">Resize a Volume </a></td>'); | |
document.write('</tr>'); | |
document.write('<tr>'); | |
document.write('<td valign="top"> </td>'); | |
document.write('<td valign="top"><img src="../images/dot.gif" width="10" height="14"></td>'); | |
document.write('<td valign="top"><a href="renamepool.asp">Rename a Volume </a></td>'); | |
document.write('</tr>'); | |
document.write('<tr>'); | |
document.write('<td valign="top"> </td>'); | |
document.write('<td valign="top"><img src="../images/dot.gif" width="10" height="14"></td>'); | |
document.write('<td valign="top"><a href="removepool.asp">Remove a Volume</a> </td>'); | |
document.write('</tr>'); | |
/* | |
document.write('<tr>'); | |
document.write('<td valign="top"> </td>'); | |
document.write('<td valign="top"><img src="../images/dot.gif" width="10" height="14"></td>'); | |
document.write('<td valign="top"><a href="addmirrorspare.asp">Add a Mirror or Spare </a></td>'); | |
document.write('</tr>'); | |
document.write('<tr>'); | |
document.write('<td valign="top"> </td>'); | |
document.write('<td valign="top"><img src="../images/dot.gif" width="10" height="14"></td>'); | |
document.write('<td valign="top"><a href="removemirrorspare.asp">Remove a Mirror or Spare </a></td>'); | |
document.write('</tr>'); | |
*/ | |
document.write('<tr>'); | |
document.write('<td valign="top"> </td>'); | |
document.write('<td valign="top"><img src="../images/dot.gif" width="10" height="14"></td>'); | |
document.write('<td valign="top"><a href="claimdisk.asp">Claim a Drive</a></td>'); | |
document.write('</tr>'); | |
document.write('<tr>'); | |
document.write('<td valign="top"> </td>'); | |
document.write('<td valign="top"><img src="../images/dot.gif" width="10" height="14"></td>'); | |
document.write('<td valign="top"><a href="renamedisk.asp">Rename a Drive</a></td>'); | |
document.write('</tr>'); | |
document.write('<tr>'); | |
document.write('<td valign="top"> </td>'); | |
document.write('<td valign="top"><img src="../images/dot.gif" width="10" height="14"></td>'); | |
document.write('<td valign="top"><a href="unclaimdisk.asp">Unclaim a Drive</a></td>'); | |
document.write('</tr>'); | |
document.write('</table>'); | |
}; | |
//End of Drive Management submenu | |
document.write('</td>'); | |
document.write('</tr>'); | |
document.write('<tr>'); | |
document.write('<td><a href="../help/index.asp"><img src="../images/icons35_help.gif" width="185" height="35" border="0"></a>'); | |
//Help submenu | |
if (section == "help"){ | |
document.write('<br><table width="190" border="0" cellspacing="2" cellpadding="2">'); | |
document.write('<tr>'); | |
document.write('<tr>'); | |
document.write('<td valign="top"> </td>'); | |
/* document.write('<td width="2" valign="top"><img src="images/spacer.gif" width="2" height="1"></td>'); */ | |
document.write('<td valign="top"><img src="../images/dot.gif" width="10" height="14"></td>'); | |
document.write('<td valign="top"><a href="solutioncenter.asp">Troubleshooting/FAQs</a></td>'); | |
document.write('</tr>'); | |
//document.write('<tr>'); | |
//document.write('<td valign="top"> </td>'); | |
//document.write('<td valign="top"><img src="../images/dot.gif" width="10" height="14"></td>'); | |
//document.write('<td valign="top"><a href="userguide.asp">Online User Guide </a></td>'); | |
//document.write('</tr>'); | |
document.write('<td valign="top"> </td>'); | |
document.write('<td valign="top"><img src="../images/dot.gif" width="10" height="14"></td>'); | |
document.write('<td valign="top"><a href="glossary.asp">Glossary </a></td>'); | |
document.write('</tr></table>'); | |
}; | |
//End of HELP Submenu | |
document.write('</td>'); | |
document.write('</tr>'); | |
document.write('</table>'); | |
} | |
function WriteHeader(section){ | |
document.write('<table width="100%" border="0" cellspacing="0" cellpadding="0">'); | |
document.write('<tr>'); | |
document.write('<td><img src="../images/header2.jpg" width="750" height="79"></td>'); | |
document.write('</tr>'); | |
document.write('<tr>'); | |
//document.write('<td align="right" class="clockframe" valign="top">'); | |
//document.write('<table width="200" border="0" cellpadding="2">'); | |
document.write('<td align="center" class="clockframe" valign="top">'); | |
document.write('<table width="715" border="0" cellpadding="2">'); | |
document.write('<tr>'); | |
document.write('<td align="right" class="clockframe">'); | |
document.write('<script language="javascript" type="text/javascript">Set_nav_DateTime();</script> '); | |
document.write('</td>'); | |
document.write('</tr>'); | |
document.write('<tr>'); | |
if (section == "nazwizard" || section == "drivemgtwizard" || section == "wizard" || section == "addshare" ){ | |
document.write('<td valign="top" align="right"><a href="../home.asp" target="_top"><img src="../images/icons35_home.gif" width="96" height="35" border="0"></a> </td>'); | |
} | |
else if (section == "setup" || section == "main") | |
{ | |
document.write('<td valign="top" align="right"> </td>'); | |
} | |
else if (section == "setup_end") | |
{ | |
document.write('<td valign="top" align="right"><a href="/home.asp" target="_top"><img src="../images/icons35_advancedsetup.gif" width="159" height="35" border="0"></a> </td>'); | |
} | |
else | |
{ | |
document.write('<td valign="top" align="right"><a href="/home.asp"><img src="../images/icons35_home.gif" width="96" height="35" border="0"></a> </td>'); | |
}; | |
document.write('</tr>'); | |
document.write('</table></td>'); | |
document.write('</tr>'); | |
document.write('</table>'); | |
} | |
function WriteFooter(section){ | |
document.write('<br>'); | |
document.write('<p style="font-size: 0.8em; color: navy;">Copyright © 2005 Western Digital Technologies, Inc. All rights reserved.</p>'); | |
document.write('<br>'); | |
} | |
function CreateBuildInfoString( rawString ) | |
{ | |
var lines = rawString.split( "\n" ); | |
return lines[ 0 ].split( "." ).slice( 0, 3 ).join( "." ); | |
} | |
function CreateBuildInfoStringExt( rawString ) | |
{ | |
var lines = rawString.split( "\n" ); | |
return lines[ 0 ]; | |
} | |
function trim(val) | |
{ | |
val = val+''; | |
for (var startIndex=0;startIndex<val.length && val.substring(startIndex,startIndex+1) == ' ';startIndex++); | |
for (var endIndex=val.length-1; endIndex>startIndex && val.substring(endIndex,endIndex+1) == ' ';endIndex--); | |
return val.substring(startIndex,endIndex+1); | |
} | |
function round_decimals(num, decimalNum) | |
{ | |
var tmpNum; | |
if(num) | |
{ | |
tmpNum =num; | |
tmpNum *= Math.pow(10,decimalNum); | |
tmpNum = Math.floor(tmpNum); | |
tmpNum /= Math.pow(10,decimalNum); | |
if (tmpNum - Math.floor(tmpNum) == 0) | |
{ | |
tmpNum = tmpNum + ".00"; | |
} | |
else | |
{ | |
string = tmpNum.toString(); | |
parts = string.split("."); | |
cents = parts[1]; | |
if (cents.length == 1) | |
{ | |
tmpNum = tmpNum + "0"; | |
} | |
} | |
return tmpNum; | |
} | |
else | |
{ | |
return '0.00'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment