- 浏览: 527457 次
- 性别:
- 来自: 广州
最新评论
-
shitouofIT:
...
Spring Autowired(required = false) 说明 -
liuchongming:
...
Spring Autowired(required = false) 说明 -
20101975liubin:
...
Spring Autowired(required = false) 说明 -
ghpaas:
orbeon作为xforms标准的实现,不论其设计器还是运行时 ...
Eclipse 下安装 Visual XForms Designer 插件 -
young.java:
[flash=200,200][url][img][list] ...
利用JS生成32位的UUID(源码)
1. 新建CalendarWidget.js文件, 内容如下:
// Calendar Widget
function CalendarWidget(InstanceName) {
// /Global Tag
this.instanceName = InstanceName;
// /Properties
this.separator = "-";
this.oBtnOKTitle = "OK";
this.oBtnTodayTitle = "Today";
this.oBtnCancelTitle = "Cancel";
this.hour="HH";
this.minute="MM";
this.second="SS";
this.weekDaySting = new Array("S", "M", "T", "W", "T", "F", "S");
this.monthSting = new Array("January", "February", "March", "April", "May",
"June", "July", "August", "September", "October", "November",
"December");
this.Width = 200;
this.currDate = new Date();
this.today = new Date();
this.startYear = 1970;
this.endYear = 2099;
// /Css
this.normalfontColor = "#666666";
this.selectedfontColor = "red";
this.divBorderCss = "1px solid #BCD0DE";
this.titleTableBgColor = "#98B8CD";
this.tableBorderColor = "#CCCCCC"
// /Method
this.Init = CalendarInit;
this.Fill = CalendarFill;
this.Refresh = CalendarRefresh;
this.Restore = CalendarRestore;
// /HTMLObject
this.oTaget = null;
this.oPreviousCell = null;
this.sDIVID = InstanceName + "_Div";
this.sTABLEID = InstanceName + "_Table";
this.sMONTHID = InstanceName + "_Month";
this.sYEARID = InstanceName + "_Year";
// /TIME
this.sMINUTEID = InstanceName + "_Minute";
this.sSECONDID = InstanceName + "_Second";
this.sHOURID = InstanceName + "_Hour";
// /ETCOBJ
this.oBTNOK = InstanceName + "_OK";
this.oTIMEDIVID = InstanceName + "_TIMEDIV";
this.sTODAYBTNID = InstanceName + "_TODAYBTN";
}
// /Create panel
function CalendarInit() {
var sMonth, sYear
sMonth = this.currDate.getMonth();
sYear = this.currDate.getYear();
htmlAll = "<div id='" + this.sDIVID
+ "' style='display:none;position:absolute;width:" + this.Width
+ ";border:" + this.divBorderCss
+ ";padding:2px;background-color:#FFFFFF;z-index:10;'>";
htmlAll += "<div align='center' style='z-index:10;'>";
// / Month
htmloMonth = "<select id='" + this.sMONTHID
+ "' onchange=CalendarMonthChange(" + this.instanceName
+ ") style='width:50%;z-index:10;'>";
for (i = 0; i < 12; i++) {
htmloMonth += "<option value='" + i + "'>" + this.monthSting[i]
+ "</option>";
}
htmloMonth += "</select>";
// / Year
htmloYear = "<select id='" + this.sYEARID
+ "' onchange=CalendarYearChange(" + this.instanceName
+ ") style='width:50%;z-index:10;'>";
for (i = this.startYear; i <= this.endYear; i++) {
htmloYear += "<option value='" + i + "'>" + i + "</option>";
}
htmloYear += "</select></div>";
// / Day
htmloDayTable = "<table id='" + this.sTABLEID
+ "' width='100%' border=0 cellpadding=0 cellspacing=1 bgcolor='"
+ this.tableBorderColor + "' sytle='z-index:10;'>";
htmloDayTable += "<tbody bgcolor='#ffffff'style='font-size:13px'>";
for (i = 0; i <= 6; i++) {
if (i == 0)
htmloDayTable += "<tr bgcolor='" + this.titleTableBgColor + "'>";
else
htmloDayTable += "<tr>";
for (j = 0; j < 7; j++) {
if (i == 0) {
htmloDayTable += "<td height='20' align='center' valign='middle' style='cursor:hand'>";
htmloDayTable += this.weekDaySting[j] + "</td>"
} else {
htmloDayTable += "<td height='20' align='center' valign='middle' style='cursor:hand'";
htmloDayTable += " onmouseover=CalendarCellsMsOver("
+ this.instanceName + ")";
htmloDayTable += " onmouseout=CalendarCellsMsOut("
+ this.instanceName + ")";
htmloDayTable += " onclick=CalendarCellsClick(this,"
+ this.instanceName + ")>";
htmloDayTable += " </td>"
}
}
htmloDayTable += "</tr>";
}
htmloDayTable += "</tbody></table>";
// / Time HH:MM:SS
htmloTime = "<div id='"+ this.oTIMEDIVID +"' align='center' style='width:100%;z-index:10;display:none'>";
htmloTime += "<select id='"+ this.sHOURID +"' style='width:28%;z-index:10;'>";
for (i = 0; i < 24; i++) {
val = CalendarDblNum(i);
htmloTime += "<option value='" + val + "'>" + val + "</option>";
}
htmloTime += "</select>" + this.hour;
htmloTime += "<select id='"+ this.sMINUTEID +"' style='width:28%;z-index:10;'>";
for (i = 0; i < 60; i++) {
val = CalendarDblNum(i);
htmloTime += "<option value='" + val + "'>" + val + "</option>";
}
htmloTime += "</select>"+ this.minute;
htmloTime += "<select id='"+ this.sSECONDID +"' style='width:26%;z-index:10;'>";
for (i = 0; i < 60; i++) {
val = CalendarDblNum(i);
htmloTime += "<option value='" + val + "'>" + val + "</option>";
}
htmloTime += "</select>"+ this.second;
htmloTime += "</div>";
// / OK Button
htmloBtnOK = "<div align='center' style='padding:3px;z-index:10;'>"
htmloBtnOK += "<button id='"+ this.oBTNOK
+ "' style='width:30%;border:1px solid #BCD0DE;cursor:hand'"
htmloBtnOK += " onclick=CalendarOkClick(" + this.instanceName + ")>"
+ this.oBtnOKTitle + "</button> "
// / Today Button
htmloButton = "<button id='"+ this.sTODAYBTNID
+ "' style='width:30%;border:1px solid #BCD0DE;cursor:hand'"
htmloButton += " onclick=CalendarTodayClick(" + this.instanceName + ")>"
+ this.oBtnTodayTitle + "</button> "
// / Reset Button
htmloButton += "<button style='width:30%;border:1px solid #BCD0DE;cursor:hand'"
htmloButton += " onclick=CalendarCancel(" + this.instanceName + ")>"
+ this.oBtnCancelTitle + "</button> "
htmloButton += "</div>"
// / All
htmlAll = htmlAll + htmloMonth + htmloYear + htmloDayTable + htmloTime + htmloBtnOK + htmloButton
+ "</div>";
document.write(htmlAll);
this.Fill();
}
// /
function CalendarFill() {
var sMonth, sYear, sWeekDay, sToday, oTable, currRow, MaxDay, iDaySn, sIndex, rowIndex, cellIndex, oSelectMonth, oSelectYear
sMonth = this.currDate.getMonth();
sYear = this.currDate.getYear();
sWeekDay = (new Date(sYear, sMonth, 1)).getDay();
sToday = this.currDate.getDate();
iDaySn = 1
oTable = document.all[this.sTABLEID];
currRow = oTable.rows[1];
MaxDay = CalendarGetMaxDay(sYear, sMonth);
oSelectMonth = document.all[this.sMONTHID]
oSelectMonth.selectedIndex = sMonth;
oSelectYear = document.all[this.sYEARID]
for (i = 0; i < oSelectYear.length; i++) {
if (parseInt(oSelectYear.options[i].value) == sYear)
oSelectYear.selectedIndex = i;
}
// //
for (rowIndex = 1; rowIndex <= 6; rowIndex++) {
if (iDaySn > MaxDay)
break;
currRow = oTable.rows[rowIndex];
cellIndex = 0;
if (rowIndex == 1)
cellIndex = sWeekDay;
for (; cellIndex < currRow.cells.length; cellIndex++) {
if (iDaySn == sToday) {
currRow.cells[cellIndex].innerHTML = "<font color='"
+ this.selectedfontColor + "'><i><b>" + iDaySn
+ "</b></i></font>";
this.oPreviousCell = currRow.cells[cellIndex];
} else {
currRow.cells[cellIndex].innerHTML = iDaySn;
currRow.cells[cellIndex].style.color = this.normalfontColor;
}
CalendarCellSetCss(0, currRow.cells[cellIndex]);
iDaySn++;
if (iDaySn > MaxDay)
break;
}
}
}
// / Clear Data
function CalendarRestore() {
var i, j, oTable
oTable = document.all[this.sTABLEID]
for (i = 1; i < oTable.rows.length; i++) {
for (j = 0; j < oTable.rows[i].cells.length; j++) {
CalendarCellSetCss(0, oTable.rows[i].cells[j]);
oTable.rows[i].cells[j].innerHTML = " ";
}
}
}
// / refresh
function CalendarRefresh(newDate) {
this.currDate = newDate;
this.Restore();
this.Fill();
}
// / Cell MouseOver
function CalendarCellsMsOver(oInstance) {
var myCell = event.srcElement;
CalendarCellSetCss(0, oInstance.oPreviousCell);
if (myCell) {
CalendarCellSetCss(1, myCell);
oInstance.oPreviousCell = myCell;
}
}
// //// Cell MouseOut
function CalendarCellsMsOut(oInstance) {
var myCell = event.srcElement;
CalendarCellSetCss(0, myCell);
}
// / Year Change
function CalendarYearChange(oInstance) {
var sDay, sMonth, sYear, newDate
sDay = oInstance.currDate.getDate();
sMonth = oInstance.currDate.getMonth();
sYear = document.all[oInstance.sYEARID].value
newDate = new Date(sYear, sMonth, sDay);
oInstance.Refresh(newDate);
}
// / Month Change
function CalendarMonthChange(oInstance) {
var sDay, sMonth, sYear, newDate
sDay = oInstance.currDate.getDate();
sMonth = document.all[oInstance.sMONTHID].value
sYear = oInstance.currDate.getYear();
newDate = new Date(sYear, sMonth, sDay);
oInstance.Refresh(newDate);
}
function CalendarCellsClick(oCell, oInstance) {
var sDay, sMonth, sYear, newDate
sYear = oInstance.currDate.getFullYear();
sMonth = oInstance.currDate.getMonth();
sDay = oInstance.currDate.getDate();
if (oCell != null && oCell.innerText != null
&& oCell.innerText.length > 0) {
sDay = parseInt(oCell.innerText);
if (sDay != oInstance.currDate.getDate()) {
newDate = new Date(sYear, sMonth, sDay);
oInstance.Refresh(newDate);
}
} else {
return "";
}
}
// / "OK" button Click
function CalendarOkClick(oInstance){
sYear = oInstance.currDate.getFullYear();
sMonth = oInstance.currDate.getMonth();
sDay = oInstance.currDate.getDate();
sTime = CalendarWidget.getSelectedTime(oInstance);
sDateString = sYear + oInstance.separator + CalendarDblNum(sMonth + 1)
+ oInstance.separator + CalendarDblNum(sDay) + sTime;
// set DateString
var tagName = oInstance.oTaget.tagName.toLowerCase();
if (tagName == "input") {
oInstance.oTaget.value = sDateString;
} else if (tagName == "label"
|| tagName == "span"
|| tagName == "div") {
if (oInstance.oTaget.attributes["value"] != null)
oInstance.oTaget.value = sDateString;
oInstance.oTaget.innerText = sDateString;
}
// Close
CalendarClose(oInstance);
return sDateString;
}
// / Get Time
CalendarWidget.getSelectedTime = function (oInstance) {
_timeDiv = document.all[oInstance.oTIMEDIVID];
if (_timeDiv != null && _timeDiv.style.display != "none") {
_hour = document.all[oInstance.sHOURID].value;
_minute = document.all[oInstance.sMINUTEID].value;
_second = document.all[oInstance.sSECONDID].value;
return " " + _hour + ":" + _minute + ":" + _second;
} else {
return "";
}
}
// / "Today" button Click
function CalendarTodayClick(oInstance) {
_hour = document.all[oInstance.sHOURID];
_minute = document.all[oInstance.sMINUTEID];
_second = document.all[oInstance.sSECONDID];
// Set Current Time
var _tody = new Date();
_hour.value = CalendarDblNum(_tody.getHours());
_minute.value = CalendarDblNum(_tody.getMinutes());
_second.value = CalendarDblNum(_tody.getSeconds());
oInstance.Refresh(_tody);
}
// / Get date content
CalendarWidget.getDateString = function(oInputSrc, oInstance, oMode){
if (oInputSrc && oInstance) {
var CalendarDiv = document.all[oInstance.sDIVID];
oInstance.oTaget = oInputSrc;
_timeDiv = document.all[oInstance.oTIMEDIVID];
_timeDiv.style.display = oMode == "1" ? "block" : "none";
CalendarDiv.style.pixelLeft = CalendargetPos(oInputSrc, "Left");
CalendarDiv.style.pixelTop = CalendargetPos(oInputSrc, "Top")
+ oInputSrc.offsetHeight;
CalendarDiv.style.display = (CalendarDiv.style.display == "none") ? ""
: "none";
}
}
// / Set Cell Css
function CalendarCellSetCss(sMode, oCell) {
// sMode
// 0: OnMouserOut 1: OnMouseOver
if (sMode) {
oCell.style.border = "1px solid #5589AA";
oCell.style.backgroundColor = "#BCD0DE";
oCell.style.zIndex = "10";
} else {
oCell.style.border = "1px solid #FFFFFF";
oCell.style.backgroundColor = "#FFFFFF";
oCell.style.zIndex = "10";
}
}
// / Get MaxDay of current month
function CalendarGetMaxDay(nowYear, nowMonth) {
var nextMonth, nextYear, currDate, nextDate, theMaxDay
nextMonth = nowMonth + 1;
if (nextMonth > 11) {
nextYear = nowYear + 1;
nextMonth = 0;
} else {
nextYear = nowYear;
}
currDate = new Date(nowYear, nowMonth, 1);
nextDate = new Date(nextYear, nextMonth, 1);
theMaxDay = (nextDate - currDate) / (24 * 60 * 60 * 1000);
return theMaxDay;
}
// / Get Absolute Position
function CalendargetPos(el, ePro) {
var ePos = 0;
while (el != null) {
ePos += el["offset" + ePro];
el = el.offsetParent;
}
return ePos;
}
function CalendarDblNum(num) {
if (num < 10)
return "0" + num;
else
return num;
}
// /Close
function CalendarClose(oInstance){
var CalendarDiv = document.all[oInstance.sDIVID];
CalendarDiv.style.display = "none";
}
// /Cancel
function CalendarCancel(oInstance) {
var tagName = oInstance.oTaget.tagName.toLowerCase();
if (tagName == "input") {
oInstance.oTaget.value = "";
} else if (tagName == "label"
|| tagName == "span"
|| tagName == "div") {
if (oInstance.oTaget.attributes["value"] != null)
oInstance.oTaget.value = "";
oInstance.oTaget.innerText = "";
}
CalendarClose(oInstance);
}
// /Calendar Instance Method
Calendar_Instance = function($instanceName){
var $instanceObj = new CalendarWidget($instanceName);
$instanceObj.weekDaySting = new Array("日", "一", "二", "三", "四", "五", "六");
$instanceObj.monthSting = new Array("一月", "二月", "三月", "四月", "五月", "六月", "七月",
"八月", "九月", "十月", "十一月", "十二月");
$instanceObj.hour = "时";
$instanceObj.minute = "分";
$instanceObj.second = "秒";
$instanceObj.oBtnOKTitle = "确定";
$instanceObj.oBtnTodayTitle = "今天";
$instanceObj.oBtnCancelTitle = "重置";
$instanceObj.Init();
return $instanceObj;
}
// /Instance Calendar
var oCalendarInstance = Calendar_Instance("oCalendarInstance");
2. 外部调用代码
CalendarWidget.getDateString(destObj, oCalendarInstance, mode);
参数说明
@param destObj 目标对象,即接受日期内容的对象
@param oCalendarInstance // 日期控件实例化对象
@param mode // 显示模式("1", 显示“时:分:秒”;"0", 不显示)
发表评论
-
android 各种权限 permission 列举
2013-05-28 11:48 1409在Android的设计中,资源的访问或者网络连接,要得到这 ... -
java 判断程序是否正在运行
2011-08-18 18:02 4253public class ProcessBuilder ... -
Spring Autowired(required = false) 说明
2011-07-21 15:29 79348当候选 Bean 数目不为 1 时的应对方法 ... -
ProcessBuilder实现Java应用程序自我重启
2011-07-12 20:01 2745程序运行的过程中,我们可能需要更改一些配置,如果配置 ... -
Spring获取Bean常用方式
2011-07-05 16:42 1877方法一:在初始化时创建ApplicationContex ... -
Java 利用线程池创建并发线程
2011-07-05 16:25 2228import java.util.concurrent. ... -
Java 超时线程控制实现
2011-07-05 16:11 9538在Java中,如果需要设定代码执行的最长时间,即超 ... -
Java 对比两字符串的相似度
2011-07-05 16:03 4152/** * 编辑距离算法,首先由俄国科学家Levensh ... -
Oracle session process lock
2011-05-26 10:30 1791须以Oracle 数据库 system 权限账户登录 ... -
Java 识别字符编码
2011-05-26 10:25 2115public class EncodingUtils { ... -
数据库主键设置为全局唯一方案
2011-04-25 15:09 2485现在通过数据的水平切分(sharding)来实现数据库 Sca ... -
JS验证浏览器端是否安装某插件
2011-04-14 14:01 2254<HTML> <HEAD><sc ... -
利用JS生成32位的UUID(源码)
2011-02-15 16:23 17568创建 UUID.js 文件, 然后复制以下内容: // ... -
Java 日期字符串date与数字long之间的转换
2010-11-30 14:32 50577public class SimpleDateUtil { ... -
Hibernate Annotation 使用说明
2010-09-25 14:18 2468/** * 注释说明: ... -
svn 如何开启用户可编辑log message的权限
2010-07-15 15:38 55361. 首先进入svn 安装目录下找到 hooks 目录, ... -
Myeclipse 7.x/8.x 插件的安装和配置
2010-06-25 23:57 1690Myeclipse 7.x/8.x 插件的安装和配置 ... -
Proxool 连接池监控页面中文乱码异常的处理
2010-06-22 12:50 4001这几天, 在使用proxool监控连接池状态的时候, 偶然发现 ... -
小图片大尺寸预览实现代码
2010-06-11 18:35 2306<!DOCTYPE HTML PUBLIC " ... -
CSS 控制背景图片自动适应宽度和高度
2010-06-10 15:28 5326<!DOCTYPE html PUBLIC " ...
相关推荐
"漂亮JavaScript弹出选择日期控件"就是这样一个实用工具,它能够提供美观且用户友好的日期选择界面。 首先,我们来看看"testdate.htm"这个文件,这通常是一个HTML页面,包含了日期控件的使用示例。在HTML中,我们...
本JS日期控件是一个经过优化和美化处理的JavaScript日期选择器插件。开发人员对原始插件进行了自定义的颜色样式调整,使其外观更加简洁美观且易于使用。该插件支持日期的选择,并提供了丰富的自定义选项,如颜色设置...
漂亮的js日期控件使用方法如下: <script language="javaScript" src="CalendarDialog.js"> (this);"/>
对于.NET开发者来说,这种JavaScript日期控件能够与ASP.NET、ASP.NET MVC或其他.NET框架无缝配合,增加网站或应用的功能性。 日期控件的调用方法通常包括以下几个步骤: 1. 引入库:首先,你需要在HTML页面中引入...
在压缩包中包含的"功能强大界面漂亮的js日期控件"很可能是一个完整的示例或者库文件,包含了JavaScript代码、CSS样式表以及可能的图像资源。开发者可以通过查看源码学习其工作原理,或者直接在自己的项目中引入这些...
【JavaScript日期控件详解】 在Web开发中,用户界面的交互性和美观性是提升用户体验的重要因素之一。"一个非常漂亮的js日期控件"正是这样的工具,它为网页提供了优雅的日期选择功能,使得用户在输入日期时能有更好...
总结来说,"很好用很漂亮的日期控件"不仅涉及到用户界面的设计美学,还包括了功能实现、交互体验和技术实现等多个方面。一个优秀的日期控件应兼顾美观和实用性,为用户提供高效且愉快的日期选择体验。在实际项目中,...
本文将深入探讨三款美观且功能丰富的JavaScript日期控件,它们分别是:jQuery UI Datepicker、Bootstrap Datepicker 和 Flatpickr。这三款控件在前端界广受欢迎,能够轻松集成到各种项目中,提升用户体验。 1. **...
5. **js**:这个文件夹可能包含日期控件的主要JavaScript代码,包括jQuery插件实现,事件处理逻辑,以及可能的本地化支持。理解这些脚本可以帮助开发者进行高级定制和错误排查。 总的来说,"jQuery漂亮日期控件"和...
JavaScript(简称JS)是一种广泛...总之,JS datapicker 是一款强大的 JavaScript 日期控件,它的灵活性和易用性使得它成为网页开发中的热门选择,通过合理配置和个性化定制,能够为用户提供高效、友好的日期选择体验。
在网页开发中,JavaScript(JS)常常用于处理与用户交互相关的功能,其中之一就是日期选择控件。本资源提供了一个“超级漂亮超级专业”的JS日期选择控件,它以直观、友好的方式帮助用户选择日期,提高了用户体验。这...
漂亮的JS日期时间控件 真的不错,就是有一点...
首先,我们来看"jQuery制作简洁漂亮日期日历控件"这一主题。jQuery是一款流行的JavaScript库,它简化了DOM操作、事件处理和动画创建等任务。在创建日历控件时,我们可以利用jQuery的这些优势,编写更简洁、高效的...
漂亮的日期控件 漂亮的日期控件 漂亮的日期控件 漂亮的日期控件
"漂亮的日期控件"正是这样一个元素,它为用户提供了一种直观、易于操作的方式来选择日期。日期控件通常用于各种应用程序,如日历应用、预订系统、事件管理等,它们提升了用户体验并简化了数据输入过程。 日期控件的...
"简单漂亮的日期控件"正如其名,旨在提供一个既美观又易于使用的日期和时间选择界面。下面将详细讨论这种控件的设计原则、实现技术以及可能的应用场景。 一、设计原则 1. 用户友好:简洁的界面设计和直观的操作...
"setday.js"则很可能是一个JavaScript文件,这是实现日期控件动态功能的关键。JavaScript是一种广泛用于网页交互的编程语言,它负责处理用户输入、控制日期选择的行为、更新页面内容等。在"setday.js"中,我们可以...
本文将深入探讨如何使用jQuery实现一个简洁、漂亮的日期选择控件,并通过提供的压缩包文件来演示具体代码实现。 jQuery是一个流行的JavaScript库,它简化了DOM操作、事件处理和动画创建等任务。在构建日期选择器时...
JavaScript日期控件可以与服务器端的Java代码进行交互,传递或接收日期数据。 "样式非常漂亮"这句话意味着这个控件可能具有高度可定制的外观,允许开发者根据项目需求调整颜色、字体、布局等视觉元素,以适应不同的...
"日历控件"是JavaScript应用中的常见组件,主要用于用户选择日期,常见于事件安排、预约系统或日期输入等场景。"calendar"这个标签表明我们将讨论的是一个特定的日历实现。 这篇描述提到了一个“漂亮的日历控件”,...