Thanks for your comments Ted,
On Oct 28, 2:13 pm, "Ted Gifford" <[EMAIL PROTECTED]> wrote:
> > I now implemented it with a class integer variable which gets
> > incremented every time the macro is called - which works ok so far.
> > Because it isn't reset (as long trac isn't restarted) there might be
> > in theory an overrun after a long runtime, which should be ok.
>
> For the devil's advocate in me: If that risk is okay, have you calculated
> the risk of duplicate random numbers? It's probably just as small, .... or
> hold that thought, this is python so I think integers grow pretty much
> without bound (where your use case is concerned).
random is worse in my opinion:
In theory a row of random numbers could be completely identical:
You can throw a dice three times and always get a 1 for example.
Ok, the cance for that gets very small for big random numbers, but it
is still there.
A incremented integer only overruns every 2^N steps (don't ask me
what's Nmax is for python)
and in no practical cases twice in the same wiki page.
But I fixed the possible overrun anyway:
I now had to change my macro to also implement a IRequestFilter anyway
in order to add some JavaScript file in the header,
so I just reset the counter there. Works very well: the first macro
now always starts with 1.
> But again, I'm not sure why you need to use getElementById. Trac ships with
> jQuery, which allows you to scope things very nicely, e.g.
>
> jQuery('.someContainerOfMyMacroClass .trigger').click(function(){
> jQuery(this).parent().append("<p>You clicked the trigger</p>");});
>
> ..........
> <div class="someContainerOfMyMacroClass">
> <a class="trigger" href="#">Click me!</a>
> <!-- <p>You clicked the trigger</p> shows up here -->
> </div>
>
> It's better than adding IDs, at least for my aesthetics.
In this example it will work even for multiple tags blocks in the same
HTML page because an event is used which gets the 'this' pointer,
but imagine that you want to set ONE specific div, which wont cause
any event to occur?
One specific, not ALL of the same class! Hey, there you need an ID,
that's the reason they exist.
To give you more details:
I'm using jQuery, but only to connect multiple onload and onunload
functions.
I'm needing getElementById because I need the handle in order to call
a lot of JavaScript methods on it.
I could maybe get this handle also with jQuery, but it would need an
also an ID - and would probably call getElementById by itself.
All browsers which can handle the rest of the JavaScript also can
getElementById, so there is no need to use an compatibility wrapper
around it.
Thanks,
Martin
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Trac
Users" 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/trac-users?hl=en
-~----------~----~----~----~------~----~------~--~---