User:John Broughton/monobook.js

User:John Broughton/monobook.js is a topic that has captured the attention of many people in recent times. Its importance and relevance have become the focus of multiple debates and discussions in different areas. From the academic field to the professional field, User:John Broughton/monobook.js has generated growing interest due to its impacts and repercussions on today's society. As more people delve into the exploration and understanding of User:John Broughton/monobook.js, new perspectives and approaches are revealed that enrich existing knowledge on this topic. In this article, we will explore in depth the key aspects related to User:John Broughton/monobook.js, analyzing its evolution, its challenges and its possible future developments.
// Checks edits to talk pages; warns if no signature:

importScript("User:John Broughton/sign.js");

// Creates multiple edit boxes, including separate ones for references and templates:

importScript("User:Magnus Manske/less edit clutter.js"); 

// ]

// importScript("User:Lupin/recent2.js"); (commented out, September 27, 2008)

// ]

// importScript('User:Lupin/popups.js');

// Note, August 26, 2008: Now using Navigation Popups from the Gadgets tab of "My preferences"

importScript('User:Anomie/ajaxpreview.js'); // Linkback: ]
 
// Adds replace option to editing window - from ]

function wpTextboxReplace()
{
    var s = prompt("Search regexp:");
    if(s){
        var r = prompt("Replace /"+s+"/ with:");
        if(!r && r != '') return;
        var txt = document.editform.wpTextbox1;
        txt.value = txt.value.replace(new RegExp(s, "mg"), r);
    }
}
addOnloadHook(function () {
    if (document.forms.editform) {
        mw.util.addPortletLink('p-cactions', 'javascript:wpTextboxReplace()', 'Replace', 'ca-replace',
                       'Regexp replace for the edit window', 'R', document.getElementById('ca-history'));
    }
});

//From ]; highlights (in green) redirects on a page, after (added) tab is clicked
var highlightRedirects = {
 
 tab_redirects : null,
 status: null,
 xhr : null,
 todo : null,
 num : { total:0, done:0, redir:0 },
 
 //
 // Try to create an XMLHTTP request object for each tile
 // with maximum browser compat.
 // code adapted from http://jibbering.com/2002/4/httprequest.html
 //
 createXMLHTTP : function()
 {
  var i, xhr;
 
  /*@cc_on @*/
  /*@if (@_jscript_version >= 5)
  // Internet Explorer (uses Conditional compilation)
  // traps security blocked creation of the objects.
   wmaDebug('Microsoft section');
   try {
    xhr = new ActiveXObject("Msxml2.XMLHTTP");
   } catch (e) {
    try {
     xhr = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (E) {
     xhr = false;
    }
   }
  @end @*/
 
  // Firefox, Konqueror, Safari, Mozilla
  if (!xhr && typeof(XMLHttpRequest) != 'undefined') {
   try {
    xhr = new XMLHttpRequest();
   } catch (e) {
    xhr = false;
   }
  }
 
  // ICE browser
  if (!xhr && window.createRequest) {
   try {
    xhr = new window.createRequest();
   } catch (e) {
    xhr = false;
   }
  }
 
  return xhr;
 },
 
 updateStatus : function()
 {
  with( highlightRedirects )
  {
   status.nodeValue = ' (' + num.redir + '/' + num.done + '/' + num.total + ')';
  }
 },
 
 // cross-browser event attachment (John Resig)
 // http://www.quirksmode.org/blog/archives/2005/10/_and_the_winner_1.html
 addEvent : function ( obj, type, fn )
 {
  if (obj.addEventListener)
   obj.addEventListener( type, fn, false );
  else if (obj.attachEvent)
  {
   obj = fn;
   obj = function() { obj( window.event ); }
   obj.attachEvent( "on"+type, obj );
  }
 },
 
 run : function()
 {
  var links = document.getElementById('bodyContent').getElementsByTagName('a');
  var len = links.length;
  var local = window.location.href + '#'
 
  if( highlightRedirects.todo != null ) return;
 
  highlightRedirects.todo = new Array();
 
  for( var key = 0; key < len; key++ )
  {
   if( links.href && 
       links.pathname &&
       links.pathname.substr(0,6) == 'https://wikifreehand.com/en/' &&
       !( links.href.substr(0,local.length) == local ) &&
       !( links.pathname.substr(6,8) == 'Special:' ) )
   {
    highlightRedirects.todo =
    {
     link : links,
     xhr  : highlightRedirects.createXMLHTTP(),
     func : new Function(
       'var me = highlightRedirects.todo;' + 
       'if(me.xhr.readyState==4) {' +
        'var ro=eval("("+me.xhr.responseText+")");' +
        'var redir=false;' +
        'for( var k in ro.query.pages ) {' + 
         'if( typeof(ro.query.pages.redirect) != "undefined" ) redir=true;' +
        '}' +
        'if(redir) {' + 
         'me.link.style.color="green";' +
         'highlightRedirects.num.redir++;' +
        '}' + 
        'else me.link.style.color="blue";' +
        'highlightRedirects.num.done++; highlightRedirects.updateStatus();' +
       '}' 
     )
    }
 
    links.style.color = 'gray';
 
    with(highlightRedirects.todo)
    {
     xhr.open("GET", 
      "/w/api.php?action=query&prop=info&format=json&titles=" +
      links.pathname.substr(6), true);
 
     xhr.onreadystatechange = func;
     xhr.send( null ); 
    }
 
    highlightRedirects.num.total++;
   }
  }
 },
 
 install : function()
 {
  with(highlightRedirects)
  {
   tab_redirects = document.createElement('li');
   tab_redirects.style.cursor = 'pointer';
   tab_redirects.style.padding = '0pt 0.8em 0pt 0.8em';
   tab_redirects.style.color = 'blue';
 
   status = document.createTextNode('');
   tab_redirects.appendChild( document.createTextNode('redirects') );
   tab_redirects.appendChild( status );
 
   if( document.getElementById('ca-history') ) 
    document.getElementById('ca-history').parentNode.appendChild( tab_redirects  );
 
   addEvent( tab_redirects, 'click', run );
  }
 }
 
};
 
//
// Hook up installation function
//
addOnloadHook(highlightRedirects.install);

// End