Szablon:Edycja: Różnice pomiędzy wersjami
Nie podano opisu zmian |
Nie podano opisu zmian |
||
(Nie pokazano 8 wersji utworzonych przez 2 użytkowników) | |||
Linia 1: | Linia 1: | ||
<altaronpanel title="[[Plik:Zwój_Przemiany.gif]] Kalkulator Punktów Nauki"> | <altaronpanel title="[[Plik:Zwój_Przemiany.gif]] Kalkulator Punktów Nauki" style="2" titleCSS="text-align: center;> | ||
<html> | <html> | ||
< | <body> | ||
<div class="form-group"> | |||
<label for="profession">Wybierz profesję:</label> | |||
<select class="form-control" id="profession"> | |||
<option value="3000">Wojownik</option> | |||
<option value="4000">Łucznik</option> | |||
<option value="2000">Mag</option> | |||
</select> | |||
</div> | |||
<div class="form-group"> | |||
<label for="ability">Wybierz umiejętność:</label> | |||
<select class="form-control" id="ability"> | |||
<option value="strength">Siła</option> | |||
<option value="shield">Obrona Tarczą</option> | |||
<option value="1h">Bron Jednoręczna</option> | |||
<option value="2h">Broń Dwuręczna</option> | |||
<option value="dist">Walka Dystansowa</option> | |||
<option value="magic">Magia</option> | |||
<option value="alchemy">Alchemia</option> | |||
<option value="agility">Zręczność</option> | |||
</select> | |||
</div> | |||
<div class="form-group"> | |||
<label for="currentLevel">Wybierz obecny poziom:</label> | |||
<select class="form-control" id="currentLevel"> | |||
</select> | |||
</div> | |||
<div class="form-group"> | |||
<label for="targetLevel" id="targetLevelLabel">Wybierz docelowy poziom:</label> | |||
<select class="form-control" id="targetLevel"> | |||
</select> | |||
</div> | |||
<div class="form-group d-flex justify-content-center"> | |||
<button onclick="calculatePoints()" class="btn btn-primary">Oblicz</button> | |||
</div> | |||
<p id="pointsNeeded" class="font-weight-bold text-center"> | |||
</p> | |||
</div> | |||
</body> | |||
<script> | |||
document.addEventListener("DOMContentLoaded",function(){ | |||
const currentLevelSelect = document.querySelector('#currentLevel'); | |||
const targetLevelSelect = document.querySelector('#targetLevel'); | |||
const professionInput = document.getElementById("profession"); | |||
const abilityInput = document.getElementById("ability"); | |||
<label for="ability">Wybierz umiejętność:</label> | |||
</ | |||
const updateLevels = function() { | |||
currentLevelSelect.innerHTML = ''; | |||
targetLevelSelect.innerHTML = ''; | |||
const limit = !!this.Altaron ? Altaron.getSkillLimit(professionInput.value, abilityInput.value) : 200; | |||
for (let i = 1; i <= limit; i++) { | |||
const option1 = document.createElement('option'); | |||
option1.value = i; | |||
option1.textContent = i; | |||
targetLevelSelect.appendChild(option1); | |||
const option2 = document.createElement('option'); | |||
option2.value = i; | |||
option2.textContent = i; | |||
currentLevelSelect.appendChild(option2); | |||
} | |||
}; | |||
updateLevels(); | |||
const clearInputErrors = function() { | |||
document.getElementById("targetLevel").classList.remove("is-invalid"); | |||
document.getElementById("targetLevelLabel").classList.remove("text-danger"); | |||
}; | |||
professionInput.addEventListener('change', function(){ | |||
updateLevels(); | |||
clearInputErrors(); | |||
}); | |||
abilityInput.addEventListener('change', function(){ | |||
updateLevels(); | |||
clearInputErrors(); | |||
}); | |||
var profession = | |||
var | window.calculatePoints = function() { | ||
var | var profession = professionInput.value; | ||
var | var ability = abilityInput.value; | ||
var currentLevel = parseInt(currentLevelSelect.value); | |||
var targetLevel = parseInt(targetLevelSelect.value); | |||
var pointsNeeded = 0; | var pointsNeeded = 0; | ||
var limit = Altaron.getSkillLimit(profession, ability); | var limit = Altaron.getSkillLimit(profession, ability); | ||
clearInputErrors(); | |||
if (targetLevel > limit) { | |||
document.getElementById("pointsNeeded").innerHTML ="Docelowy poziom jest większy niż maksymalny poziom " + limit + "."; | |||
document.getElementById("targetLevel").classList.add("is-invalid"); | |||
document.getElementById("targetLevelLabel").classList.add("text-danger") | |||
return; | |||
} | |||
else if (targetLevel < currentLevel) { | |||
document.getElementById("pointsNeeded").innerHTML ="Docelowy poziom " + targetLevel + " nie może być mniejszy od obecnego " + currentLevel + "."; | |||
document.getElementById("targetLevel").classList.add("is-invalid"); | |||
document.getElementById("targetLevelLabel").classList.add("text-danger") | |||
return; | |||
} | |||
for(var i = currentLevel; i < targetLevel; i++) { | for(var i = currentLevel; i < targetLevel; i++) { | ||
pointsNeeded += Altaron.getLearnPointsForLevel(profession, ability, i); | |||
} | } | ||
document.getElementById("pointsNeeded").innerHTML = "Brakuje Ci " + pointsNeeded + " punktów nauki."; | |||
}; | |||
}); | |||
</script> | </script> | ||
</html> | </html> | ||
</altaronpanel> | </altaronpanel> |