Try this.
<script>
var t=store.getTiddlerText('SomeTiddler','');
var target = store.getTiddler('TargetTiddler') ;
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 'Mischief Managed' ;
</script>
On Apr 11, 4:00 am, Måns <[email protected]> wrote:
> No that didn't do the trick. The '+' is going inside the doubled
> square-brackets.(But it gives the ability to add a prefix or suffix to
> all listitems, which is also very usefull!)
> Could you fetch the target tiddlers tags (that are already present)
> and add them to the start of the new string of tags in some way?
> The script is so effective that I can see a use for it as some kind of
> List/Tagimporter - with a button which resides in a newTiddler (using
> it as source) and promts for a targetTiddler (by title).
> Is this doable?
>
> YS Måns Mårtensson
>
> On 11 Apr., 13:41, Måns <[email protected]> wrote:
>
> > Hi again again...
>
> > I tried to remove the brackets like this:
> > <script>
> > var t=store.getTiddlerText('SomeTiddler','');
> > var target = store.getTiddler('TargetTiddler') ;
> > var taglist = t.split('\n') ;
> > var tagout = new Array ;
> > for(var i=0 ; i < taglist.length ; i++) {
> > if ( taglist[i] ) tagout.push('' + taglist[i] + '') ;
> > }
> > target.tags = tagout ;
> > return 'Mischief Managed' ;
> > </script>
>
> > And now it works! :-)
>
> > Is it possible not to overwrite existing tags in a target tiddler? -
> > or should I use TiddlerTweaker for this purpose, putting a + in front
> > of each [[tagname]]?
> > Maybe I could put a plus in the script like this?:tagout.push('+' +
> > taglist[i] + '') ; or will it interfere with the code in some bad
> > way?? - I'll try it out.
>
> > YS Måns Mårtensson
>
> > On 11 Apr., 13:18, Måns <[email protected]> wrote:
>
> > > Hi again
>
> > > I might add that when I hit "done" the doubled doubled square-brackets
> > > turns into
> > > [[[[ListItemCopiedToTagList]] and is wikified as
> > > [[ListItemCopiedToTagList.
>
> > > YS Måns Mårtensson
>
> > > On 11 Apr., 13:01, Måns <[email protected]> wrote:
>
> > > > Hi Mark
> > > > Thank you very much for the script!
> > > > It's very close at doing exactly what I need.
> > > > Except for the fact that it produces doubled doubled square-brackets.
> > > > Like this: [[[[ListItemCopiedToTagList]]]].
> > > > Are the list items surounded by doubled square-brackets automatically
> > > > when pushed to the tag list - and does the tagout.push('[[' + taglist
> > > > [i] + ']]') ; just double this action??
>
> > > > I don't know what to leave out and what to rewrite - Maybe you would
> > > > be so kind to modify the script so it only renders one pair of doubled
> > > > square-brackets when it gets into the taglist?
>
> > > > YS Måns Mårtensson
>
> > > > On 11 Apr., 12:07, "Mark S." <[email protected]> wrote:
>
> > > > > Set TargetTiddler to the target you want, SomeTiddler is your source
> > > > > of tiddlers, and the following script goes in your script-run tiddler.
>
> > > > > When you finish editing this script, it will pump your tag list into
> > > > > the target tiddler. Note that it will wipe out any existing tags
> > > > > there. However, you will probably need to open the target tiddler
> > > > > once, edit, and "done", in order to get rid of brackets around tags
> > > > > that don't need brackets. I'm sure there is a smarter way to do the
> > > > > clean up.
>
> > > > > <script>
> > > > > var t=store.getTiddlerText('SomeTiddler','');
> > > > > var target = store.getTiddler('TargetTiddler') ;
> > > > > var taglist = t.split('\n') ;
> > > > > var tagout = new Array ;
> > > > > for(var i=0 ; i < taglist.length ; i++) {
> > > > > if ( taglist[i] ) tagout.push('[[' + taglist[i] + ']]') ;
> > > > > }
> > > > > target.tags = tagout ;
> > > > > return 'Mischief Managed' ;
> > > > > </script>
>
> > > > > On Apr 10, 8:01 pm, Måns <[email protected]> wrote:
>
> > > > > > In my specific case - it would be fantastic if I could have a script
> > > > > > that could automate the whole process of taking a list (from a
> > > > > > tiddler):
> > > > > > 1) enclose each line in doubled square-brackets
> > > > > > 2) transpose the list from vertical to horisontal
> > > > > > 3) put the resulting row of wikilinks into the tagfield of a tiddler
>
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---