cnick.js 1.6 KB

1
  1. var __hasProp={}.hasOwnProperty;!function(a){var b,c,d,e;d=this,b=d.jQuery,c={},a(d,c,b),void 0===d.csdn&&(d.csdn=c);for(e in c)__hasProp.call(c,e)&&(d[e]=d.csdn[e]=c[e])}(function(a,b,c){var d,e,f,g,h;if(!(a.CNick instanceof Function&&a.cnick instanceof Function&&(null!=(h=a.csdn)?h.cnick:void 0)instanceof Function))return void 0===String.prototype.trim&&(String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")}),g={},e=function(b,c){var d,e;return arguments.length>1?(g[b]=c,null!=(d=a.localStorage)?d["cnick_"+b]=+new Date+","+c:void 0):null!=b?g[b]||function(a){var b,c,d,e;if(null!=a)return d=a.split(","),b=d[0],c=d[1],0<(e=new Date-new Date(parseInt(b,10)))&&1728e5>e?c:void 0}(null!=(e=a.localStorage)?e["cnick_"+b]:void 0):void 0},b.cnick=f=function(b,d,f){var g,h,i,j,k,l,m,n,o,p;for(null==b&&(b="a.user_name"),null==d&&(d=a.document),null==f&&(f=!1),h=c(b,d).filter(function(){return f||null==c(this).data("orig_username")}).data("orig_username",""),k={},o=0,p=h.length;p>o;o++)g=h[o],m=g.innerHTML.trim(),null!=(l=e(m))?c(g).data("orig_username",m).html(l):(j=k.hasOwnProperty(m)?k[m]:k[m]=[],j.push(g));for(n=function(){var a;a=[];for(i in k)__hasProp.call(k,i)&&a.push(i);return a}();n.length>0;)c.getJSON("https://passport.csdn.net/get/nick?callback=?",{users:n.splice(0,100).join()},function(a){var b,d,f,g,h;if(d=a.status,b=a.data,d&&b)for(f=0,g=b.length;g>f;f++)h=b[f],m=h.u,i=h.n,"null"===i&&(i=m),c(k[m]).data("orig_username",m).html(function(a,b){return i||b}),e(m,i)})},c(function(){return f()}),a.CNick=d=function(){function a(a){this.selector=a}return a.prototype.showNickname=function(){return f(this.selector)},a}()});