123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221 |
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <title></title>
- <script type="text/javascript"> document.domain = "1473.cn";</script>
- <script src="http://www.1473.cn/js/UC/UC23.js" type="text/javascript"></script>
- <link href="../css/UCity/U.City.css" rel="stylesheet" type="text/css" />
- <script>
- U.Date = function (idd) {
- var _U = new U.DateT();
- ($("#" + idd + "e")[0]) ? _U.dis(idd) : _U.init(idd);
- }
- U.DateT = function () { }
- U.DateT.prototype = {
- init: function (idd) { // 初始化
- this.bool = false;
- this.r_R_d = new Date();
- var _D = new Date();
- this.Year = _D.getFullYear();
- this.Day = _D.getDate();
- this.Month = _D.getMonth() + 1;
- this.Hs = _D.getHours();
- this.Mi = _D.getMinutes();
- this.Se = _D.getSeconds();
- this.LV(idd);
- this.LD();
- this.Main(idd);
- this.GOE(this, idd);
- },
- dis: function (idd) {
- var a = $("#" + idd + "e")[0];
- (a.style.display == "none") ? a.style.display = "block" : a.style.display = "none";
- ($(".U_Date_bg")[0].style.display == "none") ? $(".U_Date_bg")[0].style.display = "block" : $(".U_Date_bg")[0].style.display = "none";
- },
- LV: function (idd) { //加载视图
- // IPA = $$("a", { "onclick": [[U.M.StopBubble], [this.Zoom, (["Out", _UIOD, this])]] }, _UICD);
- var Box = $$("div", { "id": idd + "e", "className": "Box", "style": { "top": 20 + $("#" + idd)[0].offsetTop + "px", "left": $("#" + idd)[0].offsetLeft + "px"} }, document.body)
- $$("div", { "className": "U_Date_bg", "onclick": [[this.des, ([])]], "style": { "width": US.Width + "px", "height": US.Height + "px"} }, $("body")[0])
- , Top = $$("div", { "className": "Top" }, Box)
- , Middle = $$("div", { "className": "Middle" }, Box)
- , btn_T = $$("div", { "className": "btn_T" }, Middle)
- , b_left2 = $$("div", { "onclick": [[this.Lert, ([this, -1, idd])]], "className": "b_left2", "innerHTML": "◀" }, btn_T)
- , b_date = $$("div", { "className": "b_date" }, btn_T)
- , b_right = $$("div", { "onclick": [[this.Lert, ([this, 1, idd])]], "className": "b_right", "innerHTML": "▶" }, btn_T)
- , Bottom = $$("div", { "className": "bottom" }, Box)
- // , D_Y = $$("input", { "type": "text", "maxLength": "4", "style": { "margin-left": "1px", "outline": "none", "float": "left", "width": "30px", "height": "15px"} }, Bottom)
- // , D_U = $$("input", { "type": "text", "maxLength": "2", "style": { "margin-left": "1px", "outline": "none", "float": "left", "width": "15px", "height": "15px"} }, Bottom)
- // , D_R = $$("input", { "type": "text", "maxLength": "2", "style": { "margin-left": "1px", "outline": "none", "float": "left", "width": "15px", "height": "15px"} }, Bottom)
- // , D_H = $$("input", { "type": "text", "maxLength": "2", "style": { "margin-left": "5px", "outline": "none", "float": "left", "width": "15px", "height": "15px"} }, Bottom)
- // , D_M = $$("input", { "type": "text", "maxLength": "2", "style": { "margin-left": "1px", "outline": "none", "float": "left", "width": "15px", "height": "15px"} }, Bottom)
- // , D_S = $$("input", { "type": "text", "maxLength": "2", "style": { "margin-left": "1px", "outline": "none", "float": "left", "width": "15px", "height": "15px"} }, Bottom)
- , D_OK = $$("input", { "className": "D_OK", "onclick": [[this.Fix, ([this, idd])]], "type": "button", "value": "确定" }, Bottom)
- , D_clear = $$("input", { "className": "D_OK", "onclick": [[this.clear, ([this, idd])]], "type": "button", "value": "清除" }, Bottom)
- , D_Now = $$("input", { "className": "D_OK", "onclick": [[this.now, ([this, idd])]], "type": "button", "value": "至今" }, Bottom)
- , O_R = ["日", "一", "二", "三", "四", "五", "六"];
- for (var i = 0; i < O_R.length; i++) {
- var O_R_O = $$("div", { "className": "O_R_O" }, Middle);
- O_R_O.innerHTML = O_R[i];
- }
- var DateD = $$("div", { "id": idd + "d" }, Middle);
- this.Box = Box;
- this.Top = Top;
- this.Middle = Middle;
- this.DateD = DateD;
- this.b_date = b_date;
- this.Bottom = Bottom;
- // this.D_Y = D_Y;
- // this.D_U = D_U;
- // this.D_R = D_R;
- // this.D_H = D_H;
- // this.D_M = D_M;
- // this.D_S = D_S;
- },
- LD: function () { //加载数据
- this.Time();
- this.DateD.innerHTML = "";
- this.D_Y = this.Year;
- this.D_U = this.Month;
- this.D_R = this.Day;
- this.D_H = this.Hs;
- this.D_M = this.Mi;
- this.D_S = this.Se;
- this.b_date.innerHTML = this.Year + "年" + (this.Month) + "月";
- var begin = this.DOM(this.Month - 1) - this.DOW() + 1;
- for (j = 0; j < this.DOW(); j++) {
- var Ui = $$("div", { "className": "Ui" }, this.DateD);
- Ui.innerHTML = begin++;
- }
- for (var i = 0; i < this.DOM(); i++) {
- var Ui = $$("li", { "className": "U_li" }, this.DateD);
- if (i + 1 == this.r_R_d.getDate() && (this.Month) == (this.r_R_d.getMonth() + 1) && this.Year == this.r_R_d.getFullYear()) {
- Ui.style.cssText = "color:#0879e1;border:1px solid #0879e1;"
- } else {
- Ui.style.border = "1px solid white";
- }
- Ui.innerHTML = i + 1;
- }
- },
- Time: function () {
- // this.Se++;
- // if (this.Se >= 60) {
- // this.Mi++;
- // this.Se = 0;
- // }
- // if (this.Mi >= 60) {
- // this.Hs++;
- // this.Mi = 0;
- // }
- // if (this.Hs >= 24) {
- // this.Hs = 0;
- // }
- // this.Top.innerHTML = this.r_R_d.getFullYear() + "年" + (this.r_R_d.getMonth() + 1) + "月" + this.r_R_d.getDate() + "日" + this.Hs + "时" + this.Mi + "分" + this.Se + "秒";
- },
- _LY: function () { // isLeapYear 是否为闰年
- return (0 == this.Year % 4 && ((this.Year % 100 != 0) || (this.Year % 400 == 0)));
- },
- DOM: function () { //dayofMonth 获取当前月的天数
- var MArray = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; // 30,31月的数组
- (this._LY()) ? MArray[1] = 29 : MArray[1] = 28;
- return (arguments[0] ? MArray[arguments[0] - 1] : MArray[this.Month - 1]);
- },
- DOW: function () { // dayofWeek 获取星期
- return new Date(this.Year + "-" + this.Month + "-" + 1).getDay();
- },
- Main: function (idd) {
- setInterval(function (that) { return function () { that.Time(); } } (this), 1000);
- },
- GDate: function (idd) {
- var ar = $("#" + idd)[0];
- //+ " " + this.Hs + ":" + this.Mi + ":" + this.Se;
- ar.innerHTML = this.Year + "-" + this.Month + "-" + this.Day;
- },
- Fix: function (that, idd) {
- that.r_R_d.setDate(that.D_R); that.r_R_d.setMonth(that.D_U - 1);
- that.r_R_d.setFullYear(that.Year);
- that.r_R_d.setHours(that.D_H); that.r_R_d.setMinutes(that.D_M); that.r_R_d.setSeconds(that.D_S);
- that.Year = that.r_R_d.getFullYear();
- that.Month = that.r_R_d.getMonth() + 1;
- that.Day = that.r_R_d.getDate();
- that.Hs = that.r_R_d.getHours();
- that.Mi = that.r_R_d.getMinutes();
- that.Se = that.r_R_d.getSeconds();
- that.GDate(idd);
- that.LD();
- U.Alert("修改成功");
- // document.body.removeChild(that.Box);
- that.Box.style.display = "none";
- $(".U_Date_bg")[0].style.display = "none";
- that.GOE(that, idd);
- },
- Lert: function (that, n, idd) {
- n == -1 ? (that.Month == 1 ? (that.Year--, that.Month = 12) : that.Month--) : (that.Month == 12 ? (that.Year++, that.Month = 1) : that.Month++);
- that.LD();
- that.GOE(that, idd);
- },
- GOE: function (that, idd) {
- this.bool = true;
- var ty = $("#" + idd + "d")[0];
- var uet = ty.getElementsByTagName("li");
- that.D_U = that.Month;
- that.D_Y = that.Year;
- for (var i = 0; i < uet.length; i++) {
- uet[i].i = i;
- uet[i].onmouseover = function () {
- for (var i = 0; i < uet.length; i++) {
- if (that.D_R == i + 1) {
- uet[i].style.cssText = "border:1px solid #0879e1;color:#0879e1";
- }
- else if (that.D_R == undefined) {
- if (i + 1 == that.r_R_d.getDate() && (that.Month) == (that.r_R_d.getMonth() + 1) && that.Year == that.r_R_d.getFullYear()) {
- uet[i].style.cssText = "border:1px solid #0879e1;color:#0879e1";
- }
- } else {
- uet[i].style.cssText = "border:1px solid white;color:black";
- }
- }
- uet[this.i].style.cssText = "border:1px solid #0879e1;color:#0879e1";
- }
- uet[i].onmouseout = function () {
- uet[this.i].style.cssText = "border:1px solid white;color:black";
- }
- uet[i].onclick = function () {
- for (var i = 0; i < uet.length; i++) {
- uet[i].style.cssText = "border:1px solid white;color:black";
- }
- that.D_R = (this.i + 1);
- uet[this.i].style.cssText = "border:1px solid #0879e1;color:#0879e1";
- }
- }
- },
- clear: function (that, idd) {
- $("#" + idd)[0].innerHTML = "";
- that.des();
- },
- des: function () {
- $("#tene").remove();
- $(".U_Date_bg").remove();
- },
- now: function (that, idd) {
- that.des();
- //that.GDate(idd);
- var _D = new Date();
- $("#" + idd)[0].innerHTML = _D.getFullYear() + "-" + _D.getMonth() + 1 + "-" + _D.getDate();
- }
- }
- </script>
- </head>
- <body>
- <div id="ten" onclick="U.Date(ten)" style="width: 185px; height: 18px; border: 1px solid #000;
- line-height: 15px">
- 1990-01-01
- </div>
- <!-- <input type="button" value="选择日期" />
- <input id="Text1" type="text" /><input type="button" value="选择日期" onclick="U.Date(Text1)" />
- <input id="Text2" type="text" /><input type="button" value="选择日期" onclick="U.Date(Text2)" />-->
- </body>
- </html>
|