User:XTCarnage/common.js: Difference between revisions

From Idle Clans wiki
mNo edit summary
mNo edit summary
Line 12: Line 12:
             var percentageChance = 1.2 * 0.000005 * ((levelRequirement / 10) * 1.033)
             var percentageChance = 1.2 * 0.000005 * ((levelRequirement / 10) * 1.033)
             var textChance = "1 in " + (1 / percentageChance);
             var textChance = "1 in " + (1 / percentageChance);
             $(this).text(textChance); // Show the adjusted time with 2 decimals
             $(this).text(textChance.toLocaleString());
         });
         });
          
          

Revision as of 17:55, 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 " + (1 / percentageChance);
            $(this).text(textChance.toLocaleString());
        });
        
        // 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
            });
        });
    });
});