Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Open index page numbers in indesing using javascript

Guest
Nov 19, 2014 Nov 19, 2014

Hi Guys,

I am searching code to open page range in InDesign file. Is anybody can share the JS code to open page ranges in ID document CS5.5

See below the screenshot of the entries in the document. Some entries my have single digit after en dash.

index.png

I hope will get this soon with positive response.

Regards,

DanuP

Message was edited by: Danu Prasad

TOPICS
Scripting
1.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Nov 20, 2014 Nov 20, 2014

This forum is not meant as an access hub to ask people write you free custom scripts.

.. But -- fortunately for you, this particular question was interesting enough to spend 5 minutes on. It turned out to be as easy as I initially thought:

app.findGrepPreferences = null;

app.findGrepPreferences.findWhat="\\d+[-~=]\\d+";

r = app.activeDocument.findGrep(true);

while (r.length)

{

    t = r.pop();

    s = t.contents.split(/\D/);

    s[1] = s[0].substr(0,s[0].length-s[1].length)+s[1];

    s[0] |= 0; s

...
Translate
Community Expert ,
Nov 20, 2014 Nov 20, 2014

This forum is not meant as an access hub to ask people write you free custom scripts.

.. But -- fortunately for you, this particular question was interesting enough to spend 5 minutes on. It turned out to be as easy as I initially thought:

app.findGrepPreferences = null;

app.findGrepPreferences.findWhat="\\d+[-~=]\\d+";

r = app.activeDocument.findGrep(true);

while (r.length)

{

    t = r.pop();

    s = t.contents.split(/\D/);

    s[1] = s[0].substr(0,s[0].length-s[1].length)+s[1];

    s[0] |= 0; s[1] |= 0;

    u = s[0];

    while (s[0]++<s[1])

        u+=', '+s[0];

    t.contents = u;

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 20, 2014 Nov 20, 2014

Hi Jongware,

I've not tested your code lines but I suppose you don't take into account the fact that it is an index. So the page numbers should normally contain links to those pages. In your script, it's not the case. Am I right?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 20, 2014 Nov 20, 2014

That's not the OP's question. My script works on the set of numbers shown in the example (labouriously typed in, *sigh*), and it does not matter whether the ranges are page numbers or something else.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 20, 2014 Nov 20, 2014

You're right! It is a way to see the issue! 

However, I'm curious to see Peter Kahrel's view offering folios compacting in one of his scripts!

See:  Update index | Peter Kahrel

… because ultimately, IMHO, the question could be: is it possible to "uncompact"?

friendly, Obi-wan

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 20, 2014 Nov 20, 2014

> IMHO, the question could be: is it possible to "uncompact"?

well, that's what Danu's question was, and that's exactly what Jongware's script does.

Peter

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 20, 2014 Nov 20, 2014

Hi Peter,

Sorry, it's not exactly the answer to my question. What I mean:

If I use your script to "compact" the folios in an index, is there a way to "undo" it and retrieve all index links?

That is: do the opposite of your script! 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 20, 2014 Nov 20, 2014

The opposite of my script is Jongware's script

On Thu, 20 Nov 2014 13:09:40 -0000, Obi-wan Kenobi

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 20, 2014 Nov 20, 2014

Ah, and no, those links won't work any longer. I was never bothered about

those links.

On Thu, 20 Nov 2014 13:09:40 -0000, Obi-wan Kenobi

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 20, 2014 Nov 20, 2014

Peter, Jongware and Danup,

If the index is approached from the right angle [this is, according to me, a pure question of timing in the management of the index generation process!], the compacting folios manipulation is "normally" the end of an index treatment.

So, in this case, it will suffice to regenerate the index! Without any loss. 

[However, I still think that [Javascript] + UI would be THE solution to index global management when the entries are "marked" in ID!]

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Nov 20, 2014 Nov 20, 2014

Hi Jongware,

First, I would like to appreciate you to spend some time and providing me the correct answer. Its really very encouraging to see top participants like you and Peter in my post.

Thanks again for your cooperation.

Regards,

DanuP

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
May 26, 2017 May 26, 2017
LATEST

Hi Jong,

I have 2 questions to you, that would be appreciable.

1. Could you elaborate your code, I am new in scripting, please?

2. Same thing can you reverse to range number again, like 111, 112, 113, 114 to 111-4 or 118, 119, 120, 121 to 118-21?

Regards,

Sumit

-Sumit
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines