I'm trying to navigate from my bookmark listener to the root node and
collect all of the folder hierarchy, but the bookmarks API uses async
callbacks which is quite difficult to work with.

This code doesn't work because the while loop is stuck in an infinite
loop and the callback does not interupt the loop correctly.  Is there
some other way?

ex:
      function bookmarkFoldersAsTags(bookmark) {
        var tags = [];

        var mark = bookmark;
        while (mark.parentId) {
          chrome.bookmarks.get(mark.parentId, function(results) {
            mark = results[0];
            tags.push(mark.title);
          });
        }
        return tags.join(' ');
      }

      chrome.bookmarks.onCreated.addListener(function(id, bookmark) {
        if (bookmark.url) {
          console.debug(bookmarkFoldersAsTags(bookmark));
        }
      });

--

You received this message because you are subscribed to the Google Groups 
"Chromium-extensions" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/chromium-extensions?hl=en.


Reply via email to