12 Replies Latest reply: Mar 1, 2012 12:24 PM by Philippe Ruelle RSS

    [JS] Move Footnotes

    Philippe Ruelle Community Member


      Hello,
      How to move the call to a footnote on page in the text without losing the enhancements?
      thank you

       

      translation

       

      Bonjour,

      Comment déplacer l'appel d'une note de bas de page dans le texte sans perdre les enrichissements ?

      Merci

        • 1. Re: [JS] Move Footnotes
          pkahrel Community Member

          Footnotes have a property storyOffset, which gives you the position of a note marker within a note's parent story. Use the move() method to move the footnote somewhere else (in the example below, to the end of the story):

           

          myStory = app.documents[0].stories[0];

          myFn = myStory.footnotes[0];

           

          myStory.characters[myFn.storyOffset.index].move(LocationOptions.after, myStory.characters[-1]);

           

          Peter

          • 2. Re: [JS] Move Footnotes
            Philippe Ruelle Community Member
            thank you Peter
            this code gives me the error code:
            "Invalid Item"

            thank you

            I test to see the problem.

             

             

            Merci

            ce code me donne le code erreur :

            "Objet non valide"

             

            merci

             

            je test pour voir le problème.

            • 3. Re: [JS] Move Footnotes
              Philippe Ruelle Community Member

              Thank you, here is what I wanted to get my notes move footer.

               

              Merci, voici à quoi je voulais arriver déplacer mes notes de bas de page.

               

              #target indesign

              var myStory = app.selection[0].parent;

              var mesNotes = myStory.footnotes;

              for (i=0; i< mesNotes.length-1; i++) {

                  myStory.characters[mesNotes[i].storyOffset.index].move(LocationOptions.after, mesNotes[i+1].storyOffset);

              }

              • 4. Re: [JS] Move Footnotes
                [Ariel] Community Member

                myFootnoteMarker.move(LocationOptions.BEFORE, anotherCharacter);

                 

                myFootnoteMarker is a character -- the footnote marker that you want to

                move.

                 

                Check out LocationOptions to see what your other options are.

                 

                anotherCharacter is where you want to move it to -- could also be an

                insertionPoint etc.

                 

                Could be that I've got the order of the parameters the wrong way round

                or that there are other params as well (i.e. first anotherCharacter then

                LocationOptions) -- check it out in the help.

                 

                HTH,

                Arie

                • 5. Re: [JS] Move Footnotes
                  pkahrel Community Member

                  Philippe,

                   

                  Your 'undefined' error is probably caused by overrunning the footnote collection. At the last iteration of the for-loop, mesNotes[i+1] is a non-existent note. To avoid that, use this

                   

                  for (i=0; i< mesNotes.length-1; i++)

                   

                  Another thing is: what are you trying to do? It seems to me that all that your code does is to move the first footnote.

                   

                  Peter

                  • 6. Re: [JS] Move Footnotes
                    Philippe Ruelle Community Member

                    Thank you Peter,

                    The error was a poor selection of the block ... but actually there is a problem with the last note

                    To import a word file, the contents of notes (1,500 notes) are shifted.

                     

                    Merci Peter,

                     

                    L’erreur était une mauvaise sélection du bloc … mais effectivement il y a un problème avec la dernière Note

                     

                    À l'importation d'un doc word, le contenu des notes (1500 note) ce sont décalé.

                    • 7. Re: [JS] Move Footnotes
                      pkahrel Community Member

                      Philippe,

                       

                      You still haven't told uis what you want to do. Where do you want to move the notes to?

                       

                      By the way, it is rarely necessary to select anything in a script. If you're selecting all notes in a story, then simply target that story.

                       

                      Peter

                      • 8. Re: [JS] Move Footnotes
                        Philippe Ruelle Community Member

                        Peter,

                         

                        "You still haven't told uis what you want to do. Where do you want to move the notes to?"

                        The content of the notes that are offbeat, such as the text of footnote 2 is found in Note 1, Note 3 of the in Note 2 etc ...

                         

                        "By the way, it is rarely necessary to select anything in a script. If you're selecting all notes in a story, then simply target that story."

                        Exact, I have not always good reflex ... but I'm learning

                         

                        thank you

                         

                        I use Google to translate my french!

                        • 9. Re: [JS] Move Footnotes
                          pkahrel Community Member

                          Ah. You don't want to move note markers, but the note text from onr note to the next. That would be something like this:

                           

                          meNotes[i].texts[0].move (LocationOptions.after, mesNotes[i+1].insertionPoints[0]);

                           

                          but you must make sure that you work in the correct direction. You should probable do it the other way around:

                           

                          meNotes[i].texts[0].move (LocationOptions.after, mesNotes[i-1].insertionPoints[0]);

                           

                          Peter

                          • 10. Re: [JS] Move Footnotes
                            [Jongware] Community Member

                            No, that would paste the text at the end of the previous note!

                             

                            FIRST you need to add an empty note at the end, THEN loop back from last-but-one note to the first, moving each note's contents to the next one.

                            • 11. Re: [JS] Move Footnotes
                              pkahrel Community Member

                              Good idea!

                              • 12. Re: [JS] Move Footnotes
                                Philippe Ruelle Community Member
                                If my case, the version of the script very well to hand over notes (1500) to their seats, Super

                                 

                                #target indesign
                                var myStory =  app.selection[0].parent;
                                var mesNotes = myStory.footnotes;
                                     for (i=1; i< mesNotes.length-1; i++) {   
                                          myStory.characters[mesNotes[i].storyOffset.index].move(LocationOptions.after, mesNotes[i+1].storyOffset); 
                                          //mesNotes[i].texts[0].move (LocationOptions.after, mesNotes[i-1].insertionPoints[0]);
                                     }
                                again thank you