Being a programmer won't help you much with macro invocation, which can 
leave just about anyone beating their head against a wall.

I'm pretty sure that this bit won't work:

text=<<reduce "$(mytext)$">>


At least it's never worked for me to invoke a macro with a parameter inside 
a widget. If there's magic to make this happen, I haven't found it.

But since you're rolling your own JS, you have another option. You can 
retrieve the variable inside your JS macro with something like this:

 *if(!text)
        text = this.getVariable("mytext") ;*


Then your invocation can just be like this:

*... text=<<reduce>> ...*

I don't know if your JS macro works since I didn't run it, but if you start 
getting those red alert boxes then that's a clue there might be something 
wrong.

HTH
Mark


On Wednesday, March 9, 2016 at 3:00:52 PM UTC-8, Andrew wrote:
>
> Hello everyone,
>     Using the same button format as Jeremy's new editor toolbar in the 
> 5.1.12-prerelease, I'm trying to make a reduce button plugin that I can add 
> to the toolbar when it comes out.
> Here is what I have so far but since I really am not a programmer, all I 
> get is error messages so it is obvious I don't know what I am doing. Any 
> suggestions? Here is what I have so far:
> In the button:
>
> <$set name="mytext" value={{!!text}}>
> <$button class="tc-btn-invisible" tooltip={{$:/language/Buttons/Reduce/Hint}} 
> aria-label={{$:/language/Buttons/Reduce/Caption}}>
> <$action-sendmessage
>       $message="tm-edit-text-operation"
>       $param="replace-all"
>       text=<<reduce "$(mytext)$">>
> />
> {{$:/plugin/ajh/reduce/image}}
> </$button>
> </$set>
>
>  In the Macro:
>
> /*\
> $:/plugin/ajh/reduce/macro.js
> type: application/javascript
> module-type: macro
>
> <<reduce text>>
>
> Examples:
> <<reduce>>
> <<reduce "one two three">>
> <$macrocall $name="reduce" text={{!!text}}/>
>
> \*/
> (function(){
>
> /*jslint node: true, browser: true */
> /*global $tw: false */
> "use strict";
>
> /*
> This is a macro to compress text into a blob for use with making external 
> files seem searchable
> */
> exports.name = "reduce";
>
> exports.params = [
>       { name: "text" }
> ];
>
> /*
> Run the macro
> */
> exports.run = function(text) {
>       if(!text)
>               text = "mytext";
>     var zwrds = text.toLowerCase().replace(   /\W/g," ");
>     var ztrc = zwrds.split(" ").sort().reverse();
>     var zntrc = " ";
>     var add = "";
>     for (var i = 0; i < ztrc.length; i++) {
>         if (zntrc.indexOf(ztrc[i]) < 1) {
>             add = ztrc[i].toString();
>             zntrc += add;
>         }
>     }
>     var format= zntrc.slice(1);
>       return reduce; 
> };
>
> })();
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/544cad2b-1041-4a9e-a367-fdf4c301f060%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to