韩国国际航空公司-生成Flickr缩短的URL
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了韩国国际航空公司-生成Flickr缩短的URL相关的知识,希望对你有一定的参考价值。
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
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); }
以上是关于韩国国际航空公司-生成Flickr缩短的URL的主要内容,如果未能解决你的问题,请参考以下文章