Version: 1.0, Last updated: 1/23/2010
jQuery longUrl: Uniform Resource Elongator | Version: 1.0, Last updated: 1/23/2010 |
License | Copyright © 2010 “Cowboy” Ben Alman, Dual licensed under the MIT and GPL licenses. |
Examples | These working examples, complete with fully commented code, illustrate a few ways in which this plugin can be used. |
Support and Testing | Information about what version or versions of jQuery this plugin has been tested with, what browsers it has been tested in, and where the unit tests reside (so you can test it yourself). |
Release History | |
Functions | |
jQuery. | Lengthen one or more “short URLs” using a third-party lengthening service (defaults to longurlplease.com). |
jQuery. | Override the default lengthening service options with custom settings. |
jQuery. | Lengthen one or more “short URLs” in A elements, using a third-party lengthening service (defaults to longurlplease.com). |
Copyright © 2010 “Cowboy” Ben Alman, Dual licensed under the MIT and GPL licenses. http://benalman.com/about/license/
These working examples, complete with fully commented code, illustrate a few ways in which this plugin can be used.
longurl | http://benalman.com |
Information about what version or versions of jQuery this plugin has been tested with, what browsers it has been tested in, and where the unit tests reside (so you can test it yourself).
jQuery Versions | 1.3.2, 1.4.1 |
Browsers Tested | Internet Explorer 6-8, Firefox 2-3.6, Safari 3-4, Chrome, Opera 9.6-10.1. |
Unit Tests | http://benalman.com |
Lengthen one or more “short URLs” using a third-party lengthening service (defaults to longurlplease.com). Note that only absolute URLs will be lengthened.
jQuery.longUrl( urls, callback );
urls | (String) A single “short URL” to lengthen. |
urls | (Array) An array of “short URLs” to lengthen. |
callback | (Function) This function, invoked after all passed URLs have either been fetched from the internal cache or lengthening service, is passed a single argument: an object containing short URL keys to long URL values. |
Nothing.
Override the default lengthening service options with custom settings.
jQuery.longUrl( options );
options | (Object) An object containing lengthening service options. |
fetch | (Function) This function is invoked for each set of `batch` URLs to be lengthened, receiving two arguments: an array of URLs (no longer than `batch` in length), and a callback that, upon fetch success, shall be called with one argument: an object containing short URL keys to long URL values. |
batch | (Number) The maximum number of URLs that can be lengthened per request. While the longurlplease.com API allows 10 URLs per request, different services may vary. |
Nothing.
Lengthen one or more “short URLs” in A elements, using a third-party lengthening service (defaults to longurlplease.com). Note that only absolute URLs will be lengthened.
jQuery('selector').longUrl( [ options ] );
options | (Object) An optional configuration object. |
callback | (Function) This function, called after all passed URLs have either been fetched from the internal cache or lengthening service, is called once for each element (or group of elements sharing the same short URL), and passed two arguments: the original short URL, followed by the long URL. Because multiple elements sharing the same short URL href will be operated on together, for efficiency, `this` refers to a jQuery object containing references to one or more A elements. If not specified, the default behavior is to set the title and href attributes of each link to their retrieved long URL. This can be set to `false` to disable any per-element callback. Note that, since changing A elements’ href attribute in IE may also change their innerHTML, in the default callback, the old value is stored and tested after the href is updated. A user-specified callback should take this into consideration. See this for more information: http://stackoverflow.com/questions/1790698/ |
complete | (Function) This optional function, called after all `callback` executions, is passed a single argument: an object containing short URL keys to long URL values. In this function, `this` refers to the initial jQuery collection of elements. |
(jQuery) The initial jQuery collection of elements.