No edit summary Tag: sourceedit |
No edit summary Tag: sourceedit |
||
Line 55: | Line 55: | ||
}); |
}); |
||
+ | /* Special Pages will have special imports */ |
||
− | /* Check if # number is a prime number |
||
− | DEFUNCT. |
||
− | |||
− | function calculate(form) { |
||
− | var num = form.number.value; |
||
− | num = num.replace(/\,/g,''); |
||
− | num = parseInt(num,10); |
||
− | var prime; |
||
− | var x=Math.sqrt(num)+1; |
||
− | if (isNaN(num) || num < 0) { |
||
− | form.result.value=(form.number.value + " is not a valid number! Try again!"); |
||
− | return; |
||
− | } |
||
− | if (num === 0) { |
||
− | form.result.value=("Uh......are you sure about number 0?"); |
||
− | return; |
||
− | } |
||
− | if (num == 1) { |
||
− | form.result.value=("1 is not prime by definition. It has only 1 factor."); |
||
− | return; |
||
− | } |
||
− | if (num == 2) { |
||
− | form.result.value=("2 is a prime number! The only even one, sadly."); |
||
− | return; |
||
− | } |
||
− | if (num == 3) { |
||
− | form.result.value=("3 is a prime number! It's 3primetime3's favorite prime!"); |
||
− | return; |
||
− | } |
||
− | if (num == 37) { |
||
− | form.result.value=("You found an easter egg! It's Blueeighthnote's favorite prime!"); |
||
− | return; |
||
− | } |
||
− | if (num == 83) { |
||
− | form.result.value=("83 is a prime number! It's Minipop56's favorite prime!"); |
||
− | return; |
||
− | } |
||
− | for (var i=2;i<=x;i++) { |
||
− | if (num % i === 0) { |
||
− | prime="yes"; |
||
− | form.result.value=(num + " is not prime. It is divisible by " + i + "."); |
||
− | break; |
||
− | } |
||
− | if (num % i !== 0) prime="no"; |
||
− | } |
||
− | if (prime == "no") form.result.value=(num + " is prime!"); |
||
− | } |
||
+ | wgPageName === 'User:Blueeighthnote/PrimeTest' && importScript('MediaWiki:PrimeTest.js'); |
||
− | */ |
Revision as of 10:19, 3 August 2016
/* Any JavaScript here will be loaded for all users on every page load. */
/* Borrowed from Candy Crush Saga Wiki
Replaces {{USERNAME}} with the name of the user browsing the page.
Requires copying Template:USERNAME. */
$(function(){
toggle();
if (window.disableUsernameReplace || mw.config.get('wgUserName') === null) return;
$('span.insertusername').html(mw.config.get('wgUserName'));
});
/* End of the {{USERNAME}} replacement */
/* This is the toggle button javascript*/
function toggle(){
$('.toggle').each(function(){
var s = $('<div>').addClass('toggleBtn').appendTo(this), t = $(this).data({state:true, drag:false}), c = function(){
var v = t.data('drag') ? s.position().left>t.width()/4 : t.data('state'), u = v==t.data('state');
s.animate({left:v?t.width()/2-1:-1});
$(document).off('.toggle');
t.data({state:!v, drag:false});
if(u) t.trigger('change',[!v]);
};
$(this).on('click',function(){c();});
s.on('mousedown',function(e){
var x = e.pageX, o = s.position().left;
e.preventDefault();
$(document).on('mousemove.toggle',function(e){
if(e.pageX-x > 1) t.data('drag',true);
s.css('left',Math.max(-1,Math.min(e.pageX-x+o,t.width()/2-1)));
}).one('mouseup',function(){c();});
}).on('click',function(e){e.stopPropagation();});
});
}
/* Toggling the toggle. Credits to http://zh.tos.wikia.com */
$(function() {
$('.skill_toggle').add($('.toggleBtn')).click(function(){
tmp1 = $(this).parent().parent().parent().parent().find('.note').not(':hidden');
tmp2 = $(this).parent().parent().parent().parent().find('.note:hidden');
tmp1.hide();
tmp2.show();
});
});
/* Importing codes for 4th and 5th navigation extensions and Tooltips */
importArticles({
type: 'script',
articles: [
'u:dev:ExtendedNavigation/code.js',
'u:dev:Tooltips/code.js'
]
});
/* Special Pages will have special imports */
wgPageName === 'User:Blueeighthnote/PrimeTest' && importScript('MediaWiki:PrimeTest.js');