Something went wrong. Try again.
Utensil's technical posts in Chinese (mostly 2005-2020) utensil.tngl.sh/tech
Something went wrong. Try again.
1.0 kB · 1 line
JavaScript
at site
1function cal_tagcloud_width(t,i){return Math.min(60*t,Math.min(400,.8*i))}function cal_tagcloud_height(t,i){return Math.min(30*t,Math.min(250,.8*i))}var resizeTimeout={},resizeContext={};$(function(){var a=$("#tag_cloud"),t=a.data("tags-json")||["tags","json"].join(".");$.getJSON(t,function(o){$(window).resize(function(){clearTimeout(resizeTimeout),resizeTimeout=setTimeout(function(){var t=cal_tagcloud_width(o.length,resizeContext.w),i=cal_tagcloud_height(o.length,resizeContext.h),e=cal_tagcloud_width(o.length,$(window).width()),n=cal_tagcloud_height(o.length,$(window).height());a.hasClass("inited")&&t==e&&i==n||a.empty().jQCloud(o,{width:e,height:n,afterCloudRender:function(){$("a",this).click(function(){var e=$(this).attr("href").toString().substring(1);return $("[id^=tag-]").each(function(t,i){encodeURI($(i).attr("id").toString())!=e?$(i).hide():$(i).show()}),!1})}}).addClass("inited")},500),resizeContext.w=$(window).width(),resizeContext.h=$(window).height()}),$(window).resize()})});