2 Replies Latest reply on Jan 4, 2016 2:15 AM by Marc Autret

    (Javascript) I need help Abbreviating units (ie; Millimeters to mm, Inches to in.....etc)

    scottr93836726

      Hi Scripters,

       

      I was wondering if anyone would be able to help me out?

       

      I was given a piece of script for an indesign Variable which adds the Page size + Unit of measurement,

       

      Now im wondering if there is any way to have the unit to display Abbreviated?

       

      See below for current script....

       

       

       

      Thanks in advance!

      Scott

       

       

       

       

      function toTitleCase(str) {
          return str.replace(/([^\W_]+[^\s-]*) */g, function (txt) {
              return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
               
                     });
      
      function getPageDimentions(page){ // by Trevor
          var width, height, bounds, units, decPlaces;
          // function presumes that normal pages
          // i.e. same vertical and horizontal and no page shape transformations
          decPlaces = 3;
          units = toTitleCase(page.parent.parent.viewPreferences.horizontalMeasurementUnits.toString());
          bounds = page.bounds;
          height = bounds[2] - bounds[0];
          height = myRound(height, decPlaces);
          width = bounds[3] - bounds[1];
          width = myRound(width, decPlaces);
          return height + " x " + width + " " + units