FND thanks for the response, looks like my feed reader isn't properly
showing me all
the responses since I didn't think I had any responses on this post.

On Jul 25, 11:51 am, FND <[email protected]> wrote:
> Here's a more future-proof version using hijacking*:
> ---------------
> (function() {
>
> var orig = TiddlyWiki.prototype.getOrphans;
> TiddlyWiki.prototype.getOrphans = function() {
>         var orphans = orig.apply(this, arguments);
>         return orphans.filter(function(item, i) {
>                 var tiddler = store.getTiddler(orphans[i]);
>                 if(tiddler.isTagged("excludeOrphans")) {
>                         return false;
>                 }
>         });
>
> };
> })();
>
> ---------------
>
> However, the filter method is probably not supported on IE6-7, so you
> might wanna use a for loop instead.

I am not quite sure if you meant a forEachTiddler when you said "for"
loop.
I tried:
--------------
(function() {
var orig = TiddlyWiki.prototype.getOrphans;
TiddlyWiki.prototype.getOrphans = function() {
        var results = [];
        var orphans = orig.apply(this, arguments);

        orphans.forEachTiddler(function(title, tiddler) {
                if(! tiddler.isTagged("excludeOrphans")) {
                        results.push(i);
                }
        });
};
})();
-----------

which causes the list macro to fail with something like:

   orphans.forEachTiddler not a function

which I guess makes sense since groveling through the javascript (good
thing show source exists in browsers)
told me that getOrphans returns a list of titles and not a list of
tiddler objects. I doubt that an array of
strings would have a forEachTiddler method (nor would a generic array,
unless it was blessed into a tiddlerArray
or some such object).

Assuming that orphans is an array of titles I needed to loop over, I
finally arrived at:
--------------
var orig = TiddlyWiki.prototype.getOrphans;
TiddlyWiki.prototype.getOrphans = function() {
     var results = [];
     var orphans = orig.apply(this, arguments);

     for (var i=0;i<orphans.length;i++) {
       var title = orphans[i];
       var tiddler = store.getTiddler(title);
       if(this.getReferringTiddlers(title).length == 0 &&
             !tiddler.isTagged("excludeLists") &&
             !tiddler.isTagged("excludeOrphans")) {
                        results.push(title);
         }
     }
     results.sort();
     return results;
};
---------------------

This seems to work. Does it look reasonable and readable (I explicitly
assigned title to remember that orphans
was an array of titles and eliminate the need to deference the array a
couple of times through the loop).

I was looking at using forEach rather than for, but it looks like it
is a newer feature of javascript that IE 6/7 probably
doesn't support. I also came across the following syntax for a for
loop:

  for ( var title in orphans )

but I am not sure how well supported this form is. It would seem to
reduce the computation time
needed in incrementing a counter and evaluating the orphans.length
method.

Do you know of a reference for the supported syntax of the javascript
engine in IE 6/7?

Thanks again for the pointers.

-- rouilj

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" 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/TiddlyWiki?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to