Page 1 of 1

folder location button for JavaScript/stamps etc. [suggestion]

Posted: Mon Mar 11, 2024 8:13 pm
by MedBooster
viewtopic.php?p=177071#p177071''
image.png

could you please add a button under this part of the preferences that would open the javascript folder in the Windows file explorer program?

Re: javascript folder location button [suggestion]

Posted: Mon Mar 11, 2024 8:44 pm
by Daniel - PDF-XChange
Hello, MedBooster

As I mention in that other thread, the JS folder does not exist by default, and they are two different locations, so making a link to open these would not likely be added, but I will bring the idea to the Dev team for consideration.

Kind regards,

Re: javascript folder location button [suggestion]

Posted: Mon Mar 11, 2024 10:50 pm
by Mathew
This script may help. Most of the code is just to make the dialog. You'll get a security warning if you want it to open the folder.
Run it in the JavaScript console:

Code: Select all

{
// dialog data
const dialog = {
	data:[],
	initialize: function (dialog) {
		let dLoad = {};
		// add the paths to the dialog
		dLoad["apth"] = this.data[0];
		dLoad["upth"] = this.data[1];			
		dialog.load( dLoad );
	},
	commit:function (dialog) { // called when OK pressed
		console.println( this.data.join("\n") );
	},
	aLch:function (dialog) {
		this.pFolder(this.data[0]);
	},
	uLch:function (dialog) {
		this.pFolder(this.data[1]);
	},
	pFolder:function (url) {
		app.launchURL( url.replace(/[\/\\][^\/\\]+$/,"") ); 
	},
	description: {
		name: "Javascript Folder Locations", // Dialog box title
		elements:
		[{	type: "static_text",
			name: "If these folders do not exist, create a 'JavaScripts' folder in this location.",
			width: 500,
			bold: true
		},
		{	type: "cluster",
			name: "App folder",
			align_children: "align_left",
			elements:
			[{	type: "edit_text",
				name: "App Folder",
				alignment: "align_fill",
				item_id:"apth"
			},
			{	type: "button",
				name: "Open Containing Folder",
				item_id:"aLch"
			}]
		},
		{	type: "cluster",
			name: "User folder",
			align_children: "align_left",
			elements:
			[{	type: "edit_text",
				name: "User Folder",
				alignment: "align_fill",
				item_id:"upth"
			},
			{	type: "button",
				name: "Open Containing Folder",
				item_id:"uLch"
			}]
		},			
		{	type: "ok",
			alignment: "align_right",
			ok_name: "Done",
		}]
	}
}
// get both paths
let jPaths = ["app","user"].map( j => app.getPath(j,"javascript") );
// change url to windows path
if ("WIN" == app.platform ) {
	jPaths = jPaths.map( j => j.replace(/\//g,'\\').replace(/^(\\[A-Z]+)/,"$1:") );
}
dialog.data = jPaths;
app.execDialog(dialog);
}

Re: javascript folder location button [suggestion]

Posted: Mon Mar 11, 2024 10:54 pm
by Mathew
... and I agree: It would be nice to have something like this as part of the preferences.

Re: javascript folder location button [suggestion]

Posted: Mon Mar 11, 2024 11:32 pm
by Daniel - PDF-XChange
Hello again!

The dev team liked the idea, and after a little back and forth, we have made this ticket for you:

RT#6819: FR: Add "open JS folder" to JS console toolbar

Kind regards,

Re: javascript folder location button [suggestion]

Posted: Sun Dec 01, 2024 11:23 am
by MedBooster
hmhm has this been implemented yet, or did you put the button somewhere else than under preferences?

PS: this request about folder location button would pretty much apply to all tools that have a specific folder

e.g. I would also insist on having a button like this for
1) Text to speech
2) Stamps ( %appdata%\Tracker Software\PDFXEditor\3.0\Stamps)

Re: javascript folder location button [suggestion]

Posted: Sun Dec 01, 2024 2:02 pm
by rakunavi
Hello MedBooster,
MedBooster wrote: Sun Dec 01, 2024 11:23 am hmhm has this been implemented yet, or did you put the button somewhere else than under preferences?
Since build 386, it has been added to the JavaScript console toolbar as "App-Level Scripts..." command (ID: cmd.jsConsole.openFolder), exactly where the title of the ticket says it should be.

  • figure1.png

    figure2.png
Best regards,
rakunavi

folder location button for JavaScript/stamps etc. [suggestion]

Posted: Mon Dec 02, 2024 10:07 am
by Stefan - PDF-XChange
:)