On Dec 27, 3:26 pm, Dave Parker <[email protected]> wrote:
> so what you're saying is that I need to just have a simple link on the
> mainmenu to open a tiddler with the launch button in it. Is that
> right?
well.... that would work... but's it's not what you really *want*, now
is it?
Here's some 'pure HTML' that actually does what you are after:
<html><a href="javascript:;"
title="create a new bitmap tiddler"
onclick="
var txt='[img[%0]]\\n\<\<LaunchApplication [[edit this bitmap]]
click [[%0]]\\>\\>';
var cmd='\<\<newTiddler title:[[%0]] text:{{\x22'+txt+'\x22}}
tag:
[[paint]]\>\>';
var now=new Date().formatString('drawing.YYYY.0MM.0DD..hh.0mm.
0ss.jpg');
var t=cmd.format([now]);
var e=document.getElementById('invokeMacroHack');
if (!e) { e=document.createElement('span');
e.id='invokeMacroHack'; }
removeChildren(e); wikify(t,e); e.firstChild.onclick();
">new paint</a>
</html>
The trick is to create a regular HTML link with an 'onclick' handler.
When clicked, the handler dynamically constructs the desired
<<newTiddler>> macro on-the-fly, so that the *current* timestamp is
always used. Then, to invoke the macro, we use another little trick
I've come up with: create a temporary 'span' (in this case, I called
it 'invokeMacroHack'), and render the <<newTiddler>> macro into that
span. Then, click the first element in that span (i.e., the 'new
tiddler' button that was just rendered).
enjoy,
-e
Eric Shulman
TiddlyTools / ELS Design Studios
(note: as always, watch out for GoogleGroups-added newlines in the
above code).
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---