home *** CD-ROM | disk | FTP | other *** search
/ Practical Internet Web Designer 86 / PIWD86.iso / pc / contents / dreamweaver / software / dwmx2004.exe / Disk1 / data1.cab / Configuration_En / Commands / Date.js < prev    next >
Encoding:
JavaScript  |  2003-09-05  |  22.8 KB  |  739 lines

  1.  
  2. //
  3. // Copyright 2000, 2001, 2002, 2003 Macromedia, Inc. All rights reserved. 
  4. //
  5. // ----------------------------------------------------
  6. //
  7. // Date.js
  8. //
  9. //This object inserts the current date and optionally time
  10. //and day at the current insertion point. An Update Automatically
  11. //On Save Option will update the date when the document is saved.
  12. //
  13. //
  14. //Localization Note:
  15. //Read the comments in the initGlobals function for instructions
  16. //on controlling the order of the date formats in the Date Format list,
  17. //as well as specifying that certain date formats should not appear
  18. //in a localized language.
  19.  
  20.  
  21.  
  22. //*********************GLOBAL VARIABLES***********************
  23.  
  24. //see initGlobals for info on global vars
  25.  
  26. var helpDoc = MM.HELP_objDate;
  27.  
  28. //global arrays
  29. var GarrDateFormats; 
  30. var GarrDayFormats;
  31. var GarrTimeFormats;
  32.  
  33. //form element objects
  34. var GlistDateFormats;
  35. var GselDayFormats;
  36. var GselTimeFormats;
  37. var GcbUpdate;
  38.  
  39. //global strings needed for accessor functions
  40. var GstrFullDate;
  41. var GstrHTMLFullDate;
  42. var GstrDateID;
  43.  
  44. function initGlobals(){
  45.  
  46.     //The GarrDateFormats array controls the order the date formats are shown in the UI
  47.     //The list of formats is in Date.htm
  48.     GarrDateFormats = LIST_DateFormats;
  49.  
  50.     //The GarrDateFormats array controls the order the day formats are shown in the UI
  51.     //The list of formats is in Date.htm
  52.     GarrDayFormats  =  LIST_DayFormats;
  53.  
  54.     //The GarrTimeFormats array controls the order of the time formats.
  55.     //The list of formats is in Date.htm
  56.     GarrTimeFormats =  LIST_TimeFormats;
  57.  
  58.  
  59.  
  60.    //-----------------------------------------------------------------------------
  61.    
  62.    //initialize global form elements
  63.    theForm = document.forms[0]; 
  64.    GlistDateFormats = theForm.DateFormats;
  65.    GselDayFormats   = theForm.DayFormats;
  66.    GselTimeFormats  = theForm.TimeFormats;
  67.    GcbUpdate        = theForm.Update;
  68. }
  69.  
  70. function charToEntity(thechar,charCode)
  71. {
  72.     switch(thechar) {
  73.         case '\x80' :         return "€";
  74.         case '\xA1' :         return "¡";
  75.         case '\xA2' :         return "¢";
  76.         case '\xA3' :         return "£";
  77.         case '\xA4' :         return "¤";
  78.         case '\xA5' :         return "¥";
  79.         case '\xA6' :         return "¦";
  80.         case '\xA7' :         return "§";
  81.         case '\xA8' :         return "¨";
  82.         case '\xA9' :         return "©";
  83.         case '\xAA' :         return "ª";
  84.         case '\xAB' :         return "«";
  85.         case '\xAC' :         return "¬";
  86.         case '\xAD' :         return "­";
  87.         case '\xAE' :         return "®";
  88.         case '\xAF' :         return "¯";
  89.         case '\xB0' :         return "°";
  90.         case '\xB1' :         return "±";
  91.         case '\xB2' :         return "²";
  92.         case '\xB3' :         return "³";
  93.         case '\xB4' :         return "´";
  94.         case '\xB5' :         return "µ";
  95.         case '\xB6' :         return "¶";
  96.         case '\xB7' :         return "·";
  97.         case '\xB8' :         return "¸";
  98.         case '\xB9' :         return "¹";
  99.         case '\xBA' :         return "º";
  100.         case '\xBB' :         return "»";
  101.         case '\xBC' :         return "¼";
  102.         case '\xBD' :         return "½";
  103.         case '\xBE' :         return "¾";
  104.         case '\xBF' :         return "¿";
  105.         case '\xD7' :         return "×";
  106.         case '\xF7' :         return "÷";
  107.         case '\xC6' :         return "Æ";
  108.         case '\xC1' :         return "Á";
  109.         case '\xC2' :         return "Â";
  110.         case '\xC0' :         return "À";
  111.         case '\xC5' :         return "Å";
  112.         case '\xC3' :         return "Ã";
  113.         case '\xC4' :         return "Ä";
  114.         case '\xC7' :         return "Ç";
  115.         case '\xD0' :         return "Ð";
  116.         case '\xC9' :         return "É";
  117.         case '\xCA' :         return "Ê";
  118.         case '\xC8' :         return "È";
  119.         case '\xCB' :         return "Ë";
  120.         case '\xCD' :         return "Í";
  121.         case '\xCE' :         return "Î";
  122.         case '\xCC' :         return "Ì";
  123.         case '\xCF' :         return "Ï";
  124.         case '\xD1' :         return "Ñ";
  125.         case '\xD3' :         return "Ó";
  126.         case '\xD4' :         return "Ô";
  127.         case '\xD2' :         return "Ò";
  128.         case '\xD8' :         return "Ø";
  129.         case '\xD5' :         return "Õ";
  130.         case '\xD6' :         return "Ö";
  131.         case '\xDE' :         return "Þ";
  132.         case '\xDA' :         return "Ú";
  133.         case '\xDB' :         return "Û";
  134.         case '\xD9' :         return "Ù";
  135.         case '\xDC' :         return "Ü";
  136.         case '\xDD' :         return "Ý";
  137.         case '\xE1' :         return "á";
  138.         case '\xE2' :         return "â";
  139.         case '\xE6' :         return "æ";
  140.         case '\xE0' :         return "à";
  141.         case '\xE5' :         return "å";
  142.         case '\xE3' :         return "ã";
  143.         case '\xE4' :         return "ä";
  144.         case '\xE7' :         return "ç";
  145.         case '\xE9' :         return "é";
  146.         case '\xEA' :         return "ê";
  147.         case '\xE8' :         return "è";
  148.         case '\xF0' :         return "ð";
  149.         case '\xEB' :         return "ë";
  150.         case '\xED' :         return "í";
  151.         case '\xEE' :         return "î";
  152.         case '\xEC' :         return "ì";
  153.         case '\xEF' :         return "ï";
  154.         case '\xF1' :         return "ñ";
  155.         case '\xF3' :         return "ó";
  156.         case '\xF4' :         return "ô";
  157.         case '\xF2' :         return "ò";
  158.         case '\xF8' :         return "ø";
  159.         case '\xF5' :         return "õ";
  160.         case '\xF6' :         return "ö";
  161.         case '\xDF' :         return "ß";
  162.         case '\xFE' :         return "þ";
  163.         case '\xFA' :         return "ú";
  164.         case '\xFB' :         return "û";
  165.         case '\xF9' :         return "ù";
  166.         case '\xFC' :         return "ü";
  167.         case '\xFD' :         return "ý";
  168.         case '\xFF' :         return "ÿ";
  169.  
  170.     }
  171.     if (charCode > 128)
  172.         return('&#' + parseInt(charCode) + ';');
  173.     else
  174.         return(thechar);
  175. }
  176.  
  177.  
  178. function entityNameEncode(string)
  179. {
  180.     latin1Str = dreamweaver.nativeToLatin1(string);
  181.     returnString = new String();
  182.     for (i=0;i<latin1Str.length;i++) {
  183.         returnString += charToEntity(latin1Str.charAt(i),latin1Str.charCodeAt(i));
  184.     }
  185.     return(returnString);
  186. }
  187.  
  188. //*********************** API ***********************
  189.  
  190. function isDOMRequired() { 
  191.     // Return false, indicating that this command is available in code view.
  192.     return false;
  193. }
  194.  
  195. //function: commandButtons
  196. //description: generic API function, returns string to be inserted at IP
  197.  
  198. function commandButtons(){
  199.    return new Array(MM.BTN_OK,         "setDateStr();window.close()",
  200.                     MM.BTN_Cancel,     "window.close()",
  201.                     MM.BTN_Help,       "displayHelp()"    );
  202.  
  203.  
  204. }
  205.  
  206. //***********************ACCESSOR FUNCTIONS***********************
  207.  
  208. function getDateStr(){
  209.    return GstrFullDate;
  210. }
  211.  
  212. function getDateID(){
  213.    return GstrDateID;
  214. }
  215.  
  216. function getHTMLDateStr(){
  217.    return GstrHTMLFullDate;
  218. }
  219.  
  220. //***********************LOCAL FUNCTIONS***********************
  221.  
  222. //function: setDateStr
  223. //description: called from OK button of dialog,
  224. //sets the global GstrFullDate variable
  225.  
  226. function setDateStr(){
  227.     var dateStr = "";
  228.     var dateStrHTML = "";
  229.     var dateID = "";
  230.     var now = new Date();
  231.     
  232.     var dayFormat  = getSelectedOptionAttr(GselDayFormats,"value");
  233.     var dateFormat = getSelectedOptionAttr(GlistDateFormats,"value");
  234.     var timeFormat = getSelectedOptionAttr(GselTimeFormats,"value");        
  235.     
  236.     //create the date that is inserted
  237.     //if selected a Japanese date format in J version of Dreamweaver, concatenate in order of
  238.     //date, day, time
  239.     if ((dateFormat.indexOf("Japan") == 0 || dateFormat.indexOf("Korean") == 0 || dateFormat.indexOf("Chinese") == 0) && (dreamweaver.appVersion.indexOf('ja') != -1 || dreamweaver.appVersion.indexOf('ko') != -1 || dreamweaver.appVersion.indexOf('zh') != -1)) {
  240.         dateStr += createDateStr(now,dateFormat,true);
  241.         dateStr += " " + createDayStr(now,dayFormat,dateFormat,false,true);
  242.         dateStr += createTimeStr(now,timeFormat);
  243.         dateStrHTML += createDateStr(now,dateFormat,true);
  244.         dateStrHTML += " " + createDayStr(now,dayFormat,dateFormat,false,true);
  245.         dateStrHTML += createTimeStr(now,timeFormat);
  246.     }
  247.     else
  248.     {
  249.         dateStr += createDayStr(now,dayFormat,dateFormat,false,true);
  250.         dateStr += createDateStr(now,dateFormat,true);
  251.         dateStr += createTimeStr(now,timeFormat);
  252.         // we don't want to encode for J or K or C day formats
  253.         if (dreamweaver.appVersion && (dreamweaver.appVersion.indexOf('ja') != -1 || dreamweaver.appVersion.indexOf('ko') != -1 || dreamweaver.appVersion.indexOf('zh') != -1) )
  254.             dateStrHTML += createDayStr(now,dayFormat,dateFormat,false,true);
  255.         else
  256.             dateStrHTML += createDayStr(now,dayFormat,dateFormat,false,false);
  257.         dateStrHTML += createDateStr(now,dateFormat,false);
  258.         dateStrHTML += createTimeStr(now,timeFormat);
  259.     }
  260.     
  261.     //dateID is inserted into the format attribute of the lock
  262.     //and also placed in the opening comment
  263.     dateID = createDateID(dayFormat,dateFormat,timeFormat);
  264.     
  265.     //if Update Automatically On Save is visible and checked,
  266.     //add locks around the date
  267.     if (GcbUpdate!=null && GcbUpdate.checked){
  268.        dateStr = addLockMarkup(dateStr,dateID);  
  269.        dateStrHTML = addLockMarkup(dateStrHTML,dateID);   
  270.     }
  271.     
  272.     //assign to global variables accessed by accessor functions
  273.     GstrFullDate = dateStr;
  274.     GstrHTMLFullDate = dateStrHTML;
  275.     GstrDateID = dateID;  
  276. }
  277.  
  278.  
  279.  
  280. //function: addLockMarkup
  281. //description: adds correct lock markup to the date that is 
  282. //inserted
  283.  
  284. function  addLockMarkup(dateStr,dateID){
  285.  
  286.    var openBracket = "%3C";
  287.    var closeBracket = "%3E";
  288.    var quote = "%22";
  289.  
  290.    var openComment = openBracket + '!-- #BeginDate ' +
  291.                      'format:' + dateID + ' --' + closeBracket;
  292.    var closeComment = openBracket + '!-- #EndDate --' + closeBracket;
  293.    var origAttr = openComment + dateStr + closeComment;
  294.    
  295.    var openLock = '<MM:BeginLock type="mmdate" format="' + dateID + 
  296.                   '" orig="' + origAttr + '">';
  297.    var closeLock =  '<MM:EndLock>';
  298.    
  299.    return openLock +  dateStr + closeLock;
  300. }
  301.  
  302.  
  303.  
  304. //function: initializeUI
  305. //description: initializes the global variables, and populates
  306. //the UI with date format examples.
  307.  
  308. function initializeUI(){
  309.    //return if already initialized
  310.    //(this happens if command is called from PI)
  311.    if (GarrDateFormats){
  312.       GlistDateFormats.focus();
  313.       return;
  314.    }
  315.       
  316.    initGlobals(); //initialize global variables
  317.    populateUI();  //populate UI
  318. }
  319.  
  320.  
  321.  
  322. //function: populateUI
  323. //description: populate the UI with date format examples
  324.  
  325. function populateUI(){
  326.    var dateFormatsArr = GarrDateFormats;  //shorter names easier to work with
  327.    var dayFormatsArr  = GarrDayFormats;
  328.    var timeFormatsArr = GarrTimeFormats;
  329.    
  330.    var nDateFormats = dateFormatsArr.length;
  331.    var nDayFormats  = dayFormatsArr.length;
  332.    var nTimeFormats = timeFormatsArr.length;
  333.    
  334.    var dateObj = new Date("74","2","7","22","18");  //examples are for March 7, 1974
  335.    var dateStr = "",timeStr="",dayStr=""; 
  336.    
  337.     //populate day format list in UI
  338.    //the first line creates an array of formatted dayes
  339.    //(the createDayStr function is overloaded to return one item
  340.    //or an array, therefore, unfortunately the function name isn't 
  341.    //always entirely accurate)
  342.    dayFormatsArr = createDayStr(dateObj,dayFormatsArr,dateFormatsArr,true,true);
  343.    var counter = 0;
  344.    for (i in dayFormatsArr){
  345.       if (!dayFormatsArr[i].prototype){ 
  346.          // Val 13-aug-99 use temporary for speedier UI loading
  347.          var curr = new Option(dayFormatsArr[i]);
  348.          curr.value = i;
  349.          GselDayFormats.options[ counter++ ] = curr;
  350.       }
  351.    }
  352.    
  353.    //populate date format list in UI
  354.    //the first line creates an array of formatted dates
  355.    //(the createDateStr function is overloaded to return one item
  356.    //or an array, therefore, unfortunately, the function name isn't 
  357.    ///always entirely accurate)
  358.    dateFormatsArr  = createDateStr(dateObj,dateFormatsArr,true);
  359.    counter = 0;
  360.    for (i in dateFormatsArr){
  361.       if (!dateFormatsArr[i].prototype){
  362.          // Val 13-aug-99: use a temporary to make initialization faster,
  363.          // and only assign to the formats array once.
  364.            var currObj = new Option(dateFormatsArr[i]);
  365.          currObj.value = i;
  366.          GlistDateFormats.options[ counter++ ] = currObj;
  367.       }
  368.    }
  369.    
  370.    //populate time format list
  371.    for (i=0;i<nTimeFormats;i++){
  372.       timeStr = createTimeStr(dateObj, timeFormatsArr[i], true);
  373.       GselTimeFormats.options[ i ] = new Option(timeStr);
  374.       GselTimeFormats.options[ i ].value = timeFormatsArr[i];
  375.    }
  376.   
  377.    
  378.    //select first option of each menu
  379.    GselDayFormats.selectedIndex = 0;
  380.    GlistDateFormats.selectedIndex = 0;
  381.    GselTimeFormats.selectedIndex = 0;
  382.    
  383.    //put focus in date formats field
  384.    GlistDateFormats.focus();
  385. }
  386.  
  387.  
  388.  
  389. //function: lead
  390. //description: given a one or two digit number,
  391. //adds a leading 0 if a 1 digit number
  392.  
  393. function lead(num){
  394.    if (num.toString().length == "1")
  395.       return "0" + num;
  396.    return ( num );
  397. }
  398.  
  399.  
  400. //function: createDateStr
  401. //description: given a date obj and a date format or formats
  402. //returns an array with the correctly formatted date strings
  403. //overloaded: dateFormat can be one item or an array
  404. //if it is one item, returns one item
  405. //if it is an array, returns an array
  406.  
  407. function createDateStr(dateObj,dateFormat,highAscii){
  408.    var date = dateObj.getDate();
  409.    var day = dateObj.getDay();
  410.    var month = dateObj.getMonth();
  411.    var year = dateObj.getYear();
  412.    var abbrYear = (year<100)? year : year.toString().substring(1);
  413.    var fullYear = (year<100)? "19" + year : year + 1900;
  414.    
  415.    var retVal; //return value;
  416.    
  417.    var abbrMonth;
  418.    var fullMonth;
  419.    var westfullMonth;
  420.  
  421.    if (highAscii || isDoubleByteVersion()) { //highAscii is true when date format is one of double-byte ones. but we also want to use this for western date format on double-byte versions.
  422.        abbrMonth = ARR_AbbrMonths[ month ];
  423.        westfullMonth = ARR_WestFullMonths[ month ];
  424.        fullMonth = ARR_FullMonths[ month++ ];
  425.  
  426.    } else {
  427.          abbrMonth = entityNameEncode(ARR_AbbrMonths[ month ]);
  428.        fullMonth = entityNameEncode(ARR_FullMonths[ month++ ]); 
  429.        westfullMonth = fullMonth;
  430.  
  431.  
  432.    }
  433.    //the dateFormat argument is overloaded so that it
  434.    //can be either a string or an array. Handle accordingly.
  435.    if (typeof dateFormat == "string"){
  436.       if (useEnglishDate(dateFormat)) 
  437.         fullMonth = westfullMonth;
  438.         retVal = createCorrectDateFormat(dateFormat,date,day,month,abbrMonth,fullMonth,westfullMonth,
  439.                                        year,abbrYear,fullYear);
  440.    } else { //dateFormat is an array
  441.         retVal = new Array();
  442.         dateFormats = dateFormat; //rename
  443.         var nFormats = dateFormats.length;
  444.  
  445.         
  446.         for (var i=0;i<nFormats;i++){
  447.            retVal[dateFormats[i]] = createCorrectDateFormat(dateFormat[i],date,day,month,abbrMonth,
  448.                                                fullMonth,westfullMonth,year,abbrYear,fullYear);
  449.             
  450.         }
  451.    }    
  452.    
  453.    return retVal;
  454. }
  455.  
  456.  
  457. //function: createCorrectDateFormat
  458. //description: returns a correclty formatted date string
  459.  
  460. function createCorrectDateFormat(dateFormat,date,day,month,abbrMonth,fullMonth,westfullMonth,
  461.                                  year,abbrYear,fullYear,time){
  462.  
  463.     var dateStr = "";
  464.    
  465.     switch (dateFormat){
  466.     
  467.        case "American1":  // Thursday, March 7, 1974
  468.           dateStr += fullMonth + " " + date + ", " + fullYear;
  469.           break;
  470.           
  471.        case "American2":  // 3/7/74
  472.           dateStr += month + "/" + date + "/" + abbrYear;
  473.           break;
  474.           
  475.        case "American3":  // 03/07/1974
  476.           dateStr += lead(month) + "/" + lead(date) + "/" + fullYear;
  477.           break;
  478.  
  479.        case "ISO8601":  // 1974-03-07
  480.           dateStr += fullYear + "-" + lead(month) + "-" + lead(date);
  481.           break;
  482.           
  483.        case "English1":  // 7-mar-74
  484.           dateStr += date + "-" + abbrMonth + "-" + abbrYear;
  485.           break;
  486.       
  487.        case "English2":  // 07-Mar-1974
  488.           abbrMonth = abbrMonth.charAt(0).toUpperCase()+abbrMonth.substring(1);
  489.           dateStr += lead(date) + "-" + abbrMonth + "-" + fullYear;
  490.           break;
  491.           
  492.        case "Spanish1":  // 7/3/74 
  493.           dateStr += date + "/" + month + "/" + abbrYear;
  494.           break;
  495.           
  496.        case "French1":  //  7/03/74
  497.           dateStr += date + "/" + lead(month) + "/" + abbrYear;
  498.           break;
  499.           
  500.        case "Italian1":  // 7-03-1974
  501.           dateStr += date + "-" + lead(month) + "-" + fullYear;
  502.           break;
  503.           
  504.        case "Brazilian1":  // 07.03.74
  505.           dateStr += lead(date) + "." + lead(month) + "." + abbrYear;
  506.           break;
  507.           
  508.        case "German1":  // 07.03.1974
  509.           dateStr += lead(date) + "." + lead(month) + "." + fullYear;
  510.           break;
  511.           
  512.        case "Japanese1":  // 74/03/07
  513.           dateStr += abbrYear + "/" + lead(month) + "/" + lead(date) ;
  514.           break;
  515.  
  516.        case "Japanese2":  // 1974 (yearJapanese) 3(month) 7(dayJapanese)
  517.           dateStr += fullYear + yearJapanese + fullMonth + date + dayJapanese;
  518.           break;
  519.  
  520.        case "Japanese3":  // 1974(yearJapanese)03(month) 07(dayJapanese)
  521.           dateStr += fullYear + yearJapanese + lead(month) + monthJapanese + lead(date) + dayJapanese;
  522.           break;
  523.                     
  524.        case "Swedish1":  //  7 March, 1974
  525.           dateStr +=  date + " " + fullMonth + ", " + fullYear;
  526.           break;
  527.           
  528.        case "Korean1":  //  1974(korean year) 3(korean month) 7(korean day)
  529.           dateStr +=  fullYear + yearKorean + fullMonth + " " + date + dayKorean;
  530.           break;
  531.           
  532.        case "Korean2":  //  1974.3.7
  533.           dateStr +=  fullYear + "." + month + "." + date;
  534.           break;
  535.  
  536.        case "Korean3":  //  3.7.1974
  537.           dateStr +=  month + "." + date + "." + fullYear;
  538.           break;
  539.  
  540.        case "Korean4":  //  March 7,1974
  541.           dateStr += westfullMonth + " " + date + ", " + fullYear;
  542.           break;
  543.  
  544.        case "Korean5":  //  74.03.07
  545.           dateStr += abbrYear + "." + lead(month) + "." + lead(date);
  546.           break;
  547.  
  548.        case "Korean6":  // 3/7/ 1974
  549.           dateStr +=  abbrMonth + "/" + lead(date) + " " + fullYear;
  550.           break;
  551.  
  552.        case "Korean7":  //  74-03-07
  553.           dateStr += abbrYear + "-" + lead(month) + "-" + lead(date);
  554.           break;
  555.  
  556.        case "Chinese1":  // 74/3/7
  557.           dateStr += abbrYear + "/" + month + "/" + date ;
  558.           break;
  559.  
  560.        case "Chinese2":  // 1974 (yearChinese) 3(monthChinese) 7(dayChinese)
  561.           dateStr += fullYear + yearChinese + fullMonth + date + dayChinese;
  562.           break;
  563.  
  564.        default:
  565.           break;
  566.    }
  567.    
  568.    return dateStr;
  569.  
  570. }
  571.  
  572.  
  573.  
  574. //function: createDayStr
  575. //description: see createDateStr notes. Except of course this function
  576. //returns a correctly formatted day (or days) instead of a date
  577.  
  578. function createDayStr(dateObj,dayFormat,dateFormat,bPreview,highAscii){
  579.    var    day = dateObj.getDay();
  580.    var    WestFullDay = ARR_WestFullDays[day];
  581.    var    WestAbbrDay = ARR_WestAbbrDays[day];
  582.    var    fullDay;
  583.    var    abbrDay;
  584.  
  585.    if (highAscii || isDoubleByteVersion()) { //highAscii is true when data format is one of double-byte ones. but we also want to use this for western data format on double-byte versions.
  586.      fullDay = ARR_FullDays[day];
  587.      abbrDay = ARR_AbbrDays[day];
  588.    } else {
  589.       fullDay = entityNameEncode(ARR_FullDays[day]);
  590.       abbrDay = entityNameEncode(ARR_AbbrDays[day]);
  591.    }
  592.  
  593.    if (typeof dayFormat == "string"){
  594.       dayFormat = useEnglishDayFormat(dayFormat, dateFormat);
  595.       retVal = createCorrectDayFormat(dayFormat,fullDay,abbrDay,WestFullDay,WestAbbrDay,bPreview);
  596.    } else { //dayFormat is an array
  597.         retVal = new Array();
  598.         dayFormats = dayFormat; //rename for clarity
  599.         var nFormats = dayFormats.length;
  600.  
  601.         for (var i=0;i<nFormats;i++){
  602.            retVal[dayFormats[i]] = createCorrectDayFormat(dayFormat[i],fullDay,abbrDay,WestFullDay,WestAbbrDay,bPreview);
  603.         }
  604.    }    
  605.    return retVal;
  606. }
  607.  
  608.  
  609.  
  610. //function: createCorrectDayFormat
  611. //description: returns the correctly formatted day format
  612.  
  613. function createCorrectDayFormat(dayFormat,fullDay,abbrDay,WestFullDay,WestAbbrDay,bPreview){
  614.  
  615.    var dayStr = "";
  616.    switch (dayFormat){
  617.    
  618.       case "NoDay":
  619.          if (bPreview)
  620.             dayStr = "[" + OPTION_NoDay + "]";
  621.          break;
  622.           
  623.       case "FullDayComma":
  624.          dayStr = CHAR_PreDay + fullDay + CHAR_PostDay;
  625.          break;
  626.          
  627.       case "FullDay":
  628.          dayStr = fullDay + " ";
  629.          break;
  630.          
  631.       case "AbbrDayComma":
  632.          dayStr = CHAR_PreDay + abbrDay + CHAR_PostDay;
  633.          break;
  634.          
  635.       case "AbbrDay":
  636.          dayStr = abbrDay + " ";
  637.          break;
  638.          
  639.       case "LowAbbrDayComma":
  640.          dayStr = abbrDay.toLowerCase() + ", ";
  641.          break;
  642.          
  643.       case "LowAbbrDay":
  644.          dayStr = abbrDay.toLowerCase() + " ";
  645.          break;
  646.  
  647.       case "WestFullDayComma":
  648.          dayStr = WestFullDay + westSeparator;
  649.          break;
  650.     
  651.       case "WestAbbrDayComma":
  652.          dayStr = WestAbbrDay + westSeparator; 
  653.          break;
  654.          
  655.       case "Euroasian1":  // 07-Mar-1974
  656.         abbrMonth = abbrMonth.charAt(0).toUpperCase()+abbrMonth.substring(1);
  657.         dateStr += lead(date) + " " + fullMonth + " " + fullYear;
  658.         break;
  659.  
  660.       default:
  661.          break;
  662.    
  663.    }
  664.  
  665.    return dayStr;
  666.  
  667. }
  668.  
  669.  
  670.  
  671. //function: createTimeStr
  672. //description: given a dateObj and a time format,
  673. //returns the correctly formatted time string
  674. //The time format argument is "a" for AM/PM,
  675. //"m" for military time, and "" for no time
  676.  
  677. function createTimeStr(dateObj,timeFormat,bPreview){
  678.    var hours = dateObj.getHours();
  679.    var minutes = lead(dateObj.getMinutes());
  680.    var timeStr = "";  //return value
  681.    
  682.    switch (timeFormat){
  683.       case "NoTime":
  684.          if (bPreview)
  685.             timeStr = "[" + OPTION_NoTime + "]";
  686.          break;
  687.          
  688.        case "AMPMTime":
  689.              timeStr += (hours>=12) ? ((hours-12==0)?hours:hours-12) + ":" + minutes + " " + PM :
  690.                   hours + ":" + minutes + " " + AM;
  691.            timeStr = " " + timeStr;
  692.            break;
  693.           
  694.       case "MilitaryTime":
  695.          timeStr += " " + hours + ":" + minutes;
  696.            timeStr = " " + timeStr;
  697.            break;
  698.          
  699.       default:
  700.          break;
  701.    }
  702.          
  703.    return timeStr;
  704. }
  705.  
  706. // Check if user is running localized DW
  707. function isDoubleByteVersion(){
  708.     if (dreamweaver.appVersion && (dreamweaver.appVersion.indexOf('ja') != -1 || dreamweaver.appVersion.indexOf('ko') != -1 || dreamweaver.appVersion.indexOf('zh') != -1) )
  709.         return true;
  710.     else
  711.         return false;
  712. }
  713.  
  714. // Return true if selected date format is not localized specific one (i.e. Japanese1).
  715. // For example, 
  716. // -If user selected "American1" date format on Japanese DW, this function returns true.
  717. // -If user selected "Japanese1" date format on Japanese DW, this function returns false.
  718. function useEnglishDate(format) {
  719.     if ((dreamweaver.appVersion && dreamweaver.appVersion.indexOf('ja') != -1) && format.indexOf("Japan") != 0)
  720.         return true;
  721.     else if ((dreamweaver.appVersion && dreamweaver.appVersion.indexOf('ko') != -1) && format.indexOf("Korean") != 0) 
  722.         return true;
  723.     else if ((dreamweaver.appVersion && dreamweaver.appVersion.indexOf('zh') != -1) && format.indexOf("Chinese") != 0) 
  724.         return true;
  725.     else
  726.         return false;
  727. }
  728.  
  729. // if selected date was not localized specific one (i.e. Japanese1), force to use Western day formats.
  730. function useEnglishDayFormat(dayFormat, dateFormat) {
  731.     var rtnDayFormat = dayFormat;
  732.     if (useEnglishDate(dateFormat)) {
  733.         if (dayFormat == "FullDayComma" || dayFormat == "FullDay")
  734.             rtnDayFormat = "WestFullDayComma";
  735.         else if (dayFormat != "NoDay")
  736.             rtnDayFormat = "WestAbbrDayComma";
  737.     }
  738.     return rtnDayFormat;
  739. }