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/c08bfc78-785f-435f-b64a-0128ebcddb4f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.