模板:Main Page/Pokedex

来自口袋百科
跳转至: 导航搜索
更换我是谁

<script type="text/javascript"> var $mp_whoami = $('#mp_whoami'); var $mp_whoami_link = $('<a href="#" title=""></a>').appendTo($mp_whoami);

var $mp_whoami_silhouette = $('
').appendTo($mp_whoami_link); var $mp_whoami_image = $('
').appendTo($mp_whoami_silhouette).hide();

$mp_whoami_silhouette.hover( function () { $mp_whoami_image.fadeIn(1000); }, function () { $mp_whoami_image.fadeOut(500); } ); var img = document.createElement("img"); function mp_whoami_change() { var p=[]; var d = new Date(); switch ( (d.getMonth()+1)+'-'+d.getDate() ) { case '2-29': p=[448,453,454,539,605]; break; case '3-12': p=[185]; break; } if ( p.length > 0 ) { r=p[Math.floor(Math.random()*p.length)]; }else{ r= Math.floor(Math.random()*(718-1) + 1); } var isShiny = false; r=String('00').concat(r).slice(-3); $(img).attr('src','http://www.pokemon.name/res/sprites/pokemon/pdw/100px/'+r+'.00.png'); $mp_whoami_link.attr('href','/wiki/P'+r); } img.onload = function mp_whoami_silhouette() { $mp_whoami_image.css('background-image','url('+img.src+')'); var canvas = document.createElement("canvas"); if (!!(canvas.getContext) ) { var ctx = canvas.getContext('2d'); canvas.width = img.width; canvas.height = img.height; ctx.drawImage(img,0,0); var imgData = ctx.getImageData(0,0,canvas.width,canvas.height); var pix = imgData.data; for (var i=0, n = pix.length; i < n; i+= 4){ pix[i] = 0; pix[i+1] = 0; pix[i+2] = 0; } ctx.putImageData(imgData,0,0); $('#mp_whoami_silhouette').css('background-image','url('+canvas.toDataURL()+')'); } }; mp_whoami_change(); document.getElementById('mp_whoami_change').innerHTML='<a href="javascript:mp_whoami_change()">更换</a>'; </script>

进入精灵图鉴