MediaWiki:Gadget-progress-review.js

From Wikinews, the free news source you can write!
Jump to navigation Jump to search

Note: After saving, you may have to bypass your browser's cache to see the changes. Mozilla / Firefox / Safari: hold down Shift while clicking Reload, or press Ctrl-Shift-R (Cmd-Shift-R on Apple Mac); IE: hold Ctrl while clicking Refresh, or press Ctrl-F5; Konqueror: simply click the Reload button, or press F5; Opera users may need to completely clear their cache in Tools→Preferences. — More skins

try { // containerize gadget, to protect other gadgets if this one goes wrong

   /*   ╔═════════════════════════════════════════════════════════╗   *
    *   ║ PROGRESS-REVIEW.JS - MAINTAINER: MICROCHIP08@ENWIKINEWS ║   *
    *   ║ v1.0   Changes Wikinews logo depending on the number of ║   *
    *   ║ M-PR-X      articles languishing in the review category ║   * 
    *   ║ Released into the public domain (also CC-BY & CC-BY-SA) ║   *
    *   ╚═════════════════════════════════════════════════════════╝   */
 
mw.loader.load( '/w/index.php?title=' + 'User:Bawolff/mwapilib2.js' + '&action=raw&ctype=text/javascript' ); // With thanks to User:Bawolff for his 1337 h4x0r skillz
 
function pendingReview (numbWaitingForReview){
  try {
         if (numbWaitingForReview != 0)
            {
              switch (numbWaitingForReview)
                 {
                    case '1':
                      pic = 'url(//upload.wikimedia.org/wikipedia/commons/thumb/7/7c/Wikinews-en-progress-1.png/135px-Wikinews-en-progress-1.png)';
                      break;
                    case '2':
                       pic = 'url(//upload.wikimedia.org/wikipedia/commons/thumb/4/4a/Wikinews-logo-en-2.png/135px-Wikinews-logo-en-2.png)';
                       break;
                    case '3':
                       pic = 'url(//upload.wikimedia.org/wikipedia/commons/thumb/b/b1/Wikinews-logo-en-3.png/135px-Wikinews-logo-en-3.png)';
                       break;
                    case '4':
                       pic = 'url(//upload.wikimedia.org/wikipedia/commons/thumb/6/6f/Wikinews-logo-en-4.png/135px-Wikinews-logo-en-4.png)';
                       break;
                    case '5':
                       pic = 'url(//upload.wikimedia.org/wikipedia/commons/thumb/a/a9/Wikinews-logo-en-5.png/135px-Wikinews-logo-en-5.png)';
                       break;
                    case '6':
                       pic = 'url(//upload.wikimedia.org/wikipedia/commons/thumb/d/d3/Wikinews-logo-en-6.png/135px-Wikinews-logo-en-6.png)';
                       break;
                    case '7':
                       pic = 'url(//upload.wikimedia.org/wikipedia/commons/thumb/9/9e/Wikinews-logo-en-7.png/135px-Wikinews-logo-en-7.png)';
                       break;
                    case '8':
                       pic = 'url(//upload.wikimedia.org/wikipedia/commons/thumb/d/db/Wikinews-logo-en-8.png/135px-Wikinews-logo-en-8.png)';
                       break;
                    case '9':
                       pic = 'url(//upload.wikimedia.org/wikipedia/commons/thumb/a/a8/Wikinews-logo-en-9.png/135px-Wikinews-logo-en-9.png)';
                       break;
                    case '0':
                       pic = 'url(//upload.wikimedia.org/wikipedia/commons/thumb/b/bd/Wikinews-logo-en.png/135px-Wikinews-logo-en.png)';
                       jsMsg('Minor error M-PR-1: The Wikinews logo has been changed although it didn\'t have to be. Please tell <a href=\"/wiki/User:Microchip08\">Microchip08</a>!'); // zOMG ERROR!
                       break;
                    default:
                       pic = 'url(//upload.wikimedia.org/wikipedia/commons/thumb/9/9a/Wikinews-logo-en-0.png/135px-Wikinews-logo-en-0.png)';
                       break;
                 }
               document.getElementById('p-logo').getElementsByTagName('a')[0].style.backgroundImage = pic;
             }
        }
        catch(err)
        {
         jsMsg('Oh dear, the red Wikinews logo broke. It\'s not compatible with skins without the logo in the top-left hand corner: disable it to speed up load times marginally and to remove this notice. If you <i>are</i> using a compatible skin, please tell <a href=\"/wiki/User:Microchip08\">Microchip08</a> about this error.');
      }
}
 
$(function () { 
  if (api && Bawolff && Bawolff.mwapi) {
    //if statement is for google chrome, which sometimes sucks, and calls onloadhook before its loaded...
    api().pagesInCat('review').lift(pendingReview).exec();
  }
  else if(!arguments.callee.retry) {
    arguments.callee.retry = true; //only do this once
    window.setTimeout(arguments.callee, 800);
  }
});
 
// dual licensed: PD-self; CC-BY-3.0 (preferred); CC-BY-SA-2.0-UK (to be compatible with Wikimedia projects),

} catch (e) { // containerize gadget, to protect other gadgets if this one goes wrong
  // ignore
}