User:小躍/MathChallenge/MathChallenge.js
< User:小躍 | MathChallenge
注意:保存之后,你必须清除浏览器缓存才能看到做出的更改。Google Chrome、Firefox、Microsoft Edge及Safari:按住⇧ Shift键并单击工具栏的“刷新”按钮。参阅Help:绕过浏览器缓存以获取更多帮助。
/*
版本:0.0.0 繁體中文版
開發者:小躍
*/
if (mw.config.get('wgAction') == 'view' && mw.config.get('wgPageName') =='User:小躍/MathChallenge'){
document.getElementById('MathPlayingScreen').innerHTML = '您已成功載入腳本。'+'<input id="wpMathPlayingSureUser" value="確認身分" title="開始確認您的身分" type="button"/>';
document.getElementById('MathPlayingScreen2').innerHTML ='咱們一起突破重重的關卡吧!';
$('#wpMathPlayingSureUser').click(MathPlayingSureUser);
}
function MathPlayingSureUser(event) {
event.preventDefault();
var confirm_a=confirm('您的身分是'+wgUserName+'嗎?');
switch(confirm_a){
case true:{
document.getElementById('MathPlayingScreen').innerHTML ='<img src="http://upload.wikimedia.org/wikipedia/commons/4/42/Loading.gif" />'+wgUserName+
'您好,歡迎進入挑戰數學的遊戲畫面。<br/><img src="http://upload.wikimedia.org/wikipedia/commons/8/85/MathChallengePlayingStart.png" /><br/>';
document.getElementById('MathPlayingScreen2').innerHTML =MathPlayingItems;
if (wgAction == 'view' && mw.config.get('wgPageName') =='User:小躍/MathChallenge'){
window.onbeforeunload = function(){
window.event.returnValue ='';
};
}
$('#wpMathPlayingDetermineL1').click(function(){
Determine_q=0;
Determine_score=0;
Determine_ctime=0;
}).click(MathPlayingDetermineL1).click(MathPlayingDetermineTimeout);
$('#wpMathPlayingDetermineL2').click(function(){
Determine_q=0;
Determine_score=0;
Determine_ctime=0;
}).click(MathPlayingDetermineL2).click(MathPlayingDetermineTimeout);
$('#wpMathPlayingDetermineL3').click(function(){
Determine_q=0;
Determine_score=0;
Determine_ctime=0;
}).click(MathPlayingDetermineL3).click(MathPlayingDetermineTimeout);
$('#wpMathPlayingDetermineL4').click(function(){
Determine_q=0;
Determine_score=0;
Determine_ctime=0;
}).click(MathPlayingDetermineL4).click(MathPlayingDetermineTimeout);
$('#wpMathPlayingDetermineL5').click(function(){
Determine_q=0;
Determine_score=0;
Determine_ctime=0;
}).click(MathPlayingDetermineL5).click(MathPlayingDetermineTimeout);
break;
}
case false:{
document.getElementById('MathPlayingScreen').innerHTML ='<img src="https://upload.wikimedia.org/wikipedia/commons/c/ca/Crystal_error.png" />您已取消確認身分的程序。';
break;
}
}
}
var Determine_q;
var Determine_score;
var Determine_time;
var Determine_ctime;
var Determine_T;
var Determine1,Determine2,Determine3,Determine4;
var MathPlayingItems;
MathPlayingItems='選擇遊戲項目:<ul><li><input id="wpMathPlayingDetermineL1" value="第一階判斷" title="判斷大於、小於還是等於" type="button"/></li>'+
'<li><input id="wpMathPlayingDetermineL2" value="第二階判斷" title="判斷大於、小於還是等於" type="button"/></li>'+
'<li><input id="wpMathPlayingDetermineL3" value="第三階判斷" title="判斷大於、小於還是等於" type="button"/></li>'+
'<li><input id="wpMathPlayingDetermineL4" value="第四階判斷" title="判斷大於、小於還是等於" type="button"/></li>'+
'<li><input id="wpMathPlayingDetermineL5" value="第五階判斷" title="判斷大於、小於還是等於" type="button"/></li>'+
'</ul>';
function MathPlayingDetermineTimeout(){
$(document).ready(function() {
Determine_ctime=Determine_ctime+(0.01);
Determine_T=setTimeout("MathPlayingDetermineTimeout()",10);
});
}
function MathPlayingDetermineL1(event){
event.preventDefault();
Determine_time=Math.floor(Determine_ctime *100)/100;
document.getElementById('MathPlayingScreenShow').innerHTML ='使用時間:'+Determine_time+'秒,累計答對題數:'+Determine_score;
switch(Determine_q){
case 10:{
clearTimeout(Determine_T);
document.getElementById('MathPlayingScreen2').innerHTML ='<center><font size="45">題數已用完。</font><br/><input id="wpMathPlayingBack" value="返回" type="button"/></center>';
$('#wpMathPlayingBack').click(MathPlayingItem);
break;
}
default:{
++Determine_q;
Determine1=Math.floor(Math.random() *10);
Determine2=Math.floor(Math.random() *10);
document.getElementById('MathPlayingScreen2').innerHTML ='<center>第'+Determine_q+'題<br/><font size="45">'+Determine1.toString()+'<img src="http://upload.wikimedia.org/wikipedia/commons/c/cd/Chess_l45.svg" />'+Determine2.toString()+'</font><br/>'+
'<input id="wpMathPlayingDetermineBigger" value="大於" type="button"/><input id="wpMathPlayingDetermineSmaller" value="小於" type="button"/><input id="wpMathPlayingDetermineEqual" value="等於" type="button"/><br/><img src="http://3.bp.blogspot.com/_BxnVmGrZndM/THuqMI4dRaI/AAAAAAAABj0/iqjuTE10eE8/s1600/%C3%A5%E2%80%B9%E2%80%A2%C3%A7%E2%80%A2%C2%AB.gif" width="300"/></center>';
$('#wpMathPlayingDetermineBigger').click(function(){
(Determine1>Determine2)?Determine_score=Determine_score+1:Determine_score=Determine_score+0;
}).click(MathPlayingDetermineL1);
$('#wpMathPlayingDetermineSmaller').click(function(){
(Determine1<Determine2)?Determine_score=Determine_score+1:Determine_score=Determine_score+0;
}).click(MathPlayingDetermineL1);
$('#wpMathPlayingDetermineEqual').click(function(){
(Determine1==Determine2)?Determine_score=Determine_score+1:Determine_score=Determine_score+0;
}).click(MathPlayingDetermineL1);
break;
}
}//switch end
}
function MathPlayingDetermineL2(event){
event.preventDefault();
Determine_time=Math.floor(Determine_ctime *100)/100;
document.getElementById('MathPlayingScreenShow').innerHTML ='使用時間:'+Determine_time+'秒,累計答對題數:'+Determine_score;
switch(Determine_q){
case 10:{
clearTimeout(Determine_T);
document.getElementById('MathPlayingScreen2').innerHTML ='<center><font size="45">題數已用完。</font><br/><input id="wpMathPlayingBack2" value="返回" type="button"/></center>';
$('#wpMathPlayingBack2').click(MathPlayingItem);
break;
}
default:{
++Determine_q;
Determine1=1+Math.floor(Math.random() *9);
Determine2=1+Math.floor(Math.random() *9);
Determine3=1+Math.floor(Math.random() *9);
Determine4=1+Math.floor(Math.random() *9);
document.getElementById('MathPlayingScreen2').innerHTML ='<center>第'+Determine_q+'題<br/><font size="45">'+Determine1.toString()+'+'+Determine2.toString()+'<img src="http://upload.wikimedia.org/wikipedia/commons/c/cd/Chess_l45.svg" />'+Determine3.toString()+'+'+Determine4.toString()+'</font><br/>'+
'<input id="wpMathPlayingDetermineBigger2" value="大於" type="button"/><input id="wpMathPlayingDetermineSmaller2" value="小於" type="button"/><input id="wpMathPlayingDetermineEqual2" value="等於" type="button"/><br/><img src="http://3.bp.blogspot.com/_BxnVmGrZndM/THuqMI4dRaI/AAAAAAAABj0/iqjuTE10eE8/s1600/%C3%A5%E2%80%B9%E2%80%A2%C3%A7%E2%80%A2%C2%AB.gif" width="300"/></center>';
$('#wpMathPlayingDetermineBigger2').click(function(){
(Determine1+Determine2>Determine3+Determine4)?Determine_score=Determine_score+1:Determine_score=Determine_score+0;
}).click(MathPlayingDetermineL2);
$('#wpMathPlayingDetermineSmaller2').click(function(){
(Determine1+Determine2<Determine3+Determine4)?Determine_score=Determine_score+1:Determine_score=Determine_score+0;
}).click(MathPlayingDetermineL2);
$('#wpMathPlayingDetermineEqual2').click(function(){
(Determine1+Determine2==Determine3+Determine4)?Determine_score=Determine_score+1:Determine_score=Determine_score+0;
}).click(MathPlayingDetermineL2);
break;
}
}//switch end
}
function MathPlayingDetermineL3(event){
event.preventDefault();
Determine_time=Math.floor(Determine_ctime *100)/100;
document.getElementById('MathPlayingScreenShow').innerHTML ='使用時間:'+Determine_time+'秒,累計答對題數:'+Determine_score;
switch(Determine_q){
case 10:{
clearTimeout(Determine_T);
document.getElementById('MathPlayingScreen2').innerHTML ='<center><font size="45">題數已用完。</font><br/><input id="wpMathPlayingBack3" value="返回" type="button"/></center>';
$('#wpMathPlayingBack3').click(MathPlayingItem);
break;
}
default:{
++Determine_q;
Determine1=1+Math.floor(Math.random() *9);
Determine2=1+Math.floor(Math.random() *9);
Determine3=1+Math.floor(Math.random() *9);
Determine4=1+Math.floor(Math.random() *9);
document.getElementById('MathPlayingScreen2').innerHTML ='<center>第'+Determine_q+'題<br/><font size="45">'+Determine1.toString()+'×'+Determine2.toString()+'<img src="http://upload.wikimedia.org/wikipedia/commons/c/cd/Chess_l45.svg" />'+Determine3.toString()+'×'+Determine4.toString()+'</font><br/>'+
'<input id="wpMathPlayingDetermineBigger3" value="大於" type="button"/><input id="wpMathPlayingDetermineSmaller3" value="小於" type="button"/><input id="wpMathPlayingDetermineEqual3" value="等於" type="button"/><br/><img src="http://3.bp.blogspot.com/_BxnVmGrZndM/THuqMI4dRaI/AAAAAAAABj0/iqjuTE10eE8/s1600/%C3%A5%E2%80%B9%E2%80%A2%C3%A7%E2%80%A2%C2%AB.gif" width="300"/></center>';
$('#wpMathPlayingDetermineBigger3').click(function(){
(Determine1*Determine2>Determine3*Determine4)?Determine_score=Determine_score+1:Determine_score=Determine_score+0;
}).click(MathPlayingDetermineL3);
$('#wpMathPlayingDetermineSmaller3').click(function(){
(Determine1*Determine2<Determine3*Determine4)?Determine_score=Determine_score+1:Determine_score=Determine_score+0;
}).click(MathPlayingDetermineL3);
$('#wpMathPlayingDetermineEqual3').click(function(){
(Determine1*Determine2==Determine3*Determine4)?Determine_score=Determine_score+1:Determine_score=Determine_score+0;
}).click(MathPlayingDetermineL3);
break;
}
}//switch end
}
function MathPlayingDetermineL4(event){
event.preventDefault();
Determine_time=Math.floor(Determine_ctime *100)/100;
document.getElementById('MathPlayingScreenShow').innerHTML ='使用時間:'+Determine_time+'秒,累計答對題數:'+Determine_score;
switch(Determine_q){
case 10:{
clearTimeout(Determine_T);
document.getElementById('MathPlayingScreen2').innerHTML ='<center><font size="45">題數已用完。</font><br/><input id="wpMathPlayingBack4" value="返回" type="button"/></center>';
$('#wpMathPlayingBack4').click(MathPlayingItem);
break;
}
default:{
++Determine_q;
Determine1=1+Math.floor(Math.random() *9);
Determine2=1+Math.floor(Math.random() *9);
Determine3=1+Math.floor(Math.random() *9);
Determine4=1+Math.floor(Math.random() *9);
document.getElementById('MathPlayingScreen2').innerHTML ='<center>第'+Determine_q+'題<br/><font size="45">log '+Determine1.toString()+'+ log '+Determine2.toString()+'<img src="http://upload.wikimedia.org/wikipedia/commons/c/cd/Chess_l45.svg" /> log '+Determine3.toString()+'+log '+Determine4.toString()+'</font><br/>'+
'<input id="wpMathPlayingDetermineBigger4" value="大於" type="button"/><input id="wpMathPlayingDetermineSmaller4" value="小於" type="button"/><input id="wpMathPlayingDetermineEqual4" value="等於" type="button"/><br/><img src="http://3.bp.blogspot.com/_BxnVmGrZndM/THuqMI4dRaI/AAAAAAAABj0/iqjuTE10eE8/s1600/%C3%A5%E2%80%B9%E2%80%A2%C3%A7%E2%80%A2%C2%AB.gif" width="300"/></center>';
$('#wpMathPlayingDetermineBigger4').click(function(){
(Math.log10(Determine1)+Math.log10(Determine2)>Math.log10(Determine3)+Math.log10(Determine4))?Determine_score=Determine_score+1:Determine_score=Determine_score+0;
}).click(MathPlayingDetermineL4);
$('#wpMathPlayingDetermineSmaller4').click(function(){
(Math.log10(Determine1)+Math.log10(Determine2)<Math.log10(Determine3)+Math.log10(Determine4))?Determine_score=Determine_score+1:Determine_score=Determine_score+0;
}).click(MathPlayingDetermineL4);
$('#wpMathPlayingDetermineEqual4').click(function(){
(Math.log10(Determine1)+Math.log10(Determine2)==Math.log10(Determine3)+Math.log10(Determine4))?Determine_score=Determine_score+1:Determine_score=Determine_score+0;
}).click(MathPlayingDetermineL4);
break;
}
}//switch end
}
function MathPlayingDetermineL5(event){
event.preventDefault();
Determine_time=Math.floor(Determine_ctime *100)/100;
document.getElementById('MathPlayingScreenShow').innerHTML ='使用時間:'+Determine_time+'秒,累計答對題數:'+Determine_score;
switch(Determine_q){
case 10:{
clearTimeout(Determine_T);
document.getElementById('MathPlayingScreen2').innerHTML ='<center><font size="45">題數已用完。</font><br/><input id="wpMathPlayingBack5" value="返回" type="button"/></center>';
$('#wpMathPlayingBack5').click(MathPlayingItem);
break;
}
default:{
++Determine_q;
Determine1=2+Math.floor(Math.random() *9);
Determine2=2+Math.floor(Math.random() *9);
Determine3=2+Math.floor(Math.random() *9);
Determine4=2+Math.floor(Math.random() *9);
document.getElementById('MathPlayingScreen2').innerHTML ='<center>第'+Determine_q+'題<br/><font size="45">'+Determine1.toString()+'<sup>2</sup>+'+Determine2.toString()+'<sup>2</sup><img src="http://upload.wikimedia.org/wikipedia/commons/c/cd/Chess_l45.svg" />'+Determine3.toString()+'<sup>2</sup>+'+Determine4.toString()+'<sup>2</sup></font><br/>'+
'<input id="wpMathPlayingDetermineBigger5" value="大於" type="button"/><input id="wpMathPlayingDetermineSmaller5" value="小於" type="button"/><input id="wpMathPlayingDetermineEqual5" value="等於" type="button"/><br/><img src="http://3.bp.blogspot.com/_BxnVmGrZndM/THuqMI4dRaI/AAAAAAAABj0/iqjuTE10eE8/s1600/%C3%A5%E2%80%B9%E2%80%A2%C3%A7%E2%80%A2%C2%AB.gif" width="300"/></center>';
$('#wpMathPlayingDetermineBigger5').click(function(){
(Math.pow(Determine1,2)+Math.pow(Determine2,2)>Math.pow(Determine3,2)+Math.pow(Determine4,2))?Determine_score=Determine_score+1:Determine_score=Determine_score+0;
}).click(MathPlayingDetermineL5);
$('#wpMathPlayingDetermineSmaller5').click(function(){
(Math.pow(Determine1,2)+Math.pow(Determine2,2)<Math.pow(Determine3,2)+Math.pow(Determine4,2))?Determine_score=Determine_score+1:Determine_score=Determine_score+0;
}).click(MathPlayingDetermineL5);
$('#wpMathPlayingDetermineEqual5').click(function(){
(Math.pow(Determine1,2)+Math.pow(Determine2,2)==Math.pow(Determine3,2)+Math.pow(Determine4,2))?Determine_score=Determine_score+1:Determine_score=Determine_score+0;
}).click(MathPlayingDetermineL5);
break;
}
}//switch end
}
function MathPlayingItem(event){
event.preventDefault();
document.getElementById('MathPlayingScreen2').innerHTML =MathPlayingItems;
$('#wpMathPlayingDetermineL1').click(function(){
Determine_q=0;
Determine_score=0;
Determine_ctime=0;
}).click(MathPlayingDetermineL1).click(MathPlayingDetermineTimeout);
$('#wpMathPlayingDetermineL2').click(function(){
Determine_q=0;
Determine_score=0;
Determine_ctime=0;
}).click(MathPlayingDetermineL2).click(MathPlayingDetermineTimeout);
$('#wpMathPlayingDetermineL3').click(function(){
Determine_q=0;
Determine_score=0;
Determine_ctime=0;
}).click(MathPlayingDetermineL3).click(MathPlayingDetermineTimeout);
$('#wpMathPlayingDetermineL4').click(function(){
Determine_q=0;
Determine_score=0;
Determine_ctime=0;
}).click(MathPlayingDetermineL4).click(MathPlayingDetermineTimeout);
$('#wpMathPlayingDetermineL5').click(function(){
Determine_q=0;
Determine_score=0;
Determine_ctime=0;
}).click(MathPlayingDetermineL5).click(MathPlayingDetermineTimeout);
}