Jump to content

MediaWiki:Corrections.js

From Wikisource
Revision as of 13:27, 20 January 2010 by ThomasV (talk | contribs)

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
/**************
 * corrections 
 **************/

function pr_popup(str){
  var popup = window.open('','name','height=400,width=500');
  popup.document.write('<html><head><title>Typos</title>');
  popup.document.write('<style type="text\/css" media="screen,projection">/*<![CDATA[*/ @import "\/skins-1.5\/monobook\/main.css?5"; /*]]>*/<\/style>');
  popup.document.write('</head><body class="mediawiki ltr ns-subject skin-monobook" >');
  popup.document.write('<div id="content">'+str+'</div>');
  popup.document.write('<p><a href="javascript:self.close()">Close</a></p>');
  popup.document.write('</body></html>');
  popup.document.close();

}

function pr_typos() {

   if( wgNamespaceNumber==0 || self.proofreadPageViewURL ) {

     var message_title = { 
        'en':"List of corrections performed on this page" , 
        'fr':"Liste des corrections apportées à cette page" 
     }
     
     var str = message_title[wgContentLanguage]+" :<br/><ul>"; 
     j=0;
     for(var i=0; item=document.getElementsByTagName("span")[i]; i++) {
         if(item.className=="coquille") { 
           j=j+1; 
           w1=w2='';
           if(item.previousSibling) { 
              context1=item.previousSibling.data.split(' ');
              if(context1.length>1) w1 = context1[context1.length - 2];
           }
           if(item.nextSibling) { 
              context2=item.nextSibling.data.split(' ');
              if(context2.length>1) w2 = context2[1]; 
           }
           str = str+'<li> « '+w1+' '+item.title + ' '+ w2 + ' »   →   « ' + w1 + ' ' + item.innerHTML + ' ' + w2 +' »</li>'; 
         }
     } 
     str=str+'</ul>'

     if(j) {
         var optlist = get_optlist();
         optlist.innerHTML = optlist.innerHTML + "<li class=\"\"><a href='javascript:pr_popup(\""+str+"\");'>Coquilles ("+j+")</a></li>";
         cs=document.getElementById("corr-info");
         if(cs){
           if(j==1)
             cs.innerHTML = " <a href='javascript:pr_popup(\""+str+"\");'>Une coquille </a> a été corrigée.";
           else
             cs.innerHTML = " <a href='javascript:pr_popup(\""+str+"\");'>"+j+" coquilles</a> ont été corrigées.";
        }
     }
   }
}

addOnloadHook(pr_typos);