Revision: 20472
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at November 16, 2009 17:52 by loucypher
Initial Code
function flic_kr(aPhotoId) { // aPhotoId argument is Flickr photo id if (typeof aPhotoId !== 'number') { aPhotoId = parseInt(aPhotoId); } var enc='', alpha='123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ'; var div = aPhotoId, mod; while (aPhotoId >= 58) { div = aPhotoId / 58; mod = aPhotoId - (58 * Math.floor(div)); enc = '' + alpha.substr(mod, 1) + enc; aPhotoId = Math.floor(div); } return shortURL = "http://flic.kr/p/" + (div ? '' + alpha.substr(div, 1) + enc : enc); }
Initial URL
http://www.flickr.com/groups/api/discuss/72157616713786392/
Initial Description
A short photo id is a base58 conversion of the photo id. Base58 is like base62 [0-9a-zA-Z] with some characters removed to make it less confusing when printed. (namely 0, O, I, and l). So that leaves an alphabet of: 123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ
Initial Title
flic.kr - Generate Flickr shortened URL
Initial Tags
url, javascript
Initial Language
JavaScript