MediaWiki:Common.js: различия между версиями
Перейти к навигации
Перейти к поиску
Relax (обсуждение | вклад) |
SupaFly (обсуждение | вклад) |
||
| Строка 230: | Строка 230: | ||
importScriptURI('http://ru.wikipedia.org/w/index.php?title=MediaWiki:Wikificator.js&action=raw&ctype=text/javascript') | importScriptURI('http://ru.wikipedia.org/w/index.php?title=MediaWiki:Wikificator.js&action=raw&ctype=text/javascript') | ||
addOnloadHook(addWikifButton) | addOnloadHook(addWikifButton) | ||
| + | } | ||
| + | |||
| + | |||
| + | // кальк1 | ||
| + | function snature() | ||
| + | { | ||
| + | init_c1(); | ||
| + | nX = document.getElementById('Xnature').selectedIndex; | ||
| + | natureX = document.getElementById('Xnature'); | ||
| + | convert_nature(natureX.options[nX].value); | ||
| + | fido(); | ||
| + | |||
| + | } | ||
| + | |||
| + | |||
| + | function init_c1() | ||
| + | { | ||
| + | //---------------------------------[ INIT PARAM #1]------------------------------------| | ||
| + | n2 = document.getElementById('nature2').selectedIndex; n3 = document.getElementById('nature3').selectedIndex; | ||
| + | n4 = document.getElementById('nature4').selectedIndex; n5 = document.getElementById('nature5').selectedIndex; n6 = document.getElementById('nature6').selectedIndex; | ||
| + | |||
| + | maxivHP = document.getElementById('maxiv1'); maxivAT = document.getElementById('maxiv2'); maxivDEF = document.getElementById('maxiv3'); | ||
| + | maxivSP = document.getElementById('maxiv4'); maxivSPECAT = document.getElementById('maxiv5'); maxivSPECDEF = document.getElementById('maxiv6'); | ||
| + | lvlIDX = document.getElementById('lvl'); | ||
| + | minivHP = document.getElementById('miniv1'); minivAT = document.getElementById('miniv2'); minivDEF = document.getElementById('miniv3'); | ||
| + | minivSP = document.getElementById('miniv4'); minivSPECAT = document.getElementById('miniv5'); minivSPECDEF = document.getElementById('miniv6'); | ||
| + | statHP = document.getElementById('stat1'); baseHP = document.getElementById('base1'); evHP = document.getElementById('ev1'); | ||
| + | statAT = document.getElementById('stat2'); natureAT = document.getElementById('nature2'); baseAT = document.getElementById('base2'); evAT = document.getElementById('ev2'); | ||
| + | statDEF = document.getElementById('stat3'); natureDEF = document.getElementById('nature3'); baseDEF = document.getElementById('base3'); evDEF = document.getElementById('ev3'); | ||
| + | statSP = document.getElementById('stat4'); natureSP = document.getElementById('nature4'); baseSP = document.getElementById('base4'); evSP = document.getElementById('ev4'); | ||
| + | statSPECAT = document.getElementById('stat5'); natureSPECAT = document.getElementById('nature5'); baseSPECAT = document.getElementById('base5'); evSPECAT = document.getElementById('ev5'); | ||
| + | statSPECDEF = document.getElementById('stat6'); natureSPECDEF = document.getElementById('nature6'); baseSPECDEF = document.getElementById('base6'); evSPECDEF = document.getElementById('ev6'); | ||
| + | } | ||
| + | |||
| + | function fido() | ||
| + | { | ||
| + | init_c1(); | ||
| + | //ОКРУГЛВНИЗ(100*(текущий стат-9,5-левел)/левел-базовый стат*2-ОКРВНИЗ(ев/2;1)-0,0001;0) - max hp iv | ||
| + | //ОКРУГЛВНИЗ(100 * ( (текущий стат +1) / характер-5) / левел - базовый стат * 2 - ОКРУГЛВНИЗ(ев/2;1) -0,0001) - max iv | ||
| + | //ОКРУГЛВВЕРХ(100*(текущий стат-10,5-левел)/левел-базовый стат*2 -ОКРВНИЗ(ев/2;1);0) - min hp iv | ||
| + | //ОКРУГЛВВЕРХ(100*(текущий стат/характер-5)/левел - базовый стат * 2 - ОКРВНИЗ(ев/2;1);0) - min iv | ||
| + | if(lvlIDX.value != ''){ | ||
| + | //------------------------------------[ FORMULE CALCULATOR #1]--------------------------------------| | ||
| + | maxivHP.value = Math.floor(100*(statHP.value-9.5-lvlIDX.value)/lvlIDX.value-(baseHP.value*2)-Math.floor(evHP.value/2)-0.0001); | ||
| + | maxivAT.value = Math.floor(100*((statAT.value-(-1))/natureAT.options[n2].value-5)/lvlIDX.value-(baseAT.value*2)-Math.floor(evAT.value/2)-0.0001); | ||
| + | maxivDEF.value = Math.floor(100*((statDEF.value-(-1))/natureDEF.options[n3].value-5)/lvlIDX.value-(baseDEF.value*2)-Math.floor(evDEF.value/2)-0.0001); | ||
| + | maxivSP.value = Math.floor(100*((statSP.value-(-1))/natureSP.options[n4].value-5)/lvlIDX.value-(baseSP.value*2)-Math.floor(evSP.value/2)-0.0001); | ||
| + | maxivSPECAT.value = Math.floor(100*((statSPECAT.value-(-1))/natureSPECAT.options[n5].value-5)/lvlIDX.value-(baseSPECAT.value*2)-Math.floor(evSPECAT.value/2)-0.0001); | ||
| + | maxivSPECDEF.value = Math.floor(100*((statSPECDEF.value-(-1))/natureSPECDEF.options[n6].value-5)/lvlIDX.value-(baseSPECDEF.value*2)-Math.floor(evSPECDEF.value/2)-0.0001); | ||
| + | maxivHP.innerHTML = maxivHP.value; maxivAT.innerHTML = maxivAT.value; maxivDEF.innerHTML = maxivDEF.value; | ||
| + | maxivSP.innerHTML = maxivSP.value; maxivSPECAT.innerHTML = maxivSPECAT.value; maxivSPECDEF.innerHTML = maxivSPECDEF.value; | ||
| + | // | ||
| + | minivHP.value = Math.ceil(100*(statHP.value-10.5-lvlIDX.value)/lvlIDX.value-(baseHP.value*2)-Math.floor(evHP.value/2)); | ||
| + | minivAT.value = Math.ceil(100*(statAT.value/natureAT.options[n2].value-5)/lvlIDX.value-(baseAT.value*2)-Math.floor(evAT.value/2)); | ||
| + | minivDEF.value = Math.ceil(100*(statDEF.value/natureDEF.options[n3].value-5)/lvlIDX.value-(baseDEF.value*2)-Math.floor(evDEF.value/2)); | ||
| + | minivSP.value = Math.ceil(100*(statSP.value/natureSP.options[n4].value-5)/lvlIDX.value-(baseSP.value*2)-Math.floor(evSP.value/2)); | ||
| + | minivSPECAT.value = Math.ceil(100*(statSPECAT.value/natureSPECAT.options[n5].value-5)/lvlIDX.value-(baseSPECAT.value*2)-Math.floor(evSPECAT.value/2)); | ||
| + | minivSPECDEF.value = Math.ceil(100*(statSPECDEF.value/natureSPECDEF.options[n6].value-5)/lvlIDX.value-(baseSPECDEF.value*2)-Math.floor(evSPECDEF.value/2)); | ||
| + | minivHP.innerHTML = minivHP.value; minivAT.innerHTML = minivAT.value; minivDEF.innerHTML = minivDEF.value; | ||
| + | minivSP.innerHTML = minivSP.value; minivSPECAT.innerHTML = minivSPECAT.value; minivSPECDEF.innerHTML = minivSPECDEF.value; | ||
| + | } | ||
| + | } | ||
| + | |||
| + | function fido2() | ||
| + | { | ||
| + | //---------------------------------[ INIT PARAM #2]------------------------------------| | ||
| + | c2 = document.getElementById('nature_2').selectedIndex; c3 = document.getElementById('nature_3').selectedIndex; | ||
| + | c4 = document.getElementById('nature_4').selectedIndex; c5 = document.getElementById('nature_5').selectedIndex; c6 = document.getElementById('nature_6').selectedIndex; | ||
| + | iv_HP = document.getElementById('iv_1'); iv_AT = document.getElementById('iv_2'); iv_DEF = document.getElementById('iv_3'); | ||
| + | iv_SP = document.getElementById('iv_4'); iv_SPECAT = document.getElementById('iv_5'); iv_SPECDEF = document.getElementById('iv_6'); | ||
| + | lvl_IDX = document.getElementById('lvl_1'); | ||
| + | /*Trainings */ | ||
| + | tr2 = document.getElementById('tren_2').selectedIndex; tr3 = document.getElementById('tren_3').selectedIndex; | ||
| + | tr4 = document.getElementById('tren_4').selectedIndex; tr5 = document.getElementById('tren_5').selectedIndex; | ||
| + | tr6 = document.getElementById('tren_6').selectedIndex; tr_AT = document.getElementById('tren_2'); | ||
| + | tr_DEF = document.getElementById('tren_3'); tr_SP = document.getElementById('tren_4'); tr_SPECAT = document.getElementById('tren_5'); | ||
| + | tr_SPECDEF = document.getElementById('tren_6'); | ||
| + | |||
| + | stat_HP = document.getElementById('stat_1'); base_HP = document.getElementById('base_1'); ev_HP = document.getElementById('ev_1'); | ||
| + | stat_AT = document.getElementById('stat_2'); nature_AT = document.getElementById('nature_2'); base_AT = document.getElementById('base_2'); ev_AT = document.getElementById('ev_2'); | ||
| + | stat_DEF = document.getElementById('stat_3'); nature_DEF = document.getElementById('nature_3'); base_DEF = document.getElementById('base_3'); ev_DEF = document.getElementById('ev_3'); | ||
| + | stat_SP = document.getElementById('stat_4'); nature_SP = document.getElementById('nature_4'); base_SP = document.getElementById('base_4'); ev_SP = document.getElementById('ev_4'); | ||
| + | stat_SPECAT = document.getElementById('stat_5'); nature_SPECAT = document.getElementById('nature_5'); base_SPECAT = document.getElementById('base_5'); ev_SPECAT = document.getElementById('ev_5'); | ||
| + | stat_SPECDEF = document.getElementById('stat_6'); nature_SPECDEF = document.getElementById('nature_6'); base_SPECDEF = document.getElementById('base_6'); ev_SPECDEF = document.getElementById('ev_6'); | ||
| + | //ОКРУГЛ((базовый стат*2+ген+ОКРВНИЗ(ев/2;1))*уровень/100+10+уровень;0) - hp | ||
| + | //ОКРВНИЗ(((базовый стат*2+ген+ОКРВНИЗ(ев/2;1))*уровень/100+5)*характер;1) - stats | ||
| + | if(lvl_IDX.value != ''){ | ||
| + | //------------------------------------[ FORMULE CALCULATOR #2]--------------------------------------| | ||
| + | stat_HP.value = Math.round((base_HP.value*2-(-iv_HP.value)+Math.floor(ev_HP.value/2))*lvl_IDX.value/100+10-(-lvl_IDX.value)); | ||
| + | stat_AT.value = Math.floor(((base_AT.value*2-(-iv_AT.value)+Math.floor(ev_AT.value/2))*lvl_IDX.value/100+5)*nature_AT.options[c2].value); | ||
| + | stat_DEF.value = Math.floor(((base_DEF.value*2-(-iv_DEF.value)+Math.floor(ev_DEF.value/2))*lvl_IDX.value/100+5)*nature_DEF.options[c3].value); | ||
| + | stat_SP.value = Math.floor(((base_SP.value*2-(-iv_SP.value)+Math.floor(ev_SP.value/2))*lvl_IDX.value/100+5)*nature_SP.options[c4].value); | ||
| + | stat_SPECAT.value = Math.floor(((base_SPECAT.value*2-(-iv_SPECAT.value)+Math.floor(ev_SPECAT.value/2))*lvl_IDX.value/100+5)*nature_SPECAT.options[c5].value); | ||
| + | stat_SPECDEF.value = Math.floor(((base_SPECDEF.value*2-(-iv_SPECDEF.value)+Math.floor(ev_SPECDEF.value/2))*lvl_IDX.value/100+5)*nature_SPECDEF.options[c6].value); | ||
| + | //Trainings | ||
| + | if (tr_AT.options[tr2].value != 0) { stat_AT.value = Math.floor((stat_AT.value*tr_AT.options[tr2].value) + stat_AT.value);} | ||
| + | if (tr_DEF.options[tr3].value != 0) { stat_DEF.value = Math.floor((stat_DEF.value*tr_DEF.options[tr3].value) + stat_DEF.value);} | ||
| + | if (tr_SP.options[tr4].value != 0) { stat_SP.value = Math.floor((stat_SP.value*tr_SP.options[tr4].value) + stat_SP.value);} | ||
| + | if (tr_SPECAT.options[tr5].value != 0) { stat_SPECAT.value = Math.floor((stat_SPECAT.value*tr_SPECAT.options[tr5].value) + stat_SPECAT.value);} | ||
| + | if (tr_SPECDEF.options[tr6].value != 0) { stat_SPECDEF.value = Math.floor((stat_SPECDEF.value*tr_SPECDEF.options[tr6].value) + stat_SPECDEF.value);} | ||
| + | //Result | ||
| + | stat_HP.innerHTML = stat_HP.value; stat_AT.innerHTML = stat_AT.value; stat_DEF.innerHTML = stat_DEF.value; | ||
| + | stat_SP.innerHTML = stat_SP.value; stat_SPECAT.innerHTML = stat_SPECAT.value; stat_SPECDEF.innerHTML = stat_SPECDEF.value; | ||
| + | } | ||
| + | } | ||
| + | |||
| + | function fido3() | ||
| + | { | ||
| + | //---------------------------------[ INIT PARAM #3]------------------------------------| | ||
| + | d2 = document.getElementById('stab').selectedIndex; d3 = document.getElementById('types').selectedIndex; | ||
| + | stab_ATdmg = document.getElementById('stab'); types_ATdmg = document.getElementById('types'); | ||
| + | lvl_ATdmg = document.getElementById('lvl_at'); base_ATdmg = document.getElementById('base_at'); base_DEFdmg = document.getElementById('base_def'); | ||
| + | stat_ATdmg = document.getElementById('stat_at'); min_ATdmg = document.getElementById('min_dmg'); max_ATdmg = document.getElementById('max_dmg'); | ||
| + | if(lvl_ATdmg.value != ''){ | ||
| + | //------------------------------------[ FORMULE CALCULATOR #3]--------------------------------------| | ||
| + | min_ATdmg.value = Math.floor((Math.floor(Math.floor(((2+Math.floor(0.4*lvl_ATdmg.value))*stat_ATdmg.value*base_ATdmg.value)/base_DEFdmg.value)/50)+2)*(217/255*stab_ATdmg.options[d2].value*types_ATdmg.options[d3].value)); | ||
| + | max_ATdmg.value = Math.floor((Math.floor(Math.floor(((2+Math.floor(0.4*lvl_ATdmg.value))*stat_ATdmg.value*base_ATdmg.value)/base_DEFdmg.value)/50)+2)*(stab_ATdmg.options[d2].value*types_ATdmg.options[d3].value)); | ||
| + | //ОКРВНИЗ((ОКРВНИЗ(ОКРВНИЗ(((2+ОКРВНИЗ(0,4*уровень;1))*атака*базовая сила атаки)/защита противника;1)/50;1)+2)*(217/255*стаб*коэфф);1) | ||
| + | //ОКРВНИЗ((ОКРВНИЗ(ОКРВНИЗ(((2+ОКРВНИЗ(0,4*уровень;1))*атака*базовая сила атаки)/защита противника;1)/50;1)+2)*(стаб*коэфф);1) | ||
| + | min_ATdmg.innerHTML = min_ATdmg.value; max_ATdmg.innerHTML = max_ATdmg.value; | ||
| + | } | ||
| + | } | ||
| + | |||
| + | function check_lvl_1() | ||
| + | { | ||
| + | if(lvlIDX.value == "") | ||
| + | { | ||
| + | alert ('Please, enter positive value...'); | ||
| + | lvlIDX.value = 100; return fido(); | ||
| + | } | ||
| + | } | ||
| + | function check() | ||
| + | { | ||
| + | var c = new Array( | ||
| + | 'maxivHP.value','maxivAT.value','maxivDEF.value','maxivSP.value','maxivSPECAT.value','maxivSPECDEF.value', | ||
| + | 'minivHP.value','minivAT.value','minivDEF.value','minivSP.value','minivSPECAT.value','minivSPECDEF.value'); | ||
| + | for (i=0; i < 12; i++) | ||
| + | { | ||
| + | if(Array(i) !='') | ||
| + | { | ||
| + | alert ('You can not edit resault'); return fido(); | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | |||
| + | function check_lvl_2() | ||
| + | { | ||
| + | if(lvl_IDX.value == "") | ||
| + | { | ||
| + | alert ('Please, enter positive value...'); | ||
| + | lvl_IDX.value = 100; return fido2(); | ||
| + | } | ||
| + | } | ||
| + | |||
| + | function check2() | ||
| + | { | ||
| + | var d = new Array( | ||
| + | 'stat_HP.value','stat_AT.value','stat_DEF.value','stat_SP.value','stat_SPECAT.value','stat_SPECDEF.value'); | ||
| + | for (i = 0; i < 8; i++) | ||
| + | { | ||
| + | if(Array(i) !='') | ||
| + | { | ||
| + | alert ('You can not edit resault'); return fido2(); | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | |||
| + | function check_lvl_3() | ||
| + | { | ||
| + | if(lvl_ATdmg.value == "") | ||
| + | { | ||
| + | alert ('Please, enter positive value...'); | ||
| + | lvl_ATdmg.value = 100; return fido3(); | ||
| + | } | ||
| + | } | ||
| + | function check3() | ||
| + | { | ||
| + | if(min_ATdmg.value != '' || max_ATdmg.value != '') | ||
| + | { | ||
| + | alert ('You can not edit resault'); return fido3(); | ||
| + | } | ||
| + | } | ||
| + | /* | ||
| + | function check(field) | ||
| + | { | ||
| + | var val; | ||
| + | |||
| + | if (field.value == '') | ||
| + | return alert('No value entered....'); | ||
| + | |||
| + | val = parseInt(field.value); | ||
| + | if (isNaN(val)) | ||
| + | return alert('Non-integer value....'); | ||
| + | |||
| + | if (val != form.value) | ||
| + | return alert('Not an integer.......'); | ||
| + | |||
| + | if (val <= 0) | ||
| + | return alert('Please, enter positive value...'); | ||
| + | |||
| + | } | ||
| + | |||
| + | //калькбета | ||
| + | function reset_nature() | ||
| + | { | ||
| + | natureAT.options[n2].value = 1; document.getElementById('nature2').selectedIndex = 0; | ||
| + | natureDEF.options[n3].value = 1; document.getElementById('nature3').selectedIndex = 0; | ||
| + | natureSP.options[n4].value = 1; document.getElementById('nature4').selectedIndex = 0; | ||
| + | natureSPECAT.options[n5].value = 1; document.getElementById('nature5').selectedIndex = 0; | ||
| + | natureSPECDEF.options[n6].value = 1; document.getElementById('nature6').selectedIndex = 0; | ||
| + | } | ||
| + | |||
| + | function convert_nature (nature) | ||
| + | { | ||
| + | reset_nature(); | ||
| + | switch(nature) | ||
| + | { | ||
| + | case 'Normal': | ||
| + | { | ||
| + | return reset_nature(); | ||
| + | } | ||
| + | case 'Jolly': | ||
| + | { | ||
| + | return convert_value(1,1,1.1,0.9,1); | ||
| + | } | ||
| + | default: | ||
| + | { | ||
| + | reset_nature(); | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | |||
| + | function convert_value(x2, x3, x4, x5, x6) | ||
| + | { | ||
| + | rel = new Array(); | ||
| + | rel[0] = x2; rel[1] = x3; rel[2] = x4; rel[3] = x5; rel[4] = x6; | ||
| + | |||
| + | for (i = 0; i < 5; i++) | ||
| + | { | ||
| + | j = i+2; | ||
| + | if(rel[i] == 0.9) | ||
| + | { | ||
| + | document.getElementById('nature'+j).selectedIndex = 2; | ||
| + | } | ||
| + | else if(rel[i] == 1) | ||
| + | { | ||
| + | document.getElementById('nature'+j).selectedIndex = 0; | ||
| + | } | ||
| + | else if(rel[i] == 1.1) | ||
| + | { | ||
| + | document.getElementById('nature'+j).selectedIndex = 1; | ||
| + | } | ||
| + | } | ||
} | } | ||
Версия 23:58, 17 апреля 2013
/* Размещённый здесь JavaScript код будет загружаться всем пользователям при обращении к каждой странице */
importScript_ = importScript
importScript = function (page, proj){
if (!proj) importScript_(page)
else {
if (proj.indexOf('.')==-1) proj += '.wikipedia.org'
importScriptURI('http://'+proj+'/w/index.php?action=raw&ctype=text/javascript&title='+encodeURIComponent(page.replace(/ /g,'_')))
}
}
importMW = function (name) { importScript('MediaWiki:'+name+'.js') }
function LinkFA(){
var pLang = document.getElementById('p-lang')
if (!pLang) return
var list = {
'fa':'Эта статья является избранной',
'fl':'Этот список или портал является избранным',
'ga':'Эта статья является хорошей'}
var iw = pLang.getElementsByTagName('li')
for (var i=0; i<iw.length; i++)
for (var s in list)
if (document.getElementById(iw[i].className+'-'+s)){
iw[i].className += ' ' + s.toUpperCase()
iw[i].title = list[s] + ' в другом языковом разделе'
}
}
function icqIcons(){
var a, spans = document.getElementById('content').getElementsByTagName('span')
for (var i=0; a=spans[i]; i++)
if (a.className == 'ICQ')
a.style.backgroundImage = "url('http://status.icq.com/online.gif?icq="+a.id+"&img=5&randseed="+Math.floor(Math.random()*10000000)+"')"
}
function editZeroSection(){
var body = document.getElementById('bodyContent')
if (!body) return
var h2s = body.getElementsByTagName('H2')
var h2 = h2s[0]
if (!h2) return
if (h2.parentNode.id == 'toctitle') h2 = h2s[1]
if (!h2) return
var span = h2.firstChild
if (!span || span.className != 'editsection') return
var zero = span.cloneNode(true)
body.insertBefore(zero, body.firstChild)
var a = zero.getElementsByTagName('a')[0]
if (a.href.indexOf('§ion=T') == -1 ) a.title = a.title.replace(/:.*$/,': 0')
else a.title = 'Править секцию: 0'
a.setAttribute('href', wgScript + '?title='+encodeURIComponent(wgPageName) + '&action=edit§ion=0')
}
//Collapsiblе: [[ВП:СБ]]
var NavigationBarShowDefault = 2
var NavigationBarHide = '[скрыть]'
var NavigationBarShow = '[показать]'
var hasClass = (function (){
var reCache = {}
return function (element, className){
return (reCache[className] ? reCache[className] : (reCache[className] = new RegExp("(?:\\s|^)" + className + "(?:\\s|$)"))).test(element.className)
}
})()
function collapsibleTables(){
var Table, HRow, HCell, btn, a, tblIdx = 0, colTables = []
var allTables = document.getElementsByTagName('table')
for (var i=0; Table = allTables[i]; i++){
if (!hasClass(Table, 'collapsible')) continue
if (!(HRow=Table.rows[0])) continue
if (!(HCell=HRow.getElementsByTagName('th')[0])) continue
Table.id = 'collapsibleTable' + tblIdx
btn = document.createElement('span')
btn.style.cssText = 'float:right; font-weight:normal; font-size:smaller'
a = document.createElement('a')
a.id = 'collapseButton' + tblIdx
a.href = 'javascript:collapseTable(' + tblIdx + ');'
a.style.color = HCell.style.color
a.appendChild(document.createTextNode(NavigationBarHide))
btn.appendChild(a)
HCell.insertBefore(btn, HCell.childNodes[0])
colTables[tblIdx++] = Table
}
for (var i=0; i < tblIdx; i++)
if ((tblIdx > NavigationBarShowDefault && hasClass(colTables[i], 'autocollapse')) || hasClass(colTables[i], 'collapsed'))
collapseTable(i)
}
function collapseTable (idx){
var Table = document.getElementById('collapsibleTable' + idx)
var btn = document.getElementById('collapseButton' + idx)
if (!Table || !btn) return false
var Rows = Table.rows
var isShown = (btn.firstChild.data == NavigationBarHide)
btn.firstChild.data = isShown ? NavigationBarShow : NavigationBarHide
var disp = isShown ? 'none' : Rows[0].style.display
for (var i=1; i < Rows.length; i++)
Rows[i].style.display = disp
}
function collapsibleDivs(){
var navIdx = 0, colNavs = [], i, NavFrame
var divs = document.getElementById('content').getElementsByTagName('div')
for (i=0; NavFrame = divs[i]; i++) {
if (!hasClass(NavFrame, 'NavFrame')) continue
NavFrame.id = 'NavFrame' + navIdx
var a = document.createElement('a')
a.className = 'NavToggle'
a.id = 'NavToggle' + navIdx
a.href = 'javascript:collapseDiv(' + navIdx + ');'
a.appendChild(document.createTextNode(NavigationBarHide))
for (var j=0; j < NavFrame.childNodes.length; j++)
if (hasClass(NavFrame.childNodes[j], 'NavHead'))
NavFrame.childNodes[j].appendChild(a)
colNavs[navIdx++] = NavFrame
}
for (i=0; i < navIdx; i++)
if ((navIdx > NavigationBarShowDefault && !hasClass(colNavs[i], 'expanded')) || hasClass(colNavs[i], 'collapsed'))
collapseDiv(i)
}
function collapseDiv(idx) {
var div = document.getElementById('NavFrame' + idx)
var btn = document.getElementById('NavToggle' + idx)
if (!div || !btn) return false
var isShown = (btn.firstChild.data == NavigationBarHide)
btn.firstChild.data = isShown ? NavigationBarShow : NavigationBarHide
var disp = isShown ? 'none' : 'block'
for (var child = div.firstChild; child != null; child = child.nextSibling)
if (hasClass(child, 'NavPic') || hasClass(child, 'NavContent'))
child.style.display = disp
}
//Custom
//Secure server
var metaBase = 'http://meta.wikimedia.org'
if (wgServer == 'https://secure.wikimedia.org') {
importScript('MediaWiki:Common.js/secure.js','en')
metaBase = 'https://secure.wikimedia.org/wikipedia/meta'
}
//Execution
if (wgCanonicalNamespace == 'Special'){
if (/^(Uplo|Sear|Stat|Spec|Abus|Prefe)/i.test(wgCanonicalSpecialPageName))
importMW(wgCanonicalSpecialPageName)
}else switch (wgAction){
case 'history': importMW('History'); break
case 'delete': importMW('Deletepage'); break
case 'edit': case 'submit': importMW('Editpage') //and continue with the default: view, purge
default:
addOnloadHook(editZeroSection)
addOnloadHook(collapsibleDivs)
addOnloadHook(collapsibleTables)
importScriptURI(metaBase+'/w/index.php?title=MediaWiki:Wikiminiatlas.js&action=raw&ctype=text/javascript&smaxage=21600&maxage=86400')
if (navigator.platform.indexOf('Win') != -1)
importStylesheetURI('http://en.wikipedia.org/w/index.php?title=MediaWiki:Common.css/WinFixes.css&action=raw&ctype=text/css')
if (wgNamespaceNumber==0 || wgNamespaceNumber==100){
addOnloadHook(LinkFA)
importMW('Osm')
importMW('Collapserefs')
if (wgArticleId==4401) importMW('Mainpage')
}else{
if (wgNamespaceNumber==4){
if (/^(Мастер статей|Инкубатор)/.test(wgTitle)) importMW('Incubator')
if (wgTitle=='Скрипты') importMW('Scripts')
}
addOnloadHook(icqIcons)
}
}
if (wgUserGroups){
for (var i=0; i<wgUserGroups.length; i++) switch (wgUserGroups[i]){
case 'sysop': importMW('Sysop'); break
}
if (wgNamespaceNumber==2 && wgTitle.indexOf(wgUserName)==0 && wgArticleId==0 && /\/skin\.(js|css)$/.test(wgTitle))
window.location.href = window.location.href.replace(/skin\.(css|js)$/, skin+'.$1')
}
// ВП:СО, кроме статей В Контакте, Одноклассники и Facebook
if (wgArticleId!=639373 && wgArticleId!=932117 && wgArticleId!=1297302 && wgArticleId!=25133866)
importMW('Wikibugs')
// iwiki sorting
if (!wgUserName
|| (wgUserName
&& (((typeof wgLangPrefs == 'undefined') ? false : true)
|| ((typeof wgAddLangHints == 'undefined') ? false : wgAddLangHints)
|| ((typeof wgUseUserLanguage == 'undefined') ? false : wgUseUserLanguage))))
importMW('Interwiki-links');
var withJS = document.URL.match(/[&?]withjs=((mediawiki:)?([^&#]+))/i)
if (withJS) importScript_('MediaWiki:'+withJS[3])
if (!window.wgUserName) appendCSS('#mw-fr-revisiontag {display:none}')
// Wikifikator -------------------
function addWikifButton() {
var toolbar = document.getElementById('toolbar')
if (!toolbar) return
var i = document.createElement('img')
i.src = 'http://upload.wikimedia.org/wikisource/ru/d/d1/Button-wikifikator.png'
i.alt = i.title = 'викификатор'
i.onclick = Wikify
i.style.cursor = 'pointer'
toolbar.appendChild(i)
}
if (wgAction == 'edit' || wgAction == 'submit') {
importScriptURI('http://ru.wikipedia.org/w/index.php?title=MediaWiki:Wikificator.js&action=raw&ctype=text/javascript')
addOnloadHook(addWikifButton)
}
// кальк1
function snature()
{
init_c1();
nX = document.getElementById('Xnature').selectedIndex;
natureX = document.getElementById('Xnature');
convert_nature(natureX.options[nX].value);
fido();
}
function init_c1()
{
//---------------------------------[ INIT PARAM #1]------------------------------------|
n2 = document.getElementById('nature2').selectedIndex; n3 = document.getElementById('nature3').selectedIndex;
n4 = document.getElementById('nature4').selectedIndex; n5 = document.getElementById('nature5').selectedIndex; n6 = document.getElementById('nature6').selectedIndex;
maxivHP = document.getElementById('maxiv1'); maxivAT = document.getElementById('maxiv2'); maxivDEF = document.getElementById('maxiv3');
maxivSP = document.getElementById('maxiv4'); maxivSPECAT = document.getElementById('maxiv5'); maxivSPECDEF = document.getElementById('maxiv6');
lvlIDX = document.getElementById('lvl');
minivHP = document.getElementById('miniv1'); minivAT = document.getElementById('miniv2'); minivDEF = document.getElementById('miniv3');
minivSP = document.getElementById('miniv4'); minivSPECAT = document.getElementById('miniv5'); minivSPECDEF = document.getElementById('miniv6');
statHP = document.getElementById('stat1'); baseHP = document.getElementById('base1'); evHP = document.getElementById('ev1');
statAT = document.getElementById('stat2'); natureAT = document.getElementById('nature2'); baseAT = document.getElementById('base2'); evAT = document.getElementById('ev2');
statDEF = document.getElementById('stat3'); natureDEF = document.getElementById('nature3'); baseDEF = document.getElementById('base3'); evDEF = document.getElementById('ev3');
statSP = document.getElementById('stat4'); natureSP = document.getElementById('nature4'); baseSP = document.getElementById('base4'); evSP = document.getElementById('ev4');
statSPECAT = document.getElementById('stat5'); natureSPECAT = document.getElementById('nature5'); baseSPECAT = document.getElementById('base5'); evSPECAT = document.getElementById('ev5');
statSPECDEF = document.getElementById('stat6'); natureSPECDEF = document.getElementById('nature6'); baseSPECDEF = document.getElementById('base6'); evSPECDEF = document.getElementById('ev6');
}
function fido()
{
init_c1();
//ОКРУГЛВНИЗ(100*(текущий стат-9,5-левел)/левел-базовый стат*2-ОКРВНИЗ(ев/2;1)-0,0001;0) - max hp iv
//ОКРУГЛВНИЗ(100 * ( (текущий стат +1) / характер-5) / левел - базовый стат * 2 - ОКРУГЛВНИЗ(ев/2;1) -0,0001) - max iv
//ОКРУГЛВВЕРХ(100*(текущий стат-10,5-левел)/левел-базовый стат*2 -ОКРВНИЗ(ев/2;1);0) - min hp iv
//ОКРУГЛВВЕРХ(100*(текущий стат/характер-5)/левел - базовый стат * 2 - ОКРВНИЗ(ев/2;1);0) - min iv
if(lvlIDX.value != ''){
//------------------------------------[ FORMULE CALCULATOR #1]--------------------------------------|
maxivHP.value = Math.floor(100*(statHP.value-9.5-lvlIDX.value)/lvlIDX.value-(baseHP.value*2)-Math.floor(evHP.value/2)-0.0001);
maxivAT.value = Math.floor(100*((statAT.value-(-1))/natureAT.options[n2].value-5)/lvlIDX.value-(baseAT.value*2)-Math.floor(evAT.value/2)-0.0001);
maxivDEF.value = Math.floor(100*((statDEF.value-(-1))/natureDEF.options[n3].value-5)/lvlIDX.value-(baseDEF.value*2)-Math.floor(evDEF.value/2)-0.0001);
maxivSP.value = Math.floor(100*((statSP.value-(-1))/natureSP.options[n4].value-5)/lvlIDX.value-(baseSP.value*2)-Math.floor(evSP.value/2)-0.0001);
maxivSPECAT.value = Math.floor(100*((statSPECAT.value-(-1))/natureSPECAT.options[n5].value-5)/lvlIDX.value-(baseSPECAT.value*2)-Math.floor(evSPECAT.value/2)-0.0001);
maxivSPECDEF.value = Math.floor(100*((statSPECDEF.value-(-1))/natureSPECDEF.options[n6].value-5)/lvlIDX.value-(baseSPECDEF.value*2)-Math.floor(evSPECDEF.value/2)-0.0001);
maxivHP.innerHTML = maxivHP.value; maxivAT.innerHTML = maxivAT.value; maxivDEF.innerHTML = maxivDEF.value;
maxivSP.innerHTML = maxivSP.value; maxivSPECAT.innerHTML = maxivSPECAT.value; maxivSPECDEF.innerHTML = maxivSPECDEF.value;
//
minivHP.value = Math.ceil(100*(statHP.value-10.5-lvlIDX.value)/lvlIDX.value-(baseHP.value*2)-Math.floor(evHP.value/2));
minivAT.value = Math.ceil(100*(statAT.value/natureAT.options[n2].value-5)/lvlIDX.value-(baseAT.value*2)-Math.floor(evAT.value/2));
minivDEF.value = Math.ceil(100*(statDEF.value/natureDEF.options[n3].value-5)/lvlIDX.value-(baseDEF.value*2)-Math.floor(evDEF.value/2));
minivSP.value = Math.ceil(100*(statSP.value/natureSP.options[n4].value-5)/lvlIDX.value-(baseSP.value*2)-Math.floor(evSP.value/2));
minivSPECAT.value = Math.ceil(100*(statSPECAT.value/natureSPECAT.options[n5].value-5)/lvlIDX.value-(baseSPECAT.value*2)-Math.floor(evSPECAT.value/2));
minivSPECDEF.value = Math.ceil(100*(statSPECDEF.value/natureSPECDEF.options[n6].value-5)/lvlIDX.value-(baseSPECDEF.value*2)-Math.floor(evSPECDEF.value/2));
minivHP.innerHTML = minivHP.value; minivAT.innerHTML = minivAT.value; minivDEF.innerHTML = minivDEF.value;
minivSP.innerHTML = minivSP.value; minivSPECAT.innerHTML = minivSPECAT.value; minivSPECDEF.innerHTML = minivSPECDEF.value;
}
}
function fido2()
{
//---------------------------------[ INIT PARAM #2]------------------------------------|
c2 = document.getElementById('nature_2').selectedIndex; c3 = document.getElementById('nature_3').selectedIndex;
c4 = document.getElementById('nature_4').selectedIndex; c5 = document.getElementById('nature_5').selectedIndex; c6 = document.getElementById('nature_6').selectedIndex;
iv_HP = document.getElementById('iv_1'); iv_AT = document.getElementById('iv_2'); iv_DEF = document.getElementById('iv_3');
iv_SP = document.getElementById('iv_4'); iv_SPECAT = document.getElementById('iv_5'); iv_SPECDEF = document.getElementById('iv_6');
lvl_IDX = document.getElementById('lvl_1');
/*Trainings */
tr2 = document.getElementById('tren_2').selectedIndex; tr3 = document.getElementById('tren_3').selectedIndex;
tr4 = document.getElementById('tren_4').selectedIndex; tr5 = document.getElementById('tren_5').selectedIndex;
tr6 = document.getElementById('tren_6').selectedIndex; tr_AT = document.getElementById('tren_2');
tr_DEF = document.getElementById('tren_3'); tr_SP = document.getElementById('tren_4'); tr_SPECAT = document.getElementById('tren_5');
tr_SPECDEF = document.getElementById('tren_6');
stat_HP = document.getElementById('stat_1'); base_HP = document.getElementById('base_1'); ev_HP = document.getElementById('ev_1');
stat_AT = document.getElementById('stat_2'); nature_AT = document.getElementById('nature_2'); base_AT = document.getElementById('base_2'); ev_AT = document.getElementById('ev_2');
stat_DEF = document.getElementById('stat_3'); nature_DEF = document.getElementById('nature_3'); base_DEF = document.getElementById('base_3'); ev_DEF = document.getElementById('ev_3');
stat_SP = document.getElementById('stat_4'); nature_SP = document.getElementById('nature_4'); base_SP = document.getElementById('base_4'); ev_SP = document.getElementById('ev_4');
stat_SPECAT = document.getElementById('stat_5'); nature_SPECAT = document.getElementById('nature_5'); base_SPECAT = document.getElementById('base_5'); ev_SPECAT = document.getElementById('ev_5');
stat_SPECDEF = document.getElementById('stat_6'); nature_SPECDEF = document.getElementById('nature_6'); base_SPECDEF = document.getElementById('base_6'); ev_SPECDEF = document.getElementById('ev_6');
//ОКРУГЛ((базовый стат*2+ген+ОКРВНИЗ(ев/2;1))*уровень/100+10+уровень;0) - hp
//ОКРВНИЗ(((базовый стат*2+ген+ОКРВНИЗ(ев/2;1))*уровень/100+5)*характер;1) - stats
if(lvl_IDX.value != ''){
//------------------------------------[ FORMULE CALCULATOR #2]--------------------------------------|
stat_HP.value = Math.round((base_HP.value*2-(-iv_HP.value)+Math.floor(ev_HP.value/2))*lvl_IDX.value/100+10-(-lvl_IDX.value));
stat_AT.value = Math.floor(((base_AT.value*2-(-iv_AT.value)+Math.floor(ev_AT.value/2))*lvl_IDX.value/100+5)*nature_AT.options[c2].value);
stat_DEF.value = Math.floor(((base_DEF.value*2-(-iv_DEF.value)+Math.floor(ev_DEF.value/2))*lvl_IDX.value/100+5)*nature_DEF.options[c3].value);
stat_SP.value = Math.floor(((base_SP.value*2-(-iv_SP.value)+Math.floor(ev_SP.value/2))*lvl_IDX.value/100+5)*nature_SP.options[c4].value);
stat_SPECAT.value = Math.floor(((base_SPECAT.value*2-(-iv_SPECAT.value)+Math.floor(ev_SPECAT.value/2))*lvl_IDX.value/100+5)*nature_SPECAT.options[c5].value);
stat_SPECDEF.value = Math.floor(((base_SPECDEF.value*2-(-iv_SPECDEF.value)+Math.floor(ev_SPECDEF.value/2))*lvl_IDX.value/100+5)*nature_SPECDEF.options[c6].value);
//Trainings
if (tr_AT.options[tr2].value != 0) { stat_AT.value = Math.floor((stat_AT.value*tr_AT.options[tr2].value) + stat_AT.value);}
if (tr_DEF.options[tr3].value != 0) { stat_DEF.value = Math.floor((stat_DEF.value*tr_DEF.options[tr3].value) + stat_DEF.value);}
if (tr_SP.options[tr4].value != 0) { stat_SP.value = Math.floor((stat_SP.value*tr_SP.options[tr4].value) + stat_SP.value);}
if (tr_SPECAT.options[tr5].value != 0) { stat_SPECAT.value = Math.floor((stat_SPECAT.value*tr_SPECAT.options[tr5].value) + stat_SPECAT.value);}
if (tr_SPECDEF.options[tr6].value != 0) { stat_SPECDEF.value = Math.floor((stat_SPECDEF.value*tr_SPECDEF.options[tr6].value) + stat_SPECDEF.value);}
//Result
stat_HP.innerHTML = stat_HP.value; stat_AT.innerHTML = stat_AT.value; stat_DEF.innerHTML = stat_DEF.value;
stat_SP.innerHTML = stat_SP.value; stat_SPECAT.innerHTML = stat_SPECAT.value; stat_SPECDEF.innerHTML = stat_SPECDEF.value;
}
}
function fido3()
{
//---------------------------------[ INIT PARAM #3]------------------------------------|
d2 = document.getElementById('stab').selectedIndex; d3 = document.getElementById('types').selectedIndex;
stab_ATdmg = document.getElementById('stab'); types_ATdmg = document.getElementById('types');
lvl_ATdmg = document.getElementById('lvl_at'); base_ATdmg = document.getElementById('base_at'); base_DEFdmg = document.getElementById('base_def');
stat_ATdmg = document.getElementById('stat_at'); min_ATdmg = document.getElementById('min_dmg'); max_ATdmg = document.getElementById('max_dmg');
if(lvl_ATdmg.value != ''){
//------------------------------------[ FORMULE CALCULATOR #3]--------------------------------------|
min_ATdmg.value = Math.floor((Math.floor(Math.floor(((2+Math.floor(0.4*lvl_ATdmg.value))*stat_ATdmg.value*base_ATdmg.value)/base_DEFdmg.value)/50)+2)*(217/255*stab_ATdmg.options[d2].value*types_ATdmg.options[d3].value));
max_ATdmg.value = Math.floor((Math.floor(Math.floor(((2+Math.floor(0.4*lvl_ATdmg.value))*stat_ATdmg.value*base_ATdmg.value)/base_DEFdmg.value)/50)+2)*(stab_ATdmg.options[d2].value*types_ATdmg.options[d3].value));
//ОКРВНИЗ((ОКРВНИЗ(ОКРВНИЗ(((2+ОКРВНИЗ(0,4*уровень;1))*атака*базовая сила атаки)/защита противника;1)/50;1)+2)*(217/255*стаб*коэфф);1)
//ОКРВНИЗ((ОКРВНИЗ(ОКРВНИЗ(((2+ОКРВНИЗ(0,4*уровень;1))*атака*базовая сила атаки)/защита противника;1)/50;1)+2)*(стаб*коэфф);1)
min_ATdmg.innerHTML = min_ATdmg.value; max_ATdmg.innerHTML = max_ATdmg.value;
}
}
function check_lvl_1()
{
if(lvlIDX.value == "")
{
alert ('Please, enter positive value...');
lvlIDX.value = 100; return fido();
}
}
function check()
{
var c = new Array(
'maxivHP.value','maxivAT.value','maxivDEF.value','maxivSP.value','maxivSPECAT.value','maxivSPECDEF.value',
'minivHP.value','minivAT.value','minivDEF.value','minivSP.value','minivSPECAT.value','minivSPECDEF.value');
for (i=0; i < 12; i++)
{
if(Array(i) !='')
{
alert ('You can not edit resault'); return fido();
}
}
}
function check_lvl_2()
{
if(lvl_IDX.value == "")
{
alert ('Please, enter positive value...');
lvl_IDX.value = 100; return fido2();
}
}
function check2()
{
var d = new Array(
'stat_HP.value','stat_AT.value','stat_DEF.value','stat_SP.value','stat_SPECAT.value','stat_SPECDEF.value');
for (i = 0; i < 8; i++)
{
if(Array(i) !='')
{
alert ('You can not edit resault'); return fido2();
}
}
}
function check_lvl_3()
{
if(lvl_ATdmg.value == "")
{
alert ('Please, enter positive value...');
lvl_ATdmg.value = 100; return fido3();
}
}
function check3()
{
if(min_ATdmg.value != '' || max_ATdmg.value != '')
{
alert ('You can not edit resault'); return fido3();
}
}
/*
function check(field)
{
var val;
if (field.value == '')
return alert('No value entered....');
val = parseInt(field.value);
if (isNaN(val))
return alert('Non-integer value....');
if (val != form.value)
return alert('Not an integer.......');
if (val <= 0)
return alert('Please, enter positive value...');
}
//калькбета
function reset_nature()
{
natureAT.options[n2].value = 1; document.getElementById('nature2').selectedIndex = 0;
natureDEF.options[n3].value = 1; document.getElementById('nature3').selectedIndex = 0;
natureSP.options[n4].value = 1; document.getElementById('nature4').selectedIndex = 0;
natureSPECAT.options[n5].value = 1; document.getElementById('nature5').selectedIndex = 0;
natureSPECDEF.options[n6].value = 1; document.getElementById('nature6').selectedIndex = 0;
}
function convert_nature (nature)
{
reset_nature();
switch(nature)
{
case 'Normal':
{
return reset_nature();
}
case 'Jolly':
{
return convert_value(1,1,1.1,0.9,1);
}
default:
{
reset_nature();
}
}
}
function convert_value(x2, x3, x4, x5, x6)
{
rel = new Array();
rel[0] = x2; rel[1] = x3; rel[2] = x4; rel[3] = x5; rel[4] = x6;
for (i = 0; i < 5; i++)
{
j = i+2;
if(rel[i] == 0.9)
{
document.getElementById('nature'+j).selectedIndex = 2;
}
else if(rel[i] == 1)
{
document.getElementById('nature'+j).selectedIndex = 0;
}
else if(rel[i] == 1.1)
{
document.getElementById('nature'+j).selectedIndex = 1;
}
}
}