User:Topbanana/RLRL SR Utility.js

Today, User:Topbanana/RLRL SR Utility.js is a topic of great relevance and interest to a wide spectrum of people. With the advancement of technology and globalization, User:Topbanana/RLRL SR Utility.js has become a fundamental aspect in the daily lives of many individuals, impacting different aspects such as society, economy, politics and culture. This is why it is essential to delve deeper into the study and analysis of User:Topbanana/RLRL SR Utility.js, in order to better understand its influence and impact today. In this article, we will explore different aspects related to User:Topbanana/RLRL SR Utility.js, from its historical origin to its implications in the contemporary world, with the aim of providing a comprehensive and updated vision of this very relevant topic.
// Create some search-and-replace tools - this uses a slightly modified version
// of ])

mw.loader.load( 'https://en.wikipedia.org/w/index.php?title=User:Topbanana/regexReplace.js&action=raw&ctype=text/javascript');

function RLRL_SR_Utility()
{
   strAdvert = '  - ]';

   // Check if we are editing
   if ( document.getElementById("editform") )
   {
      // Check for and extract parameters
      parSearch  = mw.util.getParamValue( 'RLRLS' );
      parReplace  = mw.util.getParamValue( 'RLRLR' );
      parRedirect = mw.util.getParamValue( 'RLRLRD' );

      // First check if we are being asked to create a redirect
     if( parRedirect )
     {
        // Check we have no other parameters
        if( parSearch || parReplace )
          return;
 
        // Check the edit box is empty
        if( document.forms.editform.wpTextbox1.value.length > 0 )
          return;
 
        // Correct the parameters provided
        parRedirect = unescape( decodeURIComponent( parRedirect.replace( /_/g, " " ) ) );

        // Okay, populate the edit box and summary
        document.forms.editform.wpTextbox1.value = '#REDIRECT ]';
        document.forms.editform.wpSummary.value =
            'Link repair:  Redirecting page to ' + parRedirect + strAdvert;
        document.forms.editform.wpWatchthis.checked = false;
 
        return;
     }
 
     // Okay, not a redirect.  Check if we are being asked to search-and-replace
 
     // If we've not got a useful set of parameters, give up   
     if( !parSearch || !parReplace )
       return;
 
     // Correct the parameters provided
     parSearch = unescape( decodeURIComponent( parSearch.replace( /_/g, " " ) ) );
     parReplace = unescape( decodeURIComponent( parReplace.replace( /_/g, " " ) ) );
 
     // Check for Template namespace prefix
     if( parSearch.indexOf( "Template:" ) == 0 &&
         parReplace.indexOf( "Template:" ) == 0 )
     {
        parSearch = parSearch.slice( 9 );
        parReplace = parReplace.slice( 9 );
     }

     // Escape any characters with special meanings in regular expressions
     parRegex = parSearch.replace(/{}()*+?.,\\^$|#\s]/g, "\\$&");

     // Specifically ignore the case of the first letter
     parRegex = '[' + parRegex.substring(0, 1).toUpperCase() +
                parRegex.substring(0, 1).toLowerCase() + ']' +
                parRegex.substring(1);

     // Find and manipulate the search and replace controls
     createRegexControls();
 
     document.getElementById('tbRegex_SearchCaseSensitive').checked = true;
     document.getElementById('tbRegex_SearchTextBox').value = parRegex;
     document.getElementById('tbRegex_FindButton').click();
     document.getElementById('tbRegex_ReplaceTextBox').value = parReplace;
 
     // Populate the edit summary
     document.forms.editform.wpSummary.value =
        'Link repair:  ' + parSearch + ' -> ' + parReplace + strAdvert;
     document.forms.editform.wpMinoredit.checked = true;
   }

   // Check if we are editing
   if ( document.getElementById("movepage") )
   {
      // Check for and extract parameters
      parNewNS    = mw.util.getParamValue( 'RLRLMNS' );
      parNewTitle = mw.util.getParamValue( 'RLRLMNT' );
 
     // If we've not got a useful set of parameters, give up   
     if( !parNewNS || !parNewTitle )
       return;
 
     // Correct the parameters provided
     parNewTitle = unescape( decodeURIComponent( parNewTitle.replace( /_/g, " " ) ) );
 
     document.getElementById('wpNewTitleNs').value = parNewNS;
     document.getElementById('wpNewTitleMain').value = parNewTitle;
 
     // Populate the edit summary
     document.getElementById('wpReason').value = strAdvert;
   }
};
 
addOnloadHook( RLRL_SR_Utility );