计算器及日历

<script language=”JavaScript” > //dropdown.js // —– Popup Control ——————————————————— function at_display(x) { win = window.open(); for (var i in x) win.document.write(i+’ = ‘+x[i]+’
‘); } // —– Show Aux —– function at_show_aux(parent, child) { var p = document.getElementById(parent); var c = document.getElementById(child); var top = (c[“at_position”] == “y”) ? p.offsetHeight+2 : 0; var left = (c[“at_position”] == “x”) ? p.offsetWidth +2 : 0; for (; p; p = p.offsetParent) { top += p.offsetTop; left += p.offsetLeft; } c.style.position = “absolute”; c.style.top = top +’px’; c.style.left = left+’px’; c.style.visibility = “visible”; } // —– Show —– function at_show() { p = document.getElementById(this[“at_parent”]); c = document.getElementById(this[“at_child” ]); at_show_aux(p.id, c.id); clearTimeout(c[“at_timeout”]); } // —– Hide —– function at_hide() { c = document.getElementById(this[“at_child”]); c[“at_timeout”] = setTimeout(“document.getElementById(‘”+c.id+”‘).style.visibility = ‘hidden'”, 333); } // —– Click —– function at_click() { p = document.getElementById(this[“at_parent”]); c = document.getElementById(this[“at_child” ]); if (c.style.visibility != “visible”) at_show_aux(p.id, c.id); else c.style.visibility = “hidden”; return false; } // —– Attach —– // PARAMETERS: // parent – id of visible html element // child – id of invisible html element that will be dropdowned // showtype – “click” = you should click the parent to show/hide the child // “hover” = you should place the mouse over the parent to show // the child // position – “x” = the child is displayed to the right of the parent // “y” = the child is displayed below the parent // cursor – Omit to use default cursor or check any CSS manual for possible // values of this field function at_attach(parent, child, showtype, position, cursor) { p = document.getElementById(parent); c = document.getElementById(child); p[“at_parent”] = p.id; c[“at_parent”] = p.id; p[“at_child”] = c.id; c[“at_child”] = c.id; p[“at_position”] = position; c[“at_position”] = position; c.style.position = “absolute”; c.style.visibility = “hidden”; if (cursor != undefined) p.style.cursor = cursor; switch (showtype) { case “click”: p.onclick = at_click; p.onmouseout = at_hide; c.onmouseover = at_show; c.onmouseout = at_hide; break; case “hover”: p.onmouseover = at_show; p.onmouseout = at_hide; c.onmouseover = at_show; c.onmouseout = at_hide; break; } } </script> <script language=”JavaScript” > //calculator.js function getinput(func) { var a = document.mainform.total; var b = document.mainform.memory1; var c = document.mainform.memory2; if (document.mainform.mode[0].checked) { var mode = 1 //help mode } else { var mode = 0 //non-help mode } if (func==power) { return power(mode, a) } if (func==equa) { return equa(mode) } if (func==spec) { return spec(mode, a) } if (func==cubed) { return cubed(mode, a) } if (func==squared) { return squared(mode, a) } if (func==”mem1″) { return mem(mode, a, b) } if (func==”mem2″) { return mem(mode, a, c) } if (func==”rcl1″) { return rcl(mode, b, a) } if (func==”rcl2″) { return rcl(mode, c, a) } if (func==logrythm) { return logrythm(mode, a) } if (func==sine) { return sine(mode, a) } if (func==cosine) { return cosine(mode, a) } if (func==tangent) { return tangent(mode, a) } if (func==squareroot) { return squareroot(mode, a) } if (func==fractions) { return fractions(mode, a) } if (func==negpos) { return negpos(mode, a) } if (func==mc) { return mc(mode, b, c) } if (func==scie) { return scie(mode, a) } if (func==unscie) { return unscie(mode, a) } } //enough variables //evaluate the value in the total textbox function calc(obj, objw,form_input) { if (objw.value==””) { objw.value=” } if(eval(obj.value) == false){ alert(“有问题”); }else{ objw.value = eval(obj.value); document.getElementById(form_input).value=eval(obj.value); } } //add more characters to the total textbox function more(obj, where) { if (where.value==”” || where.value==”0″) { where.value = obj } else { where.value += obj } } //clear the total textbox value and start with this new character function doit(obj, where) { where.value = obj } //clear the value function cleart(obj) { obj.value = ‘0’ } //oops, backspace function less(obj) { obj.value = obj.value.substring(0, obj.value.length – 1) } //powers to any given number function power(mode, obj) { if (mode==1) { alert(“Power allows you to give powers to any given number.”) } if (obj.value!=”” && obj.value!=”0″) { aa = prompt(“Do you want to use the number in the total textbox as the base number?”, “y or n”); if (aa==”y”) { a = obj.value } else { a = prompt(“Enter a base number:”, “”) } b = prompt(“Enter an exponent:”, “”); if (aa==”y”) { doit(Math.pow(a, b), obj) } else { more(‘(‘ + Math.pow(a, b) + ‘)’, obj) } } else { a = prompt(“Enter a base:”, “”); b = prompt(“Enter an exponent:”, “”); doit(Math.pow(a,b), obj) } } //solve for unknown variable (“x”) in any given expression function equa(mode) { if (mode==1) { alert(“Equasion/+ is a handy little tool that will solve for /”x/” in any expression. Ex: 5*x=10, it will alert you this: x=2. But, you have to tell it exactly what you want. Method is what property of math you will be using. Ex: addition, subtraction, division, or multiplication. Remember, *=multiplication, /=division, /+=addition, and -=subtraction.”) } a = prompt(“What method will you be using? Ex: //, *, +, or -“, “”); if (a==”/”) { f = prompt(“Is /”x/” being divided?”, “y or n”) if (f==”y”) { b = prompt(“/”x/” is being divided by what?”, “”); c = prompt(“And what is the answer?”, “”); d = c*b; } else { b = prompt(“What number is being divided by /”x/”?”, “”); c = prompt(“And what is the answer?”, “”);
d = b/c; } } if (a==”*”) { b = prompt(“What is being multiplied by /”x/”?”, “”); c = prompt(“And what is the answer?”, “”); d = c/b; } if (a==”+”) { b = prompt(“What is being added to /”x/”?”, “”); c = prompt(“And what is the answer?”, “”); d = c-b } if (a==”-“) { f = prompt(“Is /”x/” being subtracted?”, “y or n”) if (f==”y”) { b = prompt(“/”x/” is being subtracted from what?”, “”); c = prompt(“And what is the answer?”, “”); d = b-c } else { b = prompt(“What number is being subtracted from /”x/”?”, “”); c = prompt(“And what is the answer?”, “”); d = (b*1)+(c*1) } } if (a==””) { d = 0 } alert(“x = “+d+””) } //multiply any number by any number, any number of times function spec(mode, obj) { if (mode==1) { alert(“Spec is handy tool that allows you to multiply a number by another number any number of times. It works kind of like powers, except the only difference is that in powers, you have multiply a number by itself any number of times. This function allows you to multiply any number by any number, any number of times.”) } if (obj.value!=”” && obj.value!=”0″) { aa = prompt(“Do you want to use the number in the total textbox as the first number?”, “y or n”) if (aa==”y”) { a = obj.value } else { a = prompt(“A number please as the first number:”, “”) } b = prompt(“And you want to multiply the number by what number?”, “”); c = prompt(“And how many times will you being multiplying the first by the second?”, “”); d = Math.pow(b,c); if (aa==”y”) { doit(a*d, obj) } else { more(‘(‘ + a*d + ‘)’, obj) } } else { a = prompt(“A number please as the first number:”, “”); b = prompt(“And you want to multiply the number by what number?”, “”); c = prompt(“And how many times will you being multiplying the first by the second?”, “”); d = Math.pow(b,c); doit(a*d, obj) } } //cube any given number function cubed(mode, obj) { if (mode==1) { alert(“Cubed allows you to cube any given number.”) } if (obj.value!=”” && obj.value!=”0″) { aa = prompt(“Do you want to cube the current number in the total textbox?”, “y or n”); if (aa==”y”) { doit(Math.pow(obj.value, 3), obj) } else { a = prompt(“Enter a number to cube:”, “”); more(‘(‘ + Math.pow(a, 3) + ‘)’, obj) } } else { a = prompt(“Enter a number to cube:”, “”); doit(Math.pow(a, 3), obj) } } //square any given number function squared(mode, obj) { if (mode==1) { alert(“Squared allows you to square any given number”) } if (obj.value!=”” && obj.value!=”0″) { aa = prompt(“Do you want to square the current number in the total textbox?”, “y or n”); if (aa==”y”) { doit(Math.pow(obj.value, 2), obj) } else { a = prompt(“Enter a number to be squared:”, “”); more(‘(‘ + Math.pow(a, 2) + ‘)’, obj) } } else { a = prompt(“Enter a number to square:”, “”); doit(Math.pow(a, 2), obj) } } //store any number in memory function mem(mode, obj, where) { if (mode==1) { alert(“Pressing the memory button allows you to save the current number in the total textbox for later use. You can Recall the remembered number by pressing the Rcl button.”) } where.value = obj.value } //recall any numbers in memory function rcl(mode, obj, where) { if (mode==1) { alert(“Rcl is a neat function that works with Memory. It recalls and gives you the number you saved in the coresponding memory.”) } if (obj.value==””) { more(”, where) } else { more(‘(‘ + obj.value + ‘)’, where) } } //find the logarythm of any given number function logrythm(mode, obj) { if (mode==1) { alert(“This function returns the natural logarythm of any given number”) } if (obj.value!=”” && obj.value!=”0″) { aa = prompt(“Do you want to find the logarythm of the number in the total textbox?”, “y or n”); if (aa==”y”) { doit(Math.log(obj.value), obj) } else { a = prompt(“Enter a number to find the logarythm of:”, “”); more(‘(‘ + Math.log(a) + ‘)’, obj) } } else { a = prompt(“Enter a number to find the logarythm of:”, “”); doit(Math.log(a), obj) } } //find the sine of any given number function sine(mode, obj) { if (mode==1) { alert(“This function returns the sine of any given number”) } if (obj.value!=”” && obj.value!=”0″) { aa = prompt(“Do you want to find the sine of the number in the total textbox?”, “y or n”); if (aa==”y”) { doit(Math.sin(obj.value), obj) } else { a = prompt(“Enter a number to find the sine of:”, “”); more(‘(‘ + Math.sin(a) + ‘)’, obj) } } else { a = prompt(“Enter a number to find the sine of:”, “”); doit(Math.sin(a), obj) } } //findthe cosine of any given number function cosine(mode, obj) { if (mode==1) { alert(“This function returns the cosine of any given number”) } if (obj.value!=”” && obj.value!=”0″) { aa = prompt(“Do you want to find the cosine of the number in the total textbox?”, “y or n”); if (aa==”y”) { doit(Math.cos(obj.value), obj) } else { a = prompt(“Enter a number to find the cosine of:”, “”); more(‘(‘ + Math.cos(a) + ‘)’, obj) } } else { a = prompt(“Enter a number to find the cosine of:”, “”); doit(Math.cos(a), obj) } } //find the tangent of any given number function tangent(mode, obj) { if (mode==1) { alert(“This function returns the tangent of any given number”) } if (obj.value!=”” && obj.value!=”0″) { aa = prompt(“Do you want to find the tangent of the number in the total textbox?”, “y or n”); if (aa==”y”) { doit(Math.tan(obj.value), obj)
} else { a = prompt(“Enter a number to find the tangent of:”, “”); more(‘(‘ + Math.tan(a) + ‘)’, obj) } } else { a = prompt(“Enter a number to find the tangent of:”, “”); doit(Math.tan(a), obj) } } //find the squareroot of any given number function squareroot(mode, obj) { if (mode==1) { alert(“This function gives you the square root of any given number”) } if (obj.value!=”” && obj.value!=”0″) { aa = prompt(“Do you want to find the square root of the current number in the total text box?”, “y or n”); if (aa==”y”) { doit(Math.sqrt(obj.value), obj) } else { a = prompt(“Enter a number to find the square root of:”, “”); more(‘(‘ + Math.sqrt(a) + ‘)’, obj) } } else { a = prompt(“Enter a number to find the square root of:”, “”); doit(Math.sqrt(a), obj) } } //fractions are cool………… function fractions(mode, obj) { if (mode==1) { alert(“Frac is a neat function that allows you to input fractions. The script will automaticly convert the fraction you give into a decimal soit will understand it. Just make sure you know the math terms: in 2 and2 fifths, 2 is the base, the next 2 is the numerator, and 5 is the denominator. If there is no base number, leave the prompt box that asks for a base empty. Without a base you can just do simple fractions such as 2 fifths.”) } if (obj.value!=”” && obj.value!=”0″) { aa = prompt(“Do you want to use the number in the total textbox as the base?”, “y or n”); if (aa==”y”) { a = obj.value } else { a = prompt(“Enter a base:”, “”); } b = prompt(“Enter a numerator:”, “”); c = prompt(“Enter a denominator”, “”); d = b/c; e = (d*1)+(a*1); if (aa==”y”) { doit(e, obj) } else { more(‘(‘ + e + ‘)’, obj) } } else { a = prompt(“Enter a base:”, “”); b = prompt(“Enter a numerator:”, “”); c = prompt(“Enter a denominator:”, “”); d = b/c; e = (d*1)+(a*1); doit(e, obj) } if (e==”nullNaN”) { more(“”, obj) } if (e==”NaN”) { more(“”, obj) } } //change the sign of any given number function negpos(mode, obj) { if (mode==1) { alert(“+/- allows the you to convert a negative(-) number to a positive(+) and a positive number to a negative. And then it puts it in the total textbox with any other number that is already in there.”) } obj.value *= (-1) } //clear any numbers in memory function mc(mode, obj1, obj2) { if (mode==1) { alert(“Memory Clear is an easy little function that erases the values of both memorys.”) } obj1.value = ”; obj2.value = ” } //convert any number into scientific notation function scie(mode, obj) { if (mode==1) { alert(“Scie is cool function that allows you to convert any given number into scientific notation. The format of the answer is as follows: Ex: input:120, output:1.2*10^2, would be 1.2 multiplied by 10 to the second power.”) } if (obj.value!=”” && obj.value!=”0″) { aa = prompt(“Do you want to convert the current number in the total textbox?”, “y or n”); if (aa==”y”) { a = obj.value } else { a = prompt(“Enter a number to convert:”, “”) } } else { a = prompt(“Enter a number to convert:”, “”) } var b = 0; while(a>10) { //divide by ten until variable is no longer greater han 10 a /= 10; b += 1 } doit(a + ‘*10^’ + b, obj) } //convert any number out of scientific notation to standard form function unscie(mode, obj) { if (mode==1) { alert(“UnScie does the exact opposite of Scie. It allows you to input number in scientific notation and it will output the number in standard notation. Ex: input:1.2*10^2, output:120”) } a = prompt(“Enter the number that is the decimal:”, “”); b = prompt(“Enter the power that is given to 10:”, “”); c = Math.pow(10, b); d = a*c; if (obj.value!=”” && obj.value!=”0″) { e = prompt(“Do you want to use this result as a part of another calculation in the total textbox?”, “y or n”); if (e==”y”) { more(‘(‘ + d + ‘)’, obj) } else { doit(d, obj) } } else { doit(d, obj) } } //HELP!! function helpround() { if (document.mainform.mode[0].checked) { alert(“Round is an easy function that simply rounds the number in the total textbox to the nearest whole number.”) } } function helppi () { if (document.mainform.mode[0].checked) { alert(“PI is an easy function that just gives you PI. 3.14……”) } } </script> <script language=”javascript”> /*********************************************** DHTML Calendar by Jason Moon hacked by billmap.com ************************************************/ varDefaultDateFormat = ‘MM/DD/YYYY’; var HideWait = 1; var Y2kPivotPoint = 76; var UnselectedMonthText = ”; var FontSize = 11; var FontFamily = ‘Tahoma’; var CellWidth = 20; var CellHeight = 16; var ImageURL = ‘http://billmap.com/images/calendar.jpg’; var NextURL = ‘http://billmap.com/images/next.gif’; var PrevURL = ‘http://billmap.com/images/prev.gif’; var CalBGColor = ‘white’; var TopRowBGColor = ‘buttonface’; var DayBGColor = ‘lightgrey’; var ZCounter = 100; var Today = new Date(); var WeekDays = new Array(‘日 ‘,’一’,’二’,’三’,’四’,’五’,’六’); var MonthDays = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); var MonthNames = new Array(‘1′,’2′,’3′,’4′,’5′,’6′,’7′,’8′,’9′,’10’,’11’,’12’); with (document) { writeln(‘<style>’); writeln(‘td.calendarDateInput {letter-spacing:normal;line-height:normal;font-family:’ + FontFamily + ‘,Sans-Serif;font-size:’ + FontSize + ‘px;}’); writeln(‘select.calendarDateInput {letter-spacing:.06em;font-family:Verdana,Sans-Serif;font-size:11px;}’); writeln(‘input.calendarDateInput {letter-spacing:.06em;font-family:Verdana,Sans-Serif;font-size:11px;}’); writeln(‘</style>’); } function GetTagPixels(StartTag, Direction) { var PixelAmt = (Direction == ‘LEFT’) ? StartTag.offsetLeft : StartTag.offsetTop; while ((StartTag.tagName != ‘BODY’) && (StartTag.tagName != ‘HTML’)) { StartTag = StartTag.offsetParent; PixelAmt += (Direction == ‘LEFT’) ? StartTag.offsetLeft : StartTag.offsetTop; } return PixelAmt; } function BehindCal(SelectList, CalLeftX, CalRightX, CalTopY, CalBottomY, ListTopY) { var ListLeftX = GetTagPixels(SelectList, ‘LEFT’); var ListRightX = ListLeftX + SelectList.offsetWidth; var ListBottomY = ListTopY + SelectList.offsetHeight; return (((ListTopY <
CalBottomY) && (ListBottomY > CalTopY)) && ((ListLeftX < CalRightX) && (ListRightX > CalLeftX))); } function FixSelectLists(Over) { if (navigator.appName == ‘Microsoft Internet Explorer’) { var CalDiv = this.getCalendar(); var CalLeftX = CalDiv.offsetLeft; var CalRightX = CalLeftX + CalDiv.offsetWidth; var CalTopY = CalDiv.offsetTop; var CalBottomY = CalTopY + (CellHeight * 9); var FoundCalInput = false; formLoop : for (var j=this.formNumber;j<document.forms.length;j++) { for (var i=0;i<document.forms[j].elements.length;i++) { if (typeof document.forms[j].elements[i].type == ‘string’) { if ((document.forms[j].elements[i].type == ‘hidden’) && (document.forms[j].elements[i].name == this.hiddenFieldName)) { FoundCalInput = true; i += 3; } if (FoundCalInput) { if (document.forms[j].elements[i].type.substr(0,6) == ‘select’) { ListTopY = GetTagPixels(document.forms[j].elements[i], ‘TOP’); if (ListTopY < CalBottomY) { if (BehindCal(document.forms[j].elements[i], CalLeftX, CalRightX, CalTopY, CalBottomY, ListTopY)) { document.forms[j].elements[i].style.visibility = (Over) ? ‘hidden’ : ‘visible’; } } else break formLoop; } } } } } } } function DayCellHover(Cell, Over, Color, HoveredDay) { Cell.style.backgroundColor = (Over) ? DayBGColor : Color; if (Over) { if ((this.yearValue == Today.getFullYear()) && (this.monthIndex == Today.getMonth()) && (HoveredDay == Today.getDate())) self.status = ‘选择今天’; else { var Suffix = HoveredDay.toString(); switch (Suffix.substr(Suffix.length – 1, 1)) { case ‘1’ : Suffix += (HoveredDay == 11) ? ‘th’ : ‘st’; break; case ‘2’ : Suffix += (HoveredDay == 12) ? ‘th’ : ‘nd’; break; case ‘3’ : Suffix += (HoveredDay == 13) ? ‘th’ : ‘rd’; break; default : Suffix += ‘th’; break; } } } else self.status = ”; return true; } function PickDisplayDay(ClickedDay) { this.show(); this.setPicked(this.displayed.yearValue, this.displayed.monthIndex, ClickedDay); } function BuildCalendarDays() { var Rows = 5; if (((this.displayed.dayCount == 31) && (this.displayed.firstDay > 4)) || ((this.displayed.dayCount == 30) && (this.displayed.firstDay == 6))) Rows = 6; else if ((this.displayed.dayCount == 28) && (this.displayed.firstDay == 0)) Rows = 4; var HTML = ‘<table width=”‘ + (CellWidth * 7) + ‘” cellspacing=”0″ cellpadding=”1″ style=”cursor:default”>’; for (var j=0;j<rows;j++) { HTML += ‘<tr>’; for (var i=1;i<=7;i++) { Day = (j * 7) + (i – this.displayed.firstDay); if ((Day >= 1) && (Day <= this.displayed.dayCount)) { if ((this.displayed.yearValue == this.picked.yearValue) && (this.displayed.monthIndex == this.picked.monthIndex) && (Day == this.picked.day)) { TextStyle = ‘color:white;font-weight:bold;’ BackColor = DayBGColor; } else { TextStyle= ‘color:black;’ BackColor = CalBGColor; } if ((this.displayed.yearValue == Today.getFullYear()) && (this.displayed.monthIndex == Today.getMonth()) && (Day == Today.getDate())) TextStyle += ‘border:1px solid darkred;padding:0px;’; HTML += ‘<td align=”center” class=”calendarDateInput” style=”cursor:default;height:’ + CellHeight + ‘;width:’ + CellWidth + ‘;’ + TextStyle + ‘;background-color:’ + BackColor + ‘” onClick=”‘ + this.objName + ‘.pickDay(‘ + Day + ‘)” onMouseOver=”return ‘ + this.objName + ‘.displayed.dayHover(this,true,/” + BackColor + ‘/’,’ + Day + ‘)” onMouseOut=”return ‘ + this.objName + ‘.displayed.dayHover(this,false,/” + BackColor + ‘/’)”>’ + Day + ‘</td>’; } else HTML += ‘<td class=”calendarDateInput” style=”height:’ + CellHeight + ‘”> </td>’; } HTML += ‘</tr>’; } return HTML += ‘</table>’; } function GetGoodYear(YearDigits) { if (YearDigits.length == 4) return YearDigits; else { var Millennium = (YearDigits < Y2kPivotPoint) ? 2000 : 1900; return Millennium + parseInt(YearDigits,10); } } function GetDayCount(SomeYear, SomeMonth) { return ((SomeMonth == 1) && ((SomeYear % 400 == 0) || ((SomeYear % 4 == 0) && (SomeYear % 100 != 0)))) ? 29 : MonthDays[SomeMonth]; } function VirtualButton(Cell, ButtonDown) { if (ButtonDown) { Cell.style.borderLeft = ‘buttonshadow 1px solid’; Cell.style.borderTop = ‘buttonshadow 1px solid’; Cell.style.borderBottom = ‘buttonhighlight 1px solid’; Cell.style.borderRight = ‘buttonhighlight 1px solid’; } else { Cell.style.borderLeft = ‘buttonhighlight 1px solid’; Cell.style.borderTop = ‘buttonhighlight 1px solid’; Cell.style.borderBottom = ‘buttonshadow 1px solid’; Cell.style.borderRight = ‘buttonshadow 1px solid’; } } function NeighborHover(Cell, Over, DateObj) { if (Over) { VirtualButton(Cell, false); } else { Cell.style.border = ‘buttonface 1px solid’; self.status = ”; } return true; } function FixDayList(DayList, NewDays) { var DayPick = DayList.selectedIndex + 1; if (NewDays != DayList.length) { var OldSize = DayList.length; for (var k=Math.min(NewDays,OldSize);k<math.max(NewDays,OldSize);k++) { (k >= NewDays) ?DayList.options[NewDays] = null : DayList.options[k] = new Option(k+1, k+1); } DayPick = Math.min(DayPick, NewDays); DayList.options[DayPick-1].selected = true; } return DayPick; } function FixYearInput(YearField) { var YearRE = new RegExp(‘//d{‘ + YearField.defaultValue.length + ‘}’); if (!YearRE.test(YearField.value)) YearField.value = YearField.defaultValue; } function CalIconHover(Over) { var Message = (this.isShowing()) ? ‘hide’ : ‘show’; return true; } function CalTimerReset() { eval(‘clearTimeout(‘ + this.timerID + ‘)’); eval(this.timerID + ‘=setTimeout(/” + this.objName + ‘.show()/’,’ + (HideWait * 1000) + ‘)’); } function DoTimer(CancelTimer) { if (CancelTimer) eval(‘clearTimeout(‘ + this.timerID + ‘)’); else { eval(this.timerID + ‘=null’); this.resetTimer(); } } function ShowCalendar() { if (this.isShowing()) { var StopTimer = true; this.getCalendar().style.zIndex = –ZCounter; this.getCalendar().style.visibility = ‘hidden’; this.fixSelects(false); } else { var StopTimer = false; this.fixSelects(true); this.getCalendar().style.zIndex = ++ZCounter; this.getCalendar().style.visibility = ‘visible’; } this.handleTimer(StopTimer); self.status = ”; } function SetElementStatus(Hide) { this.getDayList().style.visibility = (Hide) ? ‘hidden’ : ‘visible’; this.getYearField().style.visibility = (Hide) ? ‘hidden’ : ‘visible’; this.getCalendarLink().style.visibility = (Hide) ? ‘hidden’ : ‘visible’; } function CheckMonthChange(MonthList) { var DayList = this.getDayList(); if (MonthList.options[MonthList.selectedIndex].value == ”) { DayList.selectedIndex = 0; this.hideElements(true); this.setHidden(”); } else { this.hideElements(false); if (this.isShowing()) { this.resetTimer(); this.getCalendar().style.zIndex = ++ZCounter; } var DayPick = FixDayList(DayList, GetDayCount(this.picked.yearValue, MonthList.options[MonthList.selectedIndex].value)); this.setPicked(this.picked.yearValue, MonthList.options[MonthList.selectedIndex].value, DayPick); } } function CheckDayChange(DayList) { if (this.isShowing()) this.show(); this.setPicked(this.picked.yearV
alue, this.picked.monthIndex, DayList.selectedIndex+1); } function CheckYearInput(YearField) { if ((YearField.value.length == YearField.defaultValue.length) && (YearField.defaultValue != YearField.value)) { if (this.isShowing()) { this.resetTimer(); this.getCalendar().style.zIndex = ++ZCounter; } var NewYear = GetGoodYear(YearField.value); var MonthList = this.getMonthList(); var NewDay = FixDayList(this.getDayList(), GetDayCount(NewYear, this.picked.monthIndex)); this.setPicked(NewYear, this.picked.monthIndex, NewDay); YearField.defaultValue = YearField.value; } } function dateObject() { if (Function.call) { var ParentObject = this; var ArgumentStart = 0; } else { var ParentObject = arguments[0]; var ArgumentStart = 1; } ParentObject.date = (arguments.length == (ArgumentStart+1)) ? new Date(arguments[ArgumentStart+0]) : new Date(arguments[ArgumentStart+0], arguments[ArgumentStart+1], arguments[ArgumentStart+2]); ParentObject.yearValue = ParentObject.date.getFullYear(); ParentObject.monthIndex = ParentObject.date.getMonth(); ParentObject.monthName = MonthNames[ParentObject.monthIndex]; ParentObject.fullName = ParentObject.yearValue + ‘年’ +ParentObject.monthName + ‘月’ ; ParentObject.day = ParentObject.date.getDate(); ParentObject.dayCount = GetDayCount(ParentObject.yearValue, ParentObject.monthIndex); var FirstDate = new Date(ParentObject.yearValue, ParentObject.monthIndex, 1); ParentObject.firstDay = FirstDate.getDay(); } function storedMonthObject(DateFormat, DateYear, DateMonth, DateDay) { (Function.call) ? dateObject.call(this, DateYear, DateMonth, DateDay) : dateObject(this, DateYear, DateMonth, DateDay); this.yearPad = this.yearValue.toString(); this.monthPad = (this.monthIndex < 9) ? ‘0’ + String(this.monthIndex + 1) : this.monthIndex + 1; this.dayPad = (this.day < 10) ? ‘0’ + this.day.toString() : this.day; this.monthShort = this.monthName.substr(0,3).toUpperCase(); if (DateFormat.indexOf(‘YYYY’) == -1) this.yearPad = this.yearPad.substr(2); if (DateFormat.indexOf(‘/’) >= 0) var Delimiter = ‘/’; else if (DateFormat.indexOf(‘-‘) >= 0) var Delimiter = ‘-‘; else var Delimiter = ”; if (/DD?.?((MON)|(MM?M?))/.test(DateFormat)) { this.formatted = this.dayPad + Delimiter; this.formatted += (RegExp.$1.length == 3) ? this.monthShort : this.monthPad; } else if (/((MON)|(MM?M?))?.?DD?/.test(DateFormat)) { this.formatted = (RegExp.$1.length == 3) ? this.monthShort : this.monthPad; this.formatted += Delimiter + this.dayPad; } this.formatted = (DateFormat.substr(0,2) == ‘YY’) ? this.yearPad + Delimiter + this.formatted : this.formatted + Delimiter + this.yearPad; } function displayMonthObject(ParentObject, DateYear, DateMonth, DateDay) { (Function.call) ? dateObject.call(this, DateYear, DateMonth, DateDay) : dateObject(this, DateYear, DateMonth, DateDay); this.displayID = ParentObject.hiddenFieldName + ‘_Current_ID’; this.getDisplay = new Function(‘return document.getElementById(this.displayID)’); this.dayHover = DayCellHover; this.goCurrent = new Function(ParentObject.objName + ‘.getCalendar().style.zIndex=++ZCounter;’ + ParentObject.objName + ‘.setDisplayed(Today.getFullYear(),Today.getMonth());’); if (ParentObject.formNumber >= 0) this.getDisplay().innerHTML = this.fullName; } function neighborMonthObject(ParentObject, IDText, DateMS) { (Function.call) ? dateObject.call(this, DateMS) : dateObject(this, DateMS); this.buttonID = ParentObject.hiddenFieldName + ‘_’ + IDText + ‘_ID’; this.hover = new Function(‘C’,’O’,’NeighborHover(C,O,this)’); this.getButton = new Function(‘return document.getElementById(this.buttonID)’); this.go = new Function(ParentObject.objName + ‘.getCalendar().style.zIndex=++ZCounter;’ + ParentObject.objName + ‘.setDisplayed(this.yearValue,this.monthIndex);’); if (ParentObject.formNumber >= 0) this.getButton().title = this.monthName; } function SetDisplayedMonth(DispYear, DispMonth) { this.displayed = new displayMonthObject(this, DispYear, DispMonth, 1); this.previous = new neighborMonthObject(this, ‘Previous’, this.displayed.date.getTime() – 86400000); this.next = new neighborMonthObject(this, ‘Next’, this.displayed.date.getTime() + (86400000 * (this.displayed.dayCount + 1))); if (this.formNumber >= 0) this.getDayTable().innerHTML = this.buildCalendar(); } function SetPickedMonth(PickedYear, PickedMonth, PickedDay) { this.picked = new storedMonthObject(this.format, PickedYear, PickedMonth, PickedDay); this.setHidden(this.picked.formatted); this.setDisplayed(PickedYear, PickedMonth); } function calendarObject(DateName, DateFormat, DefaultDate) { this.hiddenFieldName = DateName; this.monthListID = DateName + ‘_Month_ID’; this.dayListID = DateName + ‘_Day_ID’; this.yearFieldID = DateName + ‘_Year_ID’; this.monthDisplayID = DateName + ‘_Current_ID’; this.calendarID = DateName + ‘_ID’; this.dayTableID = DateName + ‘_DayTable_ID’; this.calendarLinkID = this.calendarID + ‘_Link’; this.timerID = this.calendarID + ‘_Timer’; this.objName = DateName + ‘_Object’; this.format = DateFormat; this.formNumber = -1; this.picked = null; this.displayed = null; this.previous = null; this.next = null; /* M */ this.setPicked = SetPickedMonth; this.setDisplayed = SetDisplayedMonth; this.checkYear = CheckYearInput; this.fixYear = FixYearInput; this.changeMonth = CheckMonthChange; this.changeDay = CheckDayChange; this.resetTimer = CalTimerReset; this.hideElements = SetElementStatus; this.show = ShowCalendar; this.handleTimer = DoTimer; this.iconHover = CalIconHover; this.buildCalendar = BuildCalendarDays; this.pickDay = PickDisplayDay; this.fixSelects = FixSelectLists; this.setHidden = new Function(‘D’,’if (this.formNumber >= 0) this.getHiddenField().value=D’); this.getHiddenField = new Function(‘return document.forms[this.formNumber].elements[“d”]’); this.getMonthList = new Function(‘return document.getElementById(this.monthListID)’); this.getDayList = new Function(‘return document.getElementById(this.dayListID)’); this.getYearField = new Function(‘return document.getElementById(this.yearFieldID)’); this.getCalendar = new Function(‘return document.getElementById(this.calendarID)’); this.getDayTable = new Function(‘return document.getElementById(this.dayTableID)’); this.getCalendarLink = new Function(‘return document.getElementById(this.calendarLinkID)’); this.getMonthDisplay = new Function(‘return document.getElementById(this.monthDisplayID)’); this.isShowing = new Function(‘return !(this.getCalendar().style.visibility != /’visible/’)’); function getMonthIndex(MonthAbbr) { for (var MonPos=0;MonPos<monthNames.length;MonPos++) { if (MonthNames[MonPos].substr(0,3).toUpperCase() == MonthAbbr.toUpperCase()) break; } return MonPos; } function SetGoodDate(CalObj, Notify) { CalObj.setPicked(Today.getFullYear(), Today.getMonth(), Today.getDate()); if (Notify) alert(‘WARNING: The supplied date is not in valid /” + DateFormat + ‘/’ format: ‘ + DefaultDate + ‘./nTherefore, the current system date will be used instead: ‘ + CalObj.picked.formatted); } if (DefaultDate != ”) { if ((this.format == ‘YYYYMMDD’) && (/^(/d{4})(/d{2})(/d{2})$/.test(DefaultDate))) this.setPicked(RegExp.$1, parseInt(RegExp.$2,10)-1, RegExp.$3); else { if ((this.format.substr(0,2) == ‘YY’) && (/^(/d{2,4})(-|//)/.test(DefaultDate))) { var YearPart = GetGoodYear(RegExp.$1); if (/(-|//)(/w{1,3})(-|//)(/w{1,3})$/.test(DefaultDate)) { var MidPart = RegExp.$2; var EndPart = RegExp.$4; if (/D$/.test(this.format)) { var DayPart = EndPart; var MonthPart = MidPart;
} else { var DayPart = MidPart; var MonthPart = EndPart; } MonthPart = (//d{1,2}/i.test(MonthPart)) ? parseInt(MonthPart,10)-1 : getMonthIndex(MonthPart); this.setPicked(YearPart, MonthPart, DayPart); } else SetGoodDate(this, true); } else if (/(-|//)(/d{2,4})$/.test(DefaultDate)) { var YearPart = GetGoodYear(RegExp.$2); if (/^(/w{1,3})(-|//)(/w{1,3})(-|//)/.test(DefaultDate)) { if (this.format.substr(0,1) == ‘D’) { var DayPart = RegExp.$1; var MonthPart = RegExp.$3; } else { var MonthPart = RegExp.$1; var DayPart = RegExp.$3; } MonthPart = (//d{1,2}/i.test(MonthPart)) ? parseInt(MonthPart,10)-1 : getMonthIndex(MonthPart); this.setPicked(YearPart, MonthPart, DayPart); } else SetGoodDate(this, true); } else SetGoodDate(this, true); } } } function DateInput(DateName, Required, DateFormat, DefaultDate) { if (arguments.length == 0) document.writeln(‘<span style=”color:red;font-size:’ + FontSize + ‘px;font-family:’ + FontFamily + ‘;”>ERROR: Missing required parameter in call to /’DateInput/’: [name of hidden date field].</span>’); else { if (arguments.length < 3) { DateFormat = DefaultDateFormat; if (arguments.length < 2) Required = false; } else if (/^(Y{2,4}(-|//)?)?((MON)|(MM?M?)|(DD?))(-|//)?((MON)|(MM?M?)|(DD?))((-|//)Y{2,4})?$/i.test(DateFormat)) DateFormat = DateFormat.toUpperCase(); else { var AlertMessage = ‘WARNING: The supplied date format for the /” + DateName + ‘/’ field is not valid: ‘ + DateFormat + ‘/nTherefore, the default date format will be used instead: ‘ + DefaultDateFormat; DateFormat = DefaultDateFormat; if (arguments.length == 4) { var CurrentDate = new storedMonthObject(DateFormat, Today.getFullYear(), Today.getMonth(), Today.getDate()); AlertMessage += ‘/n/nThe supplied date (‘ + DefaultDate + ‘) cannot be interpreted with the invalid format./nTherefore, the current system date will be used instead: ‘ + CurrentDate.formatted; DefaultDate = CurrentDate.formatted; } alert(AlertMessage); } if (!CurrentDate) var CurrentDate = new storedMonthObject(DateFormat, Today.getFullYear(), Today.getMonth(), Today.getDate()); if (arguments.length < 4) { DefaultDate = (Required) ? CurrentDate.formatted : ”; } eval(DateName + ‘_Object=new calendarObject(/” + DateName + ‘/’,/” + DateFormat + ‘/’,/” + DefaultDate + ‘/’)’); if ((Required) || (arguments.length == 4)) { var InitialStatus = ”; var InitialDate = eval(DateName + ‘_Object.picked.formatted’); } else { var InitialStatus = ‘ style=”visibility:hidden”‘; var InitialDate = ”; eval(DateName + ‘_Object.setPicked(‘ + Today.getFullYear() + ‘,’ + Today.getMonth() + ‘,’ + Today.getDate() + ‘)’); } with (document) { writeln(‘<input type=”hidden” name=”‘ + DateName + ‘” value=”‘ + InitialDate + ‘”>’); for (var f=0;f<forms.length;f++) { for (var e=0;e<forms[f].elements.length;e++) { if (typeof forms[f].elements[e].type == ‘string’) { if ((forms[f].elements[e].type == ‘hidden’) && (forms[f].elements[e].name == DateName)) { eval(DateName + ‘_Object.formNumber=’+f); break; } } } } writeln(‘<table cellpadding=”0″ cellspacing=”2″><tr>’ + String.fromCharCode(13) + ‘<td valign=”middle”>’); writeln(‘<input type=”text” name=”d” id=”d” onclick=”javascript:’ + DateName + ‘_Object.show()” value=”‘+DefaultDate+'” readonly=”1″ size=”10″>’); writeln(‘<td valign=”middle”>’); write(‘<td valign=”middle”>’ + String.fromCharCode(13) + ‘<a’ + InitialStatus + ‘ id=”‘ + DateName + ‘_ID_Link” href=”javascript:’ + DateName + ‘_Object.show()” onMouseOver=”return ‘ + DateName + ‘_Object.iconHover(true)” onMouseOut=”return ‘ + DateName + ‘_Object.iconHover(false)”></a> ‘); writeln(‘<span id=”‘ + DateName + ‘_ID” style=”position:absolute;visibility:hidden;width:’ + (CellWidth * 7) + ‘px;background-color:’ + CalBGColor + ‘;border:1px solid dimgray;” onMouseOver=”‘ + DateName + ‘_Object.handleTimer(true)” onMouseOut=”‘ + DateName + ‘_Object.handleTimer(false)”>’); writeln(‘<table width=”‘ + (CellWidth * 7) + ‘” cellspacing=”0″ cellpadding=”1″>’ + String.fromCharCode(13) + ‘<tr style=”background-color:’ + TopRowBGColor + ‘;”>’); writeln(‘<td id=”‘ + DateName + ‘_Previous_ID” style=”cursor:default” align=”center” class=”calendarDateInput” style=”height:’ + CellHeight + ‘” onClick=”‘ + DateName + ‘_Object.previous.go()” onMouseDown=”VirtualButton(this,true)” onMouseUp=”VirtualButton(this,false)” onMouseOver=”return ‘ + DateName + ‘_Object.previous.hover(this,true)” onMouseOut=”return ‘ + DateName + ‘_Object.previous.hover(this,false)” title=”‘ + eval(DateName + ‘_Object.previous.monthName’) + ‘月”><img src=”‘ + PrevURL + ‘”></td>’); writeln(‘<td id=”‘ + DateName + ‘_Current_ID” style=”cursor:pointer” align=”center” class=”calendarDateInput” style=”height:’ + CellHeight + ‘” colspan=”5″ onClick=”‘ + DateName + ‘_Object.displayed.goCurrent()” onMouseOut=”self.status=/’/’;return true;” title=”显示本月”>’ + eval(DateName + ‘_Object.displayed.fullName’) + ‘</td>’); writeln(‘<td id=”‘ + DateName + ‘_Next_ID” style=”cursor:default” align=”center” class=”calendarDateInput” style=”height:’ + CellHeight + ‘” onClick=”‘ + DateName + ‘_Object.next.go()” onMouseDown=”VirtualButton(this,true)” onMouseUp=”VirtualButton(this,false)” onMouseOver=”return ‘ + DateName + ‘_Object.next.hover(this,true)” onMouseOut=”return ‘ + DateName + ‘_Object.next.hover(this,false)” title=”‘ + eval(DateName + ‘_Object.next.monthName’) + ‘月”><img src=”‘ + NextURL + ‘”></td></tr>’ + String.fromCharCode(13) + ‘<tr>’); for (var w=0;w<7;w++) writeln(‘<td width=”‘ + CellWidth + ‘” align=”center” class=”calendarDateInput” style=”height:’ + CellHeight + ‘;width:’ + CellWidth + ‘;font-weight:bold;border-top:1px solid dimgray;border-bottom:1px solid dimgray;”>’ + WeekDays[w] + ‘</td>’); writeln(‘</tr>’ + String.fromCharCode(13) + ‘</table>’ + String.fromCharCode(13) + ‘<span id=”‘ + DateName + ‘_DayTable_ID”>’ + eval(DateName + ‘_Object.buildCalendar()’) + ‘</span>’ + String.fromCharCode(13) + ‘</span>’ + String.fromCharCode(13) + ‘</td>’ + String.fromCharCode(13) + ‘</tr>’ + String.fromCharCode(13) + ‘</table>’); } } } </script> <div class=”menu”> <a href=”/home/friend.php” title=”显示你的好友”>好友</a> <a href=”/home/up.php?t=in” accessKey=”i” title=”快捷键:ALT+i”>增加收入</a> <a href=”/home/up.php?t=out” accessKey=”o” title=”快捷键:ALT+o”>增加支出</a> <a href=”/home/view.php?t=in” accessKey=”j” title=”快捷键:ALT+j”>浏览收入</a> <a href=”/home/view.php?t=out” accessKey=”k” title=”快捷键:ALT+k”>浏览支出</a> <a href=”/home/report.php” accessKey=”R” title=”快捷键:ALT+r”>报表</a> <a href=”/” accessKey=”b”>首页</a> <a href=”/tag.php” accessKey=”t”>标签</a> <a href=”/forum/index.php” accessKey=”f”>论坛</a> <a href=”/help/index.php” accessKey=”h”>帮助</a> <a href=”/intro.php” accessKey=”d”>介绍</a> <a href=”/contact.php” accessKey=”c”>联系</a> </div> <form name=”add” method=”post” action=””> <font color=red>计算器,日历及快捷键展示</font> <table> <tr><td>收入金额</td> <td><input type=”text” name=”bill” id=”bill” value=””>  <im
g src=”http://billmap.com/images/calculator.gif” width=”16″ id=”calculator_img” title=”计算器” alt=”计算器”/> <!– dropdown news start –> <style> body,table,tr,td{font-size:12px;} #cal_pad { border: 1px solid #efefef; padding: 5px; margin:5px; width:160px; background-color: #FFFFff; } .clear { clear:both; margin-bottom:-3px; * margin-bottom:-2px; } .clear_pull { clear:both; margin-bottom:-4px; * margin-bottom:-8px; } #cal_pad ul { margin:0; padding:0; } #cal_pad li { border: 1px solid #efefef; font:13px Verdana normal; list-style-type: none; float:left; margin: 0 3px 3px 0; } #cal_pad a { display:block; padding: 6px 9px; text-align:center; text-decoration: none; background: #fafafa; } #cal_pad a:hover { background: #E6E6F2; } </style> <div id=”cal_pad”> <ul> <li> <input type=”text” name=”c_result” id=”c_result” style=”width: 115px;height:20px;” value=”0″> <script language=”JavaScript” > var cr = document.getElementById(“c_result”); </script> </li> <li><a href=”javascript:void(‘0’);” onclick=”cleart(cr)” title=”清除”>C</a></li> </ul> <ul> <li><a href=”javascript:void(‘0’);” onclick=”more(1, cr)” title=”1″>1</a></li> <li><a href=”javascript:void(‘0’);” onclick=”more(2, cr)” title=”2″>2</a></li> <li><a href=”javascript:void(‘0’);” onclick=”more(3, cr)” title=”3″>3</a></li> <li><a href=”javascript:void(‘0’);” onclick=”more(‘+’, cr)” title=”加号”>+</a></li> <li><a href=”javascript:void(‘0’);” onclick=”more(‘-‘, cr)” title=”减号”>-</a></li> <li><a href=”javascript:void(‘0’);” onclick=”more(4, cr)” title=”4″>4</a></li> <li><a href=”javascript:void(‘0’);” onclick=”more(5, cr)” title=”5″>5</a></li> <li><a href=”javascript:void(‘0’);” onclick=”more(6, cr)” title=”6″>6</a></li> <li><a href=”javascript:void(‘0’);” onclick=”more(‘*’, cr)” title=”乘号”>X</a></li> <li><a href=”javascript:void(‘0’);” onclick=”more(‘/’, cr)” title=”除号”>/</a></li> <li><a href=”javascript:void(‘0’);” onclick=”more(7, cr)” title=”7″>7</a></li> <li><a href=”javascript:void(‘0’);” onclick=”more(8, cr)” title=”8″>8</a></li> <li><a href=”javascript:void(‘0’);” onclick=”more(9, cr)” title=”9″>9</a></li> <li><a href=”javascript:void(‘0’);” onclick=”more(‘(‘, cr)” title=”左括号”>(</a></li> <li><a href=”javascript:void(‘0’);” onclick=”more(‘)’, cr)” title=”右括号”>)</a></li> <li><a href=”javascript:void(‘0’);” onclick=”more(0, cr)” title=”0″>0</a></li> <li><a href=”javascript:void(‘0’);” onclick=”more(‘.’, cr)” title=”小数点”>.</a></li> <li><a href=”javascript:void(‘0′);” onclick=”calc(cr, cr ,’bill’)” title=”等号”>===</a></li> <li><a href=”javascript:void(‘0’);” onclick=”less(cr)” title=”撤销”><–</a></li> </ul> <div class=”clear”></div> </div> <script type=”text/javascript”> at_attach(“calculator_img”, “cal_pad”, “click”, “x”, “pointer”); </script> <!– dropdown news end –> <span class=”alert”>*</span> </td> </tr> <tr> <td>类别</td> <td><select name=”cat”><option label=”工资” value=”201100″>工资</option> <option label=”奖金” value=”201200″>奖金</option> <option label=”兼职” value=”201300″>兼职</option> <option label=”额外津贴” value=”201400″>额外津贴</option> <option label=”分红” value=”201500″>分红</option> <option label=”其他收入” value=”201600″>其他收入</option> </select> <span class=”alert”>*</span></td> </tr> <tr> <td>标题</td> <td><input type=”text” name=”title” value=””> <span class=”alert”>*</span></td> </tr> <tr> <td>日期</td> <td><!–<input type=”text” name=”d” id=”d” value=”” readonly=”1″>–> <script>DateInput(‘bill_date’, true, ‘YYYY-MM-DD’,’2006-05-26′)</script></td> </tr> <tr> <td>标签</td> <td><input type=”text” name=”tag” value=””> <span class=”alert”></span>(用空格分隔)</td> </tr> <tr> <td>详情</td> <td><textarea name=”content” cols=”30″ rows=”5″></textarea><span class=”alert”></span></td> </tr> <!– <tr> <td>图片</td> <td><input type=”text” name=”img” value=”” size=”26″><span class=”alert”></span><span class=”tips”>(图片链接) <a href=”/about.php#image”>怎样找图片?</a><img src=”/images/ext_link.gif”/></span></td> </tr> –> <tr> <td>状态</td> <td> <label><input type=”radio” name=”display” value=”1″ checked=”checked” />公开</label> <label><input type=”radio” name=”display” value=”0″ />不公开</label> </td> </tr> <tr> <td><input type=”hidden” name=”op” value=”add”><input type=”hidden” name=”type” value=”in”></td> <td align=”right”><input type=”submit” class=”but” value=” 填好了 “></td> </tr> </table> </form>

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理

相关文章

开始在上面输入您的搜索词,然后按回车进行搜索。按ESC取消。

返回顶部