U.DateSelect.htm 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <title></title>
  5. <script type="text/javascript"> document.domain = "1473.cn";</script>
  6. <script src="http://www.1473.cn/js/UC/UC23.js" type="text/javascript"></script>
  7. <link href="../css/UCity/U.City.css" rel="stylesheet" type="text/css" />
  8. <script>
  9. U.Date = function (idd) {
  10. var _U = new U.DateT();
  11. ($("#" + idd + "e")[0]) ? _U.dis(idd) : _U.init(idd);
  12. }
  13. U.DateT = function () { }
  14. U.DateT.prototype = {
  15. init: function (idd) { // 初始化
  16. this.bool = false;
  17. this.r_R_d = new Date();
  18. var _D = new Date();
  19. this.Year = _D.getFullYear();
  20. this.Day = _D.getDate();
  21. this.Month = _D.getMonth() + 1;
  22. this.Hs = _D.getHours();
  23. this.Mi = _D.getMinutes();
  24. this.Se = _D.getSeconds();
  25. this.LV(idd);
  26. this.LD();
  27. this.Main(idd);
  28. this.GOE(this, idd);
  29. },
  30. dis: function (idd) {
  31. var a = $("#" + idd + "e")[0];
  32. (a.style.display == "none") ? a.style.display = "block" : a.style.display = "none";
  33. ($(".U_Date_bg")[0].style.display == "none") ? $(".U_Date_bg")[0].style.display = "block" : $(".U_Date_bg")[0].style.display = "none";
  34. },
  35. LV: function (idd) { //加载视图
  36. // IPA = $$("a", { "onclick": [[U.M.StopBubble], [this.Zoom, (["Out", _UIOD, this])]] }, _UICD);
  37. var Box = $$("div", { "id": idd + "e", "className": "Box", "style": { "top": 20 + $("#" + idd)[0].offsetTop + "px", "left": $("#" + idd)[0].offsetLeft + "px"} }, document.body)
  38. $$("div", { "className": "U_Date_bg", "onclick": [[this.des, ([])]], "style": { "width": US.Width + "px", "height": US.Height + "px"} }, $("body")[0])
  39. , Top = $$("div", { "className": "Top" }, Box)
  40. , Middle = $$("div", { "className": "Middle" }, Box)
  41. , btn_T = $$("div", { "className": "btn_T" }, Middle)
  42. , b_left2 = $$("div", { "onclick": [[this.Lert, ([this, -1, idd])]], "className": "b_left2", "innerHTML": "◀" }, btn_T)
  43. , b_date = $$("div", { "className": "b_date" }, btn_T)
  44. , b_right = $$("div", { "onclick": [[this.Lert, ([this, 1, idd])]], "className": "b_right", "innerHTML": "▶" }, btn_T)
  45. , Bottom = $$("div", { "className": "bottom" }, Box)
  46. // , D_Y = $$("input", { "type": "text", "maxLength": "4", "style": { "margin-left": "1px", "outline": "none", "float": "left", "width": "30px", "height": "15px"} }, Bottom)
  47. // , D_U = $$("input", { "type": "text", "maxLength": "2", "style": { "margin-left": "1px", "outline": "none", "float": "left", "width": "15px", "height": "15px"} }, Bottom)
  48. // , D_R = $$("input", { "type": "text", "maxLength": "2", "style": { "margin-left": "1px", "outline": "none", "float": "left", "width": "15px", "height": "15px"} }, Bottom)
  49. // , D_H = $$("input", { "type": "text", "maxLength": "2", "style": { "margin-left": "5px", "outline": "none", "float": "left", "width": "15px", "height": "15px"} }, Bottom)
  50. // , D_M = $$("input", { "type": "text", "maxLength": "2", "style": { "margin-left": "1px", "outline": "none", "float": "left", "width": "15px", "height": "15px"} }, Bottom)
  51. // , D_S = $$("input", { "type": "text", "maxLength": "2", "style": { "margin-left": "1px", "outline": "none", "float": "left", "width": "15px", "height": "15px"} }, Bottom)
  52. , D_OK = $$("input", { "className": "D_OK", "onclick": [[this.Fix, ([this, idd])]], "type": "button", "value": "确定" }, Bottom)
  53. , D_clear = $$("input", { "className": "D_OK", "onclick": [[this.clear, ([this, idd])]], "type": "button", "value": "清除" }, Bottom)
  54. , D_Now = $$("input", { "className": "D_OK", "onclick": [[this.now, ([this, idd])]], "type": "button", "value": "至今" }, Bottom)
  55. , O_R = ["日", "一", "二", "三", "四", "五", "六"];
  56. for (var i = 0; i < O_R.length; i++) {
  57. var O_R_O = $$("div", { "className": "O_R_O" }, Middle);
  58. O_R_O.innerHTML = O_R[i];
  59. }
  60. var DateD = $$("div", { "id": idd + "d" }, Middle);
  61. this.Box = Box;
  62. this.Top = Top;
  63. this.Middle = Middle;
  64. this.DateD = DateD;
  65. this.b_date = b_date;
  66. this.Bottom = Bottom;
  67. // this.D_Y = D_Y;
  68. // this.D_U = D_U;
  69. // this.D_R = D_R;
  70. // this.D_H = D_H;
  71. // this.D_M = D_M;
  72. // this.D_S = D_S;
  73. },
  74. LD: function () { //加载数据
  75. this.Time();
  76. this.DateD.innerHTML = "";
  77. this.D_Y = this.Year;
  78. this.D_U = this.Month;
  79. this.D_R = this.Day;
  80. this.D_H = this.Hs;
  81. this.D_M = this.Mi;
  82. this.D_S = this.Se;
  83. this.b_date.innerHTML = this.Year + "年" + (this.Month) + "月";
  84. var begin = this.DOM(this.Month - 1) - this.DOW() + 1;
  85. for (j = 0; j < this.DOW(); j++) {
  86. var Ui = $$("div", { "className": "Ui" }, this.DateD);
  87. Ui.innerHTML = begin++;
  88. }
  89. for (var i = 0; i < this.DOM(); i++) {
  90. var Ui = $$("li", { "className": "U_li" }, this.DateD);
  91. if (i + 1 == this.r_R_d.getDate() && (this.Month) == (this.r_R_d.getMonth() + 1) && this.Year == this.r_R_d.getFullYear()) {
  92. Ui.style.cssText = "color:#0879e1;border:1px solid #0879e1;"
  93. } else {
  94. Ui.style.border = "1px solid white";
  95. }
  96. Ui.innerHTML = i + 1;
  97. }
  98. },
  99. Time: function () {
  100. // this.Se++;
  101. // if (this.Se >= 60) {
  102. // this.Mi++;
  103. // this.Se = 0;
  104. // }
  105. // if (this.Mi >= 60) {
  106. // this.Hs++;
  107. // this.Mi = 0;
  108. // }
  109. // if (this.Hs >= 24) {
  110. // this.Hs = 0;
  111. // }
  112. // 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 + "秒";
  113. },
  114. _LY: function () { // isLeapYear 是否为闰年
  115. return (0 == this.Year % 4 && ((this.Year % 100 != 0) || (this.Year % 400 == 0)));
  116. },
  117. DOM: function () { //dayofMonth 获取当前月的天数
  118. var MArray = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; // 30,31月的数组
  119. (this._LY()) ? MArray[1] = 29 : MArray[1] = 28;
  120. return (arguments[0] ? MArray[arguments[0] - 1] : MArray[this.Month - 1]);
  121. },
  122. DOW: function () { // dayofWeek 获取星期
  123. return new Date(this.Year + "-" + this.Month + "-" + 1).getDay();
  124. },
  125. Main: function (idd) {
  126. setInterval(function (that) { return function () { that.Time(); } } (this), 1000);
  127. },
  128. GDate: function (idd) {
  129. var ar = $("#" + idd)[0];
  130. //+ " " + this.Hs + ":" + this.Mi + ":" + this.Se;
  131. ar.innerHTML = this.Year + "-" + this.Month + "-" + this.Day;
  132. },
  133. Fix: function (that, idd) {
  134. that.r_R_d.setDate(that.D_R); that.r_R_d.setMonth(that.D_U - 1);
  135. that.r_R_d.setFullYear(that.Year);
  136. that.r_R_d.setHours(that.D_H); that.r_R_d.setMinutes(that.D_M); that.r_R_d.setSeconds(that.D_S);
  137. that.Year = that.r_R_d.getFullYear();
  138. that.Month = that.r_R_d.getMonth() + 1;
  139. that.Day = that.r_R_d.getDate();
  140. that.Hs = that.r_R_d.getHours();
  141. that.Mi = that.r_R_d.getMinutes();
  142. that.Se = that.r_R_d.getSeconds();
  143. that.GDate(idd);
  144. that.LD();
  145. U.Alert("修改成功");
  146. // document.body.removeChild(that.Box);
  147. that.Box.style.display = "none";
  148. $(".U_Date_bg")[0].style.display = "none";
  149. that.GOE(that, idd);
  150. },
  151. Lert: function (that, n, idd) {
  152. n == -1 ? (that.Month == 1 ? (that.Year--, that.Month = 12) : that.Month--) : (that.Month == 12 ? (that.Year++, that.Month = 1) : that.Month++);
  153. that.LD();
  154. that.GOE(that, idd);
  155. },
  156. GOE: function (that, idd) {
  157. this.bool = true;
  158. var ty = $("#" + idd + "d")[0];
  159. var uet = ty.getElementsByTagName("li");
  160. that.D_U = that.Month;
  161. that.D_Y = that.Year;
  162. for (var i = 0; i < uet.length; i++) {
  163. uet[i].i = i;
  164. uet[i].onmouseover = function () {
  165. for (var i = 0; i < uet.length; i++) {
  166. if (that.D_R == i + 1) {
  167. uet[i].style.cssText = "border:1px solid #0879e1;color:#0879e1";
  168. }
  169. else if (that.D_R == undefined) {
  170. if (i + 1 == that.r_R_d.getDate() && (that.Month) == (that.r_R_d.getMonth() + 1) && that.Year == that.r_R_d.getFullYear()) {
  171. uet[i].style.cssText = "border:1px solid #0879e1;color:#0879e1";
  172. }
  173. } else {
  174. uet[i].style.cssText = "border:1px solid white;color:black";
  175. }
  176. }
  177. uet[this.i].style.cssText = "border:1px solid #0879e1;color:#0879e1";
  178. }
  179. uet[i].onmouseout = function () {
  180. uet[this.i].style.cssText = "border:1px solid white;color:black";
  181. }
  182. uet[i].onclick = function () {
  183. for (var i = 0; i < uet.length; i++) {
  184. uet[i].style.cssText = "border:1px solid white;color:black";
  185. }
  186. that.D_R = (this.i + 1);
  187. uet[this.i].style.cssText = "border:1px solid #0879e1;color:#0879e1";
  188. }
  189. }
  190. },
  191. clear: function (that, idd) {
  192. $("#" + idd)[0].innerHTML = "";
  193. that.des();
  194. },
  195. des: function () {
  196. $("#tene").remove();
  197. $(".U_Date_bg").remove();
  198. },
  199. now: function (that, idd) {
  200. that.des();
  201. //that.GDate(idd);
  202. var _D = new Date();
  203. $("#" + idd)[0].innerHTML = _D.getFullYear() + "-" + _D.getMonth() + 1 + "-" + _D.getDate();
  204. }
  205. }
  206. </script>
  207. </head>
  208. <body>
  209. <div id="ten" onclick="U.Date(ten)" style="width: 185px; height: 18px; border: 1px solid #000;
  210. line-height: 15px">
  211. 1990-01-01
  212. </div>
  213. <!-- <input type="button" value="选择日期" />
  214. <input id="Text1" type="text" /><input type="button" value="选择日期" onclick="U.Date(Text1)" />
  215. <input id="Text2" type="text" /><input type="button" value="选择日期" onclick="U.Date(Text2)" />-->
  216. </body>
  217. </html>