Hi, Mario!

I've tried the following:

var at;
config.macros.AddTag = at = {
        locale: {
                txtTag: ""
        },

        handler: function(place, macroName, params, wikifier, paramString,
tiddler){
                var btn = null;
                var btnContent = params[0] || at.locale.txtTag;
                btn = createTiddlyButton(place, btnContent, btnContent, 
at.onClick,
'bold', 'btnAddTag');
        },

        onClick: function() {
                var here=story.findContainingTiddler(place);
                if (here) 
{tiddler=store.getTiddler(here.getAttribute("tiddler"));}
                store.setTiddlerTag(tiddler.title,true,btnContent);
        }

};

I get the label and the tooltip, but the function isn't invoked. Or
rather, it might be, but the tag isn't added. Any ideas?

w

On Feb 26, 10:54 am, PMario <[email protected]> wrote:
> Hi whatever,
> Why don't you just create real TW macros? It will make things lot
> easier and more generalized.
> Have a look at [1][2] it should give you the basic structure.
>
> have fun!
> -m
> [1]http://helloworld.tiddlyspace.com/#HelloWorldButtonPlugin
> [2]http://helloworld.tiddlyspace.com/#HelloWorldNamedParamsPlugin
>
> On Feb 26, 9:28 am, whatever <[email protected]> wrote:
>
> > Hi,
> > I've tried a somewhat different tactics. Instead of using
> > document.write, I tried createTiddlyButton, like this:
> > var strTagList = "$1";
> > var arrTags = strTagList.split(",");
> > var i;
> > for (i=0;i<arrTags.length;i++) {
> > createTiddlyButton(place, "Add "+arrTags[i], "Add "+arrTags[i],
> > function x() {
> > var here=story.findContainingTiddler(place);
> > if (here) {tiddler=store.getTiddler(here.getAttribute("tiddler"));}
> > var tags = arrTags[i];
> > store.setTiddlerTag(tiddler.title,true,tags);}, "bold");
>
> > }
>
> > However, no luck. I get the label and the tooltip, but that's it.
> > Any ideas?
> > w
>
> > On Feb 11, 7:57 am, whatever <[email protected]> wrote:
>
> > > After playing around for a while, I came to realize that the for-loop
> > > is not the problem, because if I replace the document.write line with
> > > document.write(arrTags[i]+"<br/>");
> > > I get all the words I enter displayed correctly.
>
> > > And if I replace the document.write command with alert, the popup
> > > shows the internal script rendered correctly, like so:
> > > <script label="Add foo" title="Add foo">var
> > > here=story.findContainingTiddler(place); if (here)
> > > {tiddler=store.getTiddler(here.getAttribute("tiddler"))};
> > > store.setTiddlerTag(tiddler.title,true,"foo"); </script><br/>
>
> > > If I replace document.write with return, I get the first word rendered
> > > correctly and can add it as a tag, but the other words are ignored.
> > > Also, in this case JSLint reports "Strange loop".
>
> > > The quotes are escaped correctly and I also escaped the internal
> > > script tag (<\/script>).
> > > I'm guessing it has to with the fact that the internal script calls on
> > > the variable from the parent script. Any ideas?
>
> > > w
>
> > > On Feb 10, 12:46 am, "Mark S." <[email protected]> wrote:
>
> > > > Its been awhile since I've written for TW. It looks to me that for
> > > > starters, you may have some quotes escaped incorrectly.
>
> > > > I believe that maybe this part
> > > > ..."\">var here...
>
> > > > should have been written/escaped like
>
> > > > ..."\""+">var here...
>
> > > > but my eyes were beginning to water ;-) There could be more.
>
> > > > On a larger note, I'm pretty sure that using document.write is the
> > > > wrong way to go about writing code for TW. It might work sometimes,
> > > > but on the other hand it may end up writing some place you never
> > > > intended. Maybe look through some of the various plugins to see what
> > > > TW functions they use to write out stuff.
>
> > > > Mark
>
> > > > On Feb 9, 10:53 am, whatever <[email protected]> wrote:
>
> > > > > Hi!
> > > > > I've been playing around with scripts for adding tags to tiddlers.
> > > > > I've figured out how to do it using fET-generated lists of tiddlers,
> > > > > however, I'm having trouble with passing values through transclusion.
> > > > > I've come up with the following (beware googlewrap):
>
> > > > > <<tiddler AddTagsScriptsTEST/testscript with:"tool,device">>
> > > > > <part testscript hidden>
> > > > > <script>
> > > > > var strTagList = "$1";
> > > > > var arrTags = strTagList.split(",");
> > > > > var i;
> > > > > for (i=0;i<arrTags.length;i++) {
> > > > > document.write("<script label=\"Add "+arrTags[i]+"\" title=\"Add
> > > > > "+arrTags[i]+"\">var here=story.findContainingTiddler(place); if
> > > > > (here) tiddler=store.getTiddler(here.getAttribute(\"tiddler\"));
> > > > > store.setTiddlerTag(tiddler.title,true,\""+arrTags[i]+"\"); </
> > > > > script><br/>");}
>
> > > > > </script>
> > > > > </part>
>
> > > > > It should generate two links:
> > > > > Add tool
> > > > > Add device
>
> > > > > On click, it would add the corresponding tag to the tiddler. Now, I
> > > > > know that the script in the "document.write" line works, because I've
> > > > > used it before, but I still get an error:
>
> > > > > SyntaxError: unterminated string literal
> > > > > ");}
>
> > > > > </script>
>
> > > > > I've tested it with JSLint (1), but it only reported:
> > > > > Problem at line 5 character 1: document.write can be a form of eval.
>
> > > > > I'm guessing the problem is in the first part, however, JavaScript is
> > > > > not my strong suite, so if anyone has any suggestions, I'd be
> > > > > grateful.
>
> > > > > w
>
> > > > > (1)http://www.jslint.com/

-- 
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.

Reply via email to