User:XTCarnage/common.js: Difference between revisions

From Idle Clans wiki
(Created page with "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); // Update the table values when the slider is moved...")
 
mNo edit summary
Line 16: Line 16:
             $(".production-time").each(function() {
             $(".production-time").each(function() {
                 var originalTime = $(this).data("original-time");
                 var originalTime = $(this).data("original-time");
                 var adjustedTime = originalTime * (1 - sliderValue / 100);
                 var adjustedTime = originalTime * (1 - sliderValue / 100) * 0.95;
                 $(this).text(adjustedTime.toFixed(2)); // Show the adjusted time with 2 decimals
                 $(this).text(adjustedTime.toFixed(2)); // Show the adjusted time with 2 decimals
             });
             });

Revision as of 17:30, 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);
        
        // 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
            });
        });
    });
});