MediaWiki:Gadget-HistoryNumDiff.js
|
This page is a System Message. The code in these pages is used to alter the wiki site itself Only Administrators are able to alter system messages. If you think one should be changed, leave a note on the talk page or message User:gboyers. |
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)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Press Ctrl-F5.
/* _____________________________________________________________________________ * | | * | === WARNING: GLOBAL GADGET FILE === | * | Changes to this page affect many users. | * | Please discuss changes on the talk page or on [[WT:Gadget]] before editing. | * |_____________________________________________________________________________| * * Imported from the January 17, 2011 version at [[fr:MediaWiki:Gadget-HistoryNumDiff.js]] * * Shows the number of characters added or removed, rather than the size of the revision. * This format is like the one used by the Watchlist and Recent Changes. * * See [[MediaWiki:Gadget-HistoryNumDiff]]. * * Author: The RedBurn * */ function getNumFromString (i,eltsByTag) { var regString = /\((.*) bytes?\)/; var resultString; var string = eltsByTag.item(i).innerHTML; var separator = /[^0-9]/g; var empty = "(empty)"; if(mw.config.get( 'wgUserLanguage' ) == "fr") { regString = /\((.*) octets?\)/; empty = "(vide)"; } if(string==empty) { string=0; } else { resultString= regString.exec(string); string = resultString[1].replace(separator,""); string = parseInt(string, 10); } return string; } function makeNumDiff() { var string; var resultPrevString = 0; // précédent dans l'ordre chronologique var resultNextString = 0; var className; var lastI = 0; var i = 0; var eltsByTag = document.getElementsByTagName("span"); var length = eltsByTag.length; while(i<length && eltsByTag.item(i).className != "history-size") { i++; } if(i<length) { resultNextString = getNumFromString(i,eltsByTag); lastI = i; i++; while (i<length) { if (eltsByTag.item(i).className == "history-size"){ resultPrevString = getNumFromString(i,eltsByTag); string = resultNextString - resultPrevString; if (string>0) { className = "mw-plusminus-pos"; string = "+" + string; } else { if (string<0) { className = "mw-plusminus-neg"; } else { className = "mw-plusminus-null"; } } if (string<-500 || string>500) { string = "<strong>" + "(" + string + ")" + "</strong>"; } else { string = "(" + string + ")"; } eltsByTag.item(lastI).innerHTML = string ; eltsByTag.item(lastI).className = className; resultNextString = resultPrevString; lastI = i; } i++; } } } if(mw.config.get( 'wgAction' ) && mw.config.get( 'wgAction' ) == "history") { $(makeNumDiff); }