Copy link to clipboard
Copied
So I have a UI with a button that when clicked it skips to the next folder. This works if you have consecutive folder numbers but sometimes the numbers are not consecutive. I need a way to select whatever is next. I will give you a snippet of what i am currently doing.
mySkipGroup.addBtn.onClick = function(){
myPgLoc=app.document.presentationPath.slice(0,-3);
myPgNum=app.document.presentationPath.slice(-3);
myPgNum=Number (myPgNum)+1;
myPgNum = myPgNum.toString();
if (myPgNum.length==3){
myPgNum=myPgNum;
}
if (myPgNum.length==2){
myPgNum=("0"+myPgNum);
}
if(myPgNum.length==1){
myPgNum=("00"+myPgNum);
}
if(pgInput.text!=""){
pgtoSkip=pgInput.text;
if (pgtoSkip.length==3){
pgtoSkip=pgtoSkip;
}
if (pgtoSkip.length==2){
pgtoSkip=("0"+pgtoSkip);
}
if(pgtoSkip.length==1){
pgtoSkip=("00"+pgtoSkip);
}
//alert(myPgLoc+pgtoSkip);
app.document.setPresentationMode("browser",myPgLoc+pgtoSkip);
}
else{
app.document.setPresentationMode("browser",myPgLoc+myPgNum);
}
}
the presentation Mode is looking for an exact location.
...mySkipGroup.addBtn.onClick = function(){
myPgLoc=app.document.presentationPath.slice(0,-3);
myPgNum=app.document.presentationPath.slice(-3);
myPgNum=Number (myPgNum)+1;
myPgNum = myPgNum.toString();
pgLocIndex=myPgLoc.slice(0,-14);
direct=myPgLoc.slice(0,-50);
folderIndx=new Folder([pgLocIndex]);
folderIndx=folderIndx.getFiles();
for (i=0; i<folderIndx.length; i++){
var myF = folderIndx;
if(app.document.presentationPath.match (myF)){
myPgN
Copy link to clipboard
Copied
mySkipGroup.addBtn.onClick = function(){
myPgLoc=app.document.presentationPath.slice(0,-3);
myPgNum=app.document.presentationPath.slice(-3);
myPgNum=Number (myPgNum)+1;
myPgNum = myPgNum.toString();
pgLocIndex=myPgLoc.slice(0,-14);
direct=myPgLoc.slice(0,-50);
folderIndx=new Folder([pgLocIndex]);
folderIndx=folderIndx.getFiles();
for (i=0; i<folderIndx.length; i++){
var myF = folderIndx;
if(app.document.presentationPath.match (myF)){
myPgNum=folderIndx[++i];
myPgNum2=myPgNum.toString();
break;}
}
if(pgInput.text!=""){
pgtoSkip=pgInput.text;
if (pgtoSkip.length==3){
pgtoSkip=pgtoSkip;
}
if (pgtoSkip.length==2){
pgtoSkip=("0"+pgtoSkip);
}
if(pgtoSkip.length==1){
pgtoSkip=("00"+pgtoSkip);
}
app.document.setPresentationMode("browser",myPgLoc+pgtoSkip);
}
else{
//alert(direct+myPgNum2);
app.document.setPresentationMode("browser",direct+myPgNum2);
}
}
This is the solution that I came up with to my problem. I created an array of items from the folder then use the path from the next in the array. So if the next folder is 0000-4 or 0000-12 it goes to the next folder whether its 12 or 14 it goes to next.