Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

User:LaluShi/common.js: Difference between revisions

From Growtopia Wiki
LaluShi (talk | contribs)
No edit summary
LaluShi (talk | contribs)
Replaced content with "importArticles({ type: 'script', articles: [ 'u:dev:MediaWiki:CategoryQuickRemove.js', ] });"
Line 4: Line 4:
         'u:dev:MediaWiki:CategoryQuickRemove.js',
         'u:dev:MediaWiki:CategoryQuickRemove.js',
     ]
     ]
});
$(document).ready(function() {
    // Check if we are on the page where we want to insert the XP calculation box
    if (mw.config.get('wgCanonicalNamespace') === 'User_blog' && mw.config.get('wgAction') === 'view') {
        // Create the XP calculation box
        var xpCalculationBox = '<div id="xpCalculationBox">' +
            '<h2>XP Calculation</h2>' +
            '<div>' +
            '  <label for="rValue">Enter the rarity (R):</label>' +
            '  <input type="number" id="rValue" min="0" step="1">' +
            '</div>' +
            '<div>' +
            '  <button id="calculateBtn">Calculate XP</button>' +
            '</div>' +
            '<div>' +
            '  <p id="xpResult"></p>' +
            '</div>' +
            '</div>';
       
        // Insert the XP calculation box into the page
        $('.mw-parser-output').prepend(xpCalculationBox);
       
        // Function to calculate XP when the button is clicked
        $('#calculateBtn').on('click', function() {
            // Get the value of R from the input field
            var r = parseInt($('#rValue').val());
           
            // Calculate E using the formula E = 1 + floor(R / 5)
            var e = 1 + Math.floor(r / 5);
           
            // Display the result
            $('#xpResult').text("XP Earned: " + e);
        });
    }
});
});

Revision as of 15:15, 20 September 2024

importArticles({
    type: 'script',
    articles: [
        'u:dev:MediaWiki:CategoryQuickRemove.js',
    ]
});