Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

IdExtenso Test Scripts

Samples, Snippets, and HowTos

Notice: The /tests subdirectory is not part of IdExtenso's core distribution. It provides basic examples and case studies for newcomers to get started with the framework.

Getting Started

From this location, any .jsx script can include the core framework using:

#include '../$$.jsxinc'

Extra modules (which always belong to /etc) are selectively added using:

#include '../etc/<ModuleName>.jsxlib'

⚠️ Important: Core framework must be included before any extra modules.


Quick Navigation

Table of Contents

Script Description Key Features
AppToJson Stringify app.properties JSON handling, file operations
BasicScriptDemo PathNodes script demo UI, localization, settings
BasicScriptMenuDemo Menu-enabled PathNodes Menu extension, persistence
ByteStreamDemo ByteStream class usage Binary data handling
CheckIEEE754 IEEE754 number validation Number conversion, benchmarks
CollatorTester Collator module testing Text collation, multilingual
DomTextParcelsTest TextParcels class demo DOM manipulation, progress bars
EnvSummary Environment reporting System info, context detection
GetWebImage Web image download HTTP requests, ScriptUI
GetWebText Web text download HTTP/HTTPS, text processing
InstantDialog DOM dialog creation XML dialogs, localization
LevenFilterList Dynamic list filtering String algorithms, UI events
MarkovShuffle Text scrambling Markov chains, randomization
MenuAccess Menu component access DOM navigation, menu paths
MenuCamelCase Custom menu action Menu installation, event handling
PageRangeTester Page range parsing Range validation, formatting
ParseIntFix parseInt bug fixes ExtendScript patches
PlaceWebImage Web image placement HTTP, file handling, DOM
PlayWithBigInt Arbitrary precision math BigInt operations, algorithms
PlayWithUnit Unit conversion Measurement units, i18n
RectPackTest Rectangle packing Layout algorithms, geometry
RegexFromCodeRanges Unicode regex building Character ranges, regex patterns
ScriptUIBuilder UI construction Component factories, widgets
ScriptUIColorTester UI color testing Color management, themes
ShowEnvironment Environment display System diagnostics
ShowHelp API documentation Module introspection
SuiFactories ScriptUI components Custom widgets, factories
UnicodeToAscii Text transliteration Unicode conversion
UseJsxBlindLib Script obfuscation Binary scrambling
YaltIsGreat Localization demo Multi-language support
ZDeflate_ZInflate_Test Zip/unzip checker Data compression, validation

Detailed Script Reference

AppToJson

AppToJson.jsx

Stringify the entire contents of app.properties.

Demonstrates:

  • $$.JSON.lave() routine (just calling $$.JSON(), as this is the auto method)
  • Some nice options behind it (verbose vs. compact format…)
  • $$.File.temp() to output the result in a temp file (and open it)

BasicScriptDemo

BasicScriptDemo.jsx

Manage a complete InDesign script (PathNodes) that creates custom circles at each path point of target item(s).

BasicScriptDemo screenshot

Demonstrates:

  • Usage of BasicScript module (settings, localization, UI)
  • Providing a Yalt package in four languages (EN + FR DE ES)
  • Settings keys with various lifespans (RESET, SESSION, APP)

BasicScriptMenuDemo

BasicScriptMenuDemo.jsx

With just a few additional lines, the previous script "PathNodes" is extended into a BasicScriptMenu, that is, a BasicScript component with a MenuExtension.

BasicScriptMenuDemo anim

Demonstrates:

  • Usage of BasicScriptMenu module (settings, localization, UI + MenuExtension)
  • Providing a Yalt package in four languages (EN + FR DE ES)
  • Settings keys with various lifespans (RESET, SESSION, APP)

ByteStreamDemo

ByteStreamDemo.jsx

Getting started with the $$.ByteStream class.

Demonstrates:

  • ByteStream constructor (both modes)
  • I/O methods and various tests with number and string tags

CheckIEEE754

CheckIEEE754.jsx

Perform tests on Number.fromIEEE754() and Number.prototype.toIEEE754() functions. This script generates 10,000 random numbers in IEEE754 64bit format and check whether the dedicated routines properly handle them. We used it to benchmark and validate the implementation of fromIEEE754() and toIEEE754(). Cool thing is, the script double-checks each conversion throughout the TransformationMatrix object, which provides a hidden way to encode a Number instance into IEEE754 form. See the code for details.

CheckIEEE754 results

Demonstrates:

  • Using Number.fromIEEE754(hex) and Number.prototype.toIEEE754()
  • Getting IEEE754 representation from TransformationMatrix's name property (personal hack)
  • Using the Random class to generate random numbers

CollatorTester

CollatorTester.jsx

Experiment IdExtenso's Collator module in various languages.

CollatorTester screenshot

Demonstrates:

  • Using the Collator module
  • Adding a custom YALT package (EN + FR DE ES IT RU)
  • Simple modal dialog interface generated by ScriptUI.builder

DomTextParcelsTest

DomTextParcelsTest.jsx

Lifts the veil on the intimidating $$.Dom.TextParcels class.

Demonstrates:

  • Calling the error() function
  • Using a simple progress bar (via $$.Progress)
  • Creating a TextParcels (in short TP) instance with default options
  • Running TP.consolidate(), then TP.getSamples() handled by a custom function
  • Using the Log to collect data (Log.push)

EnvSummary

EnvSummary.jsx vs. EnvSummary.bin.jsx

Report scripting context from the Env module.

Demonstrates:

  • Usage of $$.Env.domVersion(), alias: $$.domVersion()
  • Usage of $$.Env.summary(), alias: $$.Env()
  • Main script and Running code status (JSX vs. JSXBIN), see EnvSummary.bin.jsx for additional information
  • Log in TRACE mode

GetWebImage

GetWebImage.jsx

Download a PNG through http and load it in a ScriptUI dialog.
The user can now click the image to open the URL in the navigator!

GetWebImage animation

Demonstrates:

  • $$.Web(url), shortcut of $$.Web.get(url)
  • Using toSource() with binary strings is more compact w/ IdExtenso
  • Tracing steps thru $$.trace(), and more details on Log levels
  • [190322] Use ScriptUI.builder(); call $$.Web.browse() on click

GetWebText

GetWebText.jsx

Download a text through http(s). Result is shown either in the active selection (if any) or in trace console.

Demonstrates:

  • $$.Web(url, 1) with wantText option turned on

InstantDialog

InstantDialog.jsx

InDesign DOM dialog fast, easy, and with automatic localization.

InstantDialog screenshot

Demonstrates:

  • Usage of $$.Dom.Dialog.fromXML()
  • Displaying the dialog and having strings localized through Yalt
  • Access to UI values using Dialog.setValueKey() and Dialog.getValueKey() (augmented prototype)
  • Using $$.isBooting() to prepend persistent data (makes sense when a #targetengine directive is in use)

LevenFilterList

LevenFilterList.jsx

Dynamic listbox filter based on Levenshteim distance.

LevenFilterList animation

Demonstrates:

  • Using String.levenFilter()
  • Using ScriptUI.builder() with event handlers

MarkovShuffle

MarkovShuffle.jsx

Text scrambler based on Markov chains.

Demonstrates:

  • Using the Markov module for the purpose of scrambling texts in InDesign
  • Including the Random module (to improve random functions)

📖 Cf. Full article and demo


MenuAccess

MenuAccess.jsx

Accessing existing menu components (menus, submenus, or menuitems).

Demonstrates:

  • Testing the Dom.Menu.get() routine on various paths like [ 0, '', '$ID/EditMenu_FindChange' ], [ '$ID/Main', 0, '$ID/Open...' ], etc.

MenuCamelCase

MenuCamelCase.jsx

Full example of installing a custom "Change Case > CamelCase" menu action.

MenuCamelCase animation

Demonstrates:

  • Using advanced Dom.Menu features
  • Dealing with engine-persistent script and processing DOM events accordingly via $$.globalEvent()
  • Declaring a custom module using the eval(__(MODULE, $$, ...)) macro-syntax

PageRangeTester

PageRangeTester.jsx

Parse, format and normalize page ranges.

PageRangeTester demo

Demonstrates:

  • Inclusion and usage of $$.PageRange
  • Simple modal dialog interface generated by ScriptUI.builder

ParseIntFix

ParseIntFix.jsx

Run some tests on $.global.parseInt once patched by IdExtenso. (More detail here.)

ParseIntFix screenshot

Demonstrates:

  • Fixing a native ExtendScript bug in the [[global]] scope
  • Using $$.trace

PlaceWebImage

PlaceWebImage.jsx

Download an image through http and place it in the active spread. (This script is a variant of GetWebImage.)

Demonstrates:

  • $$.Web(url), shortcut of $$.Web.get(url)
  • Using $$.Web.parseURI to identify the parts of an URL
  • Using $$.File.temp to create a temporary file

PlayWithBigInt

PlayWithBigInt.jsx

Compute (arbitrary-precision) big integers using the BigInt module.

Demonstrates:

  • Including an optional module (from /etc)
  • Various ways of declaring BigInt instances
  • Using operators: ==, <, <=, +, -, *, /, %, <<, >>, ~, &, |, ^
  • Divide-and-Remainder method, primality
  • Finding a huge prime number

PlayWithUnit

PlayWithUnit.jsx

Use a consistent facade for handling metrical units.

PlayWithUnit dialog

Demonstrates:

  • Optional module inclusion
  • Usage of $$.Dom.Dialog()
  • Basic internationalization (decimal point, etc.)
  • Experimenting the Unit API: info(), parse(), convertNumber(), format()

RectPackTest

RectPackTest.jsx

Simple rectangle packing (without rotation) on the active spread. (Undoable.)

RectPackTest Before/After

Demonstrates:

  • Using the RectPack module (etc branch)
  • Invoking the error() function

RegexFromCodeRanges

RegexFromCodeRanges.jsx

A useful static routine available in the RegExp object.

Demonstrates:

  • Converting a set of code ranges into a RegExp pattern
  • Limitations (surrogate pairs must be consistent, i.e share the same base)
  • Producing a regex that captures misc. symbols and pictographs (from U+1F300 to U+1F5FF)

ScriptUIBuilder

ScriptUIBuilder.jsx

Build a powerful ScriptUI interface with no effort.

ScriptUIBuilder demo

Demonstrates:

  • Using the static ScriptUI.builder() function
  • Example of a 'resource object' with various widgets
  • Implementing a custom component thru a 'factory'

ScriptUIColorTester

ScriptUIColorTester.jsx

Test the ScriptUI/colors snippet.

ScriptUIColorTester demo

Demonstrates:

  • Creation of random background colors
  • Color assignment via 0xRRGGBB (hex) or X|Y descriptors (normal and disabled state)
  • Retrieving a color descriptor from ScriptUI.colorGetter
  • Usage of ScriptUI.builder() with color keys

ShowEnvironment

ShowEnvironment.jsx

Simply displays the $$.Env.summary() string in a box. This (minimal) test script can be executed in various locales, versions, systems and contexts to illustrate the many informations the $$.Env module can handle.

Platform Examples:

Example 1: The script is in JSXBIN form and executed in macOS 10.13 / InDesign CC 15.1 (dark UI) for the 4th time (run #4) in the 'main' engine (non-persistent). DOM version in-sync with InDesign version (15.1), user is admin, locale is FRENCH/fr_FR:

MacOS screenshot

Example 2: The script is in regular JSX form and executed in Windows 10/64 from InDesign CC 16.1 (dark UI) for the 1st time (run #1) in a persistent ('myScript') engine. Furthermore, it is executed as a startup script now (feature available from IdExtenso 2.10403). DOM version in-sync with InDesign version (15.1), user is Moi, locale is ENGLISH/en_US:

Windows screenshot

Demonstrates:

  • $$.Env() — alias of $$.Env.summary()

ShowHelp

ShowHelp.jsx

Get help on core and included modules.

ShowHelp screenshot

Demonstrates:

  • $$.help(); this method scans all present modules and displays the resulting API in a modal dialog

SuiFactories

ScriptUI Component Factory Demos

This subfolder provides basic demo scripts showing the behaviors and features of custom ScriptUI components available in etc/ScriptUI/factories:

Check Components

Color & Input Components

Interactive Components


UnicodeToAscii

UnicodeToAscii.jsx

Basic Unicode-to-ASCII transliteration.

Demonstrates:

  • Including and using the $$.UniAsc module
  • Live-testing the translit() method from a ScriptUI dialog made up from ScriptUI.builder()

UseJsxBlindLib

UseJsxBlindLib.jsx

Scramble a jsxbin file choosen by the user.

Demonstrates:

  • Including and invoking the new JsxBlindLib library from any script project

YaltIsGreat

YaltIsGreat.jsx

Basic features of the localization module (Yalt).

Demonstrates:

  • Including an optional module (from /etc)
  • Adding a localization package of your own
  • Using the __() function with a Yalt string
  • Activating another locale
  • Inserting a placeholder in a translation string

ZDeflate_ZInflate_Test

ZDeflate_ZInflate_Test.jsx

Quick test of the compression and decompression modules (ZDeflate and ZInflate).

Demonstrates:

  • Including compression modules from /etc (ZDeflate and ZInflate)
  • Testing zip() and unZip() on either a long byte string or a File
  • Data validation: check that the final uncompressed stream is strictly equal to the input
  • Timing measurements for each test case (internal methods vs. external InDesign packager/unpackager.)
  • Pushing messages in the Log system, error handling, etc.

Getting Started Guide

  1. Choose a script from the table above based on your needs
  2. Navigate directly using the anchor links
  3. Read the description and examine the demonstrations
  4. Run the script in Adobe InDesign to see it in action
  5. Study the code to understand the implementation

Tip: Start with simpler scripts like AppToJson or ShowEnvironment before moving to complex ones like MenuCamelCase or ZDeflate_ZInflate_Test.


Happy scripting with IdExtenso!