Timothy Appnel > JavaScript-Bookmarklet-0.02 > JavaScript::Bookmarklet

Download:
JavaScript-Bookmarklet-0.02.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.02   Source  

NAME ^

JavaScript::Bookmarklet - utility library and command-line script for converting human-readable JavaScript code into bookmarklet form.

SYNOPSIS ^

  use JavaScript::Bookmarklet qw(make_bookmarklet);

  my $src = <<JAVASCRIPT
  var str = document.title;
  alert(str);
  JAVASCRIPT

  my $bookmarklet = make_bookmarklet($src);
  print $bookmarklet;

The output of this script would be:

  // javascript:var%20str%20=%20document.title;alert(str);
  var str = document.title;
  alert(str);

DESCRIPTION ^

A "bookmarklet" is a little JavaScript script that's intended to be run from a web browser's bookmarks bar or menu. The reason they work as "bookmarks" is that the JavaScript source code is crammed into the form of a URL using the "javascript:" scheme.

This package is based on a text filter John Gruber of Daring Fireball fame wrote that makes writing --- and especially revising --- JavaScript bookmarklets much more pleasant.

Developing or modifying bookmarklets can be irritating, to say the least, because of this requirement that the JavaScript code be in the form of a URL.

So the problem developing bookmarklets is this: You want to write and edit normal JavaScript code, but you need to publish hard-to-read URLs.

This package provides to means of using this functionality -- as a utility method that can be called in an application and as a script that can be used on the command-line or in editors like BBEdit.

METHODS ^

make_bookmarklet $javascript, [$no_src]

This method takes a required SCALAR string ($javascript) that is presumed to be valid working JavaScript code and compresses it in to bookmarklet form. Optionally a boolean flag ($no_src) can be passed with the JavaScript code forcing the method to only return the bookmarklet screen and not the merged output of the bookmarklet and source code.

This method can be exported by request.

SUPPORT ^

Bugs should be reported via the CPAN bug tracker at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=JavaScript-Bookmarklet

For other issues, contact the author.

AUTHOR ^

Timothy Appnel <tima@cpan.org>

SEE ALSO ^

http://daringfireball.net/2007/03/javascript_bookmarklet_builder, make-bookmarklet

COPYRIGHT AND LICENCE ^

The software is released under the Artistic License. The terms of the Artistic License are described at http://www.perl.com/language/misc/Artistic.html. Except where otherwise noted, JavaScript::Bookmarklet is Copyright 2008, Timothy Appnel, tima@cpan.org. All rights reserved.

syntax highlighting: