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);
I dont understand what you meant by "jus to".
Also, and more importantly, you didn't mention where I need to paste your codes to get them to become bookmarklets. Remember I have no idea what I am doing! :-)
That should be it…
--
You received this message because you are subscribed to a topic in the Google Groups "TiddlyWiki" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tiddlywiki/cUUXichiwdU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
For more options, visit https://groups.google.com/groups/opt_out.
var pre= "\"";
--
You received this message because you are subscribed to a topic in the Google Groups "TiddlyWiki" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tiddlywiki/cUUXichiwdU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to a topic in the Google Groups "TiddlyWiki" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tiddlywiki/cUUXichiwdU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to a topic in the Google Groups "TiddlyWiki" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tiddlywiki/cUUXichiwdU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
For more options, visit https://groups.google.com/groups/opt_out.
var text2insert= "blahdeeblah";
var ta= document.activeElement;
if (ta.tagName.toLowerCase() == 'textarea') {
var startPos = ta.selectionStart;
var endPos = ta.selectionEnd;
ta.value= ta.value.substr(0,startPos) + text2insert + ta.value.substr(endPos);
var evt = document.createEvent("HTMLEvents");
evt.initEvent('input', true, true );
ta.dispatchEvent(evt);
ta.setSelectionRange(startPos, endPos+text2insert.length);
}
void(0);
Just curious if there is a way to create bookmarklets that simply insert a text rather than wrapping selected text.
--
You received this message because you are subscribed to a topic in the Google Groups "TiddlyWiki" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tiddlywiki/cUUXichiwdU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
For more options, visit https://groups.google.com/groups/opt_out.
Thanks Stephan! That is pretty cool!
Dave
On Wed, Dec 4, 2013 at 4:03 AM, Stephan Hradek <stephan...@gmail.com> wrote:
Am Dienstag, 3. Dezember 2013 01:22:39 UTC+1 schrieb David Gifford:Just curious if there is a way to create bookmarklets that simply insert a text rather than wrapping selected text.
http://tw5magick.tiddlyspot.com/#bookify
I've added a button which will create a new tiddler with the basic insert-code. Just put your text at the proper place. Your newly created bookmarklet will then show up in the list.
--
You received this message because you are subscribed to a topic in the Google Groups "TiddlyWiki" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tiddlywiki/cUUXichiwdU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tiddlywiki+unsubscribe@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
For more options, visit https://groups.google.com/groups/opt_out.