📄 script.js
字号:
for(i = 0 ; i < this.nChildren; i++) h = h + this.children[i].totalHeight(); } return h ;} // Events function clickOnFolder(folderId) { var clicked = indexOfEntries[folderId]; if(!clicked.isOpen) clickOnNode(folderId); if(clicked.isSelected) return;} function clickOnNode(folderId) { var clickedFolder = 0; var state = 0; clickedFolder = indexOfEntries[folderId]; state = clickedFolder.isOpen; clickedFolder.setState(!state); //open<->close } function initializeDocument() { if(doc.all) browserVersion = 1; //IE4 else if(doc.layers) browserVersion = 2; //NS4 else browserVersion = 0; //other ControlTree.initialize(0, 1, ""); ControlTree.display(); if(browserVersion > 0) { doc.write("<LAYER TOP="+indexOfEntries[nEntries-1].navObj.top+"> </LAYER>"); // close the whole tree clickOnNode(0); // open the root folder clickOnNode(0); } } // Auxiliary Functions for Folder-Treee backward compatibility function gFld(description, hreference) { folder = new Folder(description, hreference); return(folder);}function gLnk(target, description, linkData, itemImg) { fullLink = "" if(target == 0) { if(linkData != "") fullLink = "'"+linkData+"' TARGET=\"main\""; else fullLink = ""; } else if(target == 1) { if(linkData != "") fullLink = "'"+linkData+"' TARGET=\"_top\""; else fullLink = ""; } linkItem = new Item(description, linkData, fullLink, itemImg) return linkItem;} function insFld(parentFolder, childFolder) { return(parentFolder.addChild(childFolder));}function insDoc(parentFolder, document) { parentFolder.addChild(document);}var day;var month;var year;var hour;var minute;var second;var clock_set = 0;/** * Formats number to two digits. * * @param int number to format. */function formatNum2(i, valtype) { f = (i < 10 ? '0' : '') + i; if (valtype && valtype != '') { switch(valtype) { case 'month': f = (f > 12 ? 12 : f); break; case 'day': f = (f > 31 ? 31 : f); break; case 'hour': f = (f > 24 ? 24 : f); break; default: case 'second': case 'minute': f = (f > 59 ? 59 : f); break; } } return f;}/** * Formats number to four digits. * * @param int number to format. */function formatNum4(i) { return (i < 1000 ? i < 100 ? i < 10 ? '000' : '00' : '0' : '') + i;}/** * Initializes calendar window. */function initCalendar() { if (!year && !month && !day) { /* Called for first time */ if (window.opener.dateField.value) { value = window.opener.dateField.value; if (window.opener.dateType == 'datetime' || window.opener.dateType == 'date') { if (window.opener.dateType == 'datetime') { parts = value.split(' '); value = parts[0]; if (parts[1]) { time = parts[1].split(':'); hour = parseInt(time[0]); minute = parseInt(time[1]); second = parseInt(time[2]); } } date = value.split("-"); day = parseInt(date[2]); month = parseInt(date[1]) - 1; year = parseInt(date[0]); } else { year = parseInt(value.substr(0,4)); month = parseInt(value.substr(4,2)) - 1; day = parseInt(value.substr(6,2)); hour = parseInt(value.substr(8,2)); minute = parseInt(value.substr(10,2)); second = parseInt(value.substr(12,2)); } } if (isNaN(year) || isNaN(month) || isNaN(day) || day == 0) { dt = new Date(); year = dt.getFullYear(); month = dt.getMonth(); day = dt.getDate(); } if (isNaN(hour) || isNaN(minute) || isNaN(second)) { dt = new Date(); hour = dt.getHours(); minute = dt.getMinutes(); second = dt.getSeconds(); } } else { /* Moving in calendar */ if (month > 11) { month = 0; year++; } if (month < 0) { month = 11; year--; } } if (document.getElementById) { cnt = document.getElementById("calendar_data"); } else if (document.all) { cnt = document.all["calendar_data"]; } cnt.innerHTML = ""; str = "" //heading table str += '<table class="calendar"><tr><th width="50%">'; str += '<a href="#" onclick="month--; initCalendar();">«</a> '; str += month_names[month]; str += ' <a href="#" onclick="month++; initCalendar();">»</a>'; str += '</th><th width="50%">'; str += '<a href="#" onclick="year--; initCalendar();">«</a> '; str += year; str += ' <a href="#" onclick="year++; initCalendar();">»</a>'; str += '</th></tr></table>';/* str += '<table class="calendar"><tr><td width="50%">'; str += '<select */ str += '<table class="calendar"><tr>'; for (i = 0; i < 7; i++) { str += "<th>" + day_names[i] + "</th>"; } str += "</tr>"; var firstDay = new Date(year, month, 1).getDay(); var lastDay = new Date(year, month + 1, 0).getDate(); str += "<tr>"; dayInWeek = 0; for (i = 0; i < firstDay; i++) { str += "<td> </td>"; dayInWeek++; } for (i = 1; i <= lastDay; i++) { if (dayInWeek == 7) { str += "</tr><tr>"; dayInWeek = 0; } dispmonth = 1 + month; if (window.opener.dateType == 'datetime' || window.opener.dateType == 'date') { actVal = formatNum4(year) + "-" + formatNum2(dispmonth, 'month') + "-" + formatNum2(i, 'day'); } else { actVal = "" + formatNum4(year) + formatNum2(dispmonth, 'month') + formatNum2(i, 'day'); } if (i == day) { style = ' class="selected"'; } else { style = ''; } str += "<td" + style + "><a href='#' onclick='returnDate(\"" + actVal + "\");'>" + i + "</a></td>" dayInWeek++; } for (i = dayInWeek; i < 7; i++) { str += "<td> </td>"; } str += "</tr></table>"; cnt.innerHTML = str; // Should we handle time also? if (window.opener.dateType != 'date' && !clock_set) { if (document.getElementById) { cnt = document.getElementById("clock_data"); } else if (document.all) { cnt = document.all["clock_data"]; } str = ''; str += '<form class="clock">'; str += '<input id="hour" type="text" size="2" maxlength="2" onblur="this.value=formatNum2(this.value, \'hour\')" value="' + formatNum2(hour, 'hour') + '" />:'; str += '<input id="minute" type="text" size="2" maxlength="2" onblur="this.value=formatNum2(this.value, \'minute\')" value="' + formatNum2(minute, 'minute') + '" />:'; str += '<input id="second" type="text" size="2" maxlength="2" onblur="this.value=formatNum2(this.value, \'second\')" value="' + formatNum2(second, 'second') + '" />'; str += '</form>'; cnt.innerHTML = str; clock_set = 1; }}/** * Returns date from calendar. * * @param string date text */function returnDate(d) { window.opener.dateField.value = d; window.close();}var marked_row = new Array;/** * Sets/unsets the pointer and marker in browse mode * * @param object the table row * @param integer the row number * @param string the action calling this script (over, out or click) * @param string the default background color * @param string the color to use for mouseover * @param string the color to use for marking a row * * @return boolean whether pointer is set or not */function setPointer(theRow, theRowNum, theAction, theDefaultColor, thePointerColor, theMarkColor){ var theCells = null; // 1. Pointer and mark feature are disabled or the browser can't get the // row -> exits if ((thePointerColor == '' && theMarkColor == '') || typeof(theRow.style) == 'undefined') { return false; } // 2. Gets the current row and exits if the browser can't get it if (typeof(document.getElementsByTagName) != 'undefined') { theCells = theRow.getElementsByTagName('td'); } else if (typeof(theRow.cells) != 'undefined') { theCells = theRow.cells; } else { return false; } // 3. Gets the current color... var rowCellsCnt = theCells.length; var domDetect = null; var currentColor = null; var newColor = null; // 3.1 ... with DOM compatible browsers except Opera that does not return // valid values with "getAttribute" if (typeof(window.opera) == 'undefined' && typeof(theCells[0].getAttribute) != 'undefined') { currentColor = theCells[0].getAttribute('bgcolor'); domDetect = true; } // 3.2 ... with other browsers else { currentColor = theCells[0].style.backgroundColor; domDetect = false; } // end 3 // 3.3 ... Opera changes colors set via HTML to rgb(r,g,b) format so fix it if (currentColor.indexOf("rgb") >= 0) { var rgbStr = currentColor.slice(currentColor.indexOf('(') + 1, currentColor.indexOf(')')); var rgbValues = rgbStr.split(","); currentColor = "#"; var hexChars = "0123456789ABCDEF"; for (var i = 0; i < 3; i++) { var v = rgbValues[i].valueOf(); currentColor += hexChars.charAt(v/16) + hexChars.charAt(v%16); } } // 4. Defines the new color // 4.1 Current color is the default one if (currentColor == '' || currentColor.toLowerCase() == theDefaultColor.toLowerCase()) { if (theAction == 'over' && thePointerColor != '') { newColor = thePointerColor; } else if (theAction == 'click' && theMarkColor != '') { newColor = theMarkColor; marked_row[theRowNum] = true; // Garvin: deactivated onclick marking of the checkbox because it's also executed // when an action (like edit/delete) on a single item is performed. Then the checkbox // would get deactived, even though we need it activated. Maybe there is a way // to detect if the row was clicked, and not an item therein... // document.getElementById('id_rows_to_delete' + theRowNum).checked = true; } } // 4.1.2 Current color is the pointer one else if (currentColor.toLowerCase() == thePointerColor.toLowerCase() && (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])) { if (theAction == 'out') { newColor = theDefaultColor; } else if (theAction == 'click' && theMarkColor != '') { newColor = theMarkColor; marked_row[theRowNum] = true; // document.getElementById('id_rows_to_delete' + theRowNum).checked = true; } } // 4.1.3 Current color is the marker one else if (currentColor.toLowerCase() == theMarkColor.toLowerCase()) { if (theAction == 'click') { newColor = (thePointerColor != '') ? thePointerColor : theDefaultColor; marked_row[theRowNum] = (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum]) ? true : null; // document.getElementById('id_rows_to_delete' + theRowNum).checked = false; } } // end 4 // 5. Sets the new color... if (newColor) { var c = null; // 5.1 ... with DOM compatible browsers except Opera if (domDetect) { for (c = 0; c < rowCellsCnt; c++) { theCells[c].setAttribute('bgcolor', newColor, 0); } // end for } // 5.2 ... with other browsers else { for (c = 0; c < rowCellsCnt; c++) { theCells[c].style.backgroundColor = newColor; } } } // end 5 return true;} // end of the 'setPointer()' function
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -