What Jeremy could use from developers is a list of TW operations that
would be good candidates for this. For instance, I can see cases where
developers in their macros would want to tap into functions to saveRSS,
and saveHTML. But these functions are currenlty embedded in the
saveChanges function. So if Jeremy took them out of saveChanges and
made them a separate function instead, we could call them ourselves
with parameters like the filename, and an array of tiddlers (you get
the idea).
As you skim through the TW code, please post your candidates here.
Here are my few (mentioned above) to get us started:
saveRSS
saveHTML
Jeremy's code (it was the onDblClickTiddler(e) function) utilized
"this" as the reference to the current object. But by hijacking the
function, "this" was effectively changed to the current window instead
of the object the user had double-clicked...so the function no longer
worked. I was able to get around the problem by duplicating the entire
onDblClickTiddler(e) code and never calling the orig function (see my
WebView), but that's not clean and could mess up things if other macros
attempt to hijack the same function.
One way I found to overcome this problem was to change any "this"
reference in the hardcoded function to "e.target." This would always
reference the object of the event instead of the current object.
So 1) was there another way I could have done this without changing to
"e.target?" and if not, 2) Jeremy, as we talk about refractor code we
should keep this in mind and maybe change any "this" references to
"e.target" pending browser compatibilities.
~AlanH
> One way I found to overcome this problem was to change any "this"
> reference in the hardcoded function to "e.target." This would always
> reference the object of the event instead of the current object.
>
> So 1) was there another way I could have done this without changing to
> "e.target?"
I think it depends on how you call the original function after
hijacking it. Without your code it's hard to see. But if you call the
function on the original object (e.target.onDoubleClick(e)) or whatever
you should still get the reference to "this". I haven't tried this so
it's just a guess though ...
pagePreInit
pagePostInit
pagePreComplete
pagePostComplete
I guess these count as hooks. They might make some things easier to do.
For example, I'm interested in having a pair timestamps from when the
page is loaded to when it is cmopletely displayed, telling me what kind
of lag particular macro code causes.
Maybe this is already possible via macro. If it is, please post the
sort of code needed.
That way it can be called from main() as well as from within another
plugin.
~AlanH