3 Replies Latest reply on Jun 19, 2014 7:49 AM by SamLaundon

    From Configurator 4 to HTML5

    SamLaundon Level 1

      In a Configurator 4 created panel for Photoshop and I have a button for  the menu item Curves.

      Here is the script that I got from script editor in Configurator. When I run this script from ExtendScript, it works perfectly.

       

      ErrStrs = {}; ErrStrs.USER_CANCELLED=localize("$$$/ScriptingSupport/Error/UserCancelled=User cancelled the operation");

      try {var idCrvs = charIDToTypeID( 'Crvs' ); executeAction( idCrvs, undefined, DialogModes.ALL );

          } catch(e){if (e.toString().indexOf(ErrStrs.USER_CANCELLED)!=-1) {;

                  } else{alert(localize("$$$/ScriptingSupport/Error/CommandNotAvailable=The command is currently not available"));}}

       

      How would I transfer (translate) the above script to the main.js file in the "Hello Word" sample extension?

       

      Main.js

       

      (function () {

          'use strict';

       

          var csInterface = new CSInterface();

            

          // Reloads extension panel

          function reloadPanel() {

              location.reload();

          }

            

          function init() {

                    

              themeManager.init();

            

              $("#btn_reload").click(reloadPanel);

            

              $("#btn_test").click(function () {

                  csInterface.evalScript('sayHello()');

              });

       

               $("#btn_curves").click(function () {

              });

            

          }

            

          init();

       

      }());

       

      Thanks so much for your help. Sam

        • 1. Re: From Configurator 4 to HTML5
          Tom Ruark Adobe Employee

          You have a couple of options:

           

          1) replace the 'sayHello()' string with your code. This is difficult as you have both single quote and double quote in your code above so you would have to clean that up. Something like this might work: It has to be all one line!

           

            csInterface.evalScript('ErrStrs = {}; ErrStrs.USER_CANCELLED=localize("$$$/ScriptingSupport/Error/UserCancelled=User cancelled the operation"); try {var idCrvs = charIDToTypeID( "Crvs" ); executeAction( idCrvs, undefined, DialogModes.ALL ); } catch(e){if (e.toString().indexOf(ErrStrs.USER_CANCELLED)!=-1) {; } else{alert(localize("$$$/ScriptingSupport/Error/CommandNotAvailable=The command is currently not available"));}}');

           

          2) Find the .jsx file where function sayHello() is and replace the contents of that (between the { and } with your code above. Something like this:

           

          function sayHello() {

          ErrStrs = {};

          ErrStrs.USER_CANCELLED=localize("$$$/ScriptingSupport/Error/UserCancelled=User cancelled the operation");

          try {

               var idCrvs = charIDToTypeID( 'Crvs' );

               executeAction( idCrvs, undefined, DialogModes.ALL );

          }

          catch(e){

               if (e.toString().indexOf(ErrStrs.USER_CANCELLED)!=-1) {

                    ;

               } else {

                    alert(localize("$$$/ScriptingSupport/Error/CommandNotAvailable=The command is currently not available"));

               }

          }

          }

           

          Take a look at this page for more details on using .js files for the HTML JavaScript and .jsx files for the Photoshop ExtendScript JavaScript.

           

          A Short Guide to HTML5 Extensions | Adobe Developer Connection

          • 2. Re: From Configurator 4 to HTML5
            SamLaundon Level 1

            Thanks Tom - I will give it try and report back with my results.

             

            Sam

            • 3. Re: From Configurator 4 to HTML5
              SamLaundon Level 1

              Worked perfectly.

               

              Thanks again - Sam