ব্যবহারকারী:ARI/common.js: সংশোধিত সংস্করণের মধ্যে পার্থক্য

সম্পাদনা সারাংশ নেই
সম্পাদনা সারাংশ নেই
১ নং লাইন: ১ নং লাইন:
mw.loader.using(['mediawiki.util', 'mediawiki.api'], function () {
mw.loader.using(['mediawiki.util', 'mediawiki.api'], function () {
     $(function () {
     $(function () {
        // Prevent script from running on Special pages (which cannot be purged)
         if (mw.config.get('wgNamespaceNumber') < 0) return;
         if (mw.config.get('wgNamespaceNumber') < 0) return;


        // Add the Portlet Link
 
         var purgeLink = mw.util.addPortletLink(
         var purgeLink = mw.util.addPortletLink(
             'p-cactions',       // Target the "More" dropdown (Vector) or Actions tab (Monobook)
             'p-tb',                 // This puts it in the "Tools" list
             '#',               // Link destination (handled by click event below)
             '#',                   // Link destination
             'Purge',           // The visible text
             'Purge',               // Text to show (You can change this to 'শোধন')
             'ca-purge',         // DOM ID for the link
             't-purge',             // HTML ID
             'Purge cache and update links', // Tooltip
             'Purge cache and update links' // Tooltip
            '*'                // Keyboard shortcut (Alt+Shift+*)
         );
         );


        // Handle the click event
 
         $(purgeLink).on('click', function (e) {
         $(purgeLink).on('click', function (e) {
             e.preventDefault(); // Stop the link from following '#'
             e.preventDefault();
           


            // Change text to indicate processing
             $(this).find('a').text('Purging...');  
             $(this).find('a').text('Purging...');


            // Call the API
             new mw.Api().post({
             new mw.Api().post({
                 action: 'purge',
                 action: 'purge',
                 titles: mw.config.get('wgPageName'),
                 titles: mw.config.get('wgPageName'),
                 forcelinkupdate: 1 // This performs the "Hard Purge" (updates tables)
                 forcelinkupdate: 1  
             }).then(function () {
             }).then(function () {
                 // On success, reload the page
                 // 3. Reload on success
                 location.reload();
                 location.reload();
             }).catch(function () {
             }).catch(function () {
                 // If API fails, fallback to the standard confirmation screen
                 // Fallback if API fails
                 window.location.href = mw.util.getUrl(null, { action: 'purge' });
                 location.reload();
             });
             });
         });
         });
     });
     });
});
});