Ticket #3878 (closed enhancement: invalid)

Opened 5 years ago

Last modified 4 years ago

Press IT Bookmarklet updated

Reported by: DD32 Owned by: anonymous
Priority: normal Milestone:
Component: Administration Version: 2.2
Severity: normal Keywords: Press IT has-patch
Cc:

Description

Follow up to  http://trac.wordpress.org/ticket/3731

Since no-one else has done it, I've written up 2 bookmarklets for Wordpress 2.2-svn. I've tested under Opera9/IE6/FF2, i dont have access to any other browsers to test, however from what i can tell, it should work.

Here is an expanded form of the bookmarklet

//javascript:
function A(b){return (encodeURIComponent)?encodeURIComponent(b):escape(b);}
Q='';
if(window.getSelection){
	Q=window.getSelection();
}else if (document.getSelection){
	Q=document.getSelection();
}else if(document.selection){
	Q=document.selection.createRange().text;
}
location.href='http://*URL*/wp-admin/post-new.php?text='+A(Q)+'&popupurl='+A(location.href)+'&popuptitle='+A(document.title);

The last line can also be writen as:

void(window.open('http://*URL*/wp-admin/post-new.php?text='+A(Q)+'&popupurl='+A(location.href)+'&popuptitle='+A(document.title)));

to open in a new window, Both bookmarklets are listed in the post page.

As to getting the current selected text: window.getSelection should work for Safari document.getSelection() should work for mozilla/opera document.selection.createRange().text should work for IE variants

The total length is 388 characters for the location.href version, which leaves 100 characters spare for the domain name, and any other small fixes which get added. (IE6 SP2 has a maximum limit of 488 characters for bookmarklets:  http://subsimple.com/bookmarklets/rules.asp ) The window.open version has less space for the domain name, however most should still fit.

The function A() had to be used to pull the totalsize of the bookmarklet down to within limits allowed by IE6.

A Patch has been attached (Patch against SVN 4915).

Finally, Here are the 2 bookmarklets(with PHP and HTML):

<a href="javascript:function A(b){return (encodeURIComponent)?encodeURIComponent(b):escape(b);}Q='';if(window.getSelection){Q=window.getSelection();}else if (document.getSelection){Q=document.getSelection()}else if(document.selection){Q=document.selection.createRange().text;}void(window.open('<?php echo get_option('siteurl') ?>/wp-admin/post-new.php?text='+A(Q)+'&amp;popupurl='+A(location.href)+'&amp;popuptitle='+A(document.title)));" title="<?php printf(__('Press It - %s'), wp_specialchars(get_option('blogname'))); ?>"><?php printf(__('Press It - %s'), wp_specialchars(get_option('blogname'))); ?></a> <?php echo __('New Window/tab') ?><br/>
<a href="javascript:function A(b){return (encodeURIComponent)?encodeURIComponent(b):escape(b);}Q='';if(window.getSelection){Q=window.getSelection();}else if (document.getSelection){Q=document.getSelection()}else if(document.selection){Q=document.selection.createRange().text;}location.href='<?php echo get_option('siteurl') ?>/wp-admin/post-new.php?text='+A(Q)+'&amp;popupurl='+A(location.href)+'&amp;popuptitle='+A(document.title);" title="<?php printf(__('Press It - %s'), wp_specialchars(get_option('blogname'))); ?>"><?php printf(__('Press It - %s'), wp_specialchars(get_option('blogname'))); ?></a> <?php echo __('Current Window') ?>

Attachments

new-post-bookmarklet.patch Download (3.9 KB) - added by DD32 5 years ago.
Bookmarklet Patch

Change History

DD325 years ago

Bookmarklet Patch

comment:1   DD325 years ago

(Patch against SVN 4915).
Actually, my mistake, it seems to be against revision 4950, Which is the latest in the SVN repos as of a few hours ago.

comment:2   DD325 years ago

  • Version set to 2.2
  • Milestone changed from 2.2 to 2.3

comment:4   ryan4 years ago

  • Milestone changed from 2.3 to 2.4
  • Status changed from new to closed
  • Resolution set to invalid
  • Milestone 2.5 deleted

Closing as invalid - there is no bookmarklet anymore

Note: See TracTickets for help on using tickets.