Files
interactive/gms/KT/httpd/wwwroot/paran_monitor/status/clock.js
T
2026-08-07 17:38:18 +09:00

293 lines
8.4 KiB
JavaScript

// Removes leading and trailing spaces from the passed string. Also removes
// consecutive spaces and replaces it with one space. If something besides
// a string is passed in (null, custom object, etc.) then return the input.
function trimString(inputString) {
if (typeof inputString != "string") {
return inputString;
}
var retValue = inputString;
var ch = retValue.substring(0, 1);
while (ch == " ") {
// Check for spaces at the beginning of the string
retValue = retValue.substring(1, retValue.length);
ch = retValue.substring(0, 1);
}
ch = retValue.substring(retValue.length-1, retValue.length);
while (ch == " ") { // Check for spaces at the end of the string
retValue = retValue.substring(0, retValue.length-1);
ch = retValue.substring(retValue.length-1, retValue.length);
}
while (retValue.indexOf(" ") != -1) {
// Note that there are two spaces in the string - look for multiple spaces within the string
retValue = retValue.substring(0, retValue.indexOf(" ")) + retValue.substring(retValue.indexOf(" ")+ 1, retValue.length); // Again, there are two spaces in each of the strings
}
return retValue; // Return the trimmed string back to the user
}
// Ends the "trim" function
function idnKeyboard(url)
{
myPopupWin= window.open(url,'','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=818,height=350');
myPopupWin.focus();
}
function MM_goToURL() { //v3.0
var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+args[i+2]+args[i+3]+args[i+4]+"'");
}
function submitRequest(url)
{
self.opener.location.href=url;
self.opener.document.submit();
}
function setGainingRegIDValue(selectedform, selectedRegID ) {
selectedRegID.value = selectedform.regID.options[selectedform.regID.selectedIndex].value;
}
function PopWin(myUrl, arg1, arg2, arg3, width, height,resizable)
{
var url=myUrl+arg1+arg2+arg3;
myPopupWin = window.open(url,'','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=800,height=700', copyhistory=0);
myPopupWin.focus();
}
function appendValues(nameObj)
{
if (isEmpty(nameObj.value) ) return;
appendOptionToSelectBox(window.document.form1.userNameList,
nameObj.value, false);
}
function appendNVPair(nameObj, valueObj)
{
if (isEmpty(nameObj.value) ) return;
if (isEmpty(valueObj.value) ) return;
str = nameObj.value + "=" + valueObj.value;
appendOptionToSelectBox(window.document.form1.userNameList, str, false);
}
function appendContPairs(nameObj, valueObj)
{
if (isEmpty(nameObj.value) ) return;
if (isEmpty(valueObj.value) ) return;
str = nameObj.value + "=" + valueObj.value;
appendOptionToSelectBox(window.document.form1.regContList, str, false);
}
function appendIPAdressValue(nameObj, valueObj)
{
if (isEmpty(nameObj.value) ) return;
if (isEmpty(valueObj.value) ) return;
str = nameObj.value + "=" + valueObj.value;
appendOptionToSelectBox(window.document.form1.nsIplist, str, false);
}
function removeNVPair()
{
if(window.document.form1.userNameList.selectedIndex >=0 ){
//removeOptionSelected(window.document.form1.userValueList);
removeOptionSelected(window.document.form1.userNameList);
}
}
function MM_jumpMenu(targ,selObj,restore){ //v3.0
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
if (restore) selObj.selectedIndex=0;
}
function validateIP(theIP,theField, formCxt)
{
if( !isValidIPV4(theIP) ) {
formCxt.setError();
alert('invalid entry: '+formCxt.getFieldDescription(theField.name));
}
}
function setRegIDValue(selectedRegID ) {
selectedRegID.value = window.document.query.regID.options[window.document.query.regID.selectedIndex].value;
}
var timerID ;
function tzone(tz, os, ds, cl)
{
this.ct = new Date(0) ; // datetime
this.tz = tz ; // code
this.os = os ; // GMT offset
this.ds = ds ; // has daylight savings
this.cl = cl ; // font color
}
function UpdateClocks()
{
// www.timeanddate.com/worldclock
var ct = new Array(
new tzone('UTC: ', 0, 1, '#FFAA00'),
new tzone('KST: ', +9, 1, '#FFAA00'),
new tzone('EST: ', -5, 1, '#FFAA00'),
new tzone('GMT: ', 0, 1, '#FFAA00'),
new tzone('C N : ', +8, 0, 'silver'),
new tzone('KST: ', +9, 0, 'silver'),
new tzone('EDT: ', -4, 1, 'silver'),
new tzone('GER: ', +1, 1, 'silver')
) ;
var dt = new Date() ; // [GMT] time according to machine clock
var startDST = new Date(dt.getFullYear(), 3, 1) ;
while (startDST.getDay() != 0)
startDST.setDate(startDST.getDate() + 1) ;
var endDST = new Date(dt.getFullYear(), 9, 31) ;
while (endDST.getDay() != 0)
endDST.setDate(endDST.getDate() - 1) ;
var ds_active ; // DS currently active
if (startDST < dt && dt < endDST)
ds_active = 1 ;
else
ds_active = 0 ;
// Adjust each clock offset if that clock has DS and in DS.
for(n=0 ; n<ct.length ; n++)
if (ct[n].ds == 1 && ds_active == 1) ct[n].os++ ;
// compensate time zones
gmdt = new Date() ;
for (n=0 ; n<ct.length ; n++)
ct[n].ct = new Date(gmdt.getTime() + ct[n].os * 3600 * 1000) ;
window.document.getElementById("Clock0").innerHTML = '<font color="' + ct[0].cl + '">' + ct[0].tz + ClockString(ct[0].ct) + '</font>' ;
window.document.getElementById("Clock1").innerHTML = '<font color="' + ct[1].cl + '">' + ct[1].tz + ClockString(ct[1].ct) + '</font>' ;
window.document.getElementById("Clock2").innerHTML = '<font color="' + ct[2].cl + '">' + ct[2].tz + ClockString(ct[2].ct) + '</font>' ;
window.document.getElementById("Clock3").innerHTML = '<font color="' + ct[3].cl + '">' + ct[3].tz + ClockString(ct[3].ct) + '</font>' ;
window.document.getElementById("Clock4").innerHTML = '<font color="' + ct[4].cl + '">' + ct[4].tz + ClockString(ct[4].ct) + '</font>' ;
window.document.getElementById("Clock5").innerHTML = '<font color="' + ct[5].cl + '">' + ct[5].tz + ClockString(ct[5].ct) + '</font>' ;
window.document.getElementById("Clock6").innerHTML = '<font color="' + ct[6].cl + '">' + ct[6].tz + ClockString(ct[6].ct) + '</font>' ;
window.document.getElementById("Clock7").innerHTML = '<font color="' + ct[7].cl + '">' + ct[7].tz + ClockString(ct[7].ct) + '</font>' ;
timerID = window.setTimeout("UpdateClocks()", 1001) ;
}
function ClockString(dt)
{
var stemp, ampm ;
var dt_year = dt.getUTCFullYear() ;
var dt_month = dt.getUTCMonth() + 1 ;
var dt_day = dt.getUTCDate() ;
var dt_hour = dt.getUTCHours() ;
var dt_minute = dt.getUTCMinutes() ;
var dt_second = dt.getUTCSeconds() ;
dt_year = dt_year.toString() ;
if (0 <= dt_hour && dt_hour < 12)
{
ampm = 'AM' ;
// if (dt_hour == 0) dt_hour = 12 ;
} else {
ampm = 'PM' ;
// dt_hour = dt_hour - 12 ;
// if (dt_hour == 0) dt_hour = 12 ;
}
if (dt_hour < 10)
dt_hour = '0' + dt_hour ;
if (dt_minute < 10)
dt_minute = '0' + dt_minute ;
if (dt_second < 10)
dt_second = '0' + dt_second ;
//stemp = dt_month + '/' + dt_day + '/' + dt_year.substr(2,2) ;
stemp = dt_year + '/' + dt_month + '/' + dt_day;
stemp = stemp + ' ' + dt_hour + ":" + dt_minute + ":" + dt_second + ' ' + ampm ;
return stemp ;
}
function goToURL( myUrl, arg1, arg2, arg3 ) {
window.location.href=myUrl+arg1+arg2+arg3;
}
function validateStreet(value, theField, formCxt)
{
if(value.length >= 10) {
formCxt.setError();
alert('invalid entry: '+formCxt.getFieldDescription(theField.name));
}
}
function validateName(value,theField, formCxt )
{
if(value.length > 5) {
formCxt.setError();
alert('invalid entry: '+formCxt.getFieldDescription(theField.name));
}
}
function validateEmail(email, theField, formCxt)
{
if ( ! isValidEmail(email) ){
formCxt.setError();
alert('invalid entry: '+formCxt.getFieldDescription(theField.name));
}
}
function selectNVPair(nameObj, valueObj, nvplistObj)
{
nm = nameObj;
val = valueObj;
ix = nvplistObj.selectedIndex;
if(ix < 0 ) return;
nm.value = userNVPList.getName(ix);
val.value = userNVPList.getValue(ix);
val.focus();
}
//Name server add and delete functions
function addNS(nslistObj,nsObj)
{
appendOptionToSelectBox(nslistObj,nsObj);
}
function removeNS(nslistObj,nsObj)
{
removeOptionFromSelectBox(nslistObj,nsObj);
}
function selectNS(nslistObj,nsObj)
{
selectOption(nslistObj,nsObj);
}
function selectAll(list1, list2, list3)
{
if (list1)
selectList(list1);
if (list2)
selectList(list2);
if (list3)
selectList(list3);
}