( ′∀`)σ≡σ☆))Д′)レ(゚∀゚;)ヘ=З=З=Зε≡(ノ´_ゝ`)ノ HEX
HEX
Server: Apache/2.4.58 (Ubuntu)
System: Linux mail.thebrand.ai 6.8.0-107-generic #107-Ubuntu SMP PREEMPT_DYNAMIC Fri Mar 13 19:51:50 UTC 2026 x86_64
User: www-data (33)
PHP: 8.3.6
Disabled: NONE
Upload Files
File: /var/www/html/tmpr/../tmpr/..//TheBrandPhotoshopSelect.js
/*///////////////////////////////////////////////////////////////////////////////////
Written by Paul Riggott
Functions by Mike Hale
French translation by Google
////////////////////////////////////////////////////////////////////////////////////*/
#target photoshop
function main(){
var dialog = new Window("dialog");
g = dialog.graphics;
var myBrush = g.newBrush(g.BrushType.SOLID_COLOR, [0.99, 0.99, 0.99, 1]);
g.backgroundColor = myBrush;
dialog.title = dialog.add('statictext',undefined, 'LayerName Find');
var g = dialog.title.graphics;
g.font = ScriptUI.newFont("Georgia","BOLDITALIC",22);
dialog.p1  = dialog.add("panel", undefined, undefined, {borderStyle:"black"});
dialog.p1.grp0 =  dialog.p1.add("group");
dialog.p1.grp0.orientation='row';
dialog.p1.grp0.alignChildren='right';
dialog.p1.grp0.spacing=10;
dialog.p1.grp0.rb1 = dialog.p1.grp0.add('radiobutton',undefined,'Case Sensitive');
dialog.p1.grp0.rb2 = dialog.p1.grp0.add('radiobutton',undefined,'Not Case Sensitive');
dialog.p1.grp0.cb1 = dialog.p1.grp0.add('checkbox',undefined,'Select all occurences');
dialog.p1.grp0.rb1.value=true;
dialog.p1.grp0.cb1.value=true;
dialog.p1.grp1 =  dialog.p1.add("group");
dialog.p1.grp1.orientation='row';
dialog.p1.grp1.alignment='fill';
dialog.p1.grp1.spacing=10;
dialog.p1.grp1.st1 = dialog.p1.grp1.add('statictext',undefined,'Layer Name:');
dialog.p1.grp1.st1.helpTip= 'All layers with the same name will be selected';
dialog.p1.grp1.et1 = dialog.p1.grp1.add('edittext');
dialog.p1.grp1.et1.preferredSize=[300,20];
dialog.p1.grp1.et1.active=true;
dialog.p1.grp2 =  dialog.p1.add("group");
dialog.p1.grp2.orientation='row';
dialog.p1.grp2.spacing=10;
dialog.p1.grp2.bu1 = dialog.p1.grp2.add('button',undefined,'Select');
dialog.p1.grp2.bu1.preferredSize=[190,25];
dialog.p1.grp2.bu2 = dialog.p1.grp2.add('button',undefined,'Cancel');
dialog.p1.grp2.bu2.preferredSize=[190,25];
dialog.p1.grp2.bu1.onClick = function(){
    if(dialog.p1.grp1.et1.text == ''){
        alert('No Layer Name Has Been Entered!');
        dialog.p1.grp1.et1.active=true;
        return;
        }
        dialog.close(1);
        process();
   }
dialog.p1.grp2.bu2.onClick=function(){
        dialog.close(2);
}
dialog.center();
dialog.show();
function process(){

if(dialog.p1.grp0.rb1.value){
var re = new RegExp (dialog.p1.grp1.et1.text.toString());
}else{
    var re = new RegExp ("^"+dialog.p1.grp1.et1.text.toString(),"i");
    }
var matches = collectNamesAM(re);
if(!matches.length){
    alert('Layer \"' + dialog.p1.grp1.et1.text.toString()+ '\" was not found!');
    return;
    }
if(dialog.p1.grp0.cb1.value){
if(activeDocument.layerSets.length > 1){
for(var a in matches){
   makeActiveByIndex(matches[a], false );
    }
}
for( var l = 0; l < matches.length; l++ ){
    if(l == 0) {
        makeActiveByIndex(matches[l], false );
        }else{
            makeActiveByIndex(matches[l], false,true );
            }  
 }
}else{
    if(matches.length == 1) {
        makeActiveByIndex(matches[0], false );
        }else{
 var win2 = new Window("dialog");
g = win2.graphics;
var myBrush = g.newBrush(g.BrushType.SOLID_COLOR, [0.99, 0.99, 0.99, 1]);
g.backgroundColor = myBrush;
win2.title = win2.add('statictext',undefined,'LayerName Find');
var g = win2.title.graphics;
g.font = ScriptUI.newFont("Georgia","BOLDITALIC",22);
win2.p1  = win2.add("panel", undefined, undefined, {borderStyle:"black"});
win2.p1.grp0 =  win2.p1.add("group");
win2.p1.grp0.orientation='row';
win2.p1.grp0.alignChildren='fill';
win2.p1.grp0.spacing=10;
win2.p1.grp0.st1 = win2.p1.grp0.add('statictext',undefined, 'Please select layer');
win2.p1.grp0.st1.graphics.font=ScriptUI.newFont("Georgia","BOLDITALIC",16);
win2.p1.grp0.dd1 = win2.p1.grp0.add('dropdownlist');
for(var a = 1; a< matches.length+1;a++){
    win2.p1.grp0.dd1.add('item', a);
}
win2.p1.grp0.dd1.selection=0;
win2.p1.grp2 =  win2.p1.add("group");
win2.p1.grp2.orientation='row';
win2.p1.grp2.spacing=10;
win2.p1.grp2.bu1 = win2.p1.grp2.add('button',undefined,'Select');
win2.p1.grp2.bu1.preferredSize=[100,25];
win2.p1.grp2.bu2 = win2.p1.grp2.add('button',undefined,'Cancel');
win2.p1.grp2.bu2.preferredSize=[100,25];
win2.p1.grp2.bu2.onClick=function(){
        win2.close(2);
}
win2.p1.grp2.bu1.onClick=function(){
    win2.close(1);
makeActiveByIndex(matches[Number(win2.p1.grp0.dd1.selection.index)], false );
}
win2.center();
win2.show();
}
    }
    }

function collectNamesAM(re){
     var allLayers = new Array();
   var startLoop = Number( !hasBackground() );
   var endLoop = getNumberOfLayer(); 
   for( var l = startLoop;l < endLoop; l++){
        while( !isValidActiveLayer( l ) ) {
            l++;
        }
        if( getLayerNameByIndex( l ).match(re) != null){
            if(getLayerNameByIndex( l ).length == dialog.p1.grp1.et1.text.toString().length){
            allLayers.push( l );
            }
        }
    }
     return allLayers;
};
}
function getActiveLayerIndex() {
     var ref = new ActionReference();
     ref.putProperty( 1349677170 , 1232366921 );
     ref.putEnumerated( 1283027488, 1332896878, 1416783732 );
     var res = executeActionGet(ref).getInteger( 1232366921 ) - Number( hasBackground() );
     res == 4 ? res++:res;
     return res;   
}
function isValidActiveLayer( idx ) {
     var propName = stringIDToTypeID( 'layerSection' );
     var ref = new ActionReference(); 
     ref.putProperty( 1349677170 , propName);
     ref.putIndex( 1283027488, idx );
     var desc =  executeActionGet( ref );
     var type = desc.getEnumerationValue( propName );
     var res = typeIDToStringID( type ); 
     return res == 'layerSectionEnd' ? false:true;
};
function hasBackground(){
    var res = undefined;
    try{
        var ref = new ActionReference();
        ref.putProperty( 1349677170 , 1315774496); 
        ref.putIndex( 1283027488, 0 );
        executeActionGet(ref).getString(1315774496 );
        res = true;
    }catch(e){ res = false}
    return res;
};
function makeActiveByIndex( idx, forceVisible,add ){
    add == undefined ? add = false : add = true
     try{
          var desc = new ActionDescriptor();
          var ref = new ActionReference();
          ref.putIndex(charIDToTypeID( "Lyr " ), idx)
          desc.putReference( charIDToTypeID( "null" ), ref );
          if(add) desc.putEnumerated( stringIDToTypeID( "selectionModifier" ), stringIDToTypeID( "selectionModifierType" ), stringIDToTypeID( "addToSelection" ) );
          desc.putBoolean( charIDToTypeID( "MkVs" ), forceVisible );
          executeAction( charIDToTypeID( "slct" ), desc, DialogModes.NO );
     }catch(e){ return -1;}
};
function getNumberOfLayer(){ 
var ref = new ActionReference(); 
ref.putEnumerated( charIDToTypeID("Dcmn"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") ); 
var desc = executeActionGet(ref); 
var numberOfLayer = desc.getInteger(charIDToTypeID("NmbL")); 
return numberOfLayer; 
};
function getLayerNameByIndex( idx ) { 
    var ref = new ActionReference(); 
    ref.putProperty( charIDToTypeID("Prpr") , charIDToTypeID( "Nm  " )); 
    ref.putIndex( charIDToTypeID( "Lyr " ), idx );
    return executeActionGet(ref).getString(charIDToTypeID( "Nm  " ));; 
};

main()