Skip to content

Instantly share code, notes, and snippets.

// text frame selected:
var frame = app.selection[0];
var gap = frame.parentPage.bounds[2] - frame.parentPage.marginPreferences.bottom - frame.lines[-1].baseline;
if ( app.documents.length > 0 ) {
if ( app.scriptPreferences.version >= 6 ) {
app.doScript( main, ScriptLanguage.JAVASCRIPT , [], UndoModes.ENTIRE_SCRIPT, "Search in masterpages" );
}
else {
main();
}
} else {
alert ( "No documents open!" );
}
if ( app.documents.length > 0 ) {
if ( app.scriptPreferences.version >= 6 ) {
app.doScript( main, ScriptLanguage.JAVASCRIPT , [], UndoModes.ENTIRE_SCRIPT, "Search in masterpages" );
}
else {
main();
}
} else {
alert ( "No documents open!" );
}
if ( app.documents.length > 0 ) {
if ( app.scriptPreferences.version >= 6 ) {
app.doScript( main, ScriptLanguage.JAVASCRIPT , [], UndoModes.ENTIRE_SCRIPT, "Search in masterpages" );
}
else {
main();
}
} else {
alert ( "No documents open!" );
}
function addTextToPara(pStyleName, prefixText)
{
app.findGrepPreferences.appliedParagraphStyle = pStyleName
var paraList = app.activeDocument.findGrep()
for(var i = 0 ; i < paraList.length; i++)
{
paraList[i].contents = prefixText + paraList[i].contents
}
app.findGrepPreferences = NothingEnum.nothing;
}
Минимальное
Array.prototype.min = function(){
var min = parseInt(this[this.length-1]), el;
for(var i=this.length-2; i>=0; i--){
el = parseInt(this[i]);
if(el<min){
min = el;
}
}
var aDoc = app.activeDocument;
var showLayers = function ( layers )
{
var i = layers.length, layer;
while ( i-- )
{
layer = layers[i];
layer.visible = true;
layer.layers.length && showLayers ( layer.layers );
}
#target "Indesign"
main();
function main(){
if (app.activeDocument.selection.length){
var mySel = app.activeDocument.selection;
var l = mySel.length;
for (var i = 0; i < l; i++) {
customAlert('Hello', 3, 'This is a test - Will close in 3 seconds')
customAlert('Hello', 0, 'This is a test - Will not close automatically')
function customAlert(message, delaySeconds, title){
title = title || 'Alert';
var alertWindow = new Window('palette', title);
var control_text = alertWindow.add('edittext', [0, 0, 500, 200], message, {multiline: true});
if(delaySeconds == 0){
var control_close = alertWindow.add('button', undefined, 'Close');