User:XTCarnage/SkillingTickets.js: Difference between revisions

From Idle Clans wiki
((WIP) Slider-v1)
 
mNo edit summary
 
Line 6: Line 6:
          
          
         // Append slider to the page
         // Append slider to the page
         $(".mw-slider").append(sliderLabel).append(slider);
         $(".mw-slider-md").append(sliderLabel).append(slider);
          
          
         // Update the table values when the slider is moved
         // Update the table values when the slider is moved

Latest revision as of 04:51, 18 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);
                $(this).text(adjustedTime.toFixed(2)); // Show the adjusted time with 2 decimals
            });
        });
    });
});