In a previous question I asked for a list (https://forums.adobe.com/thread/146710) which "jump_over" solved fantastically.
As so often, once it works people start complaining.
I made the script work with 150 names in it, listed surname name (which is how they have to appear in the text), but with the names are sorted alphabetically on the Name (the list comes from IT dep).
Question: is it possible to get the list in the panel in the alphabetical order sorted on the Name (Name Surname), but when placed the name and surname should reversed.
Below the script. When run, you get a panel with all the names, double click inserts the selection at the cursor point.
Inverting "Name Surname" doesn't do the trick, because in mTitles the order would be oke but the insertion is not oke. I've a script that reverses two words, but sometimes names have more than two words in them (ex John Mac Doe).
Thanks already for looking into it.
- #target indesign
- #targetengine mDialog
- var
- mTitles = ["Surname1 Name1","Surname2 Name2","Surname3 Name3"],
- w = new Window ("palette","Title multiselector", undefined);
- w.alignChildren = "left";
- w.add("staticText", undefined, "Doubleclick to choose and add. \r'Delete' button removes last added", {align:"left",multiline: true,closeButton: false});
- var
- body = w.add("group"),
- mList = body.add("listbox",undefined,mTitles,{scrollbar: true}),
- mButt = body.add("group");
- mButt.orientation = "column";
- mButt.alignment = "bottom";
- mButt.add("button", undefined, "Delete last");
- mButt.add("button", undefined, "Finish");
- mList.preferredSize = [200,150];
- mList.onDoubleClick = function() {
- app.selection[0].contents = mList.selection.text + "\r";
- }
- mButt.children[1].onClick = function() {
- w.close();
- }
- mButt.children[0].onClick = function() {
- app.selection[0].parentStory.lines[-1].remove();
- }
- if (app.selection[0].constructor.name == "InsertionPoint") w.show();
- else {
- alert("Make a cursor active inside desired text box"); exit();
- }