Hi Eric:
On Mar 22, 12:59 am, Eric Shulman <[email protected]> wrote:
> > For the slide presentation modes, I have to swap between a couple of
> > different SlideViewTemplates
> ..
> > What would be nice is to have a macro that I can click on to copy (an
> > arbitrary) source tiddler to SlideShowViewTemplate (or an arbitrary
> > target tiddler).
> Then, create a tiddler called [[SwitchContent]], containing:
> -------------------------
> <script label="$1">
> var txt=store.getTiddlerText('$2');
> if (!txt) {displayMessage('$2 not found'); return; }
> var t=store.getTiddler('$3');
> if (!t) {displayMessage('$3 not found'); return; }
> var who=config.options.txtUserName;
> var when=new Date();
> store.saveTiddler(t.title,t.title,txt,who,when,t.tags,t.fields);
> </script>
> -------------------------
>
> To use this inline 'onclick' script, embed the following in your
> tiddler content:
> <<tiddler SwitchContent with:
> "instructor mode"
> "InstructorSlideShowViewTemplate"
> "SlideShowViewTemplate">>
>
> The first parameter following the 'with:' will be used as the label on
> the onclick command. The second param is the source tiddler, the
> third param is the target tiddler whose content will be *overwritten*.
This almost works. I have two additional use cases:
* if $2 is empty I need it to delete $3
That was pretty easy adding:
if ( "$2" == "" )
store.deleteTiddler('$3');
else {
var txt=store.getTiddlerText('$2');
(I assume that deleteTiddler will work only on real tiddlers and not
delete any contents associated with a shadow tiddler named $3.
I'll find out soon I guess.)
Another problem is that $3 may not exist (it can be supplied by a
shadow tiddler).
So:
> var t=store.getTiddler('$3');
> if (!t) {displayMessage('$3 not found'); return; }
errors out when $3 is just a shadow tiddler. I seem to remember there
being a function
that will get the tiddler data from the non-shadow tiddler if it
exists or from the shadow tiddler, but I can't
seem to find it at the moment. I suppose I could use t=getTiddler
('$2') (since I know that exists as I got the text from it)
and replace the call to store.saveTiddler
(t.title,t.title,txt,who,when,t.tags,t.fields); with:
store.saveTidler('$3', '$3', txt who when t.tags, t.fields);
right?
-- 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
-~----------~----~----~----~------~----~------~--~---