Stephan Hradek! Thanks for the bookmarklets. Now, how do I make my own?

500 views
Skip to first unread message

David Gifford

unread,
Nov 30, 2013, 3:32:52 PM11/30/13
to tiddl...@googlegroups.com
Title says it all. I would love to be able to create bookmarklets of certain list filters html tags and span classes for TiddlyWiki.

Dave

Stephan Hradek

unread,
Nov 30, 2013, 5:06:29 PM11/30/13
to tiddl...@googlegroups.com
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);



David Gifford

unread,
Nov 30, 2013, 8:00:39 PM11/30/13
to tiddl...@googlegroups.com
Hi Stephan

Thanks for that! And thanks again for the idea of having bookmarklets for 5. If I can create a small library of these, it will be a huge timesaver.

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! :-)

Thanks for your help,

Dave

Stephan Hradek

unread,
Dec 1, 2013, 2:09:37 AM12/1/13
to tiddl...@googlegroups.com


Am Sonntag, 1. Dezember 2013 02:00:39 UTC+1 schrieb David Gifford:
I dont understand what you meant by "jus to".

I hate it, when I forget letters. "Just two". I had 10(?) bookmarklets, but here I pasted just two. All the others were variations of those 2.
 
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! :-)

For Firefox:
  • View all your bookmarks
  • Navigate to where you want a new bookmarklet
  • Create a new bookmark
  • Choose a proper name
  • Paste the bookmarklets code (everything starting from "javascript:", and including it, to the end) as the bookmarks address

That should be it…


David Gifford

unread,
Dec 1, 2013, 8:39:20 AM12/1/13
to tiddl...@googlegroups.com
Thanks Stephan, I am so close I can taste it! Now, hopefully last question - how do I add pre and post that contains ", since it breaks the javascript?

Dave


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



--
David Gifford
Christian Reformed World Missions, Mexico City

Stephan Hradek

unread,
Dec 1, 2013, 9:32:02 AM12/1/13
to tiddl...@googlegroups.com
var pre= "\"";


David Gifford

unread,
Dec 1, 2013, 9:35:03 AM12/1/13
to tiddl...@googlegroups.com
Please decipher that comment for me.


On Sun, Dec 1, 2013 at 8:32 AM, Stephan Hradek <stephan...@gmail.com> wrote:
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.

Stephan Hradek

unread,
Dec 1, 2013, 9:46:21 AM12/1/13
to tiddl...@googlegroups.com
You asked how to put a quote into pre and post, right? That's what I've showed.

To describe it: Put a backslash (\) before the quote.

David Gifford

unread,
Dec 1, 2013, 8:43:26 PM12/1/13
to tiddl...@googlegroups.com
Thanks for your patience, Stephan! I will give it a try. Blessings

Dave

David Gifford

unread,
Dec 1, 2013, 9:34:54 PM12/1/13
to tiddl...@googlegroups.com
Awesome Stephan! I just made bookmarks for IFrames, image links and the lists of verses I used in my resource on 1 John. I am sure it won't be long before I create several more.

TiddlyWiki just got heaps faster for me. Thanks a bunch for this!

Dave


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

Stephan Hradek

unread,
Dec 2, 2013, 6:46:15 PM12/2/13
to tiddl...@googlegroups.com
This also might help in creating bookmarklets.

I created an experimental JavaScript macro (I need to find out how to package it) and activated it on http://tw5magick.tiddlyspot.com/

If you create a tiddler containing JavaScript source, the macro "bookmarklet" will generate a bookmarklet from it.

Example:

The tiddler "Reveal Password" contains the JavaScript source.

The tiddler "Reveal Password Bookmarklet" contains some help text and this macro call:

<$macrocall $name="bookmarklet" script={{Reveal Passwords}} text="Reveal Passwords" />

One could also use the macro like this:

<<bookmarklet script="alert('Hello World');void(0);" text="Hello World Bookmarklet" tooltip="I'm your Drag Queen ;)" className="optional classes">>

David Gifford

unread,
Dec 2, 2013, 7:22:39 PM12/2/13
to tiddl...@googlegroups.com
Well, when I get a chance, I will check that out, too. But the other way was easy enough for me.

Just curious if there is a way to create bookmarklets that simply insert a text rather than wrapping selected text.

Dave


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

Stephan Hradek

unread,
Dec 3, 2013, 5:23:05 AM12/3/13
to tiddl...@googlegroups.com
Sure that's possible.

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);


Stephan Hradek

unread,
Dec 4, 2013, 5:03:45 AM12/4/13
to tiddl...@googlegroups.com


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.

David Gifford

unread,
Dec 4, 2013, 7:46:58 AM12/4/13
to tiddl...@googlegroups.com
Thanks Stephan! That is pretty cool!

Dave


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

David Gifford

unread,
Nov 29, 2015, 11:20:46 AM11/29/15
to TiddlyWiki
Hi Stephan and anyone else who might be listening in:

How would I do a bookmarklet that wraps all list items with text before and after?

Dave


On Wednesday, December 4, 2013 at 6:46:58 AM UTC-6, David Gifford wrote:
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.
Reply all
Reply to author
Forward
0 new messages