Skip to content

Instantly share code, notes, and snippets.

@octavian-nita
Created January 5, 2018 14:47
Show Gist options
  • Save octavian-nita/c97572102dc571bd480a7eabb1bfd2cc to your computer and use it in GitHub Desktop.
Save octavian-nita/c97572102dc571bd480a7eabb1bfd2cc to your computer and use it in GitHub Desktop.
ExtendScript Toolkit / utilities
/* globals $, app, BridgeTalk */
// Adobe Bridge et al. automation scripts
//
// ## (Adobe scripting-related) Resources
//
// * https://openclassrooms.com/courses/ecrivez-des-scripts-en-extendscript
// * https://github.com/yearbook/extendscript-api-documentation -> http://yearbook.github.io/esdocs/
// * https://github.com/ExtendScript/wiki/wiki
// * https://github.com/fabiantheblind/extendscript-101
// * https://github.com/bastienEichenberger/extendscript-library
// * http://jongware.mit.edu/
// * http://morris-photographics.com/photoshop/tutorials/scripting1.html
// * http://morris-photographics.com/photoshop/tutorials/scripting2.html
// * http://morris-photographics.com/photoshop/tutorials/actions.html
// * http://morris-photographics.com/photoshop/scripts/
// * http://www.kahrel.plus.com/indesignscripts.html
/**
* @module EstkUtil
*/
var EstkUtil;
(function (EstkUtil) {
'use strict';
function clc() {
if (app.name === 'ExtendScript Toolkit') {
return app.clc();
}
var estk = BridgeTalk.getSpecifier('estoolkit');
if (estk) {
var bt = new BridgeTalk();
bt.target = estk;
bt.body = 'app.clc()';
bt.send();
}
}
EstkUtil.clc = clc;
function ferr(e) {
if (!e) {
return 'An error has occurred!';
}
var
mess = e.number ? 'E#' + e.number : '',
part = e.fileName || '';
if (e.line) {
part += '@' + e.line;
}
if (part) {
mess += ' (' + part + ')';
}
return (mess ? mess + ' ' : '') + (e.message || e);
}
EstkUtil.ferr = ferr;
function ln() {
var args = Array.prototype.slice.call(arguments);
args.unshift({
sep: '\r'
});
p.apply(null, args);
}
EstkUtil.ln = ln;
function p(opts /*, ...*/ ) {
var sep, args;
if (opts && isObject(opts)) {
sep = opts.separator || opts.sep || ' ';
args = Array.prototype.slice.call(arguments, 1);
} else {
sep = ' ';
args = Array.prototype.slice.call(arguments);
}
$.writeln(args ? args.join(sep) : '');
}
EstkUtil.p = p;
function isObject(val) {
return val === null ? false : (typeof val === 'object') || (typeof val === 'function');
}
EstkUtil.isObject = isObject;
}(EstkUtil || (EstkUtil = {})));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment