Class Index | File Index

Classes


Namespace jamActions


Version 4.5.

Defined in: jamActions.jsxinc.

Namespace Summary
Constructor Attributes Constructor Name and Description
 
Global object (used to simulate a namespace in JavaScript) containing a set of functions related to decoding actions files into a format usable by scripts written with the JSON Action Manager engine.
Method Summary
Method Attributes Method Name and Description
<static>  
jamActions.dataFromActionsFile(actionsFile, isPalette)
Convert an actions file (*.atn) or actions palette file (Actions Palette.psp) into a data structure in literal object format [available in CS2 or later].
<static>  
jamActions.determineDialogMode(command)
Determine dialog mode depending on command settings
<static>  
jamActions.isActionsFile(file)
Test if a given file is an actions file (*.atn).
<static>  
jamActions.isActionsPalette(file)
Test if a given file is an actions palette file (Actions Palette.psp).
<static>  
jamActions.isLocalPlayCommand(command, actionSetName)
Test if a command is a play of a local action (belonging to the same action set).
<static>  
jamActions.readActionDescriptor(file, insertVersionPrefix)
Read an ActionDescriptor object from the current position of an open file stream [available in CS2 or later].
<static>  
jamActions.setCommandHandler(commandHandler)
Set the global command handler [available in CS2 or later].
<static>  
jamActions.traverseAction(actionSet, actionLocator, fromCommandIndex, continuePlay)
Traverse all the commands of a specific action of an action set data structure obtained from a converted actions file (*.atn) [available in CS2 or later].
Namespace Detail
jamActions
Global object (used to simulate a namespace in JavaScript) containing a set of functions related to decoding actions files into a format usable by scripts written with the JSON Action Manager engine.
Uses information found in the document Photoshop Actions File Format.
Author: Michel MARIANI.
Method Detail
<static> {Object|String} jamActions.dataFromActionsFile(actionsFile, isPalette)
Convert an actions file (*.atn) or actions palette file (Actions Palette.psp) into a data structure in literal object format [available in CS2 or later].
function actionsFileFilter (f)
{
    return (f instanceof Folder) || jamActions.isActionsFile (f);
}
var select = (File.fs === "Macintosh") ? actionsFileFilter : "Actions Files:*.atn,All Files:*";
var actionsFile = File.openDialog ("Select an actions file:", select);
if (actionsFile !== null)
{
    var fileData = jamActions.dataFromActionsFile (actionsFile);
    if (typeof fileData === 'string')
    {
        alert (fileData + "\n" + "Actions file: “" + File.decode (actionsFile.name) + "”");
    }
    else
    {
        alert ("Action set name: “" + fileData.actionSet.name + "”");
        alert ("Number of actions: " + fileData.actionSet.actions.length);
    }
}
Parameters:
{String|Object} actionsFile
Actions file (or actions palette file) path string or File object
{Boolean} isPalette Optional
true if actions palette file
Returns:
{Object|String} Converted actions file data structure in literal object format, or error message string

The actions file data structure is defined as a literal object with two members: either
{ fileVersion: fileVersion, actionSets: actionSets } for an actions palette file, or
{ fileVersion: fileVersion, actionSet: actionSet } for an actions file.

fileVersion: number
actionSets: literal array [ ] of actionSet
actionSet: literal object with three members: { name: name, expanded: expanded, actions: actions }

name: string
expanded: boolean
actions: literal array [ ] of action

action: literal object with seven members:
{ functionKey: functionKey, shiftKey: shiftKey, commandKey: commandKey, colorIndex: colorIndex, name: name, expanded: expanded, commands: commands }

functionKey: number
shiftKey: boolean
commandKey: boolean
colorIndex: number
name: string
expanded: boolean
commands: literal array [ ] of command

command: literal object with six or seven members: either
{ expanded: expanded, enabled: enabled, withDialog: withDialog, dialogOptions: dialogOptions, eventId: eventId, dictionaryName: dictionaryName } or
{ expanded: expanded, enabled: enabled, withDialog: withDialog, dialogOptions: dialogOptions, eventId: eventId, dictionaryName: dictionaryName, actionDescriptor: actionDescriptor }

expanded: boolean
enabled: boolean
withDialog: boolean
dialogOptions: number
eventId: number
dictionaryName: string
actionDescriptor: ActionDescriptor object (optional)


<static> {Object} jamActions.determineDialogMode(command)
Determine dialog mode depending on command settings
app.executeAction (command.eventId, command.actionDescriptor, jamActions.determineDialogMode (command));
Parameters:
{Object} command
Command data structure
Returns:
{Object} Dialog mode: either DialogModes.ALL or DialogModes.NO
See:
jamActions.dataFromActionsFile

<static> {Boolean} jamActions.isActionsFile(file)
Test if a given file is an actions file (*.atn).
function actionsFileFilter (f)
{
    return (f instanceof Folder) || jamActions.isActionsFile (f);
}
var select = (File.fs === "Macintosh") ? actionsFileFilter : "Actions Files:*.atn,All Files:*";
var actionsFile = File.openDialog ("Select an actions file:", select);
if (actionsFile !== null)
{
    alert ("OK!");
}
Parameters:
{Object} file
File object
Returns:
{Boolean} true if actions file

<static> {Boolean} jamActions.isActionsPalette(file)
Test if a given file is an actions palette file (Actions Palette.psp).
function actionsPaletteFilter (f)
{
    return (f instanceof Folder) || jamActions.isActionsPalette (f);
}
var select = (File.fs === "Macintosh") ? actionsPaletteFilter : "Actions Palette File:*.psp,All Files:*.*";
var actionsPaletteFile = File.openDialog ("Select an actions palette file:", select);
if (actionsPaletteFile !== null)
{
    alert ("OK!");
}
Parameters:
{Object} file
File object
Returns:
{Boolean} true if actions palette file

<static> {Array|Null} jamActions.isLocalPlayCommand(command, actionSetName)
Test if a command is a play of a local action (belonging to the same action set).
function executeCommand (command)
{
    if (command.enabled)
    {
        var playCommand = jamActions.isLocalPlayCommand (command, actionSet.name);
        if (playCommand !== null)
        {
            jamActions.traverseAction (actionSet, playCommand[0], playCommand[1], playCommand[2]);
        }
        else
        {
            var dialogMode = jamActions.determineDialogMode (command);
            app.executeAction (command.eventId, command.actionDescriptor, dialogMode);
        }
    }
}
jamActions.setCommandHandler (executeCommand);
jamActions.traverseAction (fileData.actionSet, actionName);
Parameters:
{Object} command
Command data structure
{String} actionSetName
Action set name
Returns:
{Array|Null} Array of three items: [ localActionName, localCommandIndex, localContinue ] if true, null if false
See:
jamActions.dataFromActionsFile

<static> {Object} jamActions.readActionDescriptor(file, insertVersionPrefix)
Read an ActionDescriptor object from the current position of an open file stream [available in CS2 or later].
var actionDescriptor = jamActions.readActionDescriptor (inFile);
var resultDescriptorObj = jamEngine.classIdAndActionDescriptorToJson (0, actionDescriptor);
$.writeln (jamJSON.stringify (resultDescriptorObj["<descriptor>"], '\t'));
Parameters:
{Object} file
File object
{Boolean} insertVersionPrefix
Insert missing version prefix at the beginning of the file stream
Returns:
{Object} ActionDescriptor object

<static> jamActions.setCommandHandler(commandHandler)
Set the global command handler [available in CS2 or later].
function debugCommand (command)
{
    $.writeln ("Dictionary Name: " + command.dictionaryName);
    $.writeln ("Enabled: " + command.enabled);
    $.writeln ("With Dialog: " + command.withDialog);
    $.writeln ();
}
jamActions.setCommandHandler (debugCommand);
jamActions.traverseAction (fileData.actionSet, 0);
Parameters:
{Function} commandHandler
Global command handler: function to be called by jamActions.traverseAction () for each command in the action
See:
jamActions.traverseAction

<static> jamActions.traverseAction(actionSet, actionLocator, fromCommandIndex, continuePlay)
Traverse all the commands of a specific action of an action set data structure obtained from a converted actions file (*.atn) [available in CS2 or later].
The global command handler set by jamActions.setCommandHandler () is called for each command in the action.
Folder.current = new Folder ("~/JSON Action Manager/tests/resources/");
jamEngine.jsonPlay ("open", { "target": { "<path>": "Factory.jpg" } });
var actionsFilePath = "Cross Processing.atn";
var fileData = jamActions.dataFromActionsFile (actionsFilePath);
if (typeof fileData === 'string')
{
    alert (fileData + "\n" + "Actions file: “" + actionsFilePath + "”");
}
else
{
    function executeCommand (command)
    {
        if (command.enabled)
        {
            var dialogMode = jamActions.determineDialogMode (command);
            app.executeAction (command.eventId, command.actionDescriptor, dialogMode);
        }
    }
    jamActions.setCommandHandler (executeCommand);
    jamActions.traverseAction (fileData.actionSet, "Cross Process 2");
}
Parameters:
{Object} actionSet
Action set data structure in literal object format
{String|Number} actionLocator
Action locator: action name or action index (0-based)
{Number} fromCommandIndex Optional
Index (0-based) of command to start from
{Boolean} continuePlay Optional
Continue to play remaining commands after the fromCommandIndex index
See:
jamActions.dataFromActionsFile
jamActions.setCommandHandler

Documentation generated by JsDoc Toolkit 2.4.0 on Wed Oct 12 2016 23:32:44 GMT+0200 (CEST)