Great Eric - Thank you very much for the good explanation and
especially the CoreTweaks which allow me to make my own button appear
by tiddlername in the ToolbarCommands.
It is also good to know how to prevent the script from running every
time I click done - and getting a link instead - That's really great!!
Now I need to input 2 prompts in the script - one for the
sourcetiddler (with the list)
and another for the targettiddler (which could be the same tiddler- or
not)
I've found this:
var title=prompt("Enter the title of a tiddler to edit (case
sensitive)");
while (title && title.length && !store.tiddlerExists(title)) {
displayMessage("The tiddler '%0' doesn't exist".format
([title]));
var title=prompt("Please enter a tiddler title",title);
}
if (!title||!title.length) return; /* cancelled by user */
story.displayTiddler(null,title,2);
I need to use some of it in this:
<script label="L2T" title="List2Tags">
var t=store.getTiddlerText('prompt for source tiddlertitle','');
var target = store.getTiddler('prompt for target tiddlertitle') ;
var taglist = t.split('\n') ;
for(var i=0 ; i < taglist.length ; i++) {
if ( taglist[i] && ! target.tags.contains(taglist[i]) )
target.tags.push( taglist[i] ) ;
}
return 'List 2 tags Done - Now click edit and finish in
targettiddler to make the tags active' ;
</script>
YS Måns Mårtensson
On 11 Apr., 23:06, Eric Shulman <[email protected]> wrote:
> > I've got a very nice script from Mark S.
> > 1)
> > I would like to use it from a button in a custom toolbar for a
> > tiddler.
>
> InlineJavascriptPlugin enables you to quickly create an 'onclick'
> command link from *any* script, simply by adding label="..." (and
> optional title="...") to the script definition syntax, like this:
>
> <script label="click here" title="this text appears on mousover">
> ... code goes here ...
> </script>
>
> When the plugin detects the label="..." syntax, it creates a command
> link using the indicated label text, so that instead of immediately
> invoking the script as soon as it is rendered, it is only invoked when
> that link is subsequently clicked upon.
>
> To use this command link in a tiddler toolbar definition, first put
> the script into a separate tiddler (e.g., "MyCommand") and then
> either:
>
> A) In the ViewTemplate or EditTemplate, you can insert the following
> immediately preceding or following any existing toolbar definition,
> e.g.,:
> <div class='toolbar' macro='tiddler MyCommand'></div>
> <div class='toolbar' macro='toolbar
> [[ToolbarCommands::ViewToolbar]]'></div>
>
> OR
>
> B) Install
> http://www.TiddlyTools.com/#CoreTweaks
> specifically tweak #608/609/610, which extends the core's toolbar
> syntax so that -- in addition to standard toolbar command keywords --
> TiddlerNames can be used to 'transclude' content directly into a
> toolbar definition. This allows you to use the tiddler name,
> MyCommand, anywhere within the standard
> [[ToolbarCommands::ViewToolbar]] slice, like this:
>
> |~ViewToolbar|MyCommand closeTiddler closeOthers +editTiddler > fields
> syncing permalink references jump|
>
> In either case, the result will be that the 'onclick' inline script
> defined in MyCommand will appear as a button in each tiddler's
> toolbar, ready to be clicked upon to perform it's scripted actions.
>
> Note that either technique can also be very use for embedding
> 'regular' macro-based command links as well. For example, create a
> tiddler called [[NewTiddlerCommand]] containing just this single
> macro:
> <<newTiddler>>
> Then, either edit the template or the toolbar slice definition to add
> a reference to "NewTiddlerCommand". The result will be that the "new
> tiddler" command link will then automatically appear in the toolbar of
> every tiddler.
>
> enjoy,
> -e
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---