注意:在保存之后,您可能需要清除浏览器缓存才能看到所作出的变更的影响。
?_=1
来访问最新页面。https://mzh.moegirl.org.cn/User:%E4%B9%9D%E6%B1%9F%E6%9C%88/common.js?_=1
if (window.location.href.indexOf("action=edit")!= -1){ window.onbeforeunload = function(){ return "Leaving this page may cause loss of your code!"; }; } window.onload=function(){ moedomain.init(); setclock(); return false; } //设置时钟 function setclock(){ if(!window.clockthread){ window.clockthread={}; window.clockthread.step=0; window.clockthread.targetx=0; window.clockthread.targety=0; window.clockthread.flag = $('.moe-clock').length>0?true:false; window.clockthread.func = window.clockthread.flag?setInterval(function(){ moeclock() }, 500):new function(){}; window.clockthread.func2 = window.clockthread.flag?setInterval(function(){ anime3dRotate() }, 500):new function(){}; $("#btn-clock a").html('The World!'); }else{ if(window.clockthread.flag){ clearInterval(window.clockthread.func); clearInterval(window.clockthread.func2); window.clockthread.func={}; window.clockthread.func2={}; window.clockthread.step=0; window.clockthread.targetx=0; window.clockthread.targety=0; window.clockthread.flag = false; $("#btn-clock a").html('启动时钟'); }else{ window.clockthread.step=0; window.clockthread.targetx=0; window.clockthread.targety=0; window.clockthread.flag = $('.moe-clock').length>0?true:false; window.clockthread.func = window.clockthread.flag?setInterval(function(){ moeclock() }, 500):new function(){}; window.clockthread.func2 = window.clockthread.flag?setInterval(function(){ anime3dRotate() }, 500):new function(){}; $("#btn-clock a").html('The World!'); } } } //简单动画 function anime3dRotate(){ var step = window.clockthread.step>=25?50 - (window.clockthread.step):window.clockthread.step; if(window.clockthread.step>=50){ window.clockthread.step=0; var tgx = Math.random()*(Math.random()>0.5?1:-1); var tgy =Math.random()*(Math.random()>0.5?1:-1); window.clockthread.ag = 50 * Math.PI / 180; window.clockthread.sc =Math.sin(window.clockthread.ag/2)*Math.cos(window.clockthread.ag/2); window.clockthread.sq =Math.sin(window.clockthread.ag/2)*Math.sin(window.clockthread.ag/2); window.clockthread.targetx= tgx>0?(tgx<0.5?tgx+0.5:tgx):(tgx>-0.5?tgx-0.5:tgx); window.clockthread.targety= tgy>0?(tgy<0.5?tgy+0.5:tgy):(tgy>-0.5?tgy-0.5:tgy); return; } var x =step * window.clockthread.targetx / 20; var y =step * window.clockthread.targety / 20; var z = 0; var ag = window.clockthread.ag; var sc =window.clockthread.sc; var sq =window.clockthread.sq; var tsf = "matrix3d("; tsf+=(1-2*(y*y+z*z)*sq)+","+2*(x*y*sq-z*sc)+","+2*(x*z*sq+y*sc)+",0,"; tsf+=2*(x*y*sq+z*sc)+","+(1-2*(x*x+z*z)*sq)+","+2*(y*z*sq-x*sc)+",0,"; tsf+=2*(x*z*sq-y*sc)+","+2*(y*z*sq+x*sc)+","+(1-2*(x*x+y*y)*sq)+",0,"; tsf+="0,0,0,1)"; $('.moe-clock-main').css("transform",tsf); window.clockthread.step++; } //调整时刻 function moeclock(){ if(!window.clockthread.flag){return;} $('.moe-clock-hands-hour').each(function(){ var mydate = new Date(); var deg = mydate.getHours()*30 + mydate.getMinutes()*0.5; $(this).css('transform',setRotate(deg)); }); $('.moe-clock-hands-minute').each(function(){ var mydate = new Date(); var deg = mydate.getMinutes()*6 + mydate.getSeconds()*0.1; $(this).css('transform',setRotate(deg)); }); $('.moe-clock-hands-second').each(function(){ var mydate = new Date(); var deg = mydate.getSeconds()*6; $(this).css('transform',setRotate(deg)); }); } //设置矩阵 function setRotate(deg){ var cosv = Math.cos(deg * Math.PI / 180) var sinv = Math.sin(deg * Math.PI / 180); var tsf = 'matrix('; tsf +=cosv.toFixed(6)+","; tsf +=sinv.toFixed(6)+","; tsf +=(-1 * sinv).toFixed(6)+","; tsf +=cosv.toFixed(6)+","; tsf +="0,0)"; return tsf; } function iFunc(){ this.main=function(methodName){this.data=methodName; if(typeof this[methodName]=="function"){ this.func=eval("this."+methodName+"()"); }else{console.log('不存在的方法。');}}; this.text=function(){console.log('text');}; } function mycode(){ this.data="data:null;"; this.getdata=function(){return this.data;} this.setdata=function(data){this.data=data;} this.type=function(){console.log(this.getdata());} this.main=function(index){ this.data[index].getmore(index); }; this.getmore=function(index,e){ $.ajax( { url: 'https://zh.moegirl.org/api.php', data: {action: 'parse',format: 'json',title:'预览',text:this.data}, dataType: 'json', type: 'POST', headers: { 'Api-User-Agent': 'Example/1.0' }, success: function(data) { var req = data.parse.text['*'].replace(/\n<!--((.*)|(\n))*?-->\n/g,''); $('.moe-domain:eq('+index+')').append(req); //$(req).insertBefore(e); //console.log(e); //console.log(req); if ($('.mw-collapsible')[0]) mw.loader.using('jquery.makeCollapsible').then(function() { //console.debug('jquery.makeCollapsible is loaded.'); $('.mw-collapsible').makeCollapsible(); }); }, error: function( xhr ) { alert( 'Error: Request failed.' ); } });} } function codedomain(){ this.data=[]; this.init=function(){ var pickdata=this.data; $('.moe-domain .moe-content').each(function(index,obj){ var item = new mycode(); item.setdata($(obj).html().replace(/</g,'<').replace(/>/g,'>'));//no"//"surport pickdata[pickdata.length]=item; $(obj).parent().append(newitem('input','button','查看更多','moedomain.main('+index+')')); }); }; this.main=function(index){ this.data[index].getmore(index,event.target); }; } function newitem(type1,type2,name,func){ var item = document.createElement(type1); item.setAttribute('type',type2); item.setAttribute('value',name); item.setAttribute('onclick',func); return item; } window.moedomain=new codedomain();