⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 newsheet.htm

📁 Windows Web脚本开发指南/(美) Dan Heflin, Todd Ney著 的源码
💻 HTM
字号:
<html xmlns:commonSource>
<head>
<title>Create New Timesheet</title>
</head>
<script language="JavaScript">
function initialize(){
  var currentDT = new Date();
  var currentYear = currentDT.getYear();
  if (currentYear < 100)
    currentYear += 1900;
  for (addYear=currentYear-3;addYear<currentYear+4;addYear++){
    
    if (addYear == currentYear)
      common.addItemToList(cmbYear, addYear, addYear, true);  
    else
      common.addItemToList(cmbYear, addYear, addYear, false);  
  }
  cmbMonth.selectedIndex = currentDT.getMonth();
  monthChange();
  txtFor.value = common.getPreviousUser();  
}

function yearChange(){
  if (common.getSelectedListValue(cmbMonth) == 2)
    monthChange();
}  
function monthChange(){
   var max = 30;
   var selectDay;
   var currentDT = new Date();
   
   common.clearList(cmbStartDay);
   var currentMonth = common.getSelectedListValue(cmbMonth);
   if (currentMonth == 2){
     var currentYear = common.getSelectedListValue(cmbYear);
     max = (((!(currentYear % 4)) && (currentYear % 100) ) || !(currentYear % 400)) ? 29 : 28
   }
   else{
     if (currentMonth == "1" || currentMonth == "3" || currentMonth == "5" || currentMonth == "7" || currentMonth == "8" || currentMonth == "10" || currentMonth == "12")
       max = 31;
     else 
       max = 30; 
   }
   if (cmbMonth.selectedIndex == currentDT.getMonth()){
     selectDay = currentDT.getDate();
   }
   for (var count = 0;count<=max;count++){
     if (count == selectDay)
       common.addItemToList(cmbStartDay, count, count, true);   
     else
       common.addItemToList(cmbStartDay, count, count, false);
   } 
}
function createTimesheet(){
  var currentDT = new Date();
  var year = common.getSelectedListValue(cmbYear);
  var month = common.getSelectedListValue(cmbMonth);
  var day = common.getSelectedListValue(cmbStartDay);
  var startDate = month + "/" + day + "/" + year;
  var startDateObj = new Date(year, month, day);
  var startInt = startDateObj.getTime();
  var fileName = currentDT.getTime() + ".xml";
  var dataPath = common.getDataPath();
  var tsFor = txtFor.value;
  
  if (tsFor == ""){
    alert("You must specify who to create the timesheet for.");
    txtFor.focus(); 
  }
  else {
	timeSheetList.async = false;
	timeSheetList.load("timeSheetList.xml");
	if (timeSheetList.xml == ""){
	  
          timeSheetList.loadXML("<timeSheets xmlns='x-schema:tsListSchema.xml'><Completed /><Open /></timeSheets>");
	}
	var openNode = timeSheetList.selectSingleNode("//Open");
	newElement = timeSheetList.createElement("timeSheet");
	newElement.setAttribute("createdBy", tsFor);
 	newElement.setAttribute("startDate", startDate);
	newElement.setAttribute("file", fileName);
	newElement.setAttribute("startInt", startInt);
        openNode.appendChild(newElement);
	timeSheet.async = false;
        timeSheet.resolveExternals = false;
	timeSheet.loadXML("<timeSheet xmlns='x-schema:" + common.getServerPath() + "tsDetailSchema.xml' startDate='" + startDate + "'/>");
        common.saveXMLDocument(timeSheet, dataPath + fileName);
        common.saveXMLDocument(timeSheetList, dataPath + "timeSheetList.xml");
        common.savePreviousUser(tsFor); 
	window.returnValue = dataPath + fileName;
	window.close();
  }
}

</script>
<commonSource:source ID="common" STYLE="behavior:url(commonSource.htc)" />
<xml ID="timeSheetList"></xml>
<xml ID="timeSheet"></xml>
<body onLoad="initialize()">
<BR>
<table border="0" width="100%">
  <tr>
    <td width="50%">Year:</td>
    <td width="50%"><select size="1" name="cmbYear" onClick="yearChange()">
      </select></td>
  </tr>
  <tr>
    <td>Month:</td>
    <td>
      <select size="1" name="cmbMonth" onClick="monthChange()">
        <option value="1">January</option>
        <option value="2">February</option>
        <option value="3">March</option>
        <option value="4">April</option>
        <option value="5">May</option>
        <option value="6">June</option>
        <option value="7">July</option>
        <option value="8">August</option>
        <option value="9">September</option>
        <option value="10">October</option>
        <option value="11">November</option>
        <option value="12">December</option>
      </select>
    </td>
  </tr>
  <tr>
    <td>Week Start Date:</td>
    <td><select size="1" name="cmbStartDay">
      </select></td>
  </tr>
  <tr>
    <td width="25%">Time Sheet For:</td>
    <td width="75%"><input type="text" id="txtFor" maxLength="15" size="15"></td>
  </tr>
</table>
<p align="center"><input type="button" value="Create" onClick="createTimesheet()">&nbsp;<input type="button" value="Cancel" onClick="window.close();"></p>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -