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 / FlashPaperOptions.js < prev    next >
Encoding:
JavaScript  |  2003-07-18  |  18.5 KB  |  445 lines

  1. //=========================================================================================================
  2. //
  3. // Copyright 2003 Macromedia, Inc. All rights reserved.
  4. //
  5. // Feature: FlashPaper
  6. // Author:  SRJ
  7. // Module:  FlashPaperOptions.js
  8. // Purpose:    implement the FlashPaper Options dialog
  9. //
  10. //=========================================================================================================
  11.  
  12. var helpDoc = MM.HELP_flashPaperOptions;
  13.  
  14. var g_file = null;
  15. var g_returnArray = null;
  16. var g_paperInfo = null;
  17. var g_curUnits = 0;
  18.  
  19. // ----------------------------------------
  20. function inchToMM(inch) { return inch * 25.4; }
  21. function mmToInch(mm) { return mm / 25.4; }
  22.  
  23. // ----------------------------------------
  24. function roundToThousandths(val) 
  25. {
  26.     val *= 1000.0;
  27.     val = Math.round(val);
  28.     val /= 1000.0;
  29.     return val;
  30. }
  31.  
  32. // ----------------------------------------
  33. /*const*/ var MIN_PAPER_SIZE_MM = 75;    // roughly 3 inches.
  34.  
  35. // ----------------------------------------
  36. /*const*/ var g_paperSizes =
  37. [
  38.     { id: 1, width: inchToMM(8.5), height: inchToMM(11) },            /* Letter 8 1/2 x 11 in               */
  39.     { id: 2, width: inchToMM(8.5), height: inchToMM(11) },            /* Letter Small 8 1/2 x 11 in         */
  40.     { id: 3, width: inchToMM(11), height: inchToMM(17) },            /* Tabloid 11 x 17 in                 */
  41.     { id: 4, width: inchToMM(17), height: inchToMM(11) },            /* Ledger 17 x 11 in                  */
  42.     { id: 5, width: inchToMM(8.5), height: inchToMM(14) },            /* Legal 8 1/2 x 14 in                */
  43.     { id: 6, width: inchToMM(5.5), height: inchToMM(8.5) },            /* Statement 5 1/2 x 8 1/2 in         */
  44.     { id: 7, width: inchToMM(7.25), height: inchToMM(10.5) },        /* Executive 7 1/4 x 10 1/2 in        */
  45.     { id: 8, width: 297, height: 420 },                                /* A3 297 x 420 mm                    */
  46.     { id: 9, width: 210, height: 297 },                                /* A4 210 x 297 mm                    */
  47.     { id: 10, width: 210, height: 297 },                            /* A4 Small 210 x 297 mm              */
  48.     { id: 11, width: 148, height: 210 },                            /* A5 148 x 210 mm                    */
  49.     { id: 12, width: 250, height: 354 },                            /* B4 (JIS) 250 x 354                 */
  50.     { id: 13, width: 182, height: 257 },                            /* B5 (JIS) 182 x 257 mm              */
  51.     { id: 14, width: inchToMM(8.5), height: inchToMM(13) },            /* Folio 8 1/2 x 13 in                */
  52.     { id: 15, width: 215, height: 275 },                            /* Quarto 215 x 275 mm                */
  53.     { id: 16, width: inchToMM(10), height: inchToMM(14) },            /* 10x14 in                           */
  54.     { id: 17, width: inchToMM(11), height: inchToMM(17) },            /* 11x17 in                           */
  55.     { id: 18, width: inchToMM(8.5), height: inchToMM(11) },            /* Note 8 1/2 x 11 in                 */
  56.     { id: 19, width: inchToMM(3.875), height: inchToMM(8.875) },    /* Envelope #9 3 7/8 x 8 7/8          */
  57.     { id: 20, width: inchToMM(4.125), height: inchToMM(9.5) },        /* Envelope #10 4 1/8 x 9 1/2         */
  58.     { id: 21, width: inchToMM(4.5), height: inchToMM(10.375) },        /* Envelope #11 4 1/2 x 10 3/8        */
  59.     { id: 22, width: inchToMM(4.75), height: inchToMM(11) },        /* Envelope #12 4 3/4  x 11           */
  60.     { id: 23, width: inchToMM(5), height: inchToMM(11.5) },            /* Envelope #14 5 x 11 1/2            */
  61.     { id: 24, width: inchToMM(17), height: inchToMM(22) },            /* C size sheet                       */
  62.     { id: 25, width: inchToMM(22), height: inchToMM(34) },            /* D size sheet                       */
  63.     { id: 26, width: inchToMM(34), height: inchToMM(44) },            /* E size sheet                       */
  64.     { id: 27, width: 110, height: 220 },                            /* Envelope DL 110 x 220 mm           */
  65.     { id: 28, width: 162, height: 229 },                            /* Envelope C5 162 x 229 mm           */
  66.     { id: 29, width: 324, height: 458 },                            /* Envelope C3  324 x 458 mm          */
  67.     { id: 30, width: 229, height: 324 },                            /* Envelope C4  229 x 324 mm          */
  68.     { id: 31, width: 114, height: 162 },                            /* Envelope C6  114 x 162 mm          */
  69.     { id: 32, width: 114, height: 229 },                            /* Envelope C65 114 x 229 mm          */
  70.     { id: 33, width: 250, height: 353 },                            /* Envelope B4  250 x 353 mm          */
  71.     { id: 34, width: 176, height: 250 },                            /* Envelope B5  176 x 250 mm          */
  72.     { id: 35, width: 176, height: 125 },                            /* Envelope B6  176 x 125 mm          */
  73.     { id: 36, width: 110, height: 230 },                            /* Envelope 110 x 230 mm              */
  74.     { id: 37, width: inchToMM(3.875), height: inchToMM(7.5) },        /* Envelope Monarch 3.875 x 7.5 in    */
  75.     { id: 38, width: inchToMM(3.625), height: inchToMM(6.5) },        /* 6 3/4 Envelope 3 5/8 x 6 1/2 in    */
  76.     { id: 39, width: inchToMM(14.875), height: inchToMM(11) },        /* US Std Fanfold 14 7/8 x 11 in      */
  77.     { id: 40, width: inchToMM(8.5), height: inchToMM(12) },            /* German Std Fanfold 8 1/2 x 12 in   */
  78.     { id: 41, width: inchToMM(8.5), height: inchToMM(13) },            /* German Legal Fanfold 8 1/2 x 13 in */
  79.     { id: 42, width: 250, height: 353 },                            /* B4 (ISO) 250 x 353 mm              */
  80.     { id: 43, width: 100, height: 148 },                            /* Japanese Postcard 100 x 148 mm     */
  81.     { id: 44, width: inchToMM(9), height: inchToMM(11) },            /* 9 x 11 in                          */
  82.     { id: 45, width: inchToMM(10), height: inchToMM(11) },            /* 10 x 11 in                         */
  83.     { id: 46, width: inchToMM(15), height: inchToMM(11) },            /* 15 x 11 in                         */
  84.     { id: 47, width: 220, height: 220 },                            /* Envelope Invite 220 x 220 mm       */
  85.     //{ id: 48, width: 1, height: 1 },                                ** RESERVED--DO NOT USE               */
  86.     //{ id: 49, width: 1, height: 1 },                                ** RESERVED--DO NOT USE               */
  87.     { id: 50, width: inchToMM(9.5), height: inchToMM(12) },            /* Letter Extra 9.5 x 12 in              */
  88.     { id: 51, width: inchToMM(9.5), height: inchToMM(15) },            /* Legal Extra 9.5 x 15 in            */
  89.     { id: 52, width: inchToMM(11.69), height: inchToMM(18) },        /* Tabloid Extra 11.69 x 18 in        */
  90.     { id: 53, width: inchToMM(9.27), height: inchToMM(12.69) },        /* A4 Extra 9.27 x 12.69 in           */
  91.     { id: 54, width: inchToMM(8.5), height: inchToMM(11) },            /* Letter Transverse 8.5 x 11 in      */
  92.     { id: 55, width: 210, height: 297 },                            /* A4 Transverse 210 x 297 mm         */
  93.     { id: 56, width: inchToMM(9.5), height: inchToMM(12) },            /* Letter Extra Transverse 9.5 x 12 in*/
  94.     { id: 57, width: 227, height: 356 },                            /* SuperA/SuperA/A4 227 x 356 mm      */
  95.     { id: 58, width: 305, height: 487 },                            /* SuperB/SuperB/A3 305 x 487 mm      */
  96.     { id: 59, width: inchToMM(8.5), height: inchToMM(12.69) },        /* Letter Plus 8.5 x 12.69 in         */
  97.     { id: 60, width: 210, height: 330 },                            /* A4 Plus 210 x 330 mm               */
  98.     { id: 61, width: 148, height: 210 },                            /* A5 Transverse 148 x 210 mm         */
  99.     { id: 62, width: 182, height: 257 },                            /* B5 (JIS) Transverse 182 x 257 mm   */
  100.     { id: 63, width: 322, height: 445 },                            /* A3 Extra 322 x 445 mm              */
  101.     { id: 64, width: 174, height: 235 },                            /* A5 Extra 174 x 235 mm              */
  102.     { id: 65, width: 201, height: 276 },                            /* B5 (ISO) Extra 201 x 276 mm        */
  103.     { id: 66, width: 420, height: 594 },                            /* A2 420 x 594 mm                    */
  104.     { id: 67, width: 297, height: 420 },                            /* A3 Transverse 297 x 420 mm         */
  105.     { id: 68, width: 322, height: 445 },                            /* A3 Extra Transverse 322 x 445 mm   */
  106.     { id: 69, width: 200, height: 148 },                            /* Japanese Double Postcard 200 x 148 mm */
  107.     { id: 70, width: 105, height: 148 },                            /* A6 105 x 148 mm                 */
  108.     { id: 71, width: 240, height: 332 },                            /* Japanese Envelope Kaku #2       */
  109.     { id: 72, width: 216, height: 277 },                            /* Japanese Envelope Kaku #3       */
  110.     { id: 73, width: 120, height: 235 },                            /* Japanese Envelope Chou #3       */
  111.     { id: 74, width: 90, height: 205 },                                /* Japanese Envelope Chou #4       */
  112.     { id: 75, width: inchToMM(11), height: inchToMM(8) },            /* Letter Rotated 11 x 8 1/2 11 in */
  113.     { id: 76, width: 420, height: 297 },                            /* A3 Rotated 420 x 297 mm         */
  114.     { id: 77, width: 297, height: 210 },                            /* A4 Rotated 297 x 210 mm         */
  115.     { id: 78, width: 210, height: 148 },                            /* A5 Rotated 210 x 148 mm         */
  116.     { id: 79, width: 364, height: 257 },                            /* B4 (JIS) Rotated 364 x 257 mm   */
  117.     { id: 80, width: 257, height: 182 },                            /* B5 (JIS) Rotated 257 x 182 mm   */
  118.     { id: 81, width: 148, height: 100 },                            /* Japanese Postcard Rotated 148 x 100 mm */
  119.     { id: 82, width: 148, height: 200 },                            /* Double Japanese Postcard Rotated 148 x 200 mm */
  120.     { id: 83, width: 148, height: 105 },                            /* A6 Rotated 148 x 105 mm         */
  121.     { id: 84, width: 332, height: 240 },                            /* Japanese Envelope Kaku #2 Rotated */
  122.     { id: 85, width: 277, height: 216 },                            /* Japanese Envelope Kaku #3 Rotated */
  123.     { id: 86, width: 235, height: 120 },                            /* Japanese Envelope Chou #3 Rotated */
  124.     { id: 87, width: 205, height: 90 },                                /* Japanese Envelope Chou #4 Rotated */
  125.     { id: 88, width: 128, height: 182 },                            /* B6 (JIS) 128 x 182 mm           */
  126.     { id: 89, width: 182, height: 128 },                            /* B6 (JIS) Rotated 182 x 128 mm   */
  127.     { id: 90, width: inchToMM(12), height: inchToMM(11) },            /* 12 x 11 in                      */
  128.     { id: 91, width: 105, height: 235 },                            /* Japanese Envelope You #4        */
  129.     { id: 92, width: 235, height: 105 },                            /* Japanese Envelope You #4 Rotated*/
  130.     { id: 93, width: 146, height: 215 },                            /* PRC 16K 146 x 215 mm            */
  131.     { id: 94, width: 97, height: 151 },                                /* PRC 32K 97 x 151 mm             */
  132.     { id: 95, width: 97, height: 151 },                                /* PRC 32K(Big) 97 x 151 mm        */
  133.     { id: 96, width: 102, height: 165 },                            /* PRC Envelope #1 102 x 165 mm    */
  134.     { id: 97, width: 102, height: 176 },                            /* PRC Envelope #2 102 x 176 mm    */
  135.     { id: 98, width: 125, height: 176 },                            /* PRC Envelope #3 125 x 176 mm    */
  136.     { id: 99, width: 110, height: 208 },                            /* PRC Envelope #4 110 x 208 mm    */
  137.     { id: 100, width: 110, height: 220 },                            /* PRC Envelope #5 110 x 220 mm    */
  138.     { id: 101, width: 120, height: 230 },                            /* PRC Envelope #6 120 x 230 mm    */
  139.     { id: 102, width: 160, height: 230 },                            /* PRC Envelope #7 160 x 230 mm    */
  140.     { id: 103, width: 120, height: 309 },                            /* PRC Envelope #8 120 x 309 mm    */
  141.     { id: 104, width: 229, height: 324 },                            /* PRC Envelope #9 229 x 324 mm    */
  142.     { id: 105, width: 324, height: 458 },                            /* PRC Envelope #10 324 x 458 mm   */
  143.     { id: 106, width: 215, height: 146 },                            /* PRC 16K Rotated                 */
  144.     { id: 107, width: 151, height: 97 },                            /* PRC 32K Rotated                 */
  145.     { id: 108, width: 151, height: 97 },                            /* PRC 32K(Big) Rotated            */
  146.     { id: 109, width: 165, height: 102 },                            /* PRC Envelope #1 Rotated 165 x 102 mm */
  147.     { id: 110, width: 176, height: 102 },                            /* PRC Envelope #2 Rotated 176 x 102 mm */
  148.     { id: 111, width: 176, height: 125 },                            /* PRC Envelope #3 Rotated 176 x 125 mm */
  149.     { id: 112, width: 208, height: 110 },                            /* PRC Envelope #4 Rotated 208 x 110 mm */
  150.     { id: 113, width: 220, height: 110 },                            /* PRC Envelope #5 Rotated 220 x 110 mm */
  151.     { id: 114, width: 230, height: 120 },                            /* PRC Envelope #6 Rotated 230 x 120 mm */
  152.     { id: 115, width: 230, height: 160 },                            /* PRC Envelope #7 Rotated 230 x 160 mm */
  153.     { id: 116, width: 309, height: 120 },                            /* PRC Envelope #8 Rotated 309 x 120 mm */
  154.     { id: 117, width: 324, height: 229 },                            /* PRC Envelope #9 Rotated 324 x 229 mm */
  155.     { id: 118, width: 458, height: 324 }                            /* PRC Envelope #10 Rotated 458 x 324 mm */
  156. ];
  157.  
  158. // ----------------------------------------
  159. function receiveArguments()
  160. {
  161.     g_file = arguments[0];
  162.     g_returnArray = arguments[1];
  163.  
  164.     g_paperInfo = null;
  165.  
  166.     /*const*/ var warnUserIfNotAvailable = true;
  167.     if (!isFlashPaperAvailable(warnUserIfNotAvailable))
  168.     {
  169.          return "abort"; 
  170.     }
  171.  
  172.     var isTextOnlyMode = dw.getDocumentDOM().getCCSharedSetting_TextOnlyInNonTemplates() && 
  173.         !dw.getDocumentDOM().isTemplateInstance();
  174.  
  175.     if (isTextOnlyMode)
  176.     {
  177.         // doh. can't insert. punt.
  178.         alert(dw.loadString("page props/edit text only"));
  179.          return "abort"; 
  180.     }
  181.  
  182.     // if an office doc, suck out the settings and use those...
  183.     if (g_file != null && g_file != '')
  184.     {
  185.         g_paperInfo = dw.getOfficePrintInfo(g_file);
  186.     }
  187.  
  188.     // otherwise, get the current settings from FlashPaperConnect and use those
  189.     if (g_paperInfo == null)
  190.     {
  191.         g_paperInfo = FlashPaperConnect.getCurrentPaperSettings();
  192.     }
  193.  
  194.     initializeUI();
  195. }
  196.  
  197. // ----------------------------------------
  198. function commandButtons()
  199. {
  200.     return new Array( "PutButtonsOnBottom", 
  201.                       "OkButton",            MM.BTN_OK,        "if (checkValid()) { window.close(); run(); }",
  202.                       "CancelButton",        MM.BTN_Cancel,    "window.close();",
  203.                       "PutButtonOnLeft",    MM.BTN_Help,    "displayHelp();");
  204. }
  205.  
  206. // ----------------------------------------
  207. function initializeUI()
  208. {
  209.     var orient = 0;
  210.     var paperSize = 1;
  211.     var width = inchToMM(4);
  212.     var height = inchToMM(6);
  213.  
  214.     if (g_paperInfo != null)
  215.     {
  216.         orient = g_paperInfo[0];
  217.         paperSize = g_paperInfo[1];
  218.         width = g_paperInfo[2];
  219.         height = g_paperInfo[3];
  220.     }
  221.  
  222.     g_curUnits = Number(dw.getPreferenceString("General Preferences", "FlashPaper Units", 0));
  223.     document.theForm.customunits.selectedIndex = g_curUnits;
  224.  
  225.     if (orient == 0)
  226.     {
  227.         document.theForm.orientation[0].checked = true;
  228.         document.theForm.orientation[0].focus();
  229.     }
  230.     else
  231.     {
  232.         document.theForm.orientation[1].checked = true;
  233.         document.theForm.orientation[1].focus();
  234.     }
  235.  
  236.     var found = false;
  237.     for (var i = 0; i < document.theForm.papersizelist.options.length; ++i)
  238.     {
  239.         if (document.theForm.papersizelist.options[i].value == paperSize)
  240.         {
  241.             setStandardPaperSize();
  242.             document.theForm.papersizelist.selectedIndex = i;
  243.             found = true;
  244.             break;
  245.         }
  246.     }
  247.     if (!found)
  248.     {
  249.         // could be a "standard" size that isn't in our UI.
  250.         // try looking it up.
  251.         if (width == 0 || height == 0)
  252.         {
  253.             for (var i = 0; i < g_paperSizes.length; ++i)
  254.             {
  255.                 if (g_paperSizes[i].id == paperSize)
  256.                 {
  257.                     width = g_paperSizes[i].width;
  258.                     height = g_paperSizes[i].height;
  259.                     break;
  260.                 }
  261.             }
  262.         }
  263.  
  264.         document.theForm.papersizelist.selectedIndex = 0;
  265.         if (document.theForm.customunits.selectedIndex == 0)
  266.         {
  267.             width = mmToInch(width);
  268.             height = mmToInch(height);
  269.         }
  270.         document.theForm.customwidth.value = roundToThousandths(width);
  271.         document.theForm.customheight.value = roundToThousandths(height);
  272.         setCustomPaperSize();
  273.     }
  274. }
  275.  
  276. // ----------------------------------------
  277. function setStandardPaperSize()
  278. {
  279.     document.theForm.papersize[0].checked = true;
  280.  
  281.     document.theForm.papersizelist.disabled = false;
  282.  
  283.     document.theForm.customwidth.disabled = true;
  284.     document.theForm.customheight.disabled = true;
  285.     document.theForm.customunits.disabled = true;
  286. }
  287.  
  288. // ----------------------------------------
  289. function setCustomPaperSize()
  290. {
  291.     document.theForm.papersize[1].checked = true;
  292.  
  293.     document.theForm.papersizelist.disabled = true;
  294.  
  295.     document.theForm.customwidth.disabled = false;
  296.     document.theForm.customheight.disabled = false;
  297.     document.theForm.customunits.disabled = false;
  298. }
  299.  
  300. // ----------------------------------------
  301. function onUnitsChanged()
  302. {
  303.     if (g_curUnits != document.theForm.customunits.selectedIndex)
  304.     {
  305.         var width = document.theForm.customwidth.value;
  306.         var height = document.theForm.customheight.value;
  307.         if (g_curUnits == 0)
  308.         {
  309.             // was inch, now mm
  310.             width = inchToMM(width);
  311.             height = inchToMM(height);
  312.             if (width < MIN_PAPER_SIZE_MM || isNaN(width)) 
  313.                 width = MIN_PAPER_SIZE_MM;
  314.             if (height < MIN_PAPER_SIZE_MM || isNaN(height)) 
  315.                 height = MIN_PAPER_SIZE_MM;
  316.         }
  317.         else
  318.         {
  319.             // was mm, now inch
  320.             if (width < MIN_PAPER_SIZE_MM || isNaN(width)) 
  321.                 width = MIN_PAPER_SIZE_MM;
  322.             if (height < MIN_PAPER_SIZE_MM || isNaN(height)) 
  323.                 height = MIN_PAPER_SIZE_MM;
  324.             width = mmToInch(width);
  325.             height = mmToInch(height);
  326.         }
  327.  
  328.         document.theForm.customwidth.value = roundToThousandths(width);
  329.         document.theForm.customheight.value = roundToThousandths(height);
  330.         g_curUnits = document.theForm.customunits.selectedIndex;
  331.     }
  332. }
  333.  
  334. // ----------------------------------------
  335. function onPaperSizeChanged()
  336. {
  337.     if (document.theForm.papersize[0].checked)
  338.     {
  339.         setStandardPaperSize();
  340.     }
  341.     else
  342.     {
  343.         setCustomPaperSize();
  344.     }
  345. }
  346.  
  347. // ----------------------------------------
  348. function onFlashPaperLinkClicked()
  349. {
  350.     dwscripts.displayDWHelp(MM.HELP_aboutFlashPaper);
  351. }
  352.  
  353. // ----------------------------------------
  354. function checkValid()
  355. {
  356.     if (!document.theForm.papersize[0].checked)
  357.     {
  358.         width = document.theForm.customwidth.value;
  359.         height = document.theForm.customheight.value;
  360.         if (document.theForm.customunits.selectedIndex == 0)
  361.         {
  362.             width = inchToMM(width);
  363.             height = inchToMM(height);
  364.         }
  365.         if (width < MIN_PAPER_SIZE_MM || isNaN(width) || 
  366.             height < MIN_PAPER_SIZE_MM || isNaN(height)) 
  367.         {
  368.             alert(BAD_PAPERSIZE_ENTERED);
  369.             return false;
  370.         }
  371.     }
  372.  
  373.     return true;
  374. }
  375.  
  376. // ----------------------------------------
  377. function run()
  378. {
  379.     if (typeof(FlashPaperConnect) == "undefined" || FlashPaperConnect.isAvailable() != 0)
  380.     {
  381.         return;
  382.     }
  383.  
  384.     var orient;
  385.     if (document.theForm.orientation[0].checked)
  386.         orient = 0;
  387.     else
  388.         orient = 1;
  389.  
  390.     var paperSize = 256;    // user-defined
  391.     var width = 1;
  392.     var height = 1;
  393.     if (document.theForm.papersize[0].checked)
  394.     {
  395.  
  396.         var sel = document.theForm.papersizelist.selectedIndex;
  397.         if (sel < 0) sel = 0;
  398.         paperSize = document.theForm.papersizelist.options[sel].value;
  399.         for (var i = 0; i < g_paperSizes.length; ++i)
  400.         {
  401.             if (g_paperSizes[i].id == paperSize)
  402.             {
  403.                 width = g_paperSizes[i].width;
  404.                 height = g_paperSizes[i].height;
  405.                 break;
  406.             }
  407.         }
  408.     }
  409.     else
  410.     {
  411.         width = document.theForm.customwidth.value;
  412.         height = document.theForm.customheight.value;
  413.         if (document.theForm.customunits.selectedIndex == 0)
  414.         {
  415.             width = inchToMM(width);
  416.             height = inchToMM(height);
  417.         }
  418.     }
  419.  
  420.     // many apps get very unhappy with tiny paper sizes.
  421.     // constrain to a plausible size.
  422.     if (width < MIN_PAPER_SIZE_MM || isNaN(width)) 
  423.         width = MIN_PAPER_SIZE_MM;
  424.     if (height < MIN_PAPER_SIZE_MM || isNaN(height)) 
  425.         height = MIN_PAPER_SIZE_MM;
  426.  
  427.     dw.setPreferenceString("General Preferences", "FlashPaper Units", document.theForm.customunits.selectedIndex.toString());
  428.  
  429.     if (g_returnArray)
  430.     {
  431.         // 'portrait' is always narrower than it is tall,
  432.         // 'landscape' is the opposite.
  433.         if (width > height)
  434.         {
  435.             var tmp = width;
  436.             width = height;
  437.             height = tmp;
  438.         }
  439.         if (orient == 0)
  440.             g_returnArray[0] = [ roundToThousandths(width), roundToThousandths(height) ];
  441.         else
  442.             g_returnArray[0] = [ roundToThousandths(height), roundToThousandths(width) ];
  443.     }
  444. }
  445.