4 Replies Latest reply: Aug 10, 2012 5:38 AM by Muppet Mark RSS

    Filter page items by property in Javascript

    johneday Community Member

      What is the Javascript equivalent to this AppleScript?

       

      set xxx to every page item whose note = "John"

       

      After looking at some of the tutorials, I pieced this together. Is there a better way of doing this? With 30,000 path items it took over a minute to execute...

       

      docRef = app.activeDocument;

       

      var pathLength = docRef.pathItems.length;

       

      docRef.pathItems[0].note;

       

      var hitList = []

      for (i = 0; i<pathLength; i++)

       

      {

      if (docRef.pathItems[i].note= "John")

      {

      hitList.push(i)  

      }

      }

       

      alert(hitList.length)