Szablon:Edycja: Różnice pomiędzy wersjami

Z Altaron Wiki
(dodanie klas błędu dla pola docelowego poziomu)
Nie podano opisu zmian
 
Linia 2: Linia 2:


<html>
<html>
  <head>
    <!-- Add Bootstrap CSS -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
  </head>
   <body>
   <body>
       <div class="form-group">
       <div class="form-group">
Linia 35: Linia 31:
       <div class="form-group">
       <div class="form-group">
         <label for="targetLevel" id="targetLevelLabel">Wybierz docelowy poziom:</label>
         <label for="targetLevel" id="targetLevelLabel">Wybierz docelowy poziom:</label>
         <select class="form-control" id="targetLevel" onfocus="clearInputErrors()">
         <select class="form-control" id="targetLevel">
         </select>
         </select>
       </div>
       </div>
Linia 47: Linia 43:
      
      
<script>
<script>
  const currentLevelSelect = document.querySelector('#currentLevel');
document.addEventListener("DOMContentLoaded",function(){
  for (let i = 1; i <= 200; i++) {
const currentLevelSelect = document.querySelector('#currentLevel');
    const option = document.createElement('option');
const targetLevelSelect = document.querySelector('#targetLevel');
    option.value = i;
const professionInput = document.getElementById("profession");
    option.textContent = i;
const abilityInput = document.getElementById("ability");
    currentLevelSelect.appendChild(option);
  }


  const targetLevelSelect = document.querySelector('#targetLevel');
const updateLevels = function() {
  for(let i = 2; i <= 200; i++) {
currentLevelSelect.innerHTML = '';
    const option = document.createElement('option');
targetLevelSelect.innerHTML = '';
    option.value = i;
    option.textContent = i;
const limit = !!this.Altaron ? Altaron.getSkillLimit(professionInput.value, abilityInput.value) : 200;
    targetLevelSelect.appendChild(option);
  }
for (let i = 1; i <= limit; i++) {
 
const option1 = document.createElement('option');
  function calculatePoints() {
option1.value = i;
        var profession = document.getElementById("profession").value;
option1.textContent = i;
        var currentLevel = parseInt(document.getElementById("currentLevel").value);
targetLevelSelect.appendChild(option1);
        var targetLevel = parseInt(document.getElementById("targetLevel").value);
 
         var ability = document.getElementById("ability").value;
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();
});
window.calculatePoints = function() {
        var profession = professionInput.value;
         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);


  if (targetLevel > limit) {
clearInputErrors();
    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) {
if (targetLevel > limit) {
    document.getElementById("pointsNeeded").innerHTML ="Docelowy poziom " + targetLevel + " nie może być mniejszy od obecnego " + currentLevel + ".";
document.getElementById("pointsNeeded").innerHTML ="Docelowy poziom jest większy niż maksymalny poziom " + limit + ".";
    document.getElementById("targetLevel").classList.add("is-invalid");
document.getElementById("targetLevel").classList.add("is-invalid");
    document.getElementById("targetLevelLabel").classList.add("text-danger")
document.getElementById("targetLevelLabel").classList.add("text-danger")
    return;
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);
pointsNeeded += Altaron.getLearnPointsForLevel(profession, ability, i);
         }
         }
        document.getElementById("pointsNeeded").innerHTML = "Brakuje Ci " + pointsNeeded + " punktów nauki.";
};


        document.getElementById("pointsNeeded").innerHTML = "Brakuje Ci " + pointsNeeded + " punktów nauki.";
});
  }
 
  function clearInputErrors(){
    document.getElementById("targetLevel").classList.remove("is-invalid");
    document.getElementById("targetLevelLabel").classList.remove("text-danger")
  }
</script>
</script>
</html>
</html>
</altaronpanel>
</altaronpanel>

Aktualna wersja na dzień 19:26, 15 lut 2023

Zwój Przemiany.gif Kalkulator Punktów Nauki