|
||||||
|
|
|
||||||||||||||||||||||||
Tibia Wiki:Exercise Weapons Calculator/Codigo: mudanças entre as edições
Ir para navegação
Ir para pesquisar
| Linha 3: | Linha 3: | ||
<tr> | <tr> | ||
<td style="height: 30px;" colspan="2"> | <td style="height: 30px;" colspan="2"> | ||
<div id="title" class="titulo">Hot Cuisine Calculator System</div> | <div id="training-weapon-time-title" class="titulo">Hot Cuisine Calculator System</div> | ||
</td> | </td> | ||
</tr> | </tr> | ||
| Linha 14: | Linha 14: | ||
<tr> | <tr> | ||
<td> | <td> | ||
<div | <div class="titulo">Normal Weapons:</div> | ||
<div id="normal-weapons-select"></div> | <div id="normal-weapons-select"></div> | ||
</td> | </td> | ||
| Linha 20: | Linha 20: | ||
<tr> | <tr> | ||
<td> | <td> | ||
<div | <div class="titulo">Durable Weapons:</div> | ||
<div id="durable-weapons-select"></div> | <div id="durable-weapons-select"></div> | ||
</td> | </td> | ||
| Linha 26: | Linha 26: | ||
<tr> | <tr> | ||
<td> | <td> | ||
<div | <div class="titulo">Lasting Weapons:</div> | ||
<div id="lasting-weapons-select"></div> | <div id="lasting-weapons-select"></div> | ||
</td> | </td> | ||
| Linha 199: | Linha 199: | ||
</pre> | </pre> | ||
<pre id="exercise_weapons_js"> | <pre id="exercise_weapons_js"> | ||
var | var ewc_version = "1.0.1"; | ||
const exercise_weapons = { | const exercise_weapons = { | ||
"normal": [ | "normal": [ | ||
| Linha 402: | Linha 402: | ||
$(document).ready(function() { | $(document).ready(function() { | ||
$("#title").text("Exercise Weapons Time Calculator - " + | $("#training-weapon-time-title").text("Exercise Weapons Time Calculator - " + ewc_version); | ||
populateWeaponSelect(); | populateWeaponSelect(); | ||
updateSelectedWeapon(document.getElementById("normal-weapon")); | updateSelectedWeapon(document.getElementById("normal-weapon")); | ||
}); | }); | ||
</pre> | </pre> | ||
Edição das 16h33min de 8 de agosto de 2023
<table class="main_table">
<tr>
<td style="height: 30px;" colspan="2">
<div id="training-weapon-time-title" class="titulo">Hot Cuisine Calculator System</div>
</td>
</tr>
<tr>
<td>
<table style="width:100%;height:40px;">
<tr>
<td style="width: 48%; vertical-align: top;">
<table style="width:100%;">
<tr>
<td>
<div class="titulo">Normal Weapons:</div>
<div id="normal-weapons-select"></div>
</td>
</tr>
<tr>
<td>
<div class="titulo">Durable Weapons:</div>
<div id="durable-weapons-select"></div>
</td>
</tr>
<tr>
<td>
<div class="titulo">Lasting Weapons:</div>
<div id="lasting-weapons-select"></div>
</td>
</tr>
</table>
</td>
<td style="width: 48%; vertical-align: top;">
<table style="height:100%;">
<tr>
<td style="height: 60px; vertical-align: top;">
<div class="titulo">Quantidade de Cargas:</div>
<input type="number" id="qtdCharges" name="qtdCharges" value="1" min="1" oninput="updateTime()"><br>
</td>
</tr>
<tr>
<td style="width: 48%; vertical-align: top;">
<div class="titulo">Tempo das Cargas:</div>
<div class="ingredients-list" style="max-height: 485px; overflow: auto; vertical-align: top;">
<label id="time-label"></label>
</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
.main_table {
border: #7B6E4C 1px solid;
background: #181E23;
margin: 2px;
-webkit-box-shadow: 0px 0px 10px 2px rgba(255, 255, 255, 1);
-moz-box-shadow: 0px 0px 10px 2px rgba(255, 255, 255, 1);
box-shadow: 0px 0px 10px 2px rgba(255, 255, 255, 1);
font-family: Verdana, Arial, Times New Roman, sans-serif;
font-size: 13px;
color: #B2A898;
}
.titulo {
position: relative;
margin: 1px 2px 0 2px;
border: #7B6E4C 1px solid;
background: #11161A;
padding: 0 auto;
height: 24px;
line-height: 24px;
text-align: center;
font-weight: bold;
font-size: 12px;
cursor: default;
}
.quantity-box {
position: relative;
width: 34px;
margin: 1px 2px 0 2px;
border: #7B6E4C 1px solid;
background: #11161A;
height: 15px;
line-height: 15px;
text-align: center;
font-weight: bold;
font-size: 12px;
cursor: default;
}
.title-box {
position: relative;
margin: 1px 2px 0 2px;
border: #7B6E4C 1px solid;
background: #11161A;
line-height: 50px;
text-align: center;
font-weight: bold;
font-size: 12px;
cursor: default;
height: 56px;
width: 100%;
}
#qtdCharges {
background: #11161A;
width: 273px;
height: 18px;
margin: 5px 0px 0 2px;
padding: 1px 1px 1px 1px;
border: #CBB47A 1px solid;
border-collapse: separate;
font-family: Verdana, Arial, Times New Roman, sans-serif;
font-size: 13px;
color: #B2A898;
}
#time-label {
background: transparent;
font-family: Verdana, Arial, Times New Roman, sans-serif;
font-size: 13px;
color: #B2A898;
display: block;
text-align: center;
}
.link-system {
color: #CBB47A !important;
}
#normal-weapons-select, #durable-weapons-select, #lasting-weapons-select, .ingredients-list {
background: #11161A;
margin: 5px 2px 2px 2px;
padding: 10px;
border: #CBB47A 1px solid;
border-collapse: separate;
}
input[type=checkbox] {
width: 20px;
height: 20px;
}
.image-box {
position: relative;
margin: 1px 2px 0 2px;
border: #7B6E4C 1px solid;
background: #11161A;
padding: 0 auto;
height: 34px;
width: 34px;
text-align: center;
cursor: default;
}
#qtdCharges {
border: #7B6E4C 1px solid;
background: #3d5361;
height: 18px;
line-height: 18px;
text-align: center;
display: inline-block;
vertical-align: top;
white-space: nowrap;
font-family: Verdana, Arial, Times New Roman, sans-serif;
font-size: 13px;
color: #B2A898;
}
/* Tooltip */
.tip2 {
background-color: #F2F2F2;
border-radius: 2px;
box-shadow: 0 0 6px #B2B2B2;
display: none;
position: absolute;
padding: 10px;
z-index: 1;
}
.tooltip {
position: relative;
}
.tooltip,
.tooltip:hover + .tip2,
.tip2:hover {
display: block;
}
var ewc_version = "1.0.1";
const exercise_weapons = {
"normal": [
{
name: "Exercise Axe",
charges: 500,
image: "https://www.tibiawiki.com.br/images/d/dd/Exercise_Axe.gif",
link: "https://www.tibiawiki.com.br/wiki/Exercise_Axe"
},
{
name: "Exercise Bow",
charges: 500,
image: "https://www.tibiawiki.com.br/images/2/29/Exercise_Bow.gif",
link: "https://www.tibiawiki.com.br/wiki/Exercise_Bow"
},
{
name: "Exercise Club",
charges: 500,
image: "https://www.tibiawiki.com.br/images/f/fa/Exercise_Club.gif",
link: "https://www.tibiawiki.com.br/wiki/Exercise_Club"
},
{
name: "Exercise Sword",
charges: 500,
image: "https://www.tibiawiki.com.br/images/c/c5/Exercise_Sword.gif",
link: "https://www.tibiawiki.com.br/wiki/Exercise_Sword"
},
{
name: "Exercise Rod",
charges: 500,
image: "https://www.tibiawiki.com.br/images/e/e8/Exercise_Rod.gif",
link: "https://www.tibiawiki.com.br/wiki/Exercise_Rod"
},
{
name: "Exercise Wand",
charges: 500,
image: "https://www.tibiawiki.com.br/images/9/93/Exercise_Wand.gif",
link: "https://www.tibiawiki.com.br/wiki/Exercise_Wand"
}
],
"durable": [
{
name: "Exercise Axe",
charges: 1800,
image: "https://www.tibiawiki.com.br/images/1/10/Durable_Exercise_Axe.gif",
link: "https://www.tibiawiki.com.br/wiki/Durable_Exercise_Axe"
},
{
name: "Exercise Bow",
charges: 1800,
image: "https://www.tibiawiki.com.br/images/e/e0/Durable_Exercise_Bow.gif",
link: "https://www.tibiawiki.com.br/wiki/Durable_Exercise_Bow"
},
{
name: "Exercise Club",
charges: 1800,
image: "https://www.tibiawiki.com.br/images/3/31/Durable_Exercise_Club.gif",
link: "https://www.tibiawiki.com.br/wiki/Durable_Exercise_Club"
},
{
name: "Exercise Sword",
charges: 1800,
image: "https://www.tibiawiki.com.br/images/2/2a/Durable_Exercise_Sword.gif",
link: "https://www.tibiawiki.com.br/wiki/Durable_Exercise_Sword"
},
{
name: "Exercise Rod",
charges: 1800,
image: "https://www.tibiawiki.com.br/images/3/3e/Durable_Exercise_Rod.gif",
link: "https://www.tibiawiki.com.br/wiki/Durable_Exercise_Rod"
},
{
name: "Exercise Wand",
charges: 1800,
image: "https://www.tibiawiki.com.br/images/2/25/Durable_Exercise_Wand.gif",
link: "https://www.tibiawiki.com.br/wiki/Durable_Exercise_Wand"
}
],
"lasting": [
{
name: "Exercise Axe",
charges: 14400,
image: "https://www.tibiawiki.com.br/images/4/44/Lasting_Exercise_Axe.gif",
link: "https://www.tibiawiki.com.br/wiki/Lasting_Exercise_Axe"
},
{
name: "Exercise Bow",
charges: 14400,
image: "https://www.tibiawiki.com.br/images/7/7c/Lasting_Exercise_Bow.gif",
link: "https://www.tibiawiki.com.br/wiki/Lasting_Exercise_Bow"
},
{
name: "Exercise Club",
charges: 14400,
image: "https://www.tibiawiki.com.br/images/3/3b/Lasting_Exercise_Club.gif",
link: "https://www.tibiawiki.com.br/wiki/Lasting_Exercise_Club"
},
{
name: "Exercise Sword",
charges: 14400,
image: "https://www.tibiawiki.com.br/images/d/db/Lasting_Exercise_Sword.gif",
link: "https://www.tibiawiki.com.br/wiki/Lasting_Exercise_Sword"
},
{
name: "Exercise Rod",
charges: 14400,
image: "https://www.tibiawiki.com.br/images/3/31/Lasting_Exercise_Rod.gif",
link: "https://www.tibiawiki.com.br/wiki/Lasting_Exercise_Rod"
},
{
name: "Exercise Wand",
charges: 14400,
image: "https://www.tibiawiki.com.br/images/1/1c/Lasting_Exercise_Wand.gif",
link: "https://www.tibiawiki.com.br/wiki/Lasting_Exercise_Wand"
}
]
}
const weapons = ["Axe", "Bow", "Club", "Sword", "Rod", "Wand"]
var calcTime = (charges) => {
let hour = getHour(charges * 2);
let minutes = getMinute(charges * 2);
let seconds = getSeconds(charges * 2);
return ((hour < 10) ? "0" + hour : hour) + ":" + ((minutes < 10) ? "0" + minutes : minutes) + ":" + ((seconds < 10) ? "0" + seconds : seconds) + "h";
}
var getHour = (time) => {
return Math.floor(time / 3600);
}
var getMinute = (time) => {
return Math.floor((time % 3600) / 60);
}
var getSeconds = (time) => {
return time % 60;
}
var getRandomWeapon = () => {
let randomIndex = Math.floor(Math.random() * weapons.length);
return weapons[randomIndex];
}
// Popula o Select de Items.
var populateWeaponSelect = async () => {
$("#normal-weapons-select").empty();
$("#durable-weapons-select").empty();
$("#lasting-weapons-select").empty();
let selectedWeaponClass = getRandomWeapon();
if (exercise_weapons != null) { // Verifica se a lista de weapons não é nula
let normal_weapon = exercise_weapons["normal"].find(weapon => weapon.name.includes(selectedWeaponClass));
let durable_weapon = exercise_weapons["durable"].find(weapon => weapon.name.includes(selectedWeaponClass));
let lasting_weapon = exercise_weapons["lasting"].find(weapon => weapon.name.includes(selectedWeaponClass));
populateNormalWeaponSelect(normal_weapon);
populateDurableWeaponSelect(durable_weapon);
populateLastingWeaponSelect(lasting_weapon);
}
};
var populateNormalWeaponSelect = (weapon) => {
let image = "<img style=\"width: 25px; height 25px;\" src=\""+ weapon.image + "\"/>";
image = "<span class=\"tooltip\"><img style=\"width: 25px; height 25px;\" src=\""+ weapon.image + "\" /></span><span class=\"tip2\" id=\"fonte3\"><a href=\"" + weapon.link + "\" target=\"blank\">" + weapon.name + ": " + weapon.charges +"</a></span>";
$("#normal-weapons-select").append("<div style=\"margin-top: 5px; height: 5px; margin-bottom: 5px; display: flex; align-items: center; justify-content: center; width: fit-content;\"><input type=\"checkbox\" id=\"normal-weapon\" name=\"" + weapon.name + "\" value=\"" + weapon.charges + "\" onchange=\"updateSelectedWeapon(this)\">" + image + "<label for=\"normal-weapon\"> " + weapon.name + "</label></div><br>");
}
var populateDurableWeaponSelect = (weapon) => {
let image = "<img style=\"width: 25px; height 25px;\" src=\""+ weapon.image + "\"/>";
image = "<span class=\"tooltip\"><img style=\"width: 25px; height 25px;\" src=\""+ weapon.image + "\" /></span><span class=\"tip2\" id=\"fonte3\"><a href=\"" + weapon.link + "\" target=\"blank\">Durable " + weapon.name + ": " + weapon.charges +"</a></span>";
$("#durable-weapons-select").append("<div style=\"margin-top: 5px; height: 5px; margin-bottom: 5px; display: flex; align-items: center; justify-content: center; width: fit-content;\"><input type=\"checkbox\" id=\"durable-weapon\" name=\"" + weapon.name + "\" value=\"" + weapon.charges + "\" onchange=\"updateSelectedWeapon(this)\">" + image + "<label for=\"durable-weapon\"> " + weapon.name + "</label></div><br>");
}
var populateLastingWeaponSelect = (weapon) => {
let image = "<img style=\"width: 25px; height 25px;\" src=\""+ weapon.image + "\"/>";
image = "<span class=\"tooltip\"><img style=\"width: 25px; height 25px;\" src=\""+ weapon.image + "\" /></span><span class=\"tip2\" id=\"fonte3\"><a href=\"" + weapon.link + "\" target=\"blank\">Lasting " + weapon.name + ": " + weapon.charges +"</a></span>";
$("#lasting-weapons-select").append("<div style=\"margin-top: 5px; height: 5px; margin-bottom: 5px; display: flex; align-items: center; justify-content: center; width: fit-content;\"><input type=\"checkbox\" id=\"lasting-weapon\" name=\"" + weapon.name + "\" value=\"" + weapon.charges + "\" onchange=\"updateSelectedWeapon(this)\">" + image + "<label for=\"lasting-weapon\"> " + weapon.name + "</label></div><br>");
}
var updateSelectedWeapon = (weapon) => {
document.getElementById("normal-weapon").checked = false;
document.getElementById("durable-weapon").checked = false;
document.getElementById("lasting-weapon").checked = false;
weapon.checked = true;
updateQtdCharges(weapon.value);
}
var updateQtdCharges = (charges) => {
document.getElementById("qtdCharges").value = charges;
updateTime();
}
var updateTime = () => {
let charges = document.getElementById("qtdCharges").value;
let time = calcTime(charges);
$("#time-label").text(time);
}
$(document).ready(function() {
$("#training-weapon-time-title").text("Exercise Weapons Time Calculator - " + ewc_version);
populateWeaponSelect();
updateSelectedWeapon(document.getElementById("normal-weapon"));
});