home *** CD-ROM | disk | FTP | other *** search
/ Chip 2003 October / Chip Ekim 2003.iso / prog / code / contr / setup.exe / Disk1 / data1.cab / Configuration_En / Commands / ccSubmitDialog.js < prev    next >
Encoding:
JavaScript  |  2003-07-18  |  3.6 KB  |  127 lines

  1. // Copyright 2001, 2002, 2003 Macromedia, Inc. All rights reserved.
  2.  
  3. var g_actionName = '';
  4.  
  5. function commandButtons(){
  6.     return new Array(BTN_OK, "okClicked()", BTN_Cancel, "cancelClicked()", BTN_Help, "displayHelp()");
  7. }
  8.  
  9. function receiveArguments(action)
  10. {
  11.     g_actionName = action;
  12. }    
  13.  
  14. function initializeUI()
  15. {
  16.     var FSM = FileStateManager.getManager(dw.getDocumentDOM());
  17.     var state = FSM.getState();
  18.     var labelNode = findObject('infoLabel');
  19.     if (g_actionName == 'submit' || g_actionName == 'publish')
  20.     {
  21.         if (state == 'new')
  22.             labelNode.innerHTML = LABEL_NewPage;
  23.         else
  24.             labelNode.innerHTML = LABEL_Draft;
  25.     }
  26.     else if (g_actionName == 'accept')
  27.     {
  28.         labelNode.innerHTML = LABEL_Approve;
  29.     }
  30.     else if (g_actionName == 'return')
  31.     {
  32.         labelNode.innerHTML = LABEL_Return;
  33.     }
  34. }
  35.  
  36. function okClicked() 
  37. {
  38.     var FSM = FileStateManager.getManager(dw.getDocumentDOM());
  39.     var url = FSM.getCurrentStateURL();
  40.     var notesFile = MMNotes.open(url, true);
  41.     if (notesFile)
  42.     {
  43.         // Increment the last comment number by one.
  44.         var lastCommentNumStr = MMNotes.get(notesFile, "ccNumComments");
  45.         var newCommentNum;
  46.         if (lastCommentNumStr == '')
  47.             newCommentNum = 1;
  48.         else
  49.             newCommentNum = parseInt(lastCommentNumStr) + 1;
  50.         newCommentNumStr = String(newCommentNum);
  51.         MMNotes.set(notesFile, "ccNumComments", newCommentNumStr);
  52.         MMNotes.set(notesFile, "ccCommentEvent" + newCommentNumStr, g_actionName);
  53.         MMNotes.set(notesFile, "ccCommentAuthor" + newCommentNumStr, FSM.debugOnlyGetContributorName());
  54.         MMNotes.set(notesFile, "ccCommentAuthorEmail" + newCommentNumStr, FSM.debugOnlyGetContributorEmail());
  55.         MMNotes.set(notesFile, "ccCommentAuthorIsReviewer" + newCommentNumStr, (FSM.debugOnlyGetReviewer() ? 'true' : 'false'));
  56.         MMNotes.set(notesFile, "ccCommentDate" + newCommentNumStr, getSimpleDateAndTime());
  57.         MMNotes.set(notesFile, "ccCommentContents" + newCommentNumStr, findObject('notesField').value);
  58.         MMNotes.close(notesFile);
  59.     }
  60.  
  61.     window.close();
  62. }
  63.  
  64. function cancelClicked() {
  65.     MM.returnCode = false;
  66.     window.close();
  67. }
  68.  
  69. function getSimpleDateAndTime() {
  70.     // *** TBD: localize time format as well
  71.     var today = new Date();
  72.     var date = createDateFromMask(DATE_Mask);
  73.     var hours = today.getHours();
  74.     var ampm;
  75.     if (hours < 12)
  76.     {
  77.         if (hours == 0)
  78.             hours = 12;
  79.         ampm = 'am';
  80.     }
  81.     else
  82.     {
  83.         if (hours > 12)
  84.             hours -= 12;
  85.         ampm = 'pm';
  86.     }
  87.  
  88.     var minutes = today.getMinutes();
  89.     var minStr;
  90.     if (minutes < 10)
  91.         minStr = "0" + String(minutes);
  92.     else
  93.         minStr = String(minutes);
  94.  
  95.     var time = String(hours) + ':' + minStr + ' ' + ampm;
  96.     return (date + ' ' + time);
  97. }
  98.  
  99. //Renders date (numbers only) as needed. Accepts the following tokens:
  100. //M or MM, D or DD, YY or YYYY. MM means pad with zero. Tokens can be mixed with any punctuation.
  101. //Examples: M/D/YY => 6/25/99  or  YYYY.MM.DD => 1999.06.25
  102.  
  103. //This is only temporarily in the localized code. Should be moved
  104. //to Shared/MM/Scripts/CMN/dateID.js for the next release.
  105.  
  106. function createDateFromMask(dateStr) {
  107.   var today = new Date();
  108.   var theYear  = String(today.getFullYear());
  109.   var theMonth = String(Number(today.getMonth())+1);
  110.   var theDate  = String(today.getDate());
  111.  
  112.  
  113.   //Replace Year
  114.   dateStr = dateStr.replace(/YYYY/g,theYear);
  115.   dateStr = dateStr.replace(/YY/g,theYear.substring(2));
  116.  
  117.   //Replace Month
  118.   dateStr = dateStr.replace(/MM/g,((Number(theMonth)<10)?"0":"")+theMonth);
  119.   dateStr = dateStr.replace(/M/g,theMonth);
  120.  
  121.   //Replace Date
  122.   dateStr = dateStr.replace(/DD/g,((Number(theDate)<10)?"0":"")+theDate);
  123.   dateStr = dateStr.replace(/D/g,theDate);
  124.  
  125.   return dateStr;
  126. }
  127.