The simple script for a list to tag works now!! - Thank you very much
Eric!!
I will put it (as a button) in the customViewTemplate for classes -
thereby making it possible to paste a list of students into the
Classtiddler - push the button and get a tagline referring to all
students in the class... (Now I can delete the list in edit mode - and
get it back in viewmode - read on..)
I'm using a script to show a sortable list of the tagged students in
the ClassTiddler - like this:
<script>
var out=[];
var exclude=['Class'];
var fmt='|[[%0]]|';
var here=story.findContainingTiddler(place); if (!here)
return;
var tid=store.getTiddler(here.getAttribute('tiddler'));
if (tid.tags.length) out.push('|Elever på holdet|h\n|sortable|
k');
for (var t=0; t<tid.tags.length; t++)
if (!exclude.contains(tid.tags[t]))
out.push(fmt.format([tid.tags[t]]));
return out.join('\n');
</script>
YS Måns Mårtensson
On 12 Apr., 21:43, Måns <[email protected]> wrote:
> Of course it should be more like:
>
> <script label="L2T" title="List2Tags">
> var tid=prompt("Skriv navnet på det nye hold","");
> if (!tid || !tid.length) return;
> var txt="";
> var who=config.options.txtUserName;
> var when=new Date();
> var tags=['Class'];
> var initialer=prompt("Teachers initials","");
> if (!initials || !initials.length) return;
> var fields={ teacher: initials };
> store.saveTiddler(tid,tid,txt,who,when,tags,fields);
> story.displayTiddler(null,tid);
> var t=store.getTiddlerText("ListToTags");
> var here=story.findContainingTiddler(place);
> if (!here) return;
> var title=here.getAttribute("tiddler");
> var tiddler=store.getTiddler(title);
> var target = store.getTiddler(tiddler.title) ;
> 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 - click edit and done' ;
> </script>
>
> It still fetches the list from ListToTags and puts the result in the
> tiddler holding the script..
>
> YS Måns Mårtensson
>
> On 12 Apr., 21:30, Eric Shulman <[email protected]> wrote:
>
> > > var here=store.findContainingTiddler(place);
> > > And got this: TypeError: store.findContainingTiddler is not a function
>
> > oops! typo... change "store" to "story":
>
> > var here=story.findContainingTiddler(place);
>
> > -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
-~----------~----~----~----~------~----~------~--~---