User:XTCarnage/common.js: Difference between revisions
From Idle Clans wiki
mNo edit summary |
mNo edit summary |
||
Line 13: | Line 13: | ||
var textChance = "1 in " + Math.ceil(1 / percentageChance).toLocaleString(); | var textChance = "1 in " + Math.ceil(1 / percentageChance).toLocaleString(); | ||
$(this).text(textChance); | $(this).text(textChance); | ||
}); | |||
$(".chance-per-day").each(function() { | |||
var levelRequirement = $(this).data("level"); | |||
var time = $(this).data("time") / 100; | |||
var percentageChance = 1.2 * 0.000005 * ((levelRequirement / 10) * 1.033); | |||
var chancePerDay = 1 - (1 - percentageChance)^(24*3600/time); | |||
$(this).text(chancePerDay); | |||
}); | }); | ||
Revision as of 18:03, 19 February 2025
mw.loader.using(['jquery'], function() { $(document).ready(function() { // Create the slider var slider = $('<input type="range" min="0" max="100" value="0" id="time-slider">'); var sliderLabel = $('<p>Adjust Production Time: <span id="slider-value">0</span>%</p>'); // Append slider to the page $(".mw-slider-md").append(sliderLabel).append(slider); $(".chance-per-action").each(function() { var levelRequirement = $(this).data("level"); var percentageChance = 1.2 * 0.000005 * ((levelRequirement / 10) * 1.033) var textChance = "1 in " + Math.ceil(1 / percentageChance).toLocaleString(); $(this).text(textChance); }); $(".chance-per-day").each(function() { var levelRequirement = $(this).data("level"); var time = $(this).data("time") / 100; var percentageChance = 1.2 * 0.000005 * ((levelRequirement / 10) * 1.033); var chancePerDay = 1 - (1 - percentageChance)^(24*3600/time); $(this).text(chancePerDay); }); // Update the table values when the slider is moved slider.on("input", function() { var sliderValue = $(this).val(); $("#slider-value").text(sliderValue); // Adjust production times based on slider value $(".production-time").each(function() { var originalTime = $(this).data("original-time"); var adjustedTime = originalTime * (1 - sliderValue / 100) * 0.95; $(this).text(adjustedTime.toFixed(2)); // Show the adjusted time with 2 decimals }); }); }); });