At the moment - as long as I haven't created a TW5 plugin - I recommend:

   1. Download jEdit from http://jedit.org
   2. Give me your mail address and I'll mail you a macro for jEdit
   3. Write your JavaScript Bookmarklet in jEdit
   4. call the macro to get it converted

But this is the comfortable way as the Macro is able to encode and decode.

The less comfortable: Below I'll paste from my Bookmarklets the source in 
readable form. It will be jus to. Feel free to change them to your needs. 
You will be able to use them as bookmarklets without encoding as the 
browser should be able to encode them on their own.

Bookmarklet for putting stuff before and behind a selection


javascript:
var pre= "''";
var post="''";
var ta= document.activeElement;
if (ta.tagName.toLowerCase() == 'textarea') {
    var startPos = ta.selectionStart;
    var endPos = ta.selectionEnd;
    ta.value= ta.value.substr(0,startPos) + pre + 
ta.value.substr(startPos,endPos
-startPos) + post + ta.value.substr(endPos);
    var evt = document.createEvent("HTMLEvents");
    evt.initEvent('input', true, true );
    ta.dispatchEvent(evt);
    ta.setSelectionRange(startPos+pre.length, endPos+pre.length);
}
void(0);


Bookmarklet for lists:

javascript:
var list= "*";
var ta= document.activeElement;
if (ta.tagName.toLowerCase() == 'textarea') {
    var startPos = ta.selectionStart;
    var endPos = ta.selectionEnd;
    var listtext= ta.value.substr(startPos, endPos-startPos);
    var len= listtext.length;
    listtext= listtext.replace( /^([#*]*)\s*(?=\S)/gm, "$1"+list+" ");
    var newlen= listtext.length;
    if (newlen>len) {
        ta.value= ta.value.substr(0,startPos)  + listtext + ta.value.substr(
endPos);
        var evt = document.createEvent("HTMLEvents");
        evt.initEvent('input', true, true );
        ta.dispatchEvent(evt);
        ta.setSelectionRange(startPos, endPos+newlen-len);
    }
}
void(0);



-- 
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 http://groups.google.com/group/tiddlywiki.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to