Sorry - script(B) was wrong:
<script label="script(B)" title="Tag tiddlers from a list with
doublebracketed listitems">
var tid=prompt("title of the tiddler with the list");
if (!tid) return; /* cancelled by user */
var txt=store.getTiddlerText(tid);
if (!txt) { alert(tid+" not found"); return; }
var titles=txt.readBracketedList();
for (var i=0; i<titles.length; i++) store.setTiddlerTag(titles
[i],true,'TagName');
</script>
On 10 Sep., 18:28, Måns <[email protected]> wrote:
> Hi TwWizards
>
> I'm proud to tell that I've composed a script, which takes a
> lineseperated list - and converts it to a lineseperated list with
> double bracketed listitems.
> Something I have tried to accomplish for the last few months...
>
> It's a combination of two scripts Eric Shulman showed me in another
> context - and I don't know if there's more code in it than it needs -
> please tell if it's the case.
>
> I use it in the toolbarcommands.
> It takes the lineseperated list in the active tiddler and transposes
> it to a list of bracketed wikilinks:
>
> <script label="L2W" title="convert list to wikilinks">
> var here=story.findContainingTiddler(place);
> if (!here) return;
> var title=here.getAttribute("tiddler");
> var tid=store.getTiddler(title);
> var t=store.getTiddlerText(tiddler.title) ;
> var target = store.getTiddler(tiddler.title) ;
> var txt='[['+tid.text.split('\n').join(']]\n[[')+']]';
> store.saveTiddler
> (tid.title,tid.title,txt,tid.modifier,tid.modified,tid.tags,tid.fields);
> </script>
>
> I plan to use it like this:
> 1) I paste a lineseperated list into a tiddler
> 2) I "run" the script(A"L2W") on the list to get doublebracketed
> listitems
> 3) I run another script(B)* on the (now linking) listitems, which
> tag's all listitems with a predefined tagname.
>
> My next challenge will be to change script(B)* so it also can be
> invoked from the toolbar - *and* it should also prompt for tagname!
>
> The best solution would be to combine the two scripts in one script -
> so they were run consecutively - Then we would have a script which
> could tag a linesperated list of items with a tag - However script
> (A"L2W") should be able to be reversed (again consecutively) to remove
> the doubled brackets after the tagging has taken place (script(C)??)-
> so the list appears as it was from the start.
> This way the doublebracketing is only temporary - to let script(B)* do
> it's job.
>
> *script(B):
> <script label="script(B)" title="tag bracketed list with tagName">
> var tid=prompt("tagName");
> if (!tid) return; /* cancelled by user */
> var txt=store.getTiddlerText(tid);
> if (!txt) { alert(tid+" not found"); return; }
> var titles=txt.readBracketedList();
> for (var i=0; i<titles.length; i++) store.setTiddlerTag(titles
> [i],true,'HoldListeBilleder');
> </script>
>
> YS Måns Mårtensson
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---