r50262 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r50261‎ | r50262 | r50263 >
Date:14:34, 6 May 2009
Author:jojo
Status:reverted (Comments)
Tags:
Comment:
Added code & CSS for Navpopups. Do not use configurable URLs, but a single bool variable.
Modified paths:
  • /trunk/extensions/Collection/Collection.hooks.php (modified) (history)
  • /trunk/extensions/Collection/Collection.php (modified) (history)
  • /trunk/extensions/Collection/README.txt (modified) (history)
  • /trunk/extensions/Collection/collection/Gadget-navpop.css (added) (history)
  • /trunk/extensions/Collection/collection/Gadget-popups.js (added) (history)

Diff [purge]

Index: trunk/extensions/Collection/Collection.php
@@ -94,9 +94,7 @@
9595
9696 $wgCollectionPortletForLoggedInUsersOnly = false;
9797
98 -/** URLs to the JavaScript and CSS files of the popup gadget used on Wikipedia: */
99 -$wgCollectionNavPopupJSURL = null;
100 -$wgCollectionNavPopupCSSURL = null;
 98+$wgCollectionNavPopups = true;
10199
102100 # ==============================================================================
103101
Index: trunk/extensions/Collection/Collection.hooks.php
@@ -157,9 +157,12 @@
158158 global $wgJsMimeType;
159159 global $wgScriptPath;
160160 global $wgCollectionStyleVersion;
161 - global $wgCollectionNavPopupJSURL;
162 - global $wgCollectionNavPopupCSSURL;
 161+ global $wgCollectionNavPopups;
163162
 163+ $navPopupJSURL = "$wgScriptPath/extensions/Collection/collection/Gadget-popups.js?$wgCollectionStyleVersion";
 164+ $navPopupCSSURL = "$wgScriptPath/extensions/Collection/collection/Gadget-navpop.css?$wgCollectionStyleVersion";
 165+
 166+
164167 wfLoadExtensionMessages( 'CollectionCore' );
165168
166169 if (!$ajaxHint) {
@@ -304,7 +307,7 @@
305308 ;
306309
307310 // activate popup check:
308 - if ( $wgCollectionNavPopupJSURL && $wgCollectionNavPopupCSSURL ) {
 311+ if ( $wgCollectionNavPopups ) {
309312 $addPageText = wfMsg( 'coll-add_page_popup' );
310313 $addCategoryText = wfMsg( 'coll-add_category_popup' );
311314 $removePageText = wfMsg( 'coll-remove_page_popup' );
@@ -312,8 +315,8 @@
313316 $out .= <<<EOS
314317 <script type="text/javascript">
315318 /* <![CDATA[ */
316 - wgCollectionNavPopupJSURL = '$wgCollectionNavPopupJSURL';
317 - wgCollectionNavPopupCSSURL = '$wgCollectionNavPopupCSSURL';
 319+ wgCollectionNavPopupJSURL = '$navPopupJSURL';
 320+ wgCollectionNavPopupCSSURL = '$navPopupCSSURL';
318321 wgCollectionAddPageText = '$addPageText';
319322 wgCollectionAddCategoryText = '$addCategoryText';
320323 wgCollectionRemovePageText = '$removePageText';
Index: trunk/extensions/Collection/README.txt
@@ -185,28 +185,21 @@
186186 }
187187 ?>
188188
189 - *$wgCollectionNavPopupJSURL and $wgCollectionNavPopupCSSURL (string or null)*
190 - If you want to use popups to easily add/remove linked articles to your collection,
191 - you have to provide URLs for the JavaScript and the CSS file of the popup Gadget
192 - that's used on Wikipedia (see http://en.wikipedia.org/wiki/Navpop for more
193 - information). If the stock files in the English Wikipedia are usable for you
194 - (for example because you have a similar setup of your MediaWiki), you can link
195 - them directly::
 189+ *$wgCollectionNavPopups (bool)*
 190+ If you don't want to use popups to easily add/remove linked articles to your
 191+ collection, set this variable to false.
 192+
 193+ The Collection popups are only active if
196194
197 - $wgCollectionNavPopupJSURL = 'http://en.wikipedia.org/w/index.php?title=MediaWiki:Gadget-popups.js&action=raw&ctype=text/javascript';
198 - $wgCollectionNavPopupCSSURL = 'http://en.wikipedia.org/w/index.php?title=MediaWiki:Gadget-navpop.css&action=raw&ctype=text/css';
199 -
200 - Otherwise you have to provide adjusted files and set the URLs accordingly.
201 -
202 - If the URLs are provided, the Collection popup is only active if
203195 * JavaScript is enabled,
204196 * there's at least one wiki page in the current collection (i.e. the feature
205 - is activated by clicking on "Add wiki page" for the first time and
 197+ is activated by clicking on "Add page to bok" for the first time and
206198 deactivated as soon as the collection is empty),
207 - * the current user didn't enable the navigation popup gadget (see above),
208 - which would result in conflicting popups.
 199+ * the current user didn't enable the "Navigation popup gadget" on the MediaWiki
 200+ (see http://en.wikipedia.org/wiki/Navpop) which would result in conflicting
 201+ popups.
209202
210 - Default for both variables is null, i.e. the popup is deactivated.
 203+ Default is true, i.e. the Collection popups are enabled.
211204
212205 * If you want to let users save their collections as wiki pages, make sure
213206 $wgEnableWriteAPI is set to true, i.e. put this line in your LocalSettings.php::
Index: trunk/extensions/Collection/collection/Gadget-navpop.css
@@ -0,0 +1,135 @@
 2+a.popupMoreLink { display: block; text-align: right; cursor: pointer; }
 3+
 4+ins.popupDiff { background: #AFE; }
 5+del.popupDiff { background: #FFE6E6; }
 6+
 7+#selectionPreview { /* overflow: auto; max-height: 16ex; */
 8+ border: 2px solid #DDD;
 9+ background-color: #EEF;
 10+ padding: 6px;
 11+ }
 12+
 13+.navpopup
 14+{
 15+ border: solid #FFBE20 1px;
 16+ background-color: #FFFAEF;
 17+ padding: 5px;
 18+ font-size: 8pt;
 19+ /* opacity: 0.9; */
 20+}
 21+
 22+.popupDragHandle { /* background-color: #D2FEFA; */
 23+ cursor: move; }
 24+
 25+/* menu magic - many thanks to [[User:Zocky]]! */
 26+
 27+/* popups */
 28+.popup_menu li {
 29+ margin: 3px;
 30+}
 31+
 32+.popup_menu
 33+{
 34+ display:none;
 35+ position:absolute;
 36+ left:0;
 37+ margin: 0;
 38+ margin-top: 1em;
 39+ line-height: 1.25em;
 40+ list-style-type: none;
 41+ /*top:1.6ex; */
 42+ z-index:2;
 43+ width:10em;
 44+ background:white;
 45+ border:solid 1px grey;
 46+ padding: 0.5em !important;
 47+ margin-left: -6px;
 48+ margin-top: 1em;
 49+ border-width: 1px 1px 1px 6px;
 50+}
 51+.popup_menu a {display:block;}
 52+.popup_menu_row a {display:inline;}
 53+.popup_menu_row { list-style: none;
 54+ padding: 0;
 55+ margin: 0;
 56+ /*)border: solid 1px red;*/
 57+ }
 58+.popup_drop {display:inline; position:relative}
 59+.popup_drop:hover .popup_menu,
 60+.popup_drop .popup_menu:hover {display:inline; background:White; padding:2px 2px 2px 2px}
 61+
 62+.popup_drop:hover { background:#CCF; color:#44f; }
 63+
 64+/* other colours, styles and so on */
 65+.popup_menu a:hover {background:#CCf; color:#44f}
 66+.popup_mainlink {font-size: 140%; font-weight: bold}
 67+
 68+.popup_change_title_link { color: #152; }
 69+
 70+.popup_diff_dates {
 71+ font-style: italic;
 72+ background: none;
 73+ }
 74+
 75+.popup_menu_item {
 76+ list-style: none;
 77+ padding: 0;
 78+ margin: 0;
 79+ /*border: solid 1px green;*/
 80+}
 81+/* .popup_menu_item a:hover { */
 82+/* background:#CCf; */
 83+/* color:#44f; */
 84+/* } */
 85+.popup_menu_item a{ display:block; }
 86+
 87+.popup_history_row_even { background: #eee; }
 88+.popup_history_date { font-weight: bold; font-size: 120%; }
 89+
 90+/* copied from monobook #bodyContent declarations */
 91+
 92+.popupPreview a.external,
 93+.popupPreview a[href ^="gopher://"] {
 94+ background: url(http://en.wikipedia.org/skins/monobook/external.png) center right no-repeat;
 95+ padding-right: 13px;
 96+}
 97+.popupPreview a[href ^="https://"],
 98+.link-https {
 99+ background: url(http://en.wikipedia.org/skins/monobook/lock_icon.gif) center right no-repeat;
 100+ padding-right: 16px;
 101+}
 102+.popupPreview a[href ^="mailto:"],
 103+.link-mailto {
 104+ background: url(http://en.wikipedia.org/skins/monobook/mail_icon.gif) center right no-repeat;
 105+ padding-right: 18px;
 106+}
 107+.popupPreview a[href ^="news://"] {
 108+ background: url(http://en.wikipedia.org/skins/monobook/news_icon.png) center right no-repeat;
 109+ padding-right: 18px;
 110+}
 111+.popupPreview a[href ^="ftp://"],
 112+.link-ftp {
 113+ background: url(http://en.wikipedia.org/skins/monobook/file_icon.gif) center right no-repeat;
 114+ padding-right: 18px;
 115+}
 116+.popupPreview a[href ^="irc://"],
 117+.link-irc {
 118+ background: url(http://en.wikipedia.org/skins/monobook/discussionitem_icon.gif) center right no-repeat;
 119+ padding-right: 18px;
 120+}
 121+/* disable interwiki styling */
 122+.popupPreview a.extiw,
 123+.popupPreview a.extiw:active {
 124+ color: #36b;
 125+ background: none;
 126+ padding: 0;
 127+}
 128+.popupPreview a.external {
 129+ color: #36b;
 130+}
 131+/* this can be used in the content area to switch off
 132+special external link styling */
 133+.popupPreview .plainlinks a {
 134+ background: none !important;
 135+ padding: 0 !important;
 136+}
\ No newline at end of file
Property changes on: trunk/extensions/Collection/collection/Gadget-navpop.css
___________________________________________________________________
Name: svn:eol-style
1137 + native
Index: trunk/extensions/Collection/collection/Gadget-popups.js
@@ -0,0 +1,7903 @@
 2+var popupVersion="en:MediaWiki:Gadget-popups.js " + /*/{{subst:Selfsubst/now string|js|/*/ "2009-05-04 15:11:41 (UTC)" /*/}}/*/;
 3+// STARTFILE: main.js
 4+// **********************************************************************
 5+// ** **
 6+// ** changes to this file affect many users. **
 7+// ** please discuss on the talk page before editing **
 8+// ** **
 9+// **********************************************************************
 10+// ** **
 11+// ** if you do edit this file, be sure that your editor recognizes it **
 12+// ** as utf8, or the weird and wonderful characters in the namespaces **
 13+// ** below will be completely broken. You can check with the show **
 14+// ** changes button before submitting the edit. **
 15+// ** test: مدیا מיוחד Мэдыя **
 16+// ** **
 17+// **********************************************************************
 18+
 19+//////////////////////////////////////////////////
 20+// Globals
 21+//
 22+
 23+// Trying to shove as many of these as possible into the pg (popup globals) object
 24+function pg(){}; // dummy to stop errors
 25+window.pg = {
 26+ re: {}, // regexps
 27+ ns: {}, // namespaces
 28+ string: {}, // translatable strings
 29+ wiki: {}, // local site info
 30+ misc: {}, // YUCK PHOOEY
 31+ option: {}, // options, see newOption etc
 32+ optionDefault: {}, // default option values
 33+ flag: {}, // misc flags
 34+ cache: {}, // page and image cache
 35+ structures: {}, // navlink structures
 36+ timer: {}, // all sorts of timers (too damn many)
 37+ counter: {}, // .. and all sorts of counters
 38+ current: {}, // state info
 39+ endoflist: null
 40+};
 41+window.pop = { // wrap various functions in here
 42+ init: {},
 43+ util: {},
 44+ endoflist: null
 45+};
 46+function popupsReady() {
 47+ if (!window.pg) { return false; }
 48+ if (!pg.flag) { return false; }
 49+ if (!pg.flag.finishedLoading) { return false; }
 50+ return true;
 51+}
 52+
 53+/// Local Variables: ///
 54+/// mode:c ///
 55+/// End: ///
 56+// ENDFILE: main.js
 57+// STARTFILE: actions.js
 58+function setupTooltips(container, remove, force, popData) {
 59+ log('setupTooltips, container='+container+', remove='+remove);
 60+ if (!container) {
 61+//<NOLITE>
 62+ // the main initial call
 63+ if (getValueOf('popupOnEditSelection') && window.doSelectionPopup && document && document.editform && document.editform.wpTextbox1) {
 64+ document.editform.wpTextbox1.onmouseup=doSelectionPopup;
 65+ }
 66+//</NOLITE>
 67+ // article/content is a structure-dependent thing
 68+ container = defaultPopupsContainer();
 69+ }
 70+
 71+ if (!remove && !force && container.ranSetupTooltipsAlready) { return; }
 72+ container.ranSetupTooltipsAlready = !remove;
 73+
 74+ var anchors;
 75+ anchors=container.getElementsByTagName('A');
 76+ setupTooltipsLoop(anchors, 0, 250, 100, remove, popData);
 77+}
 78+
 79+function defaultPopupsContainer() {
 80+ if (getValueOf('popupOnlyArticleLinks')) {
 81+ return document.getElementById('article') ||
 82+ document.getElementById('content') ||
 83+ document.getElementById('mw_content') || document;
 84+ }
 85+ return document;
 86+}
 87+
 88+function setupTooltipsLoop(anchors,begin,howmany,sleep, remove, popData) {
 89+ log(simplePrintf('setupTooltipsLoop(%s,%s,%s,%s,%s)', arguments));
 90+ var finish=begin+howmany;
 91+ var loopend = min(finish, anchors.length);
 92+ var j=loopend - begin;
 93+ log ('setupTooltips: anchors.length=' + anchors.length + ', begin=' + begin +
 94+ ', howmany=' + howmany + ', loopend=' + loopend + ', remove=' + remove);
 95+ var doTooltip= remove ? removeTooltip : addTooltip;
 96+ // try a faster (?) loop construct
 97+ if (j > 0) {
 98+ do {
 99+ var a=anchors[loopend - j];
 100+ if (!a || !a.href) {
 101+ log('got null anchor at index ' + loopend - j);
 102+ continue;
 103+ }
 104+ doTooltip(a, popData);
 105+ } while (--j);
 106+ }
 107+ if (finish < anchors.length) {
 108+ setTimeout(function() {
 109+ setupTooltipsLoop(anchors,finish,howmany,sleep,remove,popData);},
 110+ sleep);
 111+ } else {
 112+ if ( !remove && ! getValueOf('popupTocLinks')) { rmTocTooltips(); }
 113+ pg.flag.finishedLoading=true;
 114+ }
 115+}
 116+
 117+// eliminate popups from the TOC
 118+// This also kills any onclick stuff that used to be going on in the toc
 119+function rmTocTooltips() {
 120+ var toc=document.getElementById('toc');
 121+ if (toc) {
 122+ var tocLinks=toc.getElementsByTagName('A');
 123+ var tocLen = tocLinks.length;
 124+ for (j=0; j<tocLen; ++j) {
 125+ removeTooltip(tocLinks[j], true);
 126+ }
 127+ }
 128+}
 129+
 130+function addTooltip(a, popData) {
 131+ if ( !isPopupLink(a) ) { return; }
 132+ a.onmouseover=mouseOverWikiLink;
 133+ a.onmouseout= mouseOutWikiLink;
 134+ a.onmousedown = killPopup;
 135+ a.hasPopup = true;
 136+ a.popData = popData;
 137+}
 138+
 139+function removeTooltip(a) {
 140+ if ( !a.hasPopup ) { return; }
 141+ a.onmouseover = null;
 142+ a.onmouseout = null;
 143+ if (a.originalTitle) { a.title = a.originalTitle; }
 144+ a.hasPopup=false;
 145+}
 146+
 147+function removeTitle(a) {
 148+ if (a.originalTitle) { return; }
 149+ a.originalTitle=a.title;
 150+ a.title='';
 151+}
 152+
 153+function restoreTitle(a) {
 154+ if ( a.title || !a.originalTitle ) { return; }
 155+ a.title = a.originalTitle;
 156+ a.originalTitle='';
 157+}
 158+
 159+function registerHooks(np) {
 160+ var popupMaxWidth=getValueOf('popupMaxWidth');
 161+
 162+ if (typeof popupMaxWidth == 'number') {
 163+ var setMaxWidth = function () {
 164+ np.mainDiv.style.maxWidth = popupMaxWidth + 'px';
 165+ np.maxWidth = popupMaxWidth;
 166+
 167+ // hack for IE
 168+ // see http://www.svendtofte.com/code/max_width_in_ie/
 169+ // use setExpression as documented here on msdn: http://tinyurl dot com/dqljn
 170+
 171+ if (np.mainDiv.style.setExpression) {
 172+ np.mainDiv.style.setExpression(
 173+ 'width', 'document.body.clientWidth > ' +
 174+ popupMaxWidth + ' ? "' +popupMaxWidth + 'px": "auto"');
 175+ }
 176+ };
 177+ np.addHook(setMaxWidth, 'unhide', 'before');
 178+ }
 179+//<NOLITE>
 180+ if (window.addPopupShortcuts && window.rmPopupShortcuts) {
 181+ np.addHook(addPopupShortcuts, 'unhide', 'after');
 182+ np.addHook(rmPopupShortcuts, 'hide', 'before');
 183+ }
 184+//</NOLITE>
 185+}
 186+
 187+
 188+function mouseOverWikiLink(evt) {
 189+ if (!window.popupsReady || !window.popupsReady()) { return; }
 190+ if (!evt && window.event) {evt=window.event};
 191+ return mouseOverWikiLink2(this, evt);
 192+}
 193+
 194+function footnoteTarget(a) {
 195+ var aTitle=Title.fromAnchor(a);
 196+ // We want ".3A" rather than "%3A" or "?" here, so use the anchor property directly
 197+ var anch = aTitle.anchor;
 198+ if ( ! /^(cite_note-|_note-|endnote)/.test(anch) ) { return false; }
 199+
 200+ var lTitle=Title.fromURL(location.href);
 201+ if ( lTitle.toString(true) != aTitle.toString(true) ) { return false; }
 202+
 203+ var el=document.getElementById(anch);
 204+ while ( el && typeof el.nodeName == 'string') {
 205+ var nt = el.nodeName.toLowerCase();
 206+ if ( nt == 'li' ) { return el; }
 207+ else if ( nt == 'body' ) { return false; }
 208+ else if ( el.parentNode ) { el=el.parentNode; }
 209+ else { return false; }
 210+ }
 211+ return false;
 212+}
 213+
 214+function footnotePreview(x, navpop) {
 215+ setPopupHTML('<hr>' + x.innerHTML, 'popupPreview', navpop.idNumber,
 216+ getValueOf('popupSubpopups') ? function() {
 217+ setupTooltips(document.getElementById('popupPreview' + navpop.idNumber));
 218+ } : null);
 219+}
 220+
 221+// var modid=0;
 222+// if(!window.opera) { window.opera={postError: console.log}; }
 223+
 224+function modifierKeyHandler(a) {
 225+ return function(evt) {
 226+ // opera.postError('modifierKeyHandler called' + (++modid));
 227+ // opera.postError(''+evt + modid);
 228+ // for (var i in evt) {
 229+ // opera.postError('' + modid + ' ' + i + ' ' + evt[i]);
 230+ // }
 231+ // opera.postError(''+evt.ctrlKey + modid);
 232+ var mod=getValueOf('popupModifier');
 233+ if (!mod) { return true; }
 234+
 235+ if (!evt && window.event) {evt=window.event};
 236+ // opera.postError('And now....'+modid);
 237+ // opera.postError(''+evt+modid);
 238+ // opera.postError(''+evt.ctrlKey+modid);
 239+
 240+ var modPressed = modifierPressed(evt);
 241+ var action = getValueOf('popupModifierAction');
 242+
 243+ // FIXME: probable bug - modifierPressed should be modPressed below?
 244+ if ( action == 'disable' && modifierPressed ) { return true; }
 245+ if ( action == 'enable' && !modifierPressed ) { return true; }
 246+
 247+ mouseOverWikiLink2(a, evt);
 248+ };
 249+}
 250+
 251+function modifierPressed(evt) {
 252+ var mod=getValueOf('popupModifier');
 253+ if (!mod) { return false; }
 254+
 255+ if (!evt && window.event) {evt=window.event};
 256+// opera.postError('And now....'+modid);
 257+// opera.postError(''+evt+modid);
 258+// opera.postError(''+evt.ctrlKey+modid);
 259+
 260+ return ( evt && mod && evt[mod.toLowerCase() + 'Key'] );
 261+
 262+}
 263+
 264+function dealWithModifier(a,evt) {
 265+ if (!getValueOf('popupModifier')) { return false; }
 266+ var action = getValueOf('popupModifierAction');
 267+ if ( action == 'enable' && !modifierPressed(evt) ||
 268+ action == 'disable' && modifierPressed(evt) ) {
 269+ // if the modifier is needed and not pressed, listen for it until
 270+ // we mouseout of this link.
 271+ restoreTitle(a);
 272+ var addHandler='addEventListener';
 273+ var rmHandler='removeEventListener';
 274+ var on='';
 275+ if (!document.addEventListener) {
 276+ addHandler='attachEvent';
 277+ rmHandler='detachEvent';
 278+ on='on';
 279+ }
 280+ if (!document[addHandler]) { // forget it
 281+ return;
 282+ }
 283+
 284+ a.modifierKeyHandler=modifierKeyHandler(a);
 285+
 286+ switch (action) {
 287+ case 'enable':
 288+ document[addHandler](on+'keydown', a.modifierKeyHandler, false);
 289+ a[addHandler](on+'mouseout', function() {
 290+ document[rmHandler](on+'keydown',
 291+ a.modifierKeyHandler, false);
 292+ }, true);
 293+ break;
 294+ case 'disable':
 295+ document[addHandler](on+'keyup', a.modifierKeyHandler, false);
 296+ }
 297+
 298+ return true;
 299+ }
 300+ return false;
 301+}
 302+
 303+function mouseOverWikiLink2(a, evt) {
 304+ if (dealWithModifier(a,evt)) { return; }
 305+ if ( getValueOf('removeTitles') ) { removeTitle(a); }
 306+ if ( a==pg.current.link && a.navpopup && a.navpopup.isVisible() ) { return; }
 307+ pg.current.link=a;
 308+
 309+ if (getValueOf('simplePopups') && pg.option.popupStructure===null) {
 310+ // reset *default value* of popupStructure
 311+ setDefault('popupStructure', 'original');
 312+ }
 313+
 314+ var article=(new Title()).fromAnchor(a);
 315+ // set global variable (ugh) to hold article (wikipage)
 316+ pg.current.article = article;
 317+ if (pg.timer.image !== null) {
 318+ clearInterval(pg.timer.image);
 319+ pg.timer.image=null;
 320+ pg.counter.checkImages=0;
 321+ }
 322+
 323+ if (!a.navpopup) {
 324+ // FIXME: this doesn't behave well if you mouse out of a popup
 325+ // directly into a link with the same href
 326+ if (pg.current.linksHash[a.href] && false) {
 327+ a.navpopup = pg.current.linksHash[a.href];
 328+ }
 329+ else {
 330+ a.navpopup=newNavpopup(a, article);
 331+ pg.current.linksHash[a.href] = a.navpopup;
 332+ pg.current.links.push(a);
 333+ }
 334+ }
 335+ if (a.navpopup.pending===null || a.navpopup.pending!==0) {
 336+ // either fresh popups or those with unfinshed business are redone from scratch
 337+ simplePopupContent(a, article);
 338+ }
 339+ a.navpopup.showSoonIfStable(a.navpopup.delay);
 340+
 341+ getValueOf('popupInitialWidth');
 342+
 343+ clearInterval(pg.timer.checkPopupPosition);
 344+ pg.timer.checkPopupPosition=setInterval(checkPopupPosition, 600);
 345+
 346+ if(getValueOf('simplePopups')) {
 347+ if (getValueOf('popupPreviewButton') && !a.simpleNoMore) {
 348+ var d=document.createElement('div');
 349+ d.className='popupPreviewButtonDiv';
 350+ var s=document.createElement('span');
 351+ d.appendChild(s);
 352+ s.className='popupPreviewButton';
 353+ s['on' + getValueOf('popupPreviewButtonEvent')] = function() {
 354+ a.simpleNoMore=true;
 355+ nonsimplePopupContent(a,article);
 356+ }
 357+ s.innerHTML=popupString('show preview');
 358+ setPopupHTML(d, 'popupPreview', a.navpopup.idNumber);
 359+ }
 360+ return;
 361+ }
 362+
 363+ if (a.navpopup.pending!==0 ) {
 364+ nonsimplePopupContent(a, article);
 365+ }
 366+}
 367+
 368+// simplePopupContent: the content that is shown even when simplePopups is true
 369+function simplePopupContent(a, article) {
 370+ /* FIXME hack */ a.navpopup.hasPopupMenu=false;
 371+ a.navpopup.setInnerHTML(popupHTML(a));
 372+ fillEmptySpans({navpopup:a.navpopup});
 373+
 374+ var dragHandle = getValueOf('popupDragHandle') || null;
 375+ if (dragHandle && dragHandle != 'all') {
 376+ dragHandle += a.navpopup.idNumber;
 377+ }
 378+ setTimeout(function(){a.navpopup.makeDraggable(dragHandle);}, 150);
 379+
 380+//<NOLITE>
 381+ if (getValueOf('popupRedlinkRemoval') && a.className=='new') {
 382+ setPopupHTML('<br>'+popupRedlinkHTML(article), 'popupRedlink', a.navpopup.idNumber);
 383+ }
 384+//</NOLITE>
 385+}
 386+
 387+function debugData(navpopup) {
 388+ if(getValueOf('popupDebugging') && navpopup.idNumber) {
 389+ setPopupHTML('idNumber='+navpopup.idNumber + ', pending=' + navpopup.pending,
 390+ 'popupError', navpopup.idNumber);
 391+ }
 392+}
 393+
 394+function newNavpopup(a, article) {
 395+ var navpopup = new Navpopup();
 396+ navpopup.fuzz=5;
 397+ navpopup.delay=getValueOf('popupDelay')*1000;
 398+ // increment global counter now
 399+ navpopup.idNumber = ++pg.idNumber;
 400+ navpopup.parentAnchor = a;
 401+ navpopup.parentPopup = (a.popData && a.popData.owner);
 402+ navpopup.article = article;
 403+ registerHooks(navpopup);
 404+ return navpopup;
 405+}
 406+
 407+
 408+function nonsimplePopupContent(a, article) {
 409+ var diff=null, history=null;
 410+ var params=parseParams(a.href);
 411+ var oldid=(typeof params.oldid=='undefined' ? null : params.oldid);
 412+//<NOLITE>
 413+ if(getValueOf('popupPreviewDiffs') && window.loadDiff) {
 414+ diff=params.diff;
 415+ }
 416+ if(getValueOf('popupPreviewHistory')) {
 417+ history=(params.action=='history');
 418+ }
 419+//</NOLITE>
 420+ a.navpopup.pending=0;
 421+ var x;
 422+ pg.misc.gImage=null;
 423+ if (x=footnoteTarget(a)) {
 424+ footnotePreview(x, a.navpopup);
 425+//<NOLITE>
 426+ } else if ( diff || diff === 0 ) {
 427+ loadDiff(article, oldid, diff, a.navpopup);
 428+ } else if ( history ) {
 429+ loadAPIPreview('history', article, a.navpopup);
 430+ } else if ( pg.re.contribs.test(a.href) ) {
 431+ loadAPIPreview('contribs', article, a.navpopup);
 432+ } else if ( pg.re.backlinks.test(a.href) ) {
 433+ loadAPIPreview('backlinks', article, a.navpopup);
 434+ } else if ( // FIXME should be able to get all preview combinations with options
 435+ article.namespace()==pg.ns.image &&
 436+ ( getValueOf('imagePopupsForImages') || ! anchorContainsImage(a) )
 437+ ) {
 438+ loadAPIPreview('imagepagepreview', article, a.navpopup);
 439+ loadImages(article);
 440+//</NOLITE>
 441+ } else {
 442+ if (article.namespace() == pg.ns.category &&
 443+ getValueOf('popupCategoryMembers')) {
 444+ loadAPIPreview('category', article, a.navpopup);
 445+ } else if ((article.namespace() == pg.ns.user || article.namespace() == pg.ns.usertalk) &&
 446+ getValueOf('popupUserInfo')) {
 447+ loadAPIPreview('userinfo', article, a.navpopup);
 448+ }
 449+ startArticlePreview(article, oldid, a.navpopup);
 450+ }
 451+}
 452+
 453+function pendingNavpopTask(navpop) {
 454+ if (navpop && navpop.pending===null) { navpop.pending=0; }
 455+ ++navpop.pending;
 456+ debugData(navpop);
 457+}
 458+
 459+function completedNavpopTask(navpop) {
 460+ if (navpop && navpop.pending) { --navpop.pending; }
 461+ debugData(navpop);
 462+}
 463+
 464+function startArticlePreview(article, oldid, navpop) {
 465+ navpop.redir=0;
 466+ loadPreview(article, oldid, navpop);
 467+}
 468+
 469+function loadPreview(article, oldid, navpop) {
 470+ pendingNavpopTask(navpop);
 471+ if (!navpop.redir) { navpop.originalArticle=article; }
 472+ if (!navpop.visible && getValueOf('popupLazyDownloads')) {
 473+ var id=(navpop.redir) ? 'DOWNLOAD_PREVIEW_REDIR_HOOK' : 'DOWNLOAD_PREVIEW_HOOK';
 474+ navpop.addHook(function() {
 475+ getWiki(article, insertPreview, oldid, navpop);
 476+ return true; }, 'unhide', 'before', id);
 477+ } else {
 478+ getWiki(article, insertPreview, oldid, navpop);
 479+ }
 480+}
 481+
 482+function loadPreviewFromRedir(redirMatch, navpop) {
 483+ // redirMatch is a regex match
 484+ var target = new Title().fromWikiText(redirMatch[2]);
 485+ // overwrite (or add) anchor from original target
 486+ // mediawiki does overwrite; eg [[User:Lupin/foo3#Done]]
 487+ if ( navpop.article.anchor ) { target.anchor = navpop.article.anchor; }
 488+ var trailingRubbish=redirMatch[4];
 489+ navpop.redir++;
 490+ navpop.redirTarget=target;
 491+//<NOLITE>
 492+ if (window.redirLink) {
 493+ var warnRedir = redirLink(target, navpop.article);
 494+ setPopupHTML(warnRedir, 'popupWarnRedir', navpop.idNumber);
 495+ }
 496+//</NOLITE>
 497+ navpop.article=target;
 498+ fillEmptySpans({redir: true, redirTarget: target, navpopup:navpop});
 499+ return loadPreview(target, null, navpop);
 500+}
 501+
 502+function insertPreview(download) {
 503+ if (!download.owner) { return; }
 504+
 505+ var redirMatch = pg.re.redirect.exec(download.data);
 506+ if (download.owner.redir===0 && redirMatch) {
 507+ completedNavpopTask(download.owner);
 508+ loadPreviewFromRedir(redirMatch, download.owner);
 509+ return;
 510+ }
 511+
 512+ if (download.owner.visible || !getValueOf('popupLazyPreviews')) {
 513+ insertPreviewNow(download);
 514+ } else {
 515+ var id=(download.owner.redir) ? 'PREVIEW_REDIR_HOOK' : 'PREVIEW_HOOK';
 516+ download.owner.addHook( function(){insertPreviewNow(download); return true;},
 517+ 'unhide', 'after', id );
 518+ }
 519+}
 520+
 521+function insertPreviewNow(download) {
 522+ if (!download.owner) { return; }
 523+ var wikiText=download.data;
 524+ var navpop=download.owner;
 525+ completedNavpopTask(navpop);
 526+ var art=navpop.redirTarget || navpop.originalArticle;
 527+
 528+//<NOLITE>
 529+ makeFixDabs(wikiText, navpop);
 530+ if (getValueOf('popupSummaryData') && window.getPageInfo) {
 531+ var info=getPageInfo(wikiText, download);
 532+ setPopupTrailer(getPageInfo(wikiText, download), navpop.idNumber);
 533+ }
 534+
 535+ var imagePage='';
 536+ if (art.namespace()==pg.ns.image) { imagePage=art.toString(); }
 537+ else { imagePage=getValidImageFromWikiText(wikiText); }
 538+ if(imagePage) { loadImages(Title.fromWikiText(imagePage)); }
 539+//</NOLITE>
 540+
 541+ if (getValueOf('popupPreviews')) { insertArticlePreview(download, art, navpop); }
 542+
 543+}
 544+
 545+function insertArticlePreview(download, art, navpop) {
 546+ if (download && typeof download.data == typeof ''){
 547+ if (art.namespace()==pg.ns.template && getValueOf('popupPreviewRawTemplates')) {
 548+ // FIXME compare/consolidate with diff escaping code for wikitext
 549+ var h='<hr><tt>' + download.data.entify().split('\\n').join('<br>\\n') + '</tt>';
 550+ setPopupHTML(h, 'popupPreview', navpop.idNumber);
 551+ }
 552+ else {
 553+ var p=prepPreviewmaker(download.data, art, navpop);
 554+ p.showPreview();
 555+ }
 556+ }
 557+}
 558+
 559+function prepPreviewmaker(data, article, navpop) {
 560+ // deal with tricksy anchors
 561+ var d=anchorize(data, article.anchorString());
 562+ var urlBase=joinPath([pg.wiki.articlebase, article.urlString()]);
 563+ var p=new Previewmaker(d, urlBase, navpop);
 564+ return p;
 565+}
 566+
 567+
 568+// Try to imitate the way mediawiki generates HTML anchors from section titles
 569+function anchorize(d, anch) {
 570+ if (!anch) { return d; }
 571+ var anchRe=RegExp('=+\\s*' + literalizeRegex(anch).replace(/[_ ]/g, '[_ ]') + '\\s*=+');
 572+ var match=d.match(anchRe);
 573+ if(match && match.length > 0 && match[0]) { return d.substring(d.indexOf(match[0])); }
 574+
 575+ // now try to deal with == foo [[bar|baz]] boom == -> #foo_baz_boom
 576+ var lines=d.split('\n');
 577+ for (var i=0; i<lines.length; ++i) {
 578+ lines[i]=lines[i].replace(RegExp('[[]{2}([^|\\]]*?[|])?(.*?)[\\]]{2}', 'g'), '$2')
 579+ .replace(/'''([^'])/g, '$1').replace(RegExp("''([^'])", 'g'), '$1');
 580+ if (lines[i].match(anchRe)) {
 581+ return d.split('\n').slice(i).join('\n').replace(RegExp('^[^=]*'), '');
 582+ }
 583+ }
 584+ return d;
 585+}
 586+
 587+function killPopup() {
 588+ if (getValueOf('popupShortcutKeys') && window.rmPopupShortcuts) { rmPopupShortcuts(); }
 589+ if (!pg) { return; }
 590+ pg.current.link && pg.current.link.navpopup && pg.current.link.navpopup.banish();
 591+ pg.current.link=null;
 592+ abortAllDownloads();
 593+ window.stopImagesDownloading && stopImagesDownloading();
 594+ if (pg.timer.checkPopupPosition !== null) {
 595+ clearInterval(pg.timer.checkPopupPosition);
 596+ pg.timer.checkPopupPosition=null;
 597+ }
 598+ if (pg.timer.checkImages !== null) { clearInterval(pg.timer.checkImages); pg.timer.checkImages=null; }
 599+ if (pg.timer.image !== null) { clearInterval(pg.timer.image); pg.timer.image=null; }
 600+ return true; // preserve default action
 601+}
 602+// ENDFILE: actions.js
 603+// STARTFILE: domdrag.js
 604+/**
 605+ @fileoverview
 606+ The {@link Drag} object, which enables objects to be dragged around.
 607+
 608+ <pre>
 609+ *************************************************
 610+ dom-drag.js
 611+ 09.25.2001
 612+ www.youngpup.net
 613+ **************************************************
 614+ 10.28.2001 - fixed minor bug where events
 615+ sometimes fired off the handle, not the root.
 616+ *************************************************
 617+ Pared down, some hooks added by [[User:Lupin]]
 618+
 619+ Copyright Aaron Boodman.
 620+ Saying stupid things daily since March 2001.
 621+ </pre>
 622+*/
 623+
 624+/**
 625+ Creates a new Drag object. This is used to make various DOM elements draggable.
 626+ @constructor
 627+*/
 628+function Drag () {
 629+ /**
 630+ Condition to determine whether or not to drag. This function should take one parameter, an Event.
 631+ To disable this, set it to <code>null</code>.
 632+ @type Function
 633+ */
 634+ this.startCondition = null;
 635+ /**
 636+ Hook to be run when the drag finishes. This is passed the final coordinates of
 637+ the dragged object (two integers, x and y). To disables this, set it to <code>null</code>.
 638+ @type Function
 639+ */
 640+ this.endHook = null;
 641+}
 642+
 643+/**
 644+ Gets an event in a cross-browser manner.
 645+ @param {Event} e
 646+ @private
 647+*/
 648+Drag.prototype.fixE = function(e) {
 649+ if (typeof e == 'undefined') { e = window.event; }
 650+ if (typeof e.layerX == 'undefined') { e.layerX = e.offsetX; }
 651+ if (typeof e.layerY == 'undefined') { e.layerY = e.offsetY; }
 652+ return e;
 653+};
 654+/**
 655+ Initialises the Drag instance by telling it which object you want to be draggable, and what you want to drag it by.
 656+ @param {DOMElement} o The "handle" by which <code>oRoot</code> is dragged.
 657+ @param {DOMElement} oRoot The object which moves when <code>o</code> is dragged, or <code>o</code> if omitted.
 658+*/
 659+Drag.prototype.init = function(o, oRoot) {
 660+ var dragObj = this;
 661+ this.obj = o;
 662+ o.onmousedown = function(e) { dragObj.start.apply( dragObj, [e]); };
 663+ o.dragging = false;
 664+ o.draggable = true;
 665+ o.hmode = true;
 666+ o.vmode = true;
 667+
 668+ o.root = oRoot && oRoot !== null ? oRoot : o ;
 669+
 670+ if (isNaN(parseInt(o.root.style.left, 10))) { o.root.style.left = "0px"; }
 671+ if (isNaN(parseInt(o.root.style.top, 10))) { o.root.style.top = "0px"; }
 672+
 673+ o.root.onthisStart = function(){};
 674+ o.root.onthisEnd = function(){};
 675+ o.root.onthis = function(){};
 676+};
 677+
 678+/**
 679+ Starts the drag.
 680+ @private
 681+ @param {Event} e
 682+*/
 683+Drag.prototype.start = function(e) {
 684+ var o = this.obj; // = this;
 685+ e = this.fixE(e);
 686+ if (this.startCondition && !this.startCondition(e)) { return; }
 687+ var y = parseInt(o.vmode ? o.root.style.top : o.root.style.bottom, 10);
 688+ var x = parseInt(o.hmode ? o.root.style.left : o.root.style.right, 10);
 689+ o.root.onthisStart(x, y);
 690+
 691+ o.lastMouseX = e.clientX;
 692+ o.lastMouseY = e.clientY;
 693+
 694+ var dragObj = this;
 695+ o.onmousemoveDefault = document.onmousemove;
 696+ o.dragging = true;
 697+ document.onmousemove = function(e) { dragObj.drag.apply( dragObj, [e] ); };
 698+ document.onmouseup = function(e) { dragObj.end.apply( dragObj, [e] ); };
 699+ return false;
 700+};
 701+/**
 702+ Does the drag.
 703+ @param {Event} e
 704+ @private
 705+*/
 706+Drag.prototype.drag = function(e) {
 707+ e = this.fixE(e);
 708+ var o = this.obj;
 709+
 710+ var ey = e.clientY;
 711+ var ex = e.clientX;
 712+ var y = parseInt(o.vmode ? o.root.style.top : o.root.style.bottom, 10);
 713+ var x = parseInt(o.hmode ? o.root.style.left : o.root.style.right, 10 );
 714+ var nx, ny;
 715+
 716+ nx = x + ((ex - o.lastMouseX) * (o.hmode ? 1 : -1));
 717+ ny = y + ((ey - o.lastMouseY) * (o.vmode ? 1 : -1));
 718+
 719+ this.obj.root.style[o.hmode ? "left" : "right"] = nx + "px";
 720+ this.obj.root.style[o.vmode ? "top" : "bottom"] = ny + "px";
 721+ this.obj.lastMouseX = ex;
 722+ this.obj.lastMouseY = ey;
 723+
 724+ this.obj.root.onthis(nx, ny);
 725+ return false;
 726+};
 727+
 728+/**
 729+ Ends the drag.
 730+ @private
 731+*/
 732+Drag.prototype.end = function() {
 733+ document.onmousemove=this.obj.onmousemoveDefault;
 734+ document.onmouseup = null;
 735+ this.obj.dragging = false;
 736+ if (this.endHook) {
 737+ this.endHook( parseInt(this.obj.root.style[this.obj.hmode ? "left" : "right"], 10),
 738+ parseInt(this.obj.root.style[this.obj.vmode ? "top" : "bottom"], 10));
 739+ }
 740+};
 741+// ENDFILE: domdrag.js
 742+// STARTFILE: structures.js
 743+//<NOLITE>
 744+pg.structures.original={};
 745+pg.structures.original.popupLayout=function () {
 746+ return ['popupError', 'popupImage', 'popupTopLinks', 'popupTitle',
 747+ 'popupData', 'popupOtherLinks',
 748+ 'popupRedir', ['popupWarnRedir', 'popupRedirTopLinks',
 749+ 'popupRedirTitle', 'popupRedirData', 'popupRedirOtherLinks'],
 750+ 'popupMiscTools', ['popupRedlink'],
 751+ 'popupPrePreviewSep', 'popupPreview', 'popupSecondPreview', 'popupPreviewMore', 'popupPostPreview', 'popupFixDab'];
 752+};
 753+pg.structures.original.popupRedirSpans=function () {
 754+ return ['popupRedir', 'popupWarnRedir', 'popupRedirTopLinks',
 755+ 'popupRedirTitle', 'popupRedirData', 'popupRedirOtherLinks'];
 756+};
 757+pg.structures.original.popupTitle=function (x) {
 758+ log ('defaultstructure.popupTitle');
 759+ if (!getValueOf('popupNavLinks')) {
 760+ return navlinkStringToHTML('<b><<mainlink>></b>',x.article,x.params);
 761+ }
 762+ return '';
 763+};
 764+pg.structures.original.popupTopLinks=function (x) {
 765+ log ('defaultstructure.popupTopLinks');
 766+ if (getValueOf('popupNavLinks')) { return navLinksHTML(x.article, x.hint, x.params); }
 767+ return '';
 768+};
 769+pg.structures.original.popupImage=function(x) {
 770+ log ('original.popupImage, x.article='+x.article+', x.navpop.idNumber='+x.navpop.idNumber);
 771+ return imageHTML(x.article, x.navpop.idNumber);
 772+};
 773+pg.structures.original.popupRedirTitle=pg.structures.original.popupTitle;
 774+pg.structures.original.popupRedirTopLinks=pg.structures.original.popupTopLinks;
 775+
 776+
 777+function copyStructure(oldStructure, newStructure) {
 778+ pg.structures[newStructure]={};
 779+ for (var prop in pg.structures[oldStructure]) {
 780+ pg.structures[newStructure][prop]=pg.structures[oldStructure][prop];
 781+ }
 782+}
 783+
 784+copyStructure('original', 'nostalgia');
 785+pg.structures.nostalgia.popupTopLinks=function(x) {
 786+ var str='';
 787+ str += '<b><<mainlink|shortcut= >></b>';
 788+
 789+ // user links
 790+ // contribs - log - count - email - block
 791+ // count only if applicable; block only if popupAdminLinks
 792+ str += 'if(user){<br><<contribs|shortcut=c>>';
 793+ str+='if(wikimedia){*<<count|shortcut=#>>}';
 794+ str+='if(ipuser){}else{*<<email|shortcut=E>>}if(admin){*<<block|shortcut=b>>}}';
 795+
 796+ // editing links
 797+ // talkpage -> edit|new - history - un|watch - article|edit
 798+ // other page -> edit - history - un|watch - talk|edit|new
 799+ var editstr='<<edit|shortcut=e>>';
 800+ var editOldidStr='if(oldid){<<editOld|shortcut=e>>|<<revert|shortcut=v|rv>>|<<edit|cur>>}else{'
 801+ + editstr + '}'
 802+ var historystr='<<history|shortcut=h>>';
 803+ var watchstr='<<unwatch|unwatchShort>>|<<watch|shortcut=w|watchThingy>>';
 804+
 805+ str+='<br>if(talk){' +
 806+ editOldidStr+'|<<new|shortcut=+>>' + '*' + historystr+'*'+watchstr + '*' +
 807+ '<b><<article|shortcut=a>></b>|<<editArticle|edit>>' +
 808+ '}else{' + // not a talk page
 809+ editOldidStr + '*' + historystr + '*' + watchstr + '*' +
 810+ '<b><<talk|shortcut=t>></b>|<<editTalk|edit>>|<<newTalk|shortcut=+|new>>'
 811+ + '}';
 812+
 813+ // misc links
 814+ str += '<br><<whatLinksHere|shortcut=l>>*<<relatedChanges|shortcut=r>>';
 815+ str += 'if(admin){<br>}else{*}<<move|shortcut=m>>';
 816+
 817+ // admin links
 818+ str += 'if(admin){*<<unprotect|unprotectShort>>|<<protect|shortcut=p>>*' +
 819+ '<<undelete|undeleteShort>>|<<delete|shortcut=d>>}';
 820+ return navlinkStringToHTML(str, x.article, x.params);
 821+};
 822+pg.structures.nostalgia.popupRedirTopLinks=pg.structures.nostalgia.popupTopLinks;
 823+
 824+/** -- fancy -- **/
 825+copyStructure('original', 'fancy');
 826+pg.structures.fancy.popupTitle=function (x) {
 827+ return navlinkStringToHTML('<font size=+0><<mainlink>></font>',x.article,x.params);
 828+};
 829+pg.structures.fancy.popupTopLinks=function(x) {
 830+ var hist='<<history|shortcut=h|hist>>|<<lastEdit|shortcut=/|last>>if(mainspace_en){|<<editors|shortcut=E|eds>>}';
 831+ var watch='<<unwatch|unwatchShort>>|<<watch|shortcut=w|watchThingy>>';
 832+ var move='<<move|shortcut=m|move>>';
 833+ return navlinkStringToHTML('if(talk){' +
 834+ '<<edit|shortcut=e>>|<<new|shortcut=+|+>>*' + hist + '*' +
 835+ '<<article|shortcut=a>>|<<editArticle|edit>>' + '*' + watch + '*' + move +
 836+ '}else{<<edit|shortcut=e>>*' + hist +
 837+ '*<<talk|shortcut=t|>>|<<editTalk|edit>>|<<newTalk|shortcut=+|new>>' +
 838+ '*' + watch + '*' + move+'}<br>', x.article, x.params);
 839+};
 840+pg.structures.fancy.popupOtherLinks=function(x) {
 841+ var admin='<<unprotect|unprotectShort>>|<<protect|shortcut=p>>*<<undelete|undeleteShort>>|<<delete|shortcut=d|del>>';
 842+ var user='<<contribs|shortcut=c>>if(wikimedia){|<<count|shortcut=#|#>>}';
 843+ user+='if(ipuser){|<<arin>>}else{*<<email|shortcut=E|'+
 844+ popupString('email')+'>>}if(admin){*<<block|shortcut=b>>}';
 845+
 846+ var normal='<<whatLinksHere|shortcut=l|links here>>*<<relatedChanges|shortcut=r|related>>';
 847+ return navlinkStringToHTML('<br>if(user){' + user + '*}if(admin){'+admin+'if(user){<br>}else{*}}' + normal,
 848+ x.article, x.params);
 849+};
 850+pg.structures.fancy.popupRedirTitle=pg.structures.fancy.popupTitle;
 851+pg.structures.fancy.popupRedirTopLinks=pg.structures.fancy.popupTopLinks;
 852+pg.structures.fancy.popupRedirOtherLinks=pg.structures.fancy.popupOtherLinks;
 853+
 854+
 855+/** -- fancy2 -- **/
 856+// hack for [[User:MacGyverMagic]]
 857+copyStructure('fancy', 'fancy2');
 858+pg.structures.fancy2.popupTopLinks=function(x) { // hack out the <br> at the end and put one at the beginning
 859+ return '<br>'+pg.structures.fancy.popupTopLinks(x).replace(RegExp('<br>$','i'),'');
 860+};
 861+pg.structures.fancy2.popupLayout=function () { // move toplinks to after the title
 862+ return ['popupError', 'popupImage', 'popupTitle', 'popupData', 'popupTopLinks', 'popupOtherLinks',
 863+ 'popupRedir', ['popupWarnRedir', 'popupRedirTopLinks', 'popupRedirTitle', 'popupRedirData', 'popupRedirOtherLinks'],
 864+ 'popupMiscTools', ['popupRedlink'],
 865+ 'popupPrePreviewSep', 'popupPreview', 'popupSecondPreview', 'popupPreviewMore', 'popupPostPreview', 'popupFixDab'];
 866+};
 867+
 868+/** -- menus -- **/
 869+copyStructure('original', 'menus');
 870+pg.structures.menus.popupLayout=function () {
 871+ return ['popupError', 'popupImage', 'popupTopLinks', 'popupTitle', 'popupOtherLinks',
 872+ 'popupRedir', ['popupWarnRedir', 'popupRedirTopLinks', 'popupRedirTitle', 'popupRedirData', 'popupRedirOtherLinks'],
 873+ 'popupData', 'popupMiscTools', ['popupRedlink'],
 874+ 'popupPrePreviewSep', 'popupPreview', 'popupSecondPreview', 'popupPreviewMore', 'popupPostPreview', 'popupFixDab'];
 875+};
 876+function toggleSticky(uid) {
 877+ var popDiv=document.getElementById('navpopup_maindiv'+uid);
 878+ if (!popDiv) { return; }
 879+ if (!popDiv.navpopup.sticky) { popDiv.navpopup.stick(); }
 880+ else {
 881+ popDiv.navpopup.unstick();
 882+ popDiv.navpopup.hide();
 883+ }
 884+}
 885+pg.structures.menus.popupTopLinks = function (x, shorter) {
 886+ // FIXME maybe this stuff should be cached
 887+ var s=[];
 888+ var dropdiv='<div class="popup_drop">';
 889+ var enddiv='</div>';
 890+ var endspan='</span>';
 891+ var hist='<<history|shortcut=h>>';
 892+ if (!shorter) { hist = '<menurow>' + hist +
 893+ '|<<historyfeed|rss>>if(mainspace_en){|<<editors|shortcut=E>>}</menurow>'; }
 894+ var lastedit='<<lastEdit|shortcut=/|show last edit>>';
 895+ var jsHistory='<<lastContrib|last set of edits>><<sinceMe|changes since mine>>';
 896+ var linkshere='<<whatLinksHere|shortcut=l|what links here>>';
 897+ var related='<<relatedChanges|shortcut=r|related changes>>';
 898+ var search='<menurow><<search|shortcut=s>>if(wikimedia){|<<globalsearch|shortcut=g|global>>}' +
 899+ '|<<google|shortcut=G|web>></menurow>';
 900+ var watch='<menurow><<unwatch|unwatchShort>>|<<watch|shortcut=w|watchThingy>></menurow>';
 901+ var protect='<menurow><<unprotect|unprotectShort>>|' +
 902+ '<<protect|shortcut=p>>|<<protectlog|log>></menurow>';
 903+ var del='<menurow><<undelete|undeleteShort>>|<<delete|shortcut=d>>|' +
 904+ '<<deletelog|log>></menurow>';
 905+ var move='<<move|shortcut=m|move page>>';
 906+ var nullPurge='<menurow><<nullEdit|shortcut=n|null edit>>|<<purge|shortcut=P>></menurow>';
 907+ var viewOptions='<menurow><<view|shortcut=v>>|<<render|shortcut=S>>|<<raw>></menurow>';
 908+ var editRow='if(oldid){' +
 909+ '<menurow><<edit|shortcut=e>>|<<editOld|shortcut=e|this&nbsp;revision>></menurow>' +
 910+ '<menurow><<revert|shortcut=v>>|<<undo>></menurow>' + '}else{<<edit|shortcut=e>>}';
 911+ var markPatrolled='if(rcid){<<markpatrolled|mark patrolled>>}';
 912+ var newTopic='if(talk){<<new|shortcut=+|new topic>>}';
 913+ var protectDelete='if(admin){' + protect + del + '}';
 914+
 915+ if (getValueOf('popupActionsMenu')) {
 916+ s.push( '<<mainlink>>*' + dropdiv + menuTitle('actions'));
 917+ } else {
 918+ s.push( dropdiv + '<<mainlink>>');
 919+ }
 920+ s.push( '<menu>')
 921+ s.push( editRow + markPatrolled + newTopic + hist + lastedit )
 922+ if (!shorter) { s.push(jsHistory); }
 923+ s.push( move + linkshere + related)
 924+ if (!shorter) { s.push(nullPurge + search); }
 925+ if (!shorter) { s.push(viewOptions); }
 926+ s.push('<hr>' + watch + protectDelete);
 927+ s.push('<hr>' +
 928+ 'if(talk){<<article|shortcut=a|view article>><<editArticle|edit article>>}' +
 929+ 'else{<<talk|shortcut=t|talk page>><<editTalk|edit talk>>' +
 930+ '<<newTalk|shortcut=+|new topic>>}</menu>' + enddiv);
 931+
 932+ // user menu starts here
 933+ var email='<<email|shortcut=E|email user>>';
 934+ var contribs= 'if(wikimedia){<menurow>}<<contribs|shortcut=c|contributions>>if(wikimedia){</menurow>}' +
 935+ 'if(admin){<menurow><<deletedContribs>></menurow>}';
 936+
 937+
 938+ s.push('if(user){*' + dropdiv + menuTitle('user'));
 939+ s.push('<menu>'); +
 940+ s.push('<menurow><<userPage|shortcut=u|user&nbsp;page>>|<<userSpace|space>></menurow>');
 941+ s.push('<<userTalk|shortcut=t|user talk>><<editUserTalk|edit user talk>>' +
 942+ '<<newUserTalk|shortcut=+|leave comment>>');
 943+ if(!shorter) { s.push( 'if(ipuser){<<arin>>}else{' + email + '}') }
 944+ else { s.push( 'if(ipuser){}else{' + email + '}') }
 945+ s.push('<hr>' + contribs + '<<userlog|shortcut=L|user log>>');
 946+ s.push('if(wikimedia){<<count|shortcut=#|edit counter>>}');
 947+ s.push('if(admin){<menurow><<unblock|unblockShort>>|<<block|shortcut=b|block user>></menurow>}');
 948+ s.push('<<blocklog|shortcut=B|block log>>' + getValueOf('popupExtraUserMenu'));
 949+ s.push('</menu>' + enddiv + '}');
 950+
 951+ // popups menu starts here
 952+ if (getValueOf('popupSetupMenu') && !x.navpop.hasPopupMenu /* FIXME: hack */) {
 953+ x.navpop.hasPopupMenu=true;
 954+ s.push('*' + dropdiv + menuTitle('popupsMenu') + '<menu>');
 955+ s.push('<<togglePreviews|toggle previews>>');
 956+ s.push('<<purgePopups|reset>>');
 957+ s.push('<<disablePopups|disable>>');
 958+ s.push('</menu>'+enddiv);
 959+ }
 960+ return navlinkStringToHTML(s.join(''), x.article, x.params);
 961+};
 962+
 963+function menuTitle(s) {
 964+ return '<a href="#" noPopup=1>' + popupString(s) + '</a>';
 965+}
 966+
 967+pg.structures.menus.popupRedirTitle=pg.structures.menus.popupTitle;
 968+pg.structures.menus.popupRedirTopLinks=pg.structures.menus.popupTopLinks;
 969+
 970+copyStructure('menus', 'shortmenus');
 971+pg.structures.shortmenus.popupTopLinks=function(x) {
 972+ return pg.structures.menus.popupTopLinks(x,true);
 973+};
 974+pg.structures.shortmenus.popupRedirTopLinks=pg.structures.shortmenus.popupTopLinks;
 975+
 976+copyStructure('shortmenus', 'dabshortmenus');
 977+pg.structures.dabshortmenus.popupLayout=function () {
 978+ return ['popupError', 'popupImage', 'popupTopLinks', 'popupTitle', 'popupOtherLinks',
 979+ 'popupRedir', ['popupWarnRedir', 'popupRedirTopLinks', 'popupRedirTitle', 'popupRedirData', 'popupRedirOtherLinks'],
 980+ 'popupData', 'popupMiscTools', ['popupRedlink'], 'popupFixDab',
 981+ 'popupPrePreviewSep', 'popupPreview', 'popupSecondPreview', 'popupPreviewMore', 'popupPostPreview'];
 982+};
 983+
 984+copyStructure('menus', 'dabmenus');
 985+pg.structures.dabmenus.popupLayout=pg.structures.dabshortmenus.popupLayout;
 986+
 987+
 988+//</NOLITE>
 989+pg.structures.lite={};
 990+pg.structures.lite.popupLayout=function () {
 991+ return ['popupTitle', 'popupPreview' ];
 992+};
 993+pg.structures.lite.popupTitle=function (x) {
 994+ log (x.article + ': structures.lite.popupTitle');
 995+ //return navlinkStringToHTML('<b><<mainlink>></b>',x.article,x.params);
 996+ return '<div><span class="popup_mainlink"><b>' + x.article.toString() + '</b></span></div>';
 997+};
 998+// ENDFILE: structures.js
 999+// STARTFILE: autoedit.js
 1000+//<NOLITE>
 1001+function getParamValue(paramName, h) {
 1002+ if (typeof h == 'undefined' ) { h = document.location.href; }
 1003+ var cmdRe=RegExp('[&?]'+paramName+'=([^&]*)');
 1004+ var m=cmdRe.exec(h);
 1005+ if (m) {
 1006+ try {
 1007+ return decodeURIComponent(m[1]);
 1008+ } catch (someError) {}
 1009+ }
 1010+ return null;
 1011+}
 1012+
 1013+function substitute(data,cmdBody) {
 1014+ // alert('sub\nfrom: '+cmdBody.from+'\nto: '+cmdBody.to+'\nflags: '+cmdBody.flags);
 1015+ var fromRe=RegExp(cmdBody.from, cmdBody.flags);
 1016+ return data.replace(fromRe, cmdBody.to);
 1017+}
 1018+
 1019+function execCmds(data, cmdList) {
 1020+ for (var i=0; i<cmdList.length; ++i) {
 1021+ data=cmdList[i].action(data, cmdList[i]);
 1022+ }
 1023+ return data;
 1024+}
 1025+
 1026+function parseCmd(str) {
 1027+ // returns a list of commands
 1028+ if (!str.length) { return []; }
 1029+ var p=false;
 1030+ switch (str.charAt(0)) {
 1031+ case 's':
 1032+ p=parseSubstitute(str);
 1033+ break;
 1034+ default:
 1035+ return false;
 1036+ }
 1037+ if (p) { return [p].concat(parseCmd(p.remainder)); }
 1038+ return false;
 1039+}
 1040+
 1041+function unEscape(str, sep) {
 1042+ return str.split('\\\\').join('\\').split('\\'+sep).join(sep).split('\\n').join('\n');
 1043+}
 1044+
 1045+
 1046+function parseSubstitute(str) {
 1047+ // takes a string like s/a/b/flags;othercmds and parses it
 1048+
 1049+ var from,to,flags,tmp;
 1050+
 1051+ if (str.length<4) { return false; }
 1052+ var sep=str.charAt(1);
 1053+ str=str.substring(2);
 1054+
 1055+ tmp=skipOver(str,sep);
 1056+ if (tmp) { from=tmp.segment; str=tmp.remainder; }
 1057+ else { return false; }
 1058+
 1059+ tmp=skipOver(str,sep);
 1060+ if (tmp) { to=tmp.segment; str=tmp.remainder; }
 1061+ else { return false; }
 1062+
 1063+ flags='';
 1064+ if (str.length) {
 1065+ tmp=skipOver(str,';') || skipToEnd(str, ';');
 1066+ if (tmp) {flags=tmp.segment; str=tmp.remainder; }
 1067+ }
 1068+
 1069+ return {action: substitute, from: from, to: to, flags: flags, remainder: str};
 1070+
 1071+}
 1072+
 1073+function skipOver(str,sep) {
 1074+ var endSegment=findNext(str,sep);
 1075+ if (endSegment<0) { return false; }
 1076+ var segment=unEscape(str.substring(0,endSegment), sep);
 1077+ return {segment: segment, remainder: str.substring(endSegment+1)};
 1078+}
 1079+
 1080+function skipToEnd(str,sep) {
 1081+ return {segment: str, remainder: ''};
 1082+}
 1083+
 1084+function findNext(str, ch) {
 1085+ for (var i=0; i<str.length; ++i) {
 1086+ if (str.charAt(i)=='\\') { i+=2; }
 1087+ if (str.charAt(i)==ch) { return i; }
 1088+ }
 1089+ return -1;
 1090+}
 1091+
 1092+function setCheckbox(param, box) {
 1093+ var val=getParamValue(param);
 1094+ if (val!==null) {
 1095+ switch (val) {
 1096+ case '1': case 'yes': case 'true':
 1097+ box.checked=true;
 1098+ break;
 1099+ case '0': case 'no': case 'false':
 1100+ box.checked=false;
 1101+ }
 1102+ }
 1103+}
 1104+
 1105+function autoEdit() {
 1106+ if (!setupPopups.completed) { setupPopups(); }
 1107+ if (!document.editform || !window.wgEnableAPI || !wgEnableAPI ) { return false; }
 1108+ if (window.autoEdit.alreadyRan) { return false; }
 1109+ window.autoEdit.alreadyRan=true;
 1110+ var cmdString=getParamValue('autoedit');
 1111+ if (cmdString) {
 1112+ try {
 1113+ var editbox=document.editform.wpTextbox1;
 1114+ } catch (dang) { return; }
 1115+ var cmdList=parseCmd(cmdString);
 1116+ var input=editbox.value;
 1117+ var output=execCmds(input, cmdList);
 1118+ editbox.value=output;
 1119+ // wikEd user script compatibility
 1120+ if (typeof(wikEdUseWikEd) != 'undefined') {
 1121+ if (wikEdUseWikEd == true) {
 1122+ WikEdUpdateFrame();
 1123+ }
 1124+ }
 1125+ }
 1126+ setCheckbox('autominor', document.editform.wpMinoredit);
 1127+ setCheckbox('autowatch', document.editform.wpWatchthis);
 1128+
 1129+ var rvid = getParamValue('autorv');
 1130+ if (rvid) {
 1131+ var url=pg.wiki.wikibase + '/api.php?action=query&format=json&prop=revisions&revids='+rvid;
 1132+ startDownload(url, null, autoEdit2);
 1133+ } else { autoEdit2(); }
 1134+}
 1135+
 1136+function autoEdit2(d) {
 1137+ var summary=getParamValue('autosummary');
 1138+ var summaryprompt=getParamValue('autosummaryprompt');
 1139+ var summarynotice='';
 1140+ if (d && d.data && getParamValue('autorv')) {
 1141+ var s = getRvSummary(summary, d.data);
 1142+ if (s===false) {
 1143+ summaryprompt=true;
 1144+ summarynotice=popupString('Failed to get revision information, please edit manually.\n\n');
 1145+ summary = simplePrintf(summary, [getParamValue('autorv'), '(unknown)', '(unknown)']);
 1146+ } else { summary = s; }
 1147+ }
 1148+ if (summaryprompt) {
 1149+ var txt= summarynotice +
 1150+ popupString('Enter a non-empty edit summary or press cancel to abort');
 1151+ var response=prompt(txt, summary);
 1152+ if (response) { summary=response; }
 1153+ else { return; }
 1154+ }
 1155+ if (summary) { document.editform.wpSummary.value=summary; }
 1156+ // Attempt to avoid possible premature clicking of the save button
 1157+ // (maybe delays in updates to the DOM are to blame?? or a red herring)
 1158+ setTimeout(autoEdit3, 100);
 1159+}
 1160+
 1161+function autoClickToken() {
 1162+ return document.cookie.substr(document.cookie.indexOf("session=")+8,4);
 1163+}
 1164+
 1165+function autoEdit3() {
 1166+ if( getParamValue('actoken') != autoClickToken()) return;
 1167+
 1168+ var btn=getParamValue('autoclick');
 1169+ if (btn) {
 1170+ if (document.editform && document.editform[btn]) {
 1171+ var button=document.editform[btn];
 1172+ var msg=tprintf('The %s button has been automatically clicked. Please wait for the next page to load.',
 1173+ [ button.value ]);
 1174+ bannerMessage(msg);
 1175+ document.title='('+document.title+')';
 1176+ button.click();
 1177+ } else {
 1178+ alert(tprintf('Could not find button %s. Please check the settings in your javascript file.',
 1179+ [ btn ]));
 1180+ }
 1181+ }
 1182+}
 1183+
 1184+function bannerMessage(s) {
 1185+ var headings=document.getElementsByTagName('h1');
 1186+ if (headings) {
 1187+ var div=document.createElement('div');
 1188+ div.innerHTML='<font size=+1><b>' + s + '</b></font>';
 1189+ headings[0].parentNode.insertBefore(div, headings[0]);
 1190+ }
 1191+}
 1192+
 1193+function getRvSummary(template, json) {
 1194+ try {
 1195+ var o=getJsObj(json);
 1196+ var edit = anyChild(o.query.pages).revisions[0];
 1197+ } catch (badness) {return false;}
 1198+ var timestamp = edit.timestamp.split(/[A-Z]/g).join(' ').replace(/^ *| *$/g, '');
 1199+ return simplePrintf(template, [edit.revid, timestamp, edit.user]);
 1200+}
 1201+
 1202+//</NOLITE>
 1203+// ENDFILE: autoedit.js
 1204+// STARTFILE: downloader.js
 1205+/**
 1206+ @fileoverview
 1207+ {@link Downloader}, a xmlhttprequest wrapper, and helper functions.
 1208+*/
 1209+
 1210+/**
 1211+ Creates a new Downloader
 1212+ @constructor
 1213+ @class The Downloader class. Create a new instance of this class to download stuff.
 1214+ @param {String} url The url to download. This can be omitted and supplied later.
 1215+*/
 1216+function Downloader(url) {
 1217+ // Source: http://jibbering.com/2002/4/httprequest.html
 1218+ /** xmlhttprequest object which we're wrapping */
 1219+ this.http = false;
 1220+
 1221+ /*@cc_on @*/
 1222+ /*@if (@_jscript_version >= 5)
 1223+ // JScript gives us Conditional compilation,
 1224+ // we can cope with old IE versions.
 1225+ // and security blocked creation of the objects.
 1226+ try {
 1227+ this.http = new ActiveXObject("Msxml2.XMLHTTP");
 1228+ } catch (e) {
 1229+ try {
 1230+ this.http = new ActiveXObject("Microsoft.XMLHTTP");
 1231+ } catch (E) {
 1232+ // this.http = false;
 1233+ }
 1234+ }
 1235+ @end @*/
 1236+
 1237+ if (! this.http && typeof XMLHttpRequest!='undefined') { this.http = new XMLHttpRequest(); }
 1238+ /**
 1239+ The url to download
 1240+ @type String
 1241+ */
 1242+ this.url = url;
 1243+ /**
 1244+ A universally unique ID number
 1245+ @type integer
 1246+ */
 1247+ this.id=null;
 1248+ /**
 1249+ Modification date, to be culled from the incoming headers
 1250+ @type Date
 1251+ @private
 1252+ */
 1253+ this.lastModified = null;
 1254+ /**
 1255+ What to do when the download completes successfully
 1256+ @type Function
 1257+ @private
 1258+ */
 1259+ this.callbackFunction = null;
 1260+ /**
 1261+ What to do on failure
 1262+ @type Function
 1263+ @private
 1264+ */
 1265+ this.onFailure = null;
 1266+ /**
 1267+ Flag set on <code>abort</code>
 1268+ @type boolean
 1269+ */
 1270+ this.aborted = false;
 1271+ /**
 1272+ HTTP method. See http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html for possibilities.
 1273+ @type String
 1274+ */
 1275+ this.method='GET';
 1276+ /**
 1277+ Async flag.
 1278+ @type boolean
 1279+ */
 1280+ this.async=true;
 1281+}
 1282+
 1283+new Downloader();
 1284+
 1285+/** Submits the http request. */
 1286+Downloader.prototype.send = function (x) {
 1287+ if (!this.http) { return null; }
 1288+ return this.http.send(x);
 1289+};
 1290+/** Aborts the download, setting the <code>aborted</code> field to true. */
 1291+Downloader.prototype.abort = function () {
 1292+ if (!this.http) { return null; }
 1293+ this.aborted=true;
 1294+ return this.http.abort();
 1295+};
 1296+/** Returns the downloaded data. */
 1297+Downloader.prototype.getData = function () {if (!this.http) { return null; } return this.http.responseText;};
 1298+/** Prepares the download. */
 1299+Downloader.prototype.setTarget = function () {
 1300+ if (!this.http) { return null; }
 1301+ this.http.open(this.method, this.url, this.async);
 1302+};
 1303+/** Gets the state of the download. */
 1304+Downloader.prototype.getReadyState=function () {if (!this.http) { return null; } return this.http.readyState;};
 1305+
 1306+pg.misc.downloadsInProgress = { };
 1307+
 1308+/** Starts the download.
 1309+ Note that setTarget {@link Downloader#setTarget} must be run first
 1310+*/
 1311+Downloader.prototype.start=function () {
 1312+ if (!this.http) { return; }
 1313+ pg.misc.downloadsInProgress[this.id] = this;
 1314+ this.http.send(null);
 1315+};
 1316+
 1317+/** Gets the 'Last-Modified' date from the download headers.
 1318+ Should be run after the download completes.
 1319+ Returns <code>null</code> on failure.
 1320+ @return {Date}
 1321+*/
 1322+Downloader.prototype.getLastModifiedDate=function () {
 1323+ if(!this.http) { return null; }
 1324+ var lastmod=null;
 1325+ try {
 1326+ lastmod=this.http.getResponseHeader('Last-Modified');
 1327+ } catch (err) {}
 1328+ if (lastmod) { return new Date(lastmod); }
 1329+ return null;
 1330+};
 1331+
 1332+/** Sets the callback function.
 1333+ @param {Function} f callback function, called as <code>f(this)</code> on success
 1334+*/
 1335+Downloader.prototype.setCallback = function (f) {
 1336+ if(!this.http) { return; }
 1337+ this.http.onreadystatechange = f;
 1338+};
 1339+
 1340+Downloader.prototype.getStatus = function() { if (!this.http) { return null; } return this.http.status; };
 1341+
 1342+//////////////////////////////////////////////////
 1343+// helper functions
 1344+
 1345+/** Creates a new {@link Downloader} and prepares it for action.
 1346+ @param {String} url The url to download
 1347+ @param {integer} id The ID of the {@link Downloader} object
 1348+ @param {Function} callback The callback function invoked on success
 1349+ @return {String/Downloader} the {@link Downloader} object created, or 'ohdear' if an unsupported browser
 1350+*/
 1351+function newDownload(url, id, callback, onfailure) {
 1352+ var d=new Downloader(url);
 1353+ if (!d.http) { return 'ohdear'; }
 1354+ d.id=id;
 1355+ d.setTarget();
 1356+ if (!onfailure) {
 1357+ onfailure=2;
 1358+ }
 1359+ var f = function () {
 1360+ if (d.getReadyState() == 4) {
 1361+ delete pg.misc.downloadsInProgress[this.id];
 1362+ try {
 1363+ if ( d.getStatus() == 200 ) {
 1364+ d.data=d.getData();
 1365+ d.lastModified=d.getLastModifiedDate();
 1366+ callback(d);
 1367+ } else if (typeof onfailure == typeof 1) {
 1368+ if (onfailure > 0) {
 1369+ // retry
 1370+ newDownload(url, id, callback, onfailure - 1);
 1371+ }
 1372+ } else if (typeof onfailure == 'function') {
 1373+ onfailure(d,url,id,callback);
 1374+ }
 1375+ } catch (somerr) { /* ignore it */ }
 1376+ }
 1377+ };
 1378+ d.setCallback(f);
 1379+ return d;
 1380+}
 1381+/** Simulates a download from cached data.
 1382+ The supplied data is put into a {@link Downloader} as if it had downloaded it.
 1383+ @param {String} url The url.
 1384+ @param {integer} id The ID.
 1385+ @param {Function} callback The callback, which is invoked immediately as <code>callback(d)</code>,
 1386+ where <code>d</code> is the new {@link Downloader}.
 1387+ @param {String} data The (cached) data.
 1388+ @param {Date} lastModified The (cached) last modified date.
 1389+*/
 1390+function fakeDownload(url, id, callback, data, lastModified, owner) {
 1391+ var d=newDownload(url,callback);
 1392+ d.owner=owner;
 1393+ d.id=id; d.data=data;
 1394+ d.lastModified=lastModified;
 1395+ return callback(d);
 1396+}
 1397+
 1398+/**
 1399+ Starts a download.
 1400+ @param {String} url The url to download
 1401+ @param {integer} id The ID of the {@link Downloader} object
 1402+ @param {Function} callback The callback function invoked on success
 1403+ @return {String/Downloader} the {@link Downloader} object created, or 'ohdear' if an unsupported browser
 1404+*/
 1405+function startDownload(url, id, callback) {
 1406+ var d=newDownload(url, id, callback);
 1407+ if (typeof d == typeof '' ) { return d; }
 1408+ d.start();
 1409+ return d;
 1410+}
 1411+
 1412+/**
 1413+ Aborts all downloads which have been started.
 1414+*/
 1415+function abortAllDownloads() {
 1416+ for ( var x in pg.misc.downloadsInProgress ) {
 1417+ try {
 1418+ pg.misc.downloadsInProgress[x].aborted=true;
 1419+ pg.misc.downloadsInProgress[x].abort();
 1420+ delete pg.misc.downloadsInProgress[x];
 1421+ } catch (e) { }
 1422+ }
 1423+}
 1424+// ENDFILE: downloader.js
 1425+// STARTFILE: livepreview.js
 1426+// TODO: location is often not correct (eg relative links in previews)
 1427+
 1428+/**
 1429+ * InstaView - a Mediawiki to HTML converter in JavaScript
 1430+ * Version 0.6.1
 1431+ * Copyright (C) Pedro Fayolle 2005-2006
 1432+ * http://en.wikipedia.org/wiki/User:Pilaf
 1433+ * Distributed under the BSD license
 1434+ *
 1435+ * Changelog:
 1436+ *
 1437+ * 0.6.1
 1438+ * - Fixed problem caused by \r characters
 1439+ * - Improved inline formatting parser
 1440+ *
 1441+ * 0.6
 1442+ * - Changed name to InstaView
 1443+ * - Some major code reorganizations and factored out some common functions
 1444+ * - Handled conversion of relative links (i.e. [[/foo]])
 1445+ * - Fixed misrendering of adjacent definition list items
 1446+ * - Fixed bug in table headings handling
 1447+ * - Changed date format in signatures to reflect Mediawiki's
 1448+ * - Fixed handling of [[:Image:...]]
 1449+ * - Updated MD5 function (hopefully it will work with UTF-8)
 1450+ * - Fixed bug in handling of links inside images
 1451+ *
 1452+ * To do:
 1453+ * - Better support for <math>
 1454+ * - Full support for <nowiki>
 1455+ * - Parser-based (as opposed to RegExp-based) inline wikicode handling (make it one-pass and bullet-proof)
 1456+ * - Support for templates (through AJAX)
 1457+ * - Support for coloured links (AJAX)
 1458+ */
 1459+
 1460+
 1461+var Insta = {}
 1462+
 1463+function setupLivePreview() {
 1464+
 1465+ // options
 1466+ Insta.conf =
 1467+ {
 1468+ baseUrl: '',
 1469+
 1470+ user: {},
 1471+
 1472+ wiki: {
 1473+ lang: pg.wiki.lang,
 1474+ interwiki: pg.wiki.interwiki,
 1475+ default_thumb_width: 180
 1476+ },
 1477+
 1478+ paths: {
 1479+ articles: '/' + joinPath([pg.wiki.prePath, pg.wiki.articlePath]) + '/',
 1480+ math: '/math/', // FIXME
 1481+ images: ( window.getImageUrlStart ? getImageUrlStart(pg.wiki.hostname) : ''),
 1482+ images_fallback: 'http://upload.wikimedia.org/wikipedia/commons/',
 1483+ magnify_icon: 'skins/common/images/magnify-clip.png'
 1484+ },
 1485+
 1486+ locale: {
 1487+ user: pg.ns.user,
 1488+ image: pg.ns.image,
 1489+ category: pg.ns.category,
 1490+ // shouldn't be used in popup previews, i think
 1491+ months: ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']
 1492+ }
 1493+ }
 1494+
 1495+ // options with default values or backreferences
 1496+ with (Insta.conf) {
 1497+ user.name = user.name || 'Wikipedian'
 1498+ user.signature = '[['+locale.user+':'+user.name+'|'+user.name+']]'
 1499+ //paths.images = 'http://upload.wikimedia.org/wikipedia/' + wiki.lang + '/'
 1500+ }
 1501+
 1502+ // define constants
 1503+ Insta.BLOCK_IMAGE = new RegExp('^\\[\\[(?:File|Image|'+Insta.conf.locale.image+
 1504+ '):.*?\\|.*?(?:frame|thumbnail|thumb|none|right|left|center)', 'i');
 1505+
 1506+}
 1507+
 1508+
 1509+Insta.dump = function(from, to)
 1510+{
 1511+ if (typeof from == 'string') from = document.getElementById(from)
 1512+ if (typeof to == 'string') to = document.getElementById(to)
 1513+ to.innerHTML = this.convert(from.value)
 1514+}
 1515+
 1516+Insta.convert = function(wiki)
 1517+{
 1518+ var ll = (typeof wiki == 'string')? wiki.replace(/\r/g,'').split(/\n/): wiki, // lines of wikicode
 1519+ o='', // output
 1520+ p=0, // para flag
 1521+ $r // result of passing a regexp to $()
 1522+
 1523+ // some shorthands
 1524+ function remain() { return ll.length }
 1525+ function sh() { return ll.shift() } // shift
 1526+ function ps(s) { o+=s } // push
 1527+
 1528+ function f() // similar to C's printf, uses ? as placeholders, ?? to escape question marks
 1529+ {
 1530+ var i=1,a=arguments,f=a[0],o='',c,p
 1531+ for (;i<a.length; i++) if ((p=f.indexOf('?'))+1) {
 1532+ // allow character escaping
 1533+ i -= c=f.charAt(p+1)=='?'?1:0
 1534+ o += f.substring(0,p)+(c?'?':a[i])
 1535+ f=f.substr(p+1+c)
 1536+ } else break;
 1537+ return o+f
 1538+ }
 1539+
 1540+ function html_entities(s) { return s.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;") }
 1541+
 1542+ function max(a,b) { return (a>b)?a:b }
 1543+ function min(a,b) { return (a<b)?a:b }
 1544+
 1545+ // return the first non matching character position between two strings
 1546+ function str_imatch(a, b)
 1547+ {
 1548+ for (var i=0, l=min(a.length, b.length); i<l; i++) if (a.charAt(i)!=b.charAt(i)) break
 1549+ return i
 1550+ }
 1551+
 1552+ // compare current line against a string or regexp
 1553+ // if passed a string it will compare only the first string.length characters
 1554+ // if passed a regexp the result is stored in $r
 1555+ function $(c) { return (typeof c == 'string') ? (ll[0].substr(0,c.length)==c) : ($r = ll[0].match(c)) }
 1556+
 1557+ function $$(c) { return ll[0]==c } // compare current line against a string
 1558+ function _(p) { return ll[0].charAt(p) } // return char at pos p
 1559+
 1560+ function endl(s) { ps(s); sh() }
 1561+
 1562+ function parse_list()
 1563+ {
 1564+ var prev='';
 1565+
 1566+ while (remain() && $(/^([*#:;]+)(.*)$/)) {
 1567+
 1568+ var l_match = $r
 1569+
 1570+ sh()
 1571+
 1572+ var ipos = str_imatch(prev, l_match[1])
 1573+
 1574+ // close uncontinued lists
 1575+ for (var i=prev.length-1; i >= ipos; i--) {
 1576+
 1577+ var pi = prev.charAt(i)
 1578+
 1579+ if (pi=='*') ps('</ul>')
 1580+ else if (pi=='#') ps('</ol>')
 1581+ // close a dl only if the new item is not a dl item (:, ; or empty)
 1582+ else switch (l_match[1].charAt(i)) { case'':case'*':case'#': ps('</dl>') }
 1583+ }
 1584+
 1585+ // open new lists
 1586+ for (var i=ipos; i<l_match[1].length; i++) {
 1587+
 1588+ var li = l_match[1].charAt(i)
 1589+
 1590+ if (li=='*') ps('<ul>')
 1591+ else if (li=='#') ps('<ol>')
 1592+ // open a new dl only if the prev item is not a dl item (:, ; or empty)
 1593+ else switch(prev.charAt(i)) { case'':case'*':case'#': ps('<dl>') }
 1594+ }
 1595+
 1596+ switch (l_match[1].charAt(l_match[1].length-1)) {
 1597+
 1598+ case '*': case '#':
 1599+ ps('<li>' + parse_inline_nowiki(l_match[2])); break
 1600+
 1601+ case ';':
 1602+ ps('<dt>')
 1603+
 1604+ var dt_match
 1605+
 1606+ // handle ;dt :dd format
 1607+ if (dt_match = l_match[2].match(/(.*?)(:.*?)$/)) {
 1608+
 1609+ ps(parse_inline_nowiki(dt_match[1]))
 1610+ ll.unshift(dt_match[2])
 1611+
 1612+ } else ps(parse_inline_nowiki(l_match[2]))
 1613+
 1614+ break
 1615+
 1616+ case ':':
 1617+ ps('<dd>' + parse_inline_nowiki(l_match[2]))
 1618+ }
 1619+
 1620+ prev=l_match[1]
 1621+ }
 1622+
 1623+ // close remaining lists
 1624+ for (var i=prev.length-1; i>=0; i--)
 1625+ ps(f('</?>', (prev.charAt(i)=='*')? 'ul': ((prev.charAt(i)=='#')? 'ol': 'dl')))
 1626+ }
 1627+
 1628+ function parse_table()
 1629+ {
 1630+ endl(f('<table?>', $(/^\{\|( .*)$/)? $r[1]: ''))
 1631+
 1632+ for (;remain();) if ($('|')) switch (_(1)) {
 1633+ case '}': endl('</table>'); return
 1634+ case '-': endl(f('<tr ?>', $(/\|-*(.*)/)[1])); break
 1635+ default: parse_table_data()
 1636+ }
 1637+ else if ($('!')) parse_table_data()
 1638+ else sh()
 1639+ }
 1640+
 1641+ function parse_table_data()
 1642+ {
 1643+ var td_line, match_i
 1644+
 1645+ // 1: "|+", '|' or '+'
 1646+ // 2: ??
 1647+ // 3: attributes ??
 1648+ // TODO: finish commenting this regexp
 1649+ var td_match = sh().match(/^(\|\+|\||!)((?:([^[|]*?)\|(?!\|))?(.*))$/)
 1650+
 1651+ if (td_match[1] == '|+') ps('<caption');
 1652+ else ps('<t' + ((td_match[1]=='|')?'d':'h'))
 1653+
 1654+ if (typeof td_match[3] != 'undefined') {
 1655+
 1656+ ps(' ' + td_match[3])
 1657+ match_i = 4
 1658+
 1659+ } else match_i = 2
 1660+
 1661+ ps('>')
 1662+
 1663+ if (td_match[1] != '|+') {
 1664+
 1665+ // use || or !! as a cell separator depending on context
 1666+ // NOTE: when split() is passed a regexp make sure to use non-capturing brackets
 1667+ td_line = td_match[match_i].split((td_match[1] == '|')? '||': /(?:\|\||!!)/)
 1668+
 1669+ ps(parse_inline_nowiki(td_line.shift()))
 1670+
 1671+ while (td_line.length) ll.unshift(td_match[1] + td_line.pop())
 1672+
 1673+ } else ps(td_match[match_i])
 1674+
 1675+ var tc = 0, td = []
 1676+
 1677+ for (;remain(); td.push(sh()))
 1678+ if ($('|')) {
 1679+ if (!tc) break // we're at the outer-most level (no nested tables), skip to td parse
 1680+ else if (_(1)=='}') tc--
 1681+ }
 1682+ else if (!tc && $('!')) break
 1683+ else if ($('{|')) tc++
 1684+
 1685+ if (td.length) ps(Insta.convert(td))
 1686+ }
 1687+
 1688+ function parse_pre()
 1689+ {
 1690+ ps('<pre>')
 1691+ do endl(parse_inline_nowiki(ll[0].substring(1)) + "\n"); while (remain() && $(' '))
 1692+ ps('</pre>')
 1693+ }
 1694+
 1695+ function parse_block_image()
 1696+ {
 1697+ ps(parse_image(sh()))
 1698+ }
 1699+
 1700+ function parse_image(str)
 1701+ {
 1702+//<NOLITE>
 1703+ // get what's in between "[[Image:" and "]]"
 1704+ var tag = str.substring(str.indexOf(':') + 1, str.length - 2);
 1705+
 1706+ var width;
 1707+ var attr = [], filename, caption = '';
 1708+ var thumb=0, frame=0, center=0;
 1709+ var align='';
 1710+
 1711+ if (tag.match(/\|/)) {
 1712+ // manage nested links
 1713+ var nesting = 0;
 1714+ var last_attr;
 1715+ for (var i = tag.length-1; i > 0; i--) {
 1716+ if (tag.charAt(i) == '|' && !nesting) {
 1717+ last_attr = tag.substr(i+1);
 1718+ tag = tag.substring(0, i);
 1719+ break;
 1720+ } else switch (tag.substr(i-1, 2)) {
 1721+ case ']]':
 1722+ nesting++;
 1723+ i--;
 1724+ break;
 1725+ case '[[':
 1726+ nesting--;
 1727+ i--;
 1728+ }
 1729+ }
 1730+
 1731+ attr = tag.split(/\s*\|\s*/);
 1732+ attr.push(last_attr);
 1733+ filename = attr.shift();
 1734+
 1735+ var w_match;
 1736+
 1737+ for (;attr.length; attr.shift())
 1738+ if (w_match = attr[0].match(/^(\d*)(?:[px]*\d*)?px$/)) width = w_match[1]
 1739+ else switch(attr[0]) {
 1740+ case 'thumb':
 1741+ case 'thumbnail':
 1742+ thumb=true;
 1743+ case 'frame':
 1744+ frame=true;
 1745+ break;
 1746+ case 'none':
 1747+ case 'right':
 1748+ case 'left':
 1749+ center=false;
 1750+ align=attr[0];
 1751+ break;
 1752+ case 'center':
 1753+ center=true;
 1754+ align='none';
 1755+ break;
 1756+ default:
 1757+ if (attr.length == 1) caption = attr[0];
 1758+ }
 1759+
 1760+ } else filename = tag;
 1761+
 1762+
 1763+ var o='';
 1764+
 1765+ if (frame) {
 1766+
 1767+ if (align=='') align = 'right';
 1768+
 1769+ o += f("<div class='thumb t?'>", align);
 1770+
 1771+ if (thumb) {
 1772+ if (!width) width = Insta.conf.wiki.default_thumb_width;
 1773+
 1774+ o += f("<div style='width:?px;'>?", 2+width*1, make_image(filename, caption, width)) +
 1775+ f("<div class='thumbcaption'><div class='magnify' style='float:right'><a href='?' class='internal' title='Enlarge'><img src='?'></a></div>?</div>",
 1776+ Insta.conf.paths.articles + Insta.conf.locale.image + ':' + filename,
 1777+ Insta.conf.paths.magnify_icon,
 1778+ parse_inline_nowiki(caption)
 1779+ )
 1780+ } else {
 1781+ o += '<div>' + make_image(filename, caption) + f("<div class='thumbcaption'>?</div>", parse_inline_nowiki(caption))
 1782+ }
 1783+
 1784+ o += '</div></div>';
 1785+
 1786+ } else if (align != '') {
 1787+ o += f("<div class='float?'><span>?</span></div>", align, make_image(filename, caption, width));
 1788+ } else {
 1789+ return make_image(filename, caption, width);
 1790+ }
 1791+
 1792+ return center? f("<div class='center'>?</div>", o): o;
 1793+//</NOLITE>
 1794+ }
 1795+
 1796+ function parse_inline_nowiki(str)
 1797+ {
 1798+ var start, lastend=0
 1799+ var substart=0, nestlev=0, open, close, subloop;
 1800+ var html='';
 1801+
 1802+ while (-1 != (start = str.indexOf('<nowiki>', substart))) {
 1803+ html += parse_inline_wiki(str.substring(lastend, start));
 1804+ start += 8;
 1805+ substart = start;
 1806+ subloop = true;
 1807+ do {
 1808+ open = str.indexOf('<nowiki>', substart);
 1809+ close = str.indexOf('</nowiki>', substart);
 1810+ if (close<=open || open==-1) {
 1811+ if (close==-1) {
 1812+ return html + html_entities(str.substr(start));
 1813+ }
 1814+ substart = close+9;
 1815+ if (nestlev) {
 1816+ nestlev--;
 1817+ } else {
 1818+ lastend = substart;
 1819+ html += html_entities(str.substring(start, lastend-9));
 1820+ subloop = false;
 1821+ }
 1822+ } else {
 1823+ substart = open+8;
 1824+ nestlev++;
 1825+ }
 1826+ } while (subloop)
 1827+ }
 1828+
 1829+ return html + parse_inline_wiki(str.substr(lastend));
 1830+ }
 1831+
 1832+ function make_image(filename, caption, width)
 1833+ {
 1834+//<NOLITE>
 1835+ // uppercase first letter in file name
 1836+ filename = filename.charAt(0).toUpperCase() + filename.substr(1);
 1837+ // replace spaces with underscores
 1838+ filename = filename.replace(/ /g, '_');
 1839+
 1840+ caption = strip_inline_wiki(caption);
 1841+
 1842+ var md5 = hex_md5(filename);
 1843+
 1844+ var source = md5.charAt(0) + '/' + md5.substr(0,2) + '/' + filename;
 1845+
 1846+ if (width) width = "width='" + width + "px'";
 1847+
 1848+ var img = f("<img onerror=\"this.onerror=null;this.src='?'\" src='?' ? ?>", Insta.conf.paths.images_fallback + source, Insta.conf.paths.images + source, (caption!='')? "alt='" + caption + "'" : '', width);
 1849+
 1850+ return f("<a class='image' ? href='?'>?</a>", (caption!='')? "title='" + caption + "'" : '', Insta.conf.paths.articles + Insta.conf.locale.image + ':' + filename, img);
 1851+//</NOLITE>
 1852+ }
 1853+
 1854+ function parse_inline_images(str)
 1855+ {
 1856+//<NOLITE>
 1857+ var start, substart=0, nestlev=0;
 1858+ var loop, close, open, wiki, html;
 1859+
 1860+ while (-1 != (start=str.indexOf('[[', substart))) {
 1861+ if(str.substr(start+2).match(RegExp('^(Image|File|' + Insta.conf.locale.image + '):','i'))) {
 1862+ loop=true;
 1863+ substart=start;
 1864+ do {
 1865+ substart+=2;
 1866+ close=str.indexOf(']]',substart);
 1867+ open=str.indexOf('[[',substart);
 1868+ if (close<=open||open==-1) {
 1869+ if (close==-1) return str;
 1870+ substart=close;
 1871+ if (nestlev) {
 1872+ nestlev--;
 1873+ } else {
 1874+ wiki=str.substring(start,close+2);
 1875+ html=parse_image(wiki);
 1876+ str=str.replace(wiki,html);
 1877+ substart=start+html.length;
 1878+ loop=false;
 1879+ }
 1880+ } else {
 1881+ substart=open;
 1882+ nestlev++;
 1883+ }
 1884+ } while (loop)
 1885+
 1886+ } else break;
 1887+ }
 1888+
 1889+//</NOLITE>
 1890+ return str;
 1891+ }
 1892+
 1893+ // the output of this function doesn't respect the FILO structure of HTML
 1894+ // but since most browsers can handle it I'll save myself the hassle
 1895+ function parse_inline_formatting(str)
 1896+ {
 1897+ var em,st,i,li,o='';
 1898+ while ((i=str.indexOf("''",li))+1) {
 1899+ o += str.substring(li,i);
 1900+ li=i+2;
 1901+ if (str.charAt(i+2)=="'") {
 1902+ li++;
 1903+ st=!st;
 1904+ o+=st?'<strong>':'</strong>';
 1905+ } else {
 1906+ em=!em;
 1907+ o+=em?'<em>':'</em>';
 1908+ }
 1909+ }
 1910+ return o+str.substr(li);
 1911+ }
 1912+
 1913+ function parse_inline_wiki(str)
 1914+ {
 1915+ var aux_match;
 1916+
 1917+ str = parse_inline_images(str);
 1918+ str = parse_inline_formatting(str);
 1919+
 1920+ // math
 1921+ while (aux_match = str.match(/<(?:)math>(.*?)<\/math>/i)) {
 1922+ var math_md5 = hex_md5(aux_match[1]);
 1923+ str = str.replace(aux_match[0], f("<img src='?.png'>", Insta.conf.paths.math+math_md5));
 1924+ }
 1925+
 1926+ // Build a Mediawiki-formatted date string
 1927+ var date = new Date;
 1928+ var minutes = date.getUTCMinutes();
 1929+ if (minutes < 10) minutes = '0' + minutes;
 1930+ var date = f("?:?, ? ? ? (UTC)", date.getUTCHours(), minutes, date.getUTCDate(), Insta.conf.locale.months[date.getUTCMonth()], date.getUTCFullYear());
 1931+
 1932+ // text formatting
 1933+ return str.
 1934+ // signatures
 1935+ replace(/~{5}(?!~)/g, date).
 1936+ replace(/~{4}(?!~)/g, Insta.conf.user.name+' '+date).
 1937+ replace(/~{3}(?!~)/g, Insta.conf.user.name).
 1938+
 1939+ // [[:Category:...]], [[:Image:...]], etc...
 1940+ replace(RegExp('\\[\\[:((?:'+Insta.conf.locale.category+'|Image|File|'+Insta.conf.locale.image+'|'+Insta.conf.wiki.interwiki+'):[^|]*?)\\]\\](\w*)','gi'), "<a href='"+Insta.conf.paths.articles+"$1'>$1$2</a>").
 1941+ // remove straight category and interwiki tags
 1942+ replace(RegExp('\\[\\[(?:'+Insta.conf.locale.category+'|'+Insta.conf.wiki.interwiki+'):.*?\\]\\]','gi'),'').
 1943+
 1944+ // [[:Category:...|Links]], [[:Image:...|Links]], etc...
 1945+ replace(RegExp('\\[\\[:((?:'+Insta.conf.locale.category+'|Image|File|'+Insta.conf.locale.image+'|'+Insta.conf.wiki.interwiki+'):.*?)\\|([^\\]]+?)\\]\\](\\w*)','gi'), "<a href='"+Insta.conf.paths.articles+"$1'>$2$3</a>").
 1946+
 1947+ // [[/Relative links]]
 1948+ replace(/\[\[(\/[^|]*?)\]\]/g, f("<a href='?$1'>$1</a>", Insta.conf.baseUrl)).
 1949+
 1950+ // [[/Replaced|Relative links]]
 1951+ replace(/\[\[(\/.*?)\|(.+?)\]\]/g, f("<a href='?$1'>$2</a>", Insta.conf.baseUrl)).
 1952+
 1953+ // [[Common links]]
 1954+ replace(/\[\[([^|]*?)\]\](\w*)/g, f("<a href='?$1'>$1$2</a>", Insta.conf.paths.articles)).
 1955+
 1956+ // [[Replaced|Links]]
 1957+ replace(/\[\[(.*?)\|([^\]]+?)\]\](\w*)/g, f("<a href='?$1'>$2$3</a>", Insta.conf.paths.articles)).
 1958+
 1959+ // [[Stripped:Namespace|Namespace]]
 1960+ replace(/\[\[([^\]]*?:)?(.*?)( *\(.*?\))?\|\]\]/g, f("<a href='?$1$2$3'>$2</a>", Insta.conf.paths.articles)).
 1961+
 1962+ // External links
 1963+ replace(/\[(https?|news|ftp|mailto|gopher|irc):(\/*)([^\]]*?) (.*?)\]/g, "<a class='external' href='$1:$2$3'>$4</a>").
 1964+ replace(/\[http:\/\/(.*?)\]/g, "<a class='external' href='http://$1'>[#]</a>").
 1965+ replace(/\[(news|ftp|mailto|gopher|irc):(\/*)(.*?)\]/g, "<a class='external' href='$1:$2$3'>$1:$2$3</a>").
 1966+ replace(/(^| )(https?|news|ftp|mailto|gopher|irc):(\/*)([^ $]*[^.,!?;: $])/g, "$1<a class='external' href='$2:$3$4'>$2:$3$4</a>").
 1967+
 1968+ replace('__NOTOC__','').
 1969+ replace('__NOEDITSECTION__','');
 1970+ }
 1971+/*
 1972+*/
 1973+ function strip_inline_wiki(str)
 1974+ {
 1975+ return str
 1976+ .replace(/\[\[[^\]]*\|(.*?)\]\]/g,'$1')
 1977+ .replace(/\[\[(.*?)\]\]/g,'$1')
 1978+ .replace(/''(.*?)''/g,'$1');
 1979+ }
 1980+
 1981+ // begin parsing
 1982+ for (;remain();) if ($(/^(={1,6})(.*)\1(.*)$/)) {
 1983+ p=0
 1984+ endl(f('<h?>?</h?>?', $r[1].length, parse_inline_nowiki($r[2]), $r[1].length, $r[3]))
 1985+
 1986+ } else if ($(/^[*#:;]/)) {
 1987+ p=0
 1988+ parse_list()
 1989+
 1990+ } else if ($(' ')) {
 1991+ p=0
 1992+ parse_pre()
 1993+
 1994+ } else if ($('{|')) {
 1995+ p=0
 1996+ parse_table()
 1997+
 1998+ } else if ($(/^----+$/)) {
 1999+ p=0
 2000+ endl('<hr>')
 2001+
 2002+ } else if ($(Insta.BLOCK_IMAGE)) {
 2003+ p=0
 2004+ parse_block_image()
 2005+
 2006+ } else {
 2007+
 2008+ // handle paragraphs
 2009+ if ($$('')) {
 2010+ if (p = (remain()>1 && ll[1]==(''))) endl('<p><br>')
 2011+ } else {
 2012+ if(!p) {
 2013+ ps('<p>')
 2014+ p=1
 2015+ }
 2016+ ps(parse_inline_nowiki(ll[0]) + ' ')
 2017+ }
 2018+
 2019+ sh();
 2020+ }
 2021+
 2022+ return o
 2023+};
 2024+
 2025+window.wiki2html=function(txt,baseurl) {
 2026+ Insta.conf.baseUrl=baseurl;
 2027+ return Insta.convert(txt);
 2028+};
 2029+// ENDFILE: livepreview.js
 2030+// STARTFILE: pageinfo.js
 2031+//<NOLITE>
 2032+function popupFilterPageSize(data) {
 2033+ return formatBytes(data.length);
 2034+}
 2035+
 2036+function popupFilterCountLinks(data) {
 2037+ var num=countLinks(data);
 2038+ return String(num) + '&nbsp;' + ((num!=1)?popupString('wikiLinks'):popupString('wikiLink'));
 2039+}
 2040+
 2041+function popupFilterCountImages(data) {
 2042+ var num=countImages(data);
 2043+ return String(num) + '&nbsp;' + ((num!=1)?popupString('images'):popupString('image'));
 2044+}
 2045+
 2046+function popupFilterCountCategories(data) {
 2047+ var num=countCategories(data);
 2048+ return String(num) + '&nbsp;' + ((num!=1)?popupString('categories'):popupString('category'));
 2049+}
 2050+
 2051+
 2052+function popupFilterLastModified(data,download) {
 2053+ var lastmod=download.lastModified;
 2054+ var now=new Date();
 2055+ var age=now-lastmod;
 2056+ if (lastmod && getValueOf('popupLastModified')) {
 2057+ return (tprintf('%s old', [formatAge(age)])).replace(RegExp(' ','g'), '&nbsp;');
 2058+ }
 2059+ return '';
 2060+}
 2061+
 2062+function formatAge(age) {
 2063+ // coerce into a number
 2064+ var a=0+age, aa=a;
 2065+
 2066+ var seclen = 1000;
 2067+ var minlen = 60*seclen;
 2068+ var hourlen = 60*minlen;
 2069+ var daylen = 24*hourlen;
 2070+ var weeklen = 7*daylen;
 2071+
 2072+ var numweeks = (a-a%weeklen)/weeklen; a = a-numweeks*weeklen; var sweeks = addunit(numweeks, 'week');
 2073+ var numdays = (a-a%daylen)/daylen; a = a-numdays*daylen; var sdays = addunit(numdays, 'day');
 2074+ var numhours = (a-a%hourlen)/hourlen; a = a-numhours*hourlen; var shours = addunit(numhours,'hour');
 2075+ var nummins = (a-a%minlen)/minlen; a = a-nummins*minlen; var smins = addunit(nummins, 'minute');
 2076+ var numsecs = (a-a%seclen)/seclen; a = a-numsecs*seclen; var ssecs = addunit(numsecs, 'second');
 2077+
 2078+ if (aa > 4*weeklen) { return sweeks; }
 2079+ if (aa > weeklen) { return sweeks + ' ' + sdays; }
 2080+ if (aa > daylen) { return sdays + ' ' + shours; }
 2081+ if (aa > 6*hourlen) { return shours; }
 2082+ if (aa > hourlen) { return shours + ' ' + smins; }
 2083+ if (aa > 10*minlen) { return smins; }
 2084+ if (aa > minlen) { return smins + ' ' + ssecs; }
 2085+ return ssecs;
 2086+}
 2087+
 2088+function addunit(num,str) { return '' + num + ' ' + ((num!=1) ? popupString(str+'s') : popupString(str)) ;}
 2089+
 2090+function runPopupFilters(list, data, download) {
 2091+ var ret=[];
 2092+ for (var i=0; i<list.length; ++i) {
 2093+ if (list[i] && typeof list[i] == 'function') {
 2094+ var s=list[i](data, download, download.owner.article);
 2095+ if (s) { ret.push(s); }
 2096+ }
 2097+ }
 2098+ return ret;
 2099+}
 2100+
 2101+function getPageInfo(data, download) {
 2102+ if (!data || data.length === 0) { return popupString('Empty page'); }
 2103+
 2104+ var popupFilters=getValueOf('popupFilters') || [];
 2105+ var extraPopupFilters = getValueOf('extraPopupFilters') || [];
 2106+ var pageInfoArray = runPopupFilters(popupFilters.concat(extraPopupFilters), data, download);
 2107+
 2108+ var pageInfo=pageInfoArray.join(', ');
 2109+ if (pageInfo !== '' ) { pageInfo = upcaseFirst(pageInfo); }
 2110+ return pageInfo;
 2111+}
 2112+
 2113+
 2114+// this could be improved!
 2115+function countLinks(wikiText) { return wikiText.split('[[').length - 1; }
 2116+
 2117+// if N = # matches, n = # brackets, then
 2118+// String.parenSplit(regex) intersperses the N+1 split elements
 2119+// with Nn other elements. So total length is
 2120+// L= N+1 + Nn = N(n+1)+1. So N=(L-1)/(n+1).
 2121+
 2122+function countImages(wikiText) {
 2123+ return (wikiText.parenSplit(pg.re.image).length - 1) / (pg.re.imageBracketCount + 1);
 2124+}
 2125+
 2126+function countCategories(wikiText) {
 2127+ return (wikiText.parenSplit(pg.re.category).length - 1) / (pg.re.categoryBracketCount + 1);
 2128+}
 2129+
 2130+function popupFilterStubDetect(data, download, article) {
 2131+ var counts=stubCount(data, article);
 2132+ if (counts.real) { return popupString('stub'); }
 2133+ if (counts.sect) { return popupString('section stub'); }
 2134+ return '';
 2135+}
 2136+
 2137+function popupFilterDisambigDetect(data, download, article) {
 2138+ if (getValueOf('popupOnlyArticleDabStub') && article.namespace()) { return ''; }
 2139+ return (isDisambig(data, article)) ? popupString('disambig') : '';
 2140+}
 2141+
 2142+function formatBytes(num) {
 2143+ return (num > 949) ? (Math.round(num/100)/10+popupString('kB')) : (num +'&nbsp;' + popupString('bytes')) ;
 2144+}
 2145+//</NOLITE>
 2146+// ENDFILE: pageinfo.js
 2147+// STARTFILE: titles.js
 2148+/**
 2149+ @fileoverview Defines the {@link Title} class, and associated crufty functions.
 2150+
 2151+ <code>Title</code> deals with article titles and their various
 2152+ forms. {@link Stringwrapper} is the parent class of
 2153+ <code>Title</code>, which exists simply to make things a little
 2154+ neater.
 2155+
 2156+*/
 2157+
 2158+/**
 2159+ Creates a new Stringwrapper.
 2160+ @constructor
 2161+
 2162+ @class the Stringwrapper class. This base class is not really
 2163+ useful on its own; it just wraps various common string operations.
 2164+*/
 2165+function Stringwrapper() {
 2166+ /**
 2167+ Wrapper for this.toString().indexOf()
 2168+ @param {String} x
 2169+ @type integer
 2170+ */
 2171+ this.indexOf=function(x){return this.toString().indexOf(x);};
 2172+ /**
 2173+ Returns this.value.
 2174+ @type String
 2175+ */
 2176+ this.toString=function(){return this.value;};
 2177+ /**
 2178+ Wrapper for {@link String#parenSplit} applied to this.toString()
 2179+ @param {RegExp} x
 2180+ @type Array
 2181+ */
 2182+ this.parenSplit=function(x){return this.toString().parenSplit(x);};
 2183+ /**
 2184+ Wrapper for this.toString().substring()
 2185+ @param {String} x
 2186+ @param {String} y (optional)
 2187+ @type String
 2188+ */
 2189+ this.substring=function(x,y){
 2190+ if (typeof y=='undefined') { return this.toString().substring(x); }
 2191+ return this.toString().substring(x,y);
 2192+ };
 2193+ /**
 2194+ Wrapper for this.toString().split()
 2195+ @param {String} x
 2196+ @type Array
 2197+ */
 2198+ this.split=function(x){return this.toString().split(x);};
 2199+ /**
 2200+ Wrapper for this.toString().replace()
 2201+ @param {String} x
 2202+ @param {String} y
 2203+ @type String
 2204+ */
 2205+ this.replace=function(x,y){ return this.toString().replace(x,y); };
 2206+}
 2207+
 2208+
 2209+/**
 2210+ Creates a new <code>Title</code>.
 2211+ @constructor
 2212+
 2213+ @class The Title class. Holds article titles and converts them into
 2214+ various forms. Also deals with anchors, by which we mean the bits
 2215+ of the article URL after a # character, representing locations
 2216+ within an article.
 2217+
 2218+ @param {String} value The initial value to assign to the
 2219+ article. This must be the canonical title (see {@link
 2220+ Title#value}. Omit this in the constructor and use another function
 2221+ to set the title if this is unavailable.
 2222+*/
 2223+function Title(val) {
 2224+ /**
 2225+ The canonical article title. This must be in UTF-8 with no
 2226+ entities, escaping or nasties. Also, underscores should be
 2227+ replaced with spaces.
 2228+ @type String
 2229+ @private
 2230+ */
 2231+ this.value=null;
 2232+ /**
 2233+ The canonical form of the anchor. This should be exactly as
 2234+ it appears in the URL, i.e. with the .C3.0A bits in.
 2235+ @type String
 2236+ */
 2237+ this.anchor='';
 2238+
 2239+ this.setUtf(val);
 2240+}
 2241+Title.prototype=new Stringwrapper();
 2242+/**
 2243+ Returns the canonical representation of the article title, optionally without anchor.
 2244+ @param {boolean} omitAnchor
 2245+ @fixme Decide specs for anchor
 2246+ @return String The article title and the anchor.
 2247+*/
 2248+Title.prototype.toString=function(omitAnchor) {
 2249+ return this.value + ( (!omitAnchor && this.anchor) ? '#' + this.anchorString() : '' );
 2250+};
 2251+Title.prototype.anchorString=function() {
 2252+ if (!this.anchor) { return ''; }
 2253+ var split=this.anchor.parenSplit(/((?:[.][0-9A-F]{2})+)/);
 2254+ var len=split.length;
 2255+ for (var j=1; j<len; j+=2) {
 2256+ // FIXME s/decodeURI/decodeURIComponent/g ?
 2257+ split[j]=decodeURIComponent(split[j].split('.').join('%')).split('_').join(' ');
 2258+ }
 2259+ return split.join('');
 2260+};
 2261+Title.prototype.urlAnchor=function() {
 2262+ var split=this.anchor.parenSplit('/((?:[%][0-9A-F]{2})+)/');
 2263+ var len=split.length;
 2264+ for (var j=1; j<len; j+=2) {
 2265+ split[j]=split[j].split('%').join('.');
 2266+ }
 2267+ return split.join('');
 2268+};
 2269+Title.prototype.anchorFromUtf=function(str) {
 2270+ this.anchor=encodeURIComponent(str.split(' ').join('_'))
 2271+ .split('%3A').join(':').split("'").join('%27').split('%').join('.');
 2272+};
 2273+Title.fromURL=function(h) {
 2274+ return new Title().fromURL(h);
 2275+};
 2276+Title.prototype.fromURL=function(h) {
 2277+ if (typeof h != 'string') {
 2278+ this.value=null;
 2279+ return this;
 2280+ }
 2281+
 2282+ // NOTE : playing with decodeURI, encodeURI, escape, unescape,
 2283+ // we seem to be able to replicate the IE borked encoding
 2284+
 2285+ // IE doesn't do this new-fangled utf-8 thing.
 2286+ // and it's worse than that.
 2287+ // IE seems to treat the query string differently to the rest of the url
 2288+ // the query is treated as bona-fide utf8, but the first bit of the url is pissed around with
 2289+
 2290+ // we fix up & for all browsers, just in case.
 2291+ var splitted=h.split('?');
 2292+ splitted[0]=splitted[0].split('&').join('%26');
 2293+
 2294+ if (pg.flag.linksLikeIE6) {
 2295+ splitted[0]=encodeURI(decode_utf8(splitted[0]));
 2296+ }
 2297+
 2298+ h=splitted.join('?');
 2299+
 2300+ var contribs=pg.re.contribs.exec(h);
 2301+ if (contribs !== null) {
 2302+ if (contribs[1]=='title=') { contribs[3]=contribs[3].split('+').join(' '); }
 2303+ var u=new Title(contribs[3]);
 2304+ this.setUtf(this.decodeNasties(pg.ns.user + ':' + u.stripNamespace()));
 2305+ return this;
 2306+ }
 2307+
 2308+ var email=pg.re.email.exec(h);
 2309+ if (email !== null) {
 2310+ this.setUtf(this.decodeNasties(pg.ns.user + ':' + new Title(email[3]).stripNamespace()));
 2311+ return this;
 2312+ }
 2313+
 2314+ var backlinks=pg.re.backlinks.exec(h);
 2315+ if (backlinks) {
 2316+ this.setUtf(this.decodeNasties(new Title(backlinks[3])));
 2317+ return this;
 2318+ }
 2319+
 2320+ // no more special cases to check --
 2321+ // hopefully it's not a disguised user-related or specially treated special page
 2322+ var m=pg.re.main.exec(h);
 2323+ if(m===null) { this.value=null; }
 2324+ else {
 2325+ var fromBotInterface = /[?](.+[&])?title=/.test(h);
 2326+ if (fromBotInterface) {
 2327+ m[2]=m[2].split('+').join('_');
 2328+ }
 2329+ var extracted = m[2] + (m[3] ? '#' + m[3] : '');
 2330+ if (/%25[0-9A-Fa-f]{2}/.test(extracted)) {
 2331+ // Fix Safari issue
 2332+ // Safari sometimes encodes % as %25 in UTF-8 encoded strings like %E5%A3 -> %25E5%25A3.
 2333+ this.setUtf(decodeURIComponent(unescape(extracted)));
 2334+ } else {
 2335+ this.setUtf(this.decodeNasties(extracted));
 2336+ }
 2337+ }
 2338+ return this;
 2339+};
 2340+Title.prototype.decodeNasties=function(txt) {
 2341+ var ret= this.decodeEscapes(decodeURI(txt));
 2342+ ret = ret.replace(/[_ ]*$/, '');
 2343+ return ret;
 2344+};
 2345+Title.prototype.decodeEscapes=function(txt) {
 2346+ var split=txt.parenSplit(/((?:[%][0-9A-Fa-f]{2})+)/);
 2347+ var len=split.length;
 2348+ for (var i=1; i<len; i=i+2) {
 2349+ // FIXME is decodeURIComponent better?
 2350+ split[i]=unescape(split[i]);
 2351+ }
 2352+ return split.join('');
 2353+};
 2354+Title.fromAnchor=function(a) {
 2355+ return new Title().fromAnchor(a);
 2356+};
 2357+Title.prototype.fromAnchor=function(a) {
 2358+ if (!a) { this.value=null; return this; }
 2359+ return this.fromURL(a.href);
 2360+};
 2361+Title.fromWikiText=function(txt) {
 2362+ return new Title().fromWikiText(txt);
 2363+};
 2364+Title.prototype.fromWikiText=function(txt) {
 2365+ // FIXME - testing needed
 2366+ if (!pg.flag.linksLikeIE6) { txt=myDecodeURI(txt); }
 2367+ this.setUtf(txt);
 2368+ return this;
 2369+};
 2370+Title.prototype.hintValue=function(){
 2371+ if(!this.value) { return ''; }
 2372+ return safeDecodeURI(this.value);
 2373+};
 2374+//<NOLITE>
 2375+Title.prototype.toUserName=function(withNs) {
 2376+ if (this.namespace() != pg.ns.user && this.namespace() != pg.ns.usertalk) {
 2377+ this.value=null;
 2378+ return;
 2379+ }
 2380+ this.value = (withNs ? pg.ns.user + ':' : '') + this.stripNamespace().split('/')[0];
 2381+};
 2382+Title.prototype.userName=function(withNs) {
 2383+ var t=(new Title(this.value));
 2384+ t.toUserName(withNs);
 2385+ if (t.value) { return t; }
 2386+ return null;
 2387+};
 2388+Title.prototype.toTalkPage=function() {
 2389+ // convert article to a talk page, or if we can't return null
 2390+ // or, in other words, return null if this ALREADY IS a talk page
 2391+ // and return the corresponding talk page otherwise
 2392+ if (this.value===null) { return null; }
 2393+ var talkRegex=namespaceListToRegex(pg.ns.talkList);
 2394+ if (talkRegex.exec(this.value)) { this.value=null; return null;}
 2395+
 2396+ var nsReg=namespaceListToRegex(pg.ns.withTalkList);
 2397+ var splitted=this.value.parenSplit(nsReg);
 2398+ if (splitted.length<2) {
 2399+ this.value= (pg.ns.talkList[0]+':'+this.value).split(' ').join('_');
 2400+ return this.value;
 2401+ }
 2402+ for (var i=0; i< pg.ns.withTalkList.length; ++i) {
 2403+ if (splitted[1]==pg.ns.withTalkList[i]) {
 2404+ splitted[1]=pg.ns.talkList[i];
 2405+ this.value=splitted.join(':').substring(1).split(' ').join('_');
 2406+ return this.value;
 2407+ }
 2408+ }
 2409+ this.value=null;
 2410+ return null;
 2411+};
 2412+//</NOLITE>
 2413+Title.prototype.namespace=function() {
 2414+ var n=this.value.indexOf(':');
 2415+ if (n<0) { return ''; }
 2416+ var list=pg.ns.list;
 2417+ for (var i=0; i<list.length; ++i) {
 2418+ if (upcaseFirst(list[i]) == this.value.substring(0,n)) { return list[i]; }
 2419+ }
 2420+ return '';
 2421+};
 2422+//<NOLITE>
 2423+Title.prototype.talkPage=function() {
 2424+ var t=new Title(this.value);
 2425+ t.toTalkPage();
 2426+ if (t.value) { return t; }
 2427+ return null;
 2428+};
 2429+Title.prototype.isTalkPage=function() {
 2430+ if (this.talkPage()===null) { return true; }
 2431+ return false;
 2432+};
 2433+Title.prototype.toArticleFromTalkPage=function() {
 2434+ var talkRegex=namespaceListToRegex(pg.ns.talkList);
 2435+ var splitted=this.value.parenSplit(talkRegex);
 2436+ if (splitted.length < 2 || splitted[0].length > 0) { this.value=null; return null; }
 2437+ if (splitted[1]==pg.ns.talkList[0]) {
 2438+ splitted[1]='';
 2439+ this.value=splitted.join(':').substring(2).split(' ').join('_');
 2440+ return this.value;
 2441+ }
 2442+ for (var i=1; i< pg.ns.talkList.length; ++i) {
 2443+ if (splitted[1]==pg.ns.talkList[i] || splitted[1]==pg.ns.talkList[i].split(' ').join('_')) {
 2444+ splitted[1]=pg.ns.withTalkList[i];
 2445+ this.value= splitted.join(':').substring(1).split(' ').join('_');
 2446+ return this.value;
 2447+ }
 2448+ }
 2449+ this.value=null;
 2450+ return this.value;
 2451+};
 2452+Title.prototype.articleFromTalkPage=function() {
 2453+ var t=new Title(this.value);
 2454+ t.toArticleFromTalkPage();
 2455+ if (t.value) { return t; }
 2456+ return null;
 2457+};
 2458+Title.prototype.articleFromTalkOrArticle=function() {
 2459+ var t=new Title(this.value);
 2460+ if ( t.toArticleFromTalkPage() ) { return t; }
 2461+ return this;
 2462+};
 2463+Title.prototype.isIpUser=function() {
 2464+ return pg.re.ipUser.test(this.userName());
 2465+};
 2466+//</NOLITE>
 2467+Title.prototype.stripNamespace=function(){ // returns a string, not a Title
 2468+ var n=this.value.indexOf(':');
 2469+ if (n<0) { return this.value; }
 2470+ var list=pg.ns.list;
 2471+ for (var i=0; i<list.length; ++i) {
 2472+ if (upcaseFirst(list[i]) == this.value.substring(0,n)) { return this.value.substring(n+1); }
 2473+ }
 2474+ return this.value;
 2475+};
 2476+Title.prototype.setUtf=function(value){
 2477+ if (!value) { this.value=''; return; }
 2478+ var anch=value.indexOf('#');
 2479+ if(anch < 0) { this.value=value.split('_').join(' '); this.anchor=''; return; }
 2480+ this.value=value.substring(0,anch).split('_').join(' ');
 2481+ this.anchor=value.substring(anch+1);
 2482+ this.ns=null; // wait until namespace() is called
 2483+};
 2484+Title.prototype.setUrl=function(urlfrag) {
 2485+ var anch=urlfrag.indexOf('#');
 2486+ this.value=safeDecodeURI(urlfrag.substring(0,anch));
 2487+ this.anchor=value.substring(anch+1);
 2488+};
 2489+Title.prototype.append=function(x){
 2490+ this.setUtf(this.value + x);
 2491+};
 2492+Title.prototype.urlString=function(x) {
 2493+ x || ( x={} );
 2494+ var v=this.toString(true);
 2495+ if (!x.omitAnchor && this.anchor) { v+= '#' + this.urlAnchor(); }
 2496+ if (!x.keepSpaces) { v=v.split(' ').join('_'); }
 2497+ return encodeURI(v).split('&').join('%26').split('?').join('%3F').split('+').join('%2B');
 2498+};
 2499+Title.prototype.removeAnchor=function() {
 2500+ return new Title(this.toString(true));
 2501+};
 2502+Title.prototype.toUrl=function() {
 2503+ return pg.wiki.titlebase + this.urlString();
 2504+};
 2505+
 2506+
 2507+function paramValue(param, url) {
 2508+ var s=url.parenSplit(RegExp('[?&]' + literalizeRegex(param) + '=([^?&]*)'));
 2509+ if (!url) { return null; }
 2510+ return s[1] || null;
 2511+}
 2512+
 2513+function parseParams(url) {
 2514+ var ret={};
 2515+ if (url.indexOf('?')==-1) { return ret; }
 2516+ var s=url.split('?').slice(1).join();
 2517+ var t=s.split('&');
 2518+ for (var i=0; i<t.length; ++i) {
 2519+ var z=t[i].split('=');
 2520+ z.push(null);
 2521+ ret[z[0]]=z[1];
 2522+ }
 2523+ return ret;
 2524+}
 2525+
 2526+// all sorts of stuff here
 2527+// FIXME almost everything needs to be rewritten
 2528+
 2529+function oldidFromAnchor(a) { return paramValue('oldid', a.href); }
 2530+//function diffFromAnchor(a) { return paramValue('diff', a.href); }
 2531+
 2532+
 2533+function wikiMarkupToAddressFragment (str) { // for images
 2534+ var ret = safeDecodeURI(str);
 2535+ ret = ret.split(' ').join('_');
 2536+ ret = encodeURI(ret);
 2537+ return ret;
 2538+}
 2539+
 2540+// (a) myDecodeURI (first standard decodeURI, then pg.re.urlNoPopup)
 2541+// (b) change spaces to underscores
 2542+// (c) encodeURI (just the straight one, no pg.re.urlNoPopup)
 2543+
 2544+function myDecodeURI (str) {
 2545+ var ret;
 2546+ // FIXME decodeURIComponent??
 2547+ try { ret=decodeURI(str.toString()); }
 2548+ catch (summat) { return str; }
 2549+ for (var i=0; i<pg.misc.decodeExtras.length; ++i) {
 2550+ var from=pg.misc.decodeExtras[i].from;
 2551+ var to=pg.misc.decodeExtras[i].to;
 2552+ ret=ret.split(from).join(to);
 2553+ }
 2554+ return ret;
 2555+}
 2556+
 2557+function safeDecodeURI(str) { var ret=myDecodeURI(str); return ret || str; }
 2558+
 2559+///////////
 2560+// TESTS //
 2561+///////////
 2562+
 2563+//<NOLITE>
 2564+function isIpUser(user) {return pg.re.ipUser.test(user);}
 2565+
 2566+function isDisambig(data, article) {
 2567+ if (!getValueOf('popupAllDabsStubs') && article.namespace()) { return false; }
 2568+ return ! article.isTalkPage() && pg.re.disambig.test(data);
 2569+}
 2570+
 2571+function stubCount(data, article) {
 2572+ if (!getValueOf('popupAllDabsStubs') && article.namespace()) { return false; }
 2573+ var sectStub=0;
 2574+ var realStub=0;
 2575+ if (pg.re.stub.test(data)) {
 2576+ var s=data.parenSplit(pg.re.stub);
 2577+ for (var i=1; i<s.length; i=i+2) {
 2578+ if (s[i]) { ++sectStub; }
 2579+ else { ++realStub; }
 2580+ }
 2581+ }
 2582+ return { real: realStub, sect: sectStub };
 2583+}
 2584+
 2585+function isValidImageName(str){ // extend as needed...
 2586+ return ( str.indexOf('{') == -1 );
 2587+}
 2588+
 2589+function isInStrippableNamespace(article) {
 2590+ return ( findInArray( pg.ns.nonArticleList, article.namespace() ) > -1 );
 2591+}
 2592+
 2593+function isInMainNamespace(article) { return !isInStrippableNamespace(article); }
 2594+
 2595+function anchorContainsImage(a) {
 2596+ // iterate over children of anchor a
 2597+ // see if any are images
 2598+ if (a===null) { return false; }
 2599+ kids=a.childNodes;
 2600+ for (var i=0; i<kids.length; ++i) { if (kids[i].nodeName=='IMG') { return true; } }
 2601+ return false;
 2602+}
 2603+//</NOLITE>
 2604+function isPopupLink(a) {
 2605+ // NB for performance reasons, TOC links generally return true
 2606+ // they should be stripped out later
 2607+
 2608+ if (!markNopopupSpanLinks.done) { markNopopupSpanLinks(); }
 2609+ if (a.inNopopupSpan || a.className=='sortheader') { return false; }
 2610+
 2611+ // FIXME is this faster inline?
 2612+ if (a.onmousedown || a.getAttribute('nopopup')) { return false; }
 2613+ var h=a.href;
 2614+ if (!pg.re.basenames.test(h)) { return false; }
 2615+ if ( !pg.re.urlNoPopup.test(h) ) { return true; }
 2616+ return (
 2617+ (pg.re.email.test(h) || pg.re.contribs.test(h) || pg.re.backlinks.test(h)) &&
 2618+ h.indexOf('&limit=') == -1 );
 2619+}
 2620+
 2621+function markNopopupSpanLinks() {
 2622+ var s=document.getElementsByTagName('span');
 2623+ for (var i=0; i<s.length; ++i) {
 2624+ if (s[i].className && s[i].className.toLowerCase()=='nopopups') {
 2625+ var as=s[i].getElementsByTagName('a');
 2626+ for (var j=0; j<as.length; ++j) {
 2627+ as[j].inNopopupSpan=true;
 2628+ }
 2629+ }
 2630+ }
 2631+ markNopopupSpanLinks.done=true;
 2632+}
 2633+// ENDFILE: titles.js
 2634+// STARTFILE: cookies.js
 2635+//<NOLITE>
 2636+//////////////////////////////////////////////////
 2637+// Cookie handling
 2638+// from http://www.quirksmode.org/js/cookies.html
 2639+
 2640+var Cookie= {
 2641+ create: function(name,value,days)
 2642+ {
 2643+ var expires;
 2644+ if (days)
 2645+ {
 2646+ var date = new Date();
 2647+ date.setTime(date.getTime()+(days*24*60*60*1000));
 2648+ expires = "; expires="+date.toGMTString();
 2649+ }
 2650+ else { expires = ""; }
 2651+ document.cookie = name+"="+value+expires+"; path=/";
 2652+ },
 2653+
 2654+ read: function(name)
 2655+ {
 2656+ var nameEQ = name + "=";
 2657+ var ca = document.cookie.split(';');
 2658+ for(var i=0;i < ca.length;i++)
 2659+ {
 2660+ var c = ca[i];
 2661+ while (c.charAt(0)==' ') { c = c.substring(1,c.length); }
 2662+ if (c.indexOf(nameEQ) === 0) { return c.substring(nameEQ.length,c.length); }
 2663+ }
 2664+ return null;
 2665+ },
 2666+
 2667+ erase: function(name)
 2668+ {
 2669+ Cookie.create(name,"",-1);
 2670+ }
 2671+};
 2672+//</NOLITE>
 2673+// ENDFILE: cookies.js
 2674+// STARTFILE: getpage.js
 2675+//////////////////////////////////////////////////
 2676+// Wiki-specific downloading
 2677+//
 2678+
 2679+// Schematic for a getWiki call
 2680+//
 2681+// getWiki->-getPageWithCaching
 2682+// |
 2683+// false | true
 2684+// getPage<-[findPictureInCache]->-onComplete(a fake download)
 2685+// \.
 2686+// (async)->addPageToCache(download)->-onComplete(download)
 2687+
 2688+
 2689+/** @todo {document}
 2690+ @param {Title} article
 2691+ @param {Function} onComplete
 2692+ @param {integer} oldid
 2693+ @param {Navapopup} owner
 2694+*/
 2695+function getWiki(article, onComplete, oldid, owner) {
 2696+ // set ctype=text/css to get around opera gzip bug
 2697+ var url = pg.wiki.titlebase + article.removeAnchor().urlString() +
 2698+ '&action=raw&ctype=text/css';
 2699+ if (oldid || oldid===0 || oldid==='0') { url += '&oldid='+oldid; }
 2700+ url += '&maxage=0&smaxage=0';
 2701+
 2702+ getPageWithCaching(url, onComplete, owner);
 2703+}
 2704+
 2705+// check cache to see if page exists
 2706+
 2707+function getPageWithCaching(url, onComplete, owner) {
 2708+ log('getPageWithCaching, url='+url);
 2709+ var i=findInPageCache(url);
 2710+ if (i > -1) {
 2711+ var d=fakeDownload(url, owner.idNumber, onComplete,
 2712+ pg.cache.pages[i].data, pg.cache.pages[i].lastModified,
 2713+ owner);
 2714+ } else {
 2715+ var d=getPage(url, onComplete, owner);
 2716+ if (d && owner && owner.addDownload) {
 2717+ owner.addDownload(d);
 2718+ d.owner=owner;
 2719+ }
 2720+ }
 2721+}
 2722+
 2723+function getPage(url, onComplete, owner) {
 2724+ log('getPage');
 2725+ var callback= function (d) { if (!d.aborted) {addPageToCache(d); onComplete(d);} };
 2726+ return startDownload(url, owner.idNumber, callback);
 2727+}
 2728+
 2729+function findInPageCache(url) {
 2730+ for (var i=0; i<pg.cache.pages.length; ++i) {
 2731+ if (url==pg.cache.pages[i].url) { return i; }
 2732+ }
 2733+ return -1;
 2734+}
 2735+
 2736+function addPageToCache(download) {
 2737+ log('addPageToCache '+download.url);
 2738+ var page = {url: download.url, data: download.data, lastModified: download.lastModified};
 2739+ return pg.cache.pages.push(page);
 2740+}
 2741+// ENDFILE: getpage.js
 2742+// STARTFILE: md5-2.2alpha.js
 2743+//<NOLITE>
 2744+/*
 2745+ * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
 2746+ * Digest Algorithm, as defined in RFC 1321.
 2747+ * Version 2.2-alpha Copyright (C) Paul Johnston 1999 - 2005
 2748+ * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
 2749+ * Distributed under the BSD License
 2750+ * See http://pajhome.org.uk/crypt/md5 for more info.
 2751+ */
 2752+
 2753+/*
 2754+ * Configurable variables. You may need to tweak these to be compatible with
 2755+ * the server-side, but the defaults work in most cases.
 2756+ */
 2757+var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */
 2758+var b64pad = ""; /* base-64 pad character. "=" for strict RFC compliance */
 2759+
 2760+/*
 2761+ * These are the functions you'll usually want to call
 2762+ * They take string arguments and return either hex or base-64 encoded strings
 2763+ */
 2764+function hex_md5(s) { return rstr2hex(rstr_md5(str2rstr_utf8(s))); }
 2765+function b64_md5(s) { return rstr2b64(rstr_md5(str2rstr_utf8(s))); }
 2766+function any_md5(s, e) { return rstr2any(rstr_md5(str2rstr_utf8(s)), e); }
 2767+function hex_hmac_md5(k, d)
 2768+ { return rstr2hex(rstr_hmac_md5(str2rstr_utf8(k), str2rstr_utf8(d))); }
 2769+function b64_hmac_md5(k, d)
 2770+ { return rstr2b64(rstr_hmac_md5(str2rstr_utf8(k), str2rstr_utf8(d))); }
 2771+function any_hmac_md5(k, d, e)
 2772+ { return rstr2any(rstr_hmac_md5(str2rstr_utf8(k), str2rstr_utf8(d)), e); }
 2773+
 2774+/*
 2775+ * Perform a simple self-test to see if the VM is working
 2776+ */
 2777+function md5_vm_test()
 2778+{
 2779+ return hex_md5("abc") == "900150983cd24fb0d6963f7d28e17f72";
 2780+}
 2781+
 2782+/*
 2783+ * Calculate the MD5 of a raw string
 2784+ */
 2785+function rstr_md5(s)
 2786+{
 2787+ return binl2rstr(binl_md5(rstr2binl(s), s.length * 8));
 2788+}
 2789+
 2790+/*
 2791+ * Calculate the HMAC-MD5, of a key and some data (raw strings)
 2792+ */
 2793+function rstr_hmac_md5(key, data)
 2794+{
 2795+ var bkey = rstr2binl(key);
 2796+ if(bkey.length > 16) bkey = binl_md5(bkey, key.length * 8);
 2797+
 2798+ var ipad = Array(16), opad = Array(16);
 2799+ for(var i = 0; i < 16; i++)
 2800+ {
 2801+ ipad[i] = bkey[i] ^ 0x36363636;
 2802+ opad[i] = bkey[i] ^ 0x5C5C5C5C;
 2803+ }
 2804+
 2805+ var hash = binl_md5(ipad.concat(rstr2binl(data)), 512 + data.length * 8);
 2806+ return binl2rstr(binl_md5(opad.concat(hash), 512 + 128));
 2807+}
 2808+
 2809+/*
 2810+ * Convert a raw string to a hex string
 2811+ */
 2812+function rstr2hex(input)
 2813+{
 2814+ var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
 2815+ var output = "";
 2816+ var x;
 2817+ for(var i = 0; i < input.length; i++)
 2818+ {
 2819+ x = input.charCodeAt(i);
 2820+ output += hex_tab.charAt((x >>> 4) & 0x0F)
 2821+ + hex_tab.charAt( x & 0x0F);
 2822+ }
 2823+ return output;
 2824+}
 2825+
 2826+/*
 2827+ * Convert a raw string to a base-64 string
 2828+ */
 2829+function rstr2b64(input)
 2830+{
 2831+ var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
 2832+ var output = "";
 2833+ var len = input.length;
 2834+ for(var i = 0; i < len; i += 3)
 2835+ {
 2836+ var triplet = (input.charCodeAt(i) << 16)
 2837+ | (i + 1 < len ? input.charCodeAt(i+1) << 8 : 0)
 2838+ | (i + 2 < len ? input.charCodeAt(i+2) : 0);
 2839+ for(var j = 0; j < 4; j++)
 2840+ {
 2841+ if(i * 8 + j * 6 > input.length * 8) output += b64pad;
 2842+ else output += tab.charAt((triplet >>> 6*(3-j)) & 0x3F);
 2843+ }
 2844+ }
 2845+ return output;
 2846+}
 2847+
 2848+/*
 2849+ * Convert a raw string to an arbitrary string encoding
 2850+ */
 2851+function rstr2any(input, encoding)
 2852+{
 2853+ var divisor = encoding.length;
 2854+ var remainders = Array();
 2855+ var i, q, x, quotient;
 2856+
 2857+ /* Convert to an array of 16-bit big-endian values, forming the dividend */
 2858+ var dividend = Array(input.length / 2);
 2859+ for(i = 0; i < dividend.length; i++)
 2860+ {
 2861+ dividend[i] = (input.charCodeAt(i * 2) << 8) | input.charCodeAt(i * 2 + 1);
 2862+ }
 2863+
 2864+ /*
 2865+ * Repeatedly perform a long division. The binary array forms the dividend,
 2866+ * the length of the encoding is the divisor. Once computed, the quotient
 2867+ * forms the dividend for the next step. We stop when the dividend is zero.
 2868+ * All remainders are stored for later use.
 2869+ */
 2870+ while(dividend.length > 0)
 2871+ {
 2872+ quotient = Array();
 2873+ x = 0;
 2874+ for(i = 0; i < dividend.length; i++)
 2875+ {
 2876+ x = (x << 16) + dividend[i];
 2877+ q = Math.floor(x / divisor);
 2878+ x -= q * divisor;
 2879+ if(quotient.length > 0 || q > 0)
 2880+ quotient[quotient.length] = q;
 2881+ }
 2882+ remainders[remainders.length] = x;
 2883+ dividend = quotient;
 2884+ }
 2885+
 2886+ /* Convert the remainders to the output string */
 2887+ var output = "";
 2888+ for(i = remainders.length - 1; i >= 0; i--)
 2889+ output += encoding.charAt(remainders[i]);
 2890+
 2891+ return output;
 2892+}
 2893+
 2894+/*
 2895+ * Encode a string as utf-8.
 2896+ * For efficiency, this assumes the input is valid utf-16.
 2897+ */
 2898+function str2rstr_utf8(input)
 2899+{
 2900+ var output = "";
 2901+ var i = -1;
 2902+ var x, y;
 2903+
 2904+ while(++i < input.length)
 2905+ {
 2906+ /* Decode utf-16 surrogate pairs */
 2907+ x = input.charCodeAt(i);
 2908+ y = i + 1 < input.length ? input.charCodeAt(i + 1) : 0;
 2909+ if(0xD800 <= x && x <= 0xDBFF && 0xDC00 <= y && y <= 0xDFFF)
 2910+ {
 2911+ x = 0x10000 + ((x & 0x03FF) << 10) + (y & 0x03FF);
 2912+ i++;
 2913+ }
 2914+
 2915+ /* Encode output as utf-8 */
 2916+ if(x <= 0x7F)
 2917+ output += String.fromCharCode(x);
 2918+ else if(x <= 0x7FF)
 2919+ output += String.fromCharCode(0xC0 | ((x >>> 6 ) & 0x1F),
 2920+ 0x80 | ( x & 0x3F));
 2921+ else if(x <= 0xFFFF)
 2922+ output += String.fromCharCode(0xE0 | ((x >>> 12) & 0x0F),
 2923+ 0x80 | ((x >>> 6 ) & 0x3F),
 2924+ 0x80 | ( x & 0x3F));
 2925+ else if(x <= 0x1FFFFF)
 2926+ output += String.fromCharCode(0xF0 | ((x >>> 18) & 0x07),
 2927+ 0x80 | ((x >>> 12) & 0x3F),
 2928+ 0x80 | ((x >>> 6 ) & 0x3F),
 2929+ 0x80 | ( x & 0x3F));
 2930+ }
 2931+ return output;
 2932+}
 2933+
 2934+/*
 2935+ * Encode a string as utf-16
 2936+ */
 2937+function str2rstr_utf16le(input)
 2938+{
 2939+ var output = "";
 2940+ for(var i = 0; i < input.length; i++)
 2941+ output += String.fromCharCode( input.charCodeAt(i) & 0xFF,
 2942+ (input.charCodeAt(i) >>> 8) & 0xFF);
 2943+ return output;
 2944+}
 2945+
 2946+function str2rstr_utf16be(input)
 2947+{
 2948+ var output = "";
 2949+ for(var i = 0; i < input.length; i++)
 2950+ output += String.fromCharCode((input.charCodeAt(i) >>> 8) & 0xFF,
 2951+ input.charCodeAt(i) & 0xFF);
 2952+ return output;
 2953+}
 2954+
 2955+/*
 2956+ * Convert a raw string to an array of little-endian words
 2957+ * Characters >255 have their high-byte silently ignored.
 2958+ */
 2959+function rstr2binl(input)
 2960+{
 2961+ var output = Array(input.length >> 2);
 2962+ for(var i = 0; i < output.length; i++)
 2963+ output[i] = 0;
 2964+ for(var i = 0; i < input.length * 8; i += 8)
 2965+ output[i>>5] |= (input.charCodeAt(i / 8) & 0xFF) << (i%32);
 2966+ return output;
 2967+}
 2968+
 2969+/*
 2970+ * Convert an array of little-endian words to a string
 2971+ */
 2972+function binl2rstr(input)
 2973+{
 2974+ var output = "";
 2975+ for(var i = 0; i < input.length * 32; i += 8)
 2976+ output += String.fromCharCode((input[i>>5] >>> (i % 32)) & 0xFF);
 2977+ return output;
 2978+}
 2979+
 2980+/*
 2981+ * Calculate the MD5 of an array of little-endian words, and a bit length.
 2982+ */
 2983+function binl_md5(x, len)
 2984+{
 2985+ /* append padding */
 2986+ x[len >> 5] |= 0x80 << ((len) % 32);
 2987+ x[(((len + 64) >>> 9) << 4) + 14] = len;
 2988+
 2989+ var a = 1732584193;
 2990+ var b = -271733879;
 2991+ var c = -1732584194;
 2992+ var d = 271733878;
 2993+
 2994+ for(var i = 0; i < x.length; i += 16)
 2995+ {
 2996+ var olda = a;
 2997+ var oldb = b;
 2998+ var oldc = c;
 2999+ var oldd = d;
 3000+
 3001+ a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936);
 3002+ d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586);
 3003+ c = md5_ff(c, d, a, b, x[i+ 2], 17, 606105819);
 3004+ b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330);
 3005+ a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897);
 3006+ d = md5_ff(d, a, b, c, x[i+ 5], 12, 1200080426);
 3007+ c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341);
 3008+ b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983);
 3009+ a = md5_ff(a, b, c, d, x[i+ 8], 7 , 1770035416);
 3010+ d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417);
 3011+ c = md5_ff(c, d, a, b, x[i+10], 17, -42063);
 3012+ b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162);
 3013+ a = md5_ff(a, b, c, d, x[i+12], 7 , 1804603682);
 3014+ d = md5_ff(d, a, b, c, x[i+13], 12, -40341101);
 3015+ c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290);
 3016+ b = md5_ff(b, c, d, a, x[i+15], 22, 1236535329);
 3017+
 3018+ a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510);
 3019+ d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632);
 3020+ c = md5_gg(c, d, a, b, x[i+11], 14, 643717713);
 3021+ b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302);
 3022+ a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691);
 3023+ d = md5_gg(d, a, b, c, x[i+10], 9 , 38016083);
 3024+ c = md5_gg(c, d, a, b, x[i+15], 14, -660478335);
 3025+ b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848);
 3026+ a = md5_gg(a, b, c, d, x[i+ 9], 5 , 568446438);
 3027+ d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690);
 3028+ c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961);
 3029+ b = md5_gg(b, c, d, a, x[i+ 8], 20, 1163531501);
 3030+ a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467);
 3031+ d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784);
 3032+ c = md5_gg(c, d, a, b, x[i+ 7], 14, 1735328473);
 3033+ b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734);
 3034+
 3035+ a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558);
 3036+ d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463);
 3037+ c = md5_hh(c, d, a, b, x[i+11], 16, 1839030562);
 3038+ b = md5_hh(b, c, d, a, x[i+14], 23, -35309556);
 3039+ a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060);
 3040+ d = md5_hh(d, a, b, c, x[i+ 4], 11, 1272893353);
 3041+ c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632);
 3042+ b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640);
 3043+ a = md5_hh(a, b, c, d, x[i+13], 4 , 681279174);
 3044+ d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222);
 3045+ c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979);
 3046+ b = md5_hh(b, c, d, a, x[i+ 6], 23, 76029189);
 3047+ a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487);
 3048+ d = md5_hh(d, a, b, c, x[i+12], 11, -421815835);
 3049+ c = md5_hh(c, d, a, b, x[i+15], 16, 530742520);
 3050+ b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651);
 3051+
 3052+ a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844);
 3053+ d = md5_ii(d, a, b, c, x[i+ 7], 10, 1126891415);
 3054+ c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905);
 3055+ b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055);
 3056+ a = md5_ii(a, b, c, d, x[i+12], 6 , 1700485571);
 3057+ d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606);
 3058+ c = md5_ii(c, d, a, b, x[i+10], 15, -1051523);
 3059+ b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799);
 3060+ a = md5_ii(a, b, c, d, x[i+ 8], 6 , 1873313359);
 3061+ d = md5_ii(d, a, b, c, x[i+15], 10, -30611744);
 3062+ c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380);
 3063+ b = md5_ii(b, c, d, a, x[i+13], 21, 1309151649);
 3064+ a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070);
 3065+ d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379);
 3066+ c = md5_ii(c, d, a, b, x[i+ 2], 15, 718787259);
 3067+ b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551);
 3068+
 3069+ a = safe_add(a, olda);
 3070+ b = safe_add(b, oldb);
 3071+ c = safe_add(c, oldc);
 3072+ d = safe_add(d, oldd);
 3073+ }
 3074+ return Array(a, b, c, d);
 3075+}
 3076+
 3077+/*
 3078+ * These functions implement the four basic operations the algorithm uses.
 3079+ */
 3080+function md5_cmn(q, a, b, x, s, t)
 3081+{
 3082+ return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b);
 3083+}
 3084+function md5_ff(a, b, c, d, x, s, t)
 3085+{
 3086+ return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
 3087+}
 3088+function md5_gg(a, b, c, d, x, s, t)
 3089+{
 3090+ return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
 3091+}
 3092+function md5_hh(a, b, c, d, x, s, t)
 3093+{
 3094+ return md5_cmn(b ^ c ^ d, a, b, x, s, t);
 3095+}
 3096+function md5_ii(a, b, c, d, x, s, t)
 3097+{
 3098+ return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
 3099+}
 3100+
 3101+/*
 3102+ * Add integers, wrapping at 2^32. This uses 16-bit operations internally
 3103+ * to work around bugs in some JS interpreters.
 3104+ */
 3105+function safe_add(x, y)
 3106+{
 3107+ var lsw = (x & 0xFFFF) + (y & 0xFFFF);
 3108+ var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
 3109+ return (msw << 16) | (lsw & 0xFFFF);
 3110+}
 3111+
 3112+/*
 3113+ * Bitwise rotate a 32-bit number to the left.
 3114+ */
 3115+function bit_rol(num, cnt)
 3116+{
 3117+ return (num << cnt) | (num >>> (32 - cnt));
 3118+}
 3119+//</NOLITE>
 3120+// ENDFILE: md5-2.2alpha.js
 3121+// STARTFILE: parensplit.js
 3122+//////////////////////////////////////////////////
 3123+// parenSplit
 3124+
 3125+// String.prototype.parenSplit should do what ECMAscript says
 3126+// String.prototype.split does, interspersing paren matches between
 3127+// the split elements
 3128+
 3129+if (String('abc'.split(/(b)/))!='a,b,c') {
 3130+ // broken String.split, e.g. konq, IE
 3131+ String.prototype.parenSplit=function (re) {
 3132+ re=nonGlobalRegex(re);
 3133+ var s=this;
 3134+ var m=re.exec(s);
 3135+ var ret=[];
 3136+ while (m && s) {
 3137+ // without the following loop, we have
 3138+ // 'ab'.parenSplit(/a|(b)/) != 'ab'.split(/a|(b)/)
 3139+ for(var i=0; i<m.length; ++i) {
 3140+ if (typeof m[i]=='undefined') m[i]='';
 3141+ }
 3142+ ret.push(s.substring(0,m.index));
 3143+ ret = ret.concat(m.slice(1));
 3144+ s=s.substring(m.index + m[0].length);
 3145+ m=re.exec(s);
 3146+ }
 3147+ ret.push(s);
 3148+ return ret;
 3149+ };
 3150+} else {
 3151+ String.prototype.parenSplit=function (re) { return this.split(re); };
 3152+ String.prototype.parenSplit.isNative=true;
 3153+}
 3154+
 3155+function nonGlobalRegex(re) {
 3156+ var s=re.toString();
 3157+ flags='';
 3158+ for (var j=s.length; s.charAt(j) != '/'; --j) {
 3159+ if (s.charAt(j) != 'g') { flags += s.charAt(j); }
 3160+ }
 3161+ var t=s.substring(1,j);
 3162+ return RegExp(t,flags);
 3163+}
 3164+// ENDFILE: parensplit.js
 3165+// STARTFILE: tools.js
 3166+// IE madness with encoding
 3167+// ========================
 3168+//
 3169+// suppose throughout that the page is in utf8, like wikipedia
 3170+//
 3171+// if a is an anchor DOM element and a.href should consist of
 3172+//
 3173+// http://host.name.here/wiki/foo?bar=baz
 3174+//
 3175+// then IE gives foo as "latin1-encoded" utf8; we have foo = decode_utf8(decodeURI(foo_ie))
 3176+// but IE gives bar=baz correctly as plain utf8
 3177+//
 3178+// ---------------------------------
 3179+//
 3180+// IE's xmlhttp doesn't understand utf8 urls. Have to use encodeURI here.
 3181+//
 3182+// ---------------------------------
 3183+//
 3184+// summat else
 3185+
 3186+// Source: http://aktuell.de.selfhtml.org/artikel/javascript/utf8b64/utf8.htm
 3187+
 3188+//<NOLITE>
 3189+function encode_utf8(rohtext) {
 3190+ // dient der Normalisierung des Zeilenumbruchs
 3191+ rohtext = rohtext.replace(/\r\n/g,"\n");
 3192+ var utftext = "";
 3193+ for(var n=0; n<rohtext.length; n++)
 3194+ {
 3195+ // ermitteln des Unicodes des aktuellen Zeichens
 3196+ var c=rohtext.charCodeAt(n);
 3197+ // alle Zeichen von 0-127 => 1byte
 3198+ if (c<128)
 3199+ utftext += String.fromCharCode(c);
 3200+ // alle Zeichen von 127 bis 2047 => 2byte
 3201+ else if((c>127) && (c<2048)) {
 3202+ utftext += String.fromCharCode((c>>6)|192);
 3203+ utftext += String.fromCharCode((c&63)|128);}
 3204+ // alle Zeichen von 2048 bis 66536 => 3byte
 3205+ else {
 3206+ utftext += String.fromCharCode((c>>12)|224);
 3207+ utftext += String.fromCharCode(((c>>6)&63)|128);
 3208+ utftext += String.fromCharCode((c&63)|128);}
 3209+ }
 3210+ return utftext;
 3211+}
 3212+
 3213+function getJsObj(json) {
 3214+ try {
 3215+ var json_ret = eval('(' + json + ')');
 3216+ } catch (someError) {
 3217+ errlog('Something went wrong with getJsobj, json='+json);
 3218+ return 1;
 3219+ }
 3220+ if( json_ret['warnings'] ) {
 3221+ for( var w=0; w < json_ret['warnings'].length; w++ ) {
 3222+ log( json_ret['warnings'][w]['*'] );
 3223+ }
 3224+ } else if ( json_ret['error'] ) {
 3225+ errlog( json_ret['error'].code + ': ' + json_ret['error'].info );
 3226+ }
 3227+ return json_ret;
 3228+}
 3229+
 3230+function anyChild(obj) {
 3231+ for (var p in obj) {
 3232+ return obj[p];
 3233+ }
 3234+ return null;
 3235+}
 3236+
 3237+//</NOLITE>
 3238+
 3239+function decode_utf8(utftext) {
 3240+ var plaintext = ""; var i=0, c=0, c1=0, c2=0;
 3241+ // while-Schleife, weil einige Zeichen uebersprungen werden
 3242+ while(i<utftext.length)
 3243+ {
 3244+ c = utftext.charCodeAt(i);
 3245+ if (c<128) {
 3246+ plaintext += String.fromCharCode(c);
 3247+ i++;}
 3248+ else if((c>191) && (c<224)) {
 3249+ c2 = utftext.charCodeAt(i+1);
 3250+ plaintext += String.fromCharCode(((c&31)<<6) | (c2&63));
 3251+ i+=2;}
 3252+ else {
 3253+ c2 = utftext.charCodeAt(i+1); c3 = utftext.charCodeAt(i+2);
 3254+ plaintext += String.fromCharCode(((c&15)<<12) | ((c2&63)<<6) | (c3&63));
 3255+ i+=3;}
 3256+ }
 3257+ return plaintext;
 3258+}
 3259+
 3260+
 3261+function upcaseFirst(str) {
 3262+ if (typeof str != typeof '' || str=='') return '';
 3263+ return str.charAt(0).toUpperCase() + str.substring(1);
 3264+}
 3265+
 3266+
 3267+function findInArray(arr, foo) {
 3268+ if (!arr || !arr.length) { return -1; }
 3269+ var len=arr.length;
 3270+ for (var i=0; i<len; ++i) { if (arr[i]==foo) { return i; } }
 3271+ return -1;
 3272+}
 3273+
 3274+function nextOne (array, value) {
 3275+ // NB if the array has two consecutive entries equal
 3276+ // then this will loop on successive calls
 3277+ var i=findInArray(array, value);
 3278+ if (i<0) { return null; }
 3279+ return array[i+1];
 3280+}
 3281+
 3282+function literalizeRegex(str){
 3283+ return str.replace(RegExp('([-.|()\\+?*^${}\\[\\]])', 'g'), '\\$1');
 3284+}
 3285+
 3286+String.prototype.entify=function() {
 3287+ //var shy='&shy;';
 3288+ return this.split('&').join('&amp;').split('<').join('&lt;').split('>').join('&gt;'/*+shy*/).split('"').join('&quot;');
 3289+};
 3290+
 3291+function findThis(array, value) {
 3292+ if (typeof array.length == 'undefined') { return null; }
 3293+ for (var i=0; i<array.length; ++i) {
 3294+ if (array[i]==value) { return i; }
 3295+ }
 3296+ return null;
 3297+}
 3298+
 3299+function removeNulls(list) {
 3300+ var ret=[];
 3301+ for (var i=0; i<list.length; ++i) {
 3302+ if (list[i]) {
 3303+ ret.push(list[i]);
 3304+ }
 3305+ }
 3306+ return ret;
 3307+}
 3308+function joinPath(list) {
 3309+ return removeNulls(list).join('/');
 3310+}
 3311+
 3312+
 3313+function simplePrintf(str, subs) {
 3314+ if (!str || !subs) { return str; }
 3315+ var ret=[];
 3316+ var s=str.parenSplit(/(%s|\$[0-9]+)/);
 3317+ var i=0;
 3318+ do {
 3319+ ret.push(s.shift());
 3320+ if ( !s.length ) { break; }
 3321+ var cmd=s.shift();
 3322+ if (cmd == '%s') {
 3323+ if ( i < subs.length ) { ret.push(subs[i]); } else { ret.push(cmd); }
 3324+ ++i;
 3325+ } else {
 3326+ var j=parseInt( cmd.replace('$', ''), 10 ) - 1;
 3327+ if ( j > -1 && j < subs.length ) { ret.push(subs[j]); } else { ret.push(cmd); }
 3328+ }
 3329+ } while (s.length > 0);
 3330+ return ret.join('');
 3331+}
 3332+
 3333+function max(a,b){return a<b ? b : a;}
 3334+function min(a,b){return a>b ? b : a;}
 3335+
 3336+function isString(x) { return (typeof x === 'string' || x instanceof String); }
 3337+//function isNumber(x) { return (typeof x === 'number' || x instanceof Number); }
 3338+function isRegExp(x) { return x instanceof RegExp; }
 3339+function isArray (x) { return x instanceof Array; }
 3340+function isObject(x) { return x instanceof Object; }
 3341+function isFunction(x) {
 3342+ return !isRegExp(x) && (typeof x === 'function' || x instanceof Function);
 3343+}
 3344+
 3345+function repeatString(s,mult) {
 3346+ var ret='';
 3347+ for (var i=0; i<mult; ++i) { ret += s; }
 3348+ return ret;
 3349+}
 3350+
 3351+function zeroFill(s, min) {
 3352+ min = min || 2;
 3353+ var t=s.toString();
 3354+ return repeatString('0', min - t.length) + t;
 3355+}
 3356+
 3357+function map(f, o) {
 3358+ if (isArray(o)) { return map_array(f,o); }
 3359+ return map_object(f,o);
 3360+}
 3361+function map_array(f,o) {
 3362+ var ret=[];
 3363+ for (var i=0; i<o.length; ++i) {
 3364+ ret.push(f(o[i]));
 3365+ }
 3366+ return ret;
 3367+}
 3368+function map_object(f,o) {
 3369+ var ret={};
 3370+ for (var i in o) { ret[o]=f(o[i]); }
 3371+ return ret;
 3372+}
 3373+// ENDFILE: tools.js
 3374+// STARTFILE: dab.js
 3375+//<NOLITE>
 3376+//////////////////////////////////////////////////
 3377+// Dab-fixing code
 3378+//
 3379+
 3380+
 3381+function retargetDab(newTarget, oldTarget, friendlyCurrentArticleName, titleToEdit) {
 3382+ log('retargetDab: newTarget='+newTarget + ' oldTarget=' + oldTarget);
 3383+ return changeLinkTargetLink(
 3384+ {newTarget: newTarget,
 3385+ text: newTarget.split(' ').join('&nbsp;'),
 3386+ hint: tprintf('disambigHint', [newTarget]),
 3387+ summary: simplePrintf(
 3388+ getValueOf('popupFixDabsSummary'), [friendlyCurrentArticleName, newTarget ]),
 3389+ clickButton: 'wpDiff', minor: true, oldTarget: oldTarget,
 3390+ watch: getValueOf('popupWatchDisambiggedPages'),
 3391+ title: titleToEdit});
 3392+}
 3393+
 3394+function listLinks(wikitext, oldTarget, titleToEdit) {
 3395+ // mediawiki strips trailing spaces, so we do the same
 3396+ // testcase: http://en.wikipedia.org/w/index.php?title=Radial&oldid=97365633
 3397+ var reg=RegExp('\\[\\[([^|]*?) *(\\||\\]\\])', 'gi');
 3398+ var ret=[];
 3399+ var splitted=wikitext.parenSplit(reg);
 3400+ // ^[a-z]+ should match interwiki links, hopefully (case-insensitive)
 3401+ // and ^[a-z]* should match those and [[:Category...]] style links too
 3402+ var omitRegex=RegExp('^[a-z]*:|^[Ss]pecial:|^[Ii]mage|^[Cc]ategory');
 3403+ var friendlyCurrentArticleName= oldTarget.toString();
 3404+ var wikPos = getValueOf('popupDabWiktionary');
 3405+
 3406+ for (var i=1; i<splitted.length; i=i+3) {
 3407+ if (typeof splitted[i] == typeof 'string' && splitted[i].length>0 && !omitRegex.test(splitted[i])) {
 3408+ ret.push( retargetDab(splitted[i], oldTarget, friendlyCurrentArticleName, titleToEdit) );
 3409+ } /* if */
 3410+ } /* for loop */
 3411+
 3412+ ret = rmDupesFromSortedList(ret.sort());
 3413+
 3414+ if (wikPos) {
 3415+ var wikTarget='wiktionary:' +
 3416+ friendlyCurrentArticleName.replace( RegExp('^(.+)\\s+[(][^)]+[)]\\s*$'), '$1' );
 3417+
 3418+ var meth;
 3419+ if (wikPos.toLowerCase() == 'first') { meth = 'unshift'; }
 3420+ else { meth = 'push'; }
 3421+
 3422+ ret[meth]( retargetDab(wikTarget, oldTarget, friendlyCurrentArticleName, titleToEdit) );
 3423+ }
 3424+
 3425+ ret.push(changeLinkTargetLink(
 3426+ { newTarget: null,
 3427+ text: popupString('remove this link').split(' ').join('&nbsp;'),
 3428+ hint: popupString("remove all links to this disambig page from this article"),
 3429+ clickButton: "wpDiff", oldTarget: oldTarget,
 3430+ summary: simplePrintf(getValueOf('popupRmDabLinkSummary'), [friendlyCurrentArticleName]),
 3431+ watch: getValueOf('popupWatchDisambiggedPages'),
 3432+ title: titleToEdit
 3433+ }));
 3434+ return ret;
 3435+}
 3436+
 3437+function rmDupesFromSortedList(list) {
 3438+ var ret=[];
 3439+ for (var i=0; i<list.length; ++i) {
 3440+ if (ret.length===0 || list[i]!=ret[ret.length-1]) { ret.push(list[i]); }
 3441+ }
 3442+ return ret;
 3443+}
 3444+
 3445+function makeFixDab(data, navpop) {
 3446+ // grab title from parent popup if there is one; default exists in changeLinkTargetLink
 3447+ var titleToEdit=(navpop.parentPopup && navpop.parentPopup.article.toString());
 3448+ var list=listLinks(data, navpop.originalArticle, titleToEdit);
 3449+ if (list.length===0) { log('listLinks returned empty list'); return null; }
 3450+ var html='<hr>' + popupString('Click to disambiguate this link to:') + '<br>';
 3451+ html+=list.join(', ');
 3452+ return html;
 3453+}
 3454+
 3455+
 3456+function makeFixDabs(wikiText, navpop) {
 3457+ if (getValueOf('popupFixDabs') && isDisambig(wikiText, navpop.article) &&
 3458+ Title.fromURL(location.href).namespace() != pg.ns.special &&
 3459+ navpop.article.talkPage() ) {
 3460+ setPopupHTML(makeFixDab(wikiText, navpop), 'popupFixDab', navpop.idNumber);
 3461+ }
 3462+}
 3463+
 3464+function popupRedlinkHTML(article) {
 3465+ return changeLinkTargetLink(
 3466+ { newTarget: null, text: popupString('remove this link').split(' ').join('&nbsp;'),
 3467+ hint: popupString("remove all links to this page from this article"),
 3468+ clickButton: "wpDiff",
 3469+ oldTarget: article.toString(),
 3470+ summary: simplePrintf(getValueOf('popupRedlinkSummary'), [article.toString()])});
 3471+}
 3472+//</NOLITE>
 3473+// ENDFILE: dab.js
 3474+// STARTFILE: htmloutput.js
 3475+
 3476+function appendPopupContent(obj, elementId, popupId, onSuccess) {
 3477+ return setPopupHTML(obj, elementId, popupId, onSuccess, true);
 3478+}
 3479+
 3480+// this has to use a timer loop as we don't know if the DOM element exists when we want to set the text
 3481+function setPopupHTML (str, elementId, popupId, onSuccess, append) {
 3482+ if (elementId=='popupPreview') {
 3483+ }
 3484+ if (typeof popupId === 'undefined') {
 3485+ //console.error('popupId is not defined in setPopupHTML, html='+str.substring(0,100));
 3486+ popupId = pg.idNumber;
 3487+ }
 3488+
 3489+ var popupElement=document.getElementById(elementId+popupId);
 3490+ if (popupElement) {
 3491+ if (!append) { popupElement.innerHTML=''; }
 3492+ if (isString(str)) {
 3493+ popupElement.innerHTML+=str;
 3494+ } else {
 3495+ popupElement.appendChild(str);
 3496+ }
 3497+ if (onSuccess) { onSuccess(); }
 3498+ setTimeout(checkPopupPosition, 100);
 3499+ return true;
 3500+ } else {
 3501+ // call this function again in a little while...
 3502+ setTimeout(function(){
 3503+ setPopupHTML(str,elementId,popupId,onSuccess);
 3504+ }, 600);
 3505+ }
 3506+ return null;
 3507+}
 3508+
 3509+//<NOLITE>
 3510+function setImageStatus(str, id) {return; } // setPopupHTML(str, 'popupImageStatus', id);}
 3511+function setPopupTrailer(str,id) {return setPopupHTML(str, 'popupData', id);}
 3512+//</NOLITE>
 3513+
 3514+
 3515+function fillEmptySpans(args) { return fillEmptySpans2(args); }
 3516+
 3517+// args.navpopup is mandatory
 3518+// optional: args.redir, args.redirTarget
 3519+// FIXME: ye gods, this is ugly stuff
 3520+function fillEmptySpans2(args) { // if redir is present and true then redirTarget is mandatory
 3521+ var redir=true;
 3522+ if (typeof args != 'object' || typeof args.redir == 'undefined' || !args.redir) { redir=false; }
 3523+ var a=args.navpopup.parentAnchor;
 3524+
 3525+ var article, hint=null, oldid=null, params={};
 3526+ if (redir && typeof args.redirTarget == typeof {}) {
 3527+ article=args.redirTarget;
 3528+ //hint=article.hintValue();
 3529+ } else {
 3530+ article=(new Title()).fromAnchor(a);
 3531+ hint=a.originalTitle || article.hintValue();
 3532+ params=parseParams(a.href);
 3533+ oldid=(getValueOf('popupHistoricalLinks')) ? params.oldid : null;
 3534+ rcid=params.rcid;
 3535+ }
 3536+ var x={ article:article, hint: hint, oldid: oldid, rcid: rcid, navpop:args.navpopup, params:params };
 3537+
 3538+ var structure=pg.structures[getValueOf('popupStructure')];
 3539+ if (typeof structure != 'object') {
 3540+ setPopupHTML('popupError', 'Unknown structure (this should never happen): '+
 3541+ pg.option.popupStructure, args.navpopup.idNumber);
 3542+ return;
 3543+ }
 3544+ var spans=flatten(pg.misc.layout);
 3545+ var numspans = spans.length;
 3546+ var redirs=pg.misc.redirSpans;
 3547+
 3548+ for (var i=0; i<numspans; ++i) {
 3549+ var f=findThis(redirs, spans[i]);
 3550+ //log('redir='+redir+', f='+f+', spans[i]='+spans[i]);
 3551+ if ( (f!==null && !redir) || (f===null && redir) ) {
 3552+ //log('skipping this set of the loop');
 3553+ continue;
 3554+ }
 3555+ var structurefn=structure[spans[i]];
 3556+ var setfn = setPopupHTML;
 3557+ if (getValueOf('popupActiveNavlinks') &&
 3558+ (spans[i].indexOf('popupTopLinks')==0 || spans[i].indexOf('popupRedirTopLinks')==0)
 3559+ ) {
 3560+ setfn = setPopupTipsAndHTML;
 3561+ }
 3562+ switch (typeof structurefn) {
 3563+ case 'function':
 3564+ //log('running '+spans[i]+'({article:'+x.article+', hint:'+x.hint+', oldid: '+x.oldid+'})');
 3565+ setfn(structurefn(x), spans[i], args.navpopup.idNumber);
 3566+ break;
 3567+ case 'string':
 3568+ setfn(structurefn, spans[i], args.navpopup.idNumber);
 3569+ break;
 3570+ default:
 3571+ errlog('unknown thing with label '+spans[i]);
 3572+ break;
 3573+ }
 3574+ }
 3575+}
 3576+
 3577+// flatten an array
 3578+function flatten(list, start) {
 3579+ var ret=[];
 3580+ if (typeof start == 'undefined') { start=0; }
 3581+ for (var i=start; i<list.length; ++i) {
 3582+ if (typeof list[i] == typeof []) {
 3583+ return ret.concat(flatten(list[i])).concat(flatten(list, i+1));
 3584+ }
 3585+ else { ret.push(list[i]); }
 3586+ }
 3587+ return ret;
 3588+}
 3589+
 3590+// Generate html for whole popup
 3591+function popupHTML (a) {
 3592+ getValueOf('popupStructure');
 3593+ var structure=pg.structures[pg.option.popupStructure];
 3594+ if (typeof structure != 'object') {
 3595+ //return 'Unknown structure: '+pg.option.popupStructure;
 3596+ // override user choice
 3597+ pg.option.popupStructure=pg.optionDefault.popupStructure;
 3598+ return popupHTML(a);
 3599+ }
 3600+ if (typeof structure.popupLayout != 'function') { return 'Bad layout'; }
 3601+ pg.misc.layout=structure.popupLayout();
 3602+ if (typeof structure.popupRedirSpans == 'function') { pg.misc.redirSpans=structure.popupRedirSpans(); }
 3603+ else { pg.misc.redirSpans=[]; }
 3604+ return makeEmptySpans(pg.misc.layout, a.navpopup);
 3605+}
 3606+
 3607+function makeEmptySpans (list, navpop) {
 3608+ var ret='';
 3609+ for (var i=0; i<list.length; ++i) {
 3610+ if (typeof list[i] == typeof '') {
 3611+ ret += emptySpanHTML(list[i], navpop.idNumber, 'div');
 3612+ } else if (typeof list[i] == typeof [] && list[i].length > 0 ) {
 3613+ ret = ret.parenSplit(RegExp('(</[^>]*?>$)')).join(makeEmptySpans(list[i], navpop));
 3614+ } else if (typeof list[i] == typeof {} && list[i].nodeType ) {
 3615+ ret += emptySpanHTML(list[i].name, navpop.idNumber, list[i].nodeType);
 3616+ }
 3617+ }
 3618+ return ret;
 3619+}
 3620+
 3621+
 3622+function emptySpanHTML(name, id, tag, classname) {
 3623+ tag = tag || 'span';
 3624+ if (!classname) { classname = emptySpanHTML.classAliases[name]; }
 3625+ classname = classname || name;
 3626+ if (name == getValueOf('popupDragHandle')) { classname += ' popupDragHandle'; }
 3627+ return simplePrintf('<%s id="%s" class="%s"></%s>', [tag, name + id, classname, tag]);
 3628+}
 3629+emptySpanHTML.classAliases={ 'popupSecondPreview': 'popupPreview' };
 3630+
 3631+// generate html for popup image
 3632+// <a id="popupImageLinkn"><img id="popupImagen">
 3633+// where n=idNumber
 3634+function imageHTML(article, idNumber) {
 3635+ return simplePrintf('<a id="popupImageLink$1">' +
 3636+ '<img align="right" valign="top" id="popupImg$1" style="display: none;"></img>' +
 3637+ '</a>', [ idNumber ]);
 3638+}
 3639+
 3640+function popTipsSoonFn(id, when, popData) {
 3641+ when || ( when=250 );
 3642+ var popTips=function(){ setupTooltips(document.getElementById(id), false, true, popData); };
 3643+ return function() { setTimeout( popTips, when, popData ); };
 3644+}
 3645+
 3646+function setPopupTipsAndHTML(html, divname, idnumber, popData) {
 3647+ setPopupHTML(html, divname, idnumber,
 3648+ getValueOf('popupSubpopups') ?
 3649+ popTipsSoonFn(divname + idnumber, null, popData) :
 3650+ null);
 3651+}
 3652+// ENDFILE: htmloutput.js
 3653+// STARTFILE: mouseout.js
 3654+//////////////////////////////////////////////////
 3655+// fuzzy checks
 3656+
 3657+function fuzzyCursorOffMenus(x,y, fuzz, parent) {
 3658+ if (!parent) { return null; }
 3659+ var uls=parent.getElementsByTagName('ul');
 3660+ for (var i=0; i<uls.length; ++i) {
 3661+ if (uls[i].className=='popup_menu') {
 3662+ if (uls[i].offsetWidth > 0) return false;
 3663+ } // else {document.title+='.';}
 3664+ }
 3665+ return true;
 3666+}
 3667+
 3668+function checkPopupPosition () { // stop the popup running off the right of the screen
 3669+ // FIXME avoid pg.current.link
 3670+ pg.current.link && pg.current.link.navpopup &&
 3671+ pg.current.link.navpopup.limitHorizontalPosition();
 3672+}
 3673+
 3674+function mouseOutWikiLink () {
 3675+ if (!window.popupsReady || !window.popupsReady()) { return; }
 3676+ //console ('mouseOutWikiLink');
 3677+ var a=this;
 3678+ if (a.navpopup==null) return;
 3679+ if ( ! a.navpopup.isVisible() ) {
 3680+ a.navpopup.banish();
 3681+ return;
 3682+ }
 3683+ Navpopup.tracker.addHook(posCheckerHook(a.navpopup));
 3684+}
 3685+
 3686+function posCheckerHook(navpop) {
 3687+ return function() {
 3688+ if (!navpop.isVisible()) { return true; /* remove this hook */ }
 3689+ if (Navpopup.tracker.dirty) {
 3690+ return false;
 3691+ }
 3692+ var x=Navpopup.tracker.x, y=Navpopup.tracker.y;
 3693+ var mouseOverNavpop = navpop.isWithin(x,y,navpop.fuzz, navpop.mainDiv) ||
 3694+ !fuzzyCursorOffMenus(x,y,navpop.fuzz, navpop.mainDiv);
 3695+
 3696+ // FIXME it'd be prettier to do this internal to the Navpopup objects
 3697+ var t=getValueOf('popupHideDelay');
 3698+ if (t) { t = t * 1000; }
 3699+ if (!t) {
 3700+ if(!mouseOverNavpop) {
 3701+ navpop.banish();
 3702+ return true; /* remove this hook */
 3703+ }
 3704+ return false;
 3705+ }
 3706+ // we have a hide delay set
 3707+ var d=+(new Date());
 3708+ if ( !navpop.mouseLeavingTime ) {
 3709+ navpop.mouseLeavingTime = d;
 3710+ return false;
 3711+ }
 3712+ if ( mouseOverNavpop ) {
 3713+ navpop.mouseLeavingTime=null;
 3714+ return false;
 3715+ }
 3716+ if (d - navpop.mouseLeavingTime > t) {
 3717+ navpop.mouseLeavingTime=null;
 3718+ navpop.banish(); return true; /* remove this hook */
 3719+ }
 3720+ return false;
 3721+ };
 3722+}
 3723+
 3724+function runStopPopupTimer(navpop) {
 3725+ // at this point, we should have left the link but remain within the popup
 3726+ // so we call this function again until we leave the popup.
 3727+ if (!navpop.stopPopupTimer) {
 3728+ navpop.stopPopupTimer=setInterval(posCheckerHook(navpop), 500);
 3729+ navpop.addHook(function(){clearInterval(navpop.stopPopupTimer);},
 3730+ 'hide', 'before');
 3731+ }
 3732+}
 3733+// ENDFILE: mouseout.js
 3734+// STARTFILE: previewmaker.js
 3735+/**
 3736+ @fileoverview
 3737+ Defines the {@link Previewmaker} object, which generates short previews from wiki markup.
 3738+*/
 3739+
 3740+/**
 3741+ Creates a new Previewmaker
 3742+ @constructor
 3743+ @class The Previewmaker class. Use an instance of this to generate short previews from Wikitext.
 3744+ @param {String} wikiText The Wikitext source of the page we wish to preview.
 3745+ @param {String} baseUrl The url we should prepend when creating relative urls.
 3746+ @param {Navpopup} owner The navpop associated to this preview generator
 3747+*/
 3748+function Previewmaker(wikiText, baseUrl, owner) {
 3749+ /** The wikitext which is manipulated to generate the preview. */
 3750+ this.originalData=wikiText;
 3751+ this.setData();
 3752+ this.baseUrl=baseUrl;
 3753+ this.owner=owner;
 3754+ this.maxCharacters=getValueOf('popupMaxPreviewCharacters');
 3755+ this.maxSentences=getValueOf('popupMaxPreviewSentences');
 3756+}
 3757+Previewmaker.prototype.setData=function() {
 3758+ var maxSize=max(10000, 2*this.maxCharacters);
 3759+ this.data=this.originalData.substring(0,maxSize);
 3760+};
 3761+/** Remove HTML comments
 3762+ @private
 3763+*/
 3764+Previewmaker.prototype.killComments = function () {
 3765+ // this also kills trailing spaces and one trailing newline, eg [[diamyo]]
 3766+ this.data=this.data.replace(RegExp('<!--[\\s\\S]*?--> *\\n?', 'g'), '');
 3767+};
 3768+/**
 3769+ @private
 3770+*/
 3771+Previewmaker.prototype.killDivs = function () {
 3772+ // say goodbye, divs (can be nested, so use * not *?)
 3773+ this.data=this.data.replace(RegExp('< *div[^>]* *>[\\s\\S]*?< */ *div *>',
 3774+ 'gi'), '');
 3775+};
 3776+/**
 3777+ @private
 3778+*/
 3779+Previewmaker.prototype.killGalleries = function () {
 3780+ this.data=this.data.replace(RegExp('< *gallery[^>]* *>[\\s\\S]*?< */ *gallery *>',
 3781+ 'gi'), '');
 3782+};
 3783+/**
 3784+ @private
 3785+*/
 3786+Previewmaker.prototype.kill = function(opening, closing, subopening, subclosing, repl) {
 3787+ var oldk=this.data;
 3788+ var k=this.killStuff(this.data, opening, closing, subopening, subclosing, repl);
 3789+ while (k.length < oldk.length) {
 3790+ oldk=k;
 3791+ k=this.killStuff(k, opening, closing, subopening, subclosing, repl);
 3792+ }
 3793+ this.data=k;
 3794+};
 3795+/**
 3796+ @private
 3797+*/
 3798+Previewmaker.prototype.killStuff = function (txt, opening, closing, subopening, subclosing, repl) {
 3799+ var op=this.makeRegexp(opening);
 3800+ var cl=this.makeRegexp(closing, '^');
 3801+ var sb=subopening ? this.makeRegexp(subopening, '^') : null;
 3802+ var sc=subclosing ? this.makeRegexp(subclosing, '^') : cl;
 3803+ if (!op || !cl) {
 3804+ alert('Navigation Popups error: op or cl is null! something is wrong.');
 3805+ return;
 3806+ }
 3807+ if (!op.test(txt)) { return txt; }
 3808+ var ret='';
 3809+ var opResult = op.exec(txt);
 3810+ ret = txt.substring(0,opResult.index);
 3811+ txt=txt.substring(opResult.index+opResult[0].length);
 3812+ var depth = 1;
 3813+ while (txt.length > 0) {
 3814+ var removal=0;
 3815+ if (depth==1 && cl.test(txt)) {
 3816+ depth--;
 3817+ removal=cl.exec(txt)[0].length;
 3818+ } else if (depth > 1 && sc.test(txt)) {
 3819+ depth--;
 3820+ removal=sc.exec(txt)[0].length;
 3821+ }else if (sb && sb.test(txt)) {
 3822+ depth++;
 3823+ removal=sb.exec(txt)[0].length;
 3824+ }
 3825+ if ( !removal ) { removal = 1; }
 3826+ txt=txt.substring(removal);
 3827+ if (depth==0) { break; }
 3828+ }
 3829+ return ret + (repl || '') + txt;
 3830+};
 3831+/**
 3832+ @private
 3833+*/
 3834+Previewmaker.prototype.makeRegexp = function (x, prefix, suffix) {
 3835+ prefix = prefix || '';
 3836+ suffix = suffix || '';
 3837+ var reStr='';
 3838+ var flags='';
 3839+ if (isString(x)) {
 3840+ reStr=prefix + literalizeRegex(x) + suffix;
 3841+ } else if (isRegExp(x)) {
 3842+ var s=x.toString().substring(1);
 3843+ var sp=s.split('/');
 3844+ flags=sp[sp.length-1];
 3845+ sp[sp.length-1]='';
 3846+ s=sp.join('/');
 3847+ s=s.substring(0,s.length-1);
 3848+ reStr= prefix + s + suffix;
 3849+ } else {
 3850+ log ('makeRegexp failed');
 3851+ }
 3852+
 3853+ log ('makeRegexp: got reStr=' + reStr + ', flags=' + flags);
 3854+ return RegExp(reStr, flags);
 3855+};
 3856+/**
 3857+ @private
 3858+*/
 3859+Previewmaker.prototype.killBoxTemplates = function () {
 3860+
 3861+ // taxobox removal... in fact, there's a saudiprincebox_begin, so let's be more general
 3862+ // also, have float_begin, ... float_end
 3863+ this.kill(RegExp('[{][{][^{}\\s|]*?(float|box)[_ ](begin|start)', 'i'), /[}][}]\s*/, '{{');
 3864+
 3865+ // infoboxes etc
 3866+ // from [[User:Zyxw/popups.js]]: kill frames too
 3867+ this.kill(RegExp('[{][{][^{}\\s|]*?(infobox|elementbox|frame)[_ ]', 'i'), /[}][}]\s*/, '{{');
 3868+
 3869+};
 3870+/**
 3871+ @private
 3872+*/
 3873+Previewmaker.prototype.killTemplates = function () {
 3874+ this.kill('{{', '}}', '{', '}', ' ');
 3875+};
 3876+/**
 3877+ @private
 3878+*/
 3879+Previewmaker.prototype.killTables = function () {
 3880+ // tables are bad, too
 3881+ // this can be slow, but it's an inprovement over a browser hang
 3882+ // torture test: [[Comparison_of_Intel_Central_Processing_Units]]
 3883+ this.kill('{|', /[|]}\s*/, '{|');
 3884+ this.kill(/<table.*?>/i, /<\/table.*?>/i, /<table.*?>/i);
 3885+ // remove lines starting with a pipe for the hell of it (?)
 3886+ this.data=this.data.replace(RegExp('^[|].*$', 'mg'), '');
 3887+};
 3888+/**
 3889+ @private
 3890+*/
 3891+Previewmaker.prototype.killImages = function () {
 3892+ // images and categories are a nono
 3893+ this.kill(RegExp('[[][[]\\s*(Image|File|' + pg.ns.image + '|' + pg.ns.category + ')\\s*:', 'i'),
 3894+ /\]\]\s*/, '[', ']');
 3895+};
 3896+/**
 3897+ @private
 3898+*/
 3899+Previewmaker.prototype.killHTML = function () {
 3900+ // kill <ref ...>...</ref>
 3901+ this.kill(/<ref\b.*?>/i, /<\/ref>/i);
 3902+
 3903+ // let's also delete entire lines starting with <. it's worth a try.
 3904+ this.data=this.data.replace(RegExp('(^|\\n) *<.*', 'g'), '\n');
 3905+
 3906+ // and those pesky html tags, but not <nowiki> or <blockquote>
 3907+ var splitted=this.data.parenSplit(/(<.*?>)/);
 3908+ var len=splitted.length;
 3909+ for (var i=1; i<len; i=i+2) {
 3910+ switch (splitted[i]) {
 3911+ case '<nowiki>':
 3912+ case '</nowiki>':
 3913+ break;
 3914+ default:
 3915+ if (! /^< *\/? *blockquote\b/i.test(splitted[i])) {
 3916+ splitted[i]='';
 3917+ }
 3918+ }
 3919+ }
 3920+ this.data=splitted.join('');
 3921+};
 3922+/**
 3923+ @private
 3924+*/
 3925+Previewmaker.prototype.killChunks = function() { // heuristics alert
 3926+ // chunks of italic text? you crazy, man?
 3927+ var italicChunkRegex=new RegExp
 3928+ ("((^|\\n)\\s*:*\\s*''[^']([^']|'''|'[^']){20}(.|\\n[^\\n])*''[.!?\\s]*\\n)+", 'g');
 3929+ // keep stuff separated, though, so stick in \n (fixes [[Union Jack]]?
 3930+ this.data=this.data.replace(italicChunkRegex, '\n');
 3931+};
 3932+/**
 3933+ @private
 3934+*/
 3935+Previewmaker.prototype.mopup = function () {
 3936+ // we simply *can't* be doing with horizontal rules right now
 3937+ this.data=this.data.replace(RegExp('^-{4,}','mg'),'');
 3938+
 3939+ // no indented lines
 3940+ this.data=this.data.replace(RegExp('(^|\\n) *:[^\\n]*','g'), '');
 3941+
 3942+ // replace __TOC__, __NOTOC__ and whatever else there is
 3943+ // this'll probably do
 3944+ this.data=this.data.replace(RegExp('^__[A-Z_]*__ *$', 'gmi'),'');
 3945+};
 3946+/**
 3947+ @private
 3948+*/
 3949+Previewmaker.prototype.firstBit = function () {
 3950+ // dont't be givin' me no subsequent paragraphs, you hear me?
 3951+ /// first we "normalize" section headings, removing whitespace after, adding before
 3952+ var d=this.data;
 3953+
 3954+ if (getValueOf('popupPreviewCutHeadings')) {
 3955+ this.data=this.data.replace(RegExp('\\s*(==+[^=]*==+)\\s*', 'g'), '\n\n$1 ');
 3956+ /// then we want to get rid of paragraph breaks whose text ends badly
 3957+ this.data=this.data.replace(RegExp('([:;]) *\\n{2,}', 'g'), '$1\n');
 3958+
 3959+ this.data=this.data.replace(RegExp('^[\\s\\n]*'), '');
 3960+ stuff=(RegExp('^([^\\n]|\\n[^\\n\\s])*')).exec(this.data);
 3961+ if (stuff) { d = stuff[0]; }
 3962+ if (!getValueOf('popupPreviewFirstParOnly')) { d = this.data; }
 3963+
 3964+ /// now put \n\n after sections so that bullets and numbered lists work
 3965+ d=d.replace(RegExp('(==+[^=]*==+)\\s*', 'g'), '$1\n\n');
 3966+ }
 3967+
 3968+
 3969+ // superfluous sentences are RIGHT OUT.
 3970+ // note: exactly 1 set of parens here needed to make the slice work
 3971+ d = d.parenSplit(RegExp('([!?.]+["'+"'"+']*\\s)','g'));
 3972+ // leading space is bad, mmkay?
 3973+ d[0]=d[0].replace(RegExp('^\\s*'), '');
 3974+
 3975+ var notSentenceEnds=RegExp('([^.][a-z][.] *[a-z]|etc|sic|Dr|Mr|Mrs|Ms|St|no|op|cit|\\[[^\\]]*|\\s[A-Zvclm])$', 'i');
 3976+ d = this.fixSentenceEnds(d, notSentenceEnds);
 3977+
 3978+ this.fullLength=d.join('').length;
 3979+ var maxChars=getValueOf('popupMaxPreviewCharacters') + this.extraCharacters;
 3980+ var n=this.maxSentences;
 3981+ var dd=this.firstSentences(d,n);
 3982+
 3983+ do {
 3984+ dd=this.firstSentences(d,n); --n;
 3985+ } while ( dd.length > this.maxCharacters && n != 0 );
 3986+
 3987+ this.data = dd;
 3988+};
 3989+/**
 3990+ @private
 3991+*/
 3992+Previewmaker.prototype.fixSentenceEnds = function(strs, reg) {
 3993+ // take an array of strings, strs
 3994+ // join strs[i] to strs[i+1] & strs[i+2] if strs[i] matches regex reg
 3995+
 3996+ var abbrevRe=/\b[a-z][^a-z]*$/i;
 3997+
 3998+ for (var i=0; i<strs.length-2; ++i) {
 3999+ if (reg.test(strs[i])) {
 4000+ a=[];
 4001+ for (var j=0; j<strs.length; ++j) {
 4002+ if (j<i) a[j]=strs[j];
 4003+ if (j==i) a[i]=strs[i]+strs[i+1]+strs[i+2];
 4004+ if (j>i+2) a[j-2]=strs[j];
 4005+ }
 4006+ return this.fixSentenceEnds(a,reg);
 4007+ }
 4008+ // BUGGY STUFF - trying to fix up [[S. C. Johnson & Son]] preview
 4009+ if (false && abbrevRe.test(strs[i])) {
 4010+ var j=i, buf='';
 4011+ do {
 4012+ buf=buf+strs[i]+strs[i+1];
 4013+ i=i+2;
 4014+ } while (i<strs.length-2 && abbrevRe.test(strs[i]));
 4015+ strs[i]=buf+strs[i];
 4016+ var a=(j?strs.slice(0,j-1):[]).concat(strs.slice(i));
 4017+ return this.fixSentenceEnds(a,reg);
 4018+ }
 4019+ }
 4020+ return strs;
 4021+};
 4022+/**
 4023+ @private
 4024+*/
 4025+Previewmaker.prototype.firstSentences = function(strs, howmany) {
 4026+ var t=strs.slice(0, 2*howmany);
 4027+ return t.join('');
 4028+};
 4029+/**
 4030+ @private
 4031+*/
 4032+Previewmaker.prototype.killBadWhitespace = function() {
 4033+ // also cleans up isolated '''', eg [[Suntory Sungoliath]]
 4034+ this.data=this.data.replace(RegExp('^ *\'+ *$', 'gm'), '');
 4035+};
 4036+/**
 4037+ Runs the various methods to generate the preview.
 4038+ The preview is stored in the <code>html</html> field.
 4039+ @private
 4040+*/
 4041+Previewmaker.prototype.makePreview = function() {
 4042+ if (this.owner.article.namespace()!=pg.ns.template &&
 4043+ this.owner.article.namespace()!=pg.ns.image ) {
 4044+ this.killComments();
 4045+ this.killDivs();
 4046+ this.killGalleries();
 4047+ this.killBoxTemplates();
 4048+
 4049+ if (getValueOf('popupPreviewKillTemplates')) {
 4050+ this.killTemplates();
 4051+ } else {
 4052+ this.killMultilineTemplates();
 4053+ }
 4054+ this.killTables();
 4055+ this.killImages();
 4056+ this.killHTML();
 4057+ this.killChunks();
 4058+ this.mopup();
 4059+
 4060+ this.firstBit();
 4061+ this.killBadWhitespace();
 4062+ }
 4063+ else
 4064+ {
 4065+ this.killHTML();
 4066+ }
 4067+ this.html=wiki2html(this.data, this.baseUrl); // needs livepreview
 4068+ this.fixHTML();
 4069+ this.stripLongTemplates();
 4070+};
 4071+/**
 4072+ @private
 4073+*/
 4074+Previewmaker.prototype.esWiki2HtmlPart = function(data) {
 4075+ var reLinks = /(?:\[\[([^|\]]*)(?:\|([^|\]]*))*]]([a-z]*))/gi; //match a wikilink
 4076+ reLinks.lastIndex = 0; //reset regex
 4077+
 4078+ var match;
 4079+ var result = "";
 4080+ var postfixIndex = 0;
 4081+ while ((match = reLinks.exec(data)) != null) //match all wikilinks
 4082+ {
 4083+ //FIXME: the way that link is built here isn't perfect. It is clickable, but popups preview won't recognize it in some cases.
 4084+ result += escapeQuotesHTML(data.substring(postfixIndex, match.index)) +
 4085+ "<a href='"+Insta.conf.paths.articles+match[1]+"'>"+escapeQuotesHTML((match[2]?match[2]:match[1])+match[3])+"</a>";
 4086+ postfixIndex = reLinks.lastIndex;
 4087+ }
 4088+ //append the rest
 4089+ result += escapeQuotesHTML(data.substring(postfixIndex));
 4090+
 4091+ return result;
 4092+};
 4093+Previewmaker.prototype.editSummaryPreview=function() {
 4094+ var reAes = /\/\* *(.*?) *\*\//g; //match the first section marker
 4095+ reAes.lastIndex = 0; //reset regex
 4096+
 4097+ var match;
 4098+
 4099+ match = reAes.exec(this.data);
 4100+ if (match)
 4101+ {
 4102+ //we have a section link. Split it, process it, combine it.
 4103+ var prefix = this.data.substring(0,match.index-1);
 4104+ var section = match[1];
 4105+ var postfix = this.data.substring(reAes.lastIndex);
 4106+
 4107+ var start = "<span class='autocomment'>";
 4108+ var end = "</span>";
 4109+ if (prefix.length>0) start = this.esWiki2HtmlPart(prefix) + " " + start + "- ";
 4110+ if (postfix.length>0) end = ": " + end + this.esWiki2HtmlPart(postfix);
 4111+
 4112+
 4113+ var t=new Title().fromURL(this.baseUrl);
 4114+ t.anchorFromUtf(section);
 4115+ var sectionLink = Insta.conf.paths.articles + t.toString(true).split("'").join('%27') + '#' + t.anchor.split("'").join('%27');
 4116+ return start + "<a href='"+sectionLink+"'>&rarr;</a> "+escapeQuotesHTML(section) + end;
 4117+ }
 4118+
 4119+ //else there's no section link, htmlify the whole thing.
 4120+ return this.esWiki2HtmlPart(this.data);
 4121+};
 4122+
 4123+//<NOLITE>
 4124+/** Test function for debugging preview problems one step at a time.
 4125+ */
 4126+function previewSteps(txt) {
 4127+ try {
 4128+ txt=txt || document.editform.wpTextbox1.value;
 4129+ } catch (err) {
 4130+ if (pg.cache.pages.length > 0) {
 4131+ txt=pg.cache.pages[pg.cache.pages.length-1].data;
 4132+ } else {
 4133+ alert('provide text or use an edit page');
 4134+ }
 4135+ }
 4136+ txt=txt.substring(0,10000);
 4137+ var base=pg.wiki.articlebase + Title.fromURL(document.location.href).urlString();
 4138+ var p=new Previewmaker(txt, base, pg.current.link.navpopup);
 4139+ if (this.owner.article.namespace() != pg.ns.template) {
 4140+ p.killComments(); if (!confirm('done killComments(). Continue?\n---\n' + p.data)) { return; }
 4141+ p.killDivs(); if (!confirm('done killDivs(). Continue?\n---\n' + p.data)) { return; }
 4142+ p.killGalleries(); if (!confirm('done killGalleries(). Continue?\n---\n' + p.data)) { return; }
 4143+ p.killBoxTemplates(); if (!confirm('done killBoxTemplates(). Continue?\n---\n' + p.data)) { return; }
 4144+
 4145+ if (getValueOf('popupPreviewKillTemplates')) {
 4146+ p.killTemplates(); if (!confirm('done killTemplates(). Continue?\n---\n' + p.data)) { return; }
 4147+ } else {
 4148+ p.killMultilineTemplates(); if (!confirm('done killMultilineTemplates(). Continue?\n---\n' + p.data)) { return; }
 4149+ }
 4150+
 4151+ p.killTables(); if (!confirm('done killTables(). Continue?\n---\n' + p.data)) { return; }
 4152+ p.killImages(); if (!confirm('done killImages(). Continue?\n---\n' + p.data)) { return; }
 4153+ p.killHTML(); if (!confirm('done killHTML(). Continue?\n---\n' + p.data)) { return; }
 4154+ p.killChunks(); if (!confirm('done killChunks(). Continue?\n---\n' + p.data)) { return; }
 4155+ p.mopup(); if (!confirm('done mopup(). Continue?\n---\n' + p.data)) { return; }
 4156+
 4157+ p.firstBit(); if (!confirm('done firstBit(). Continue?\n---\n' + p.data)) { return; }
 4158+ p.killBadWhitespace(); if (!confirm('done killBadWhitespace(). Continue?\n---\n' + p.data)) { return; }
 4159+ }
 4160+
 4161+ p.html=wiki2html(p.data, base); // needs livepreview
 4162+ p.fixHTML(); if (!confirm('done fixHTML(). Continue?\n---\n' + p.html)) { return; }
 4163+ p.stripLongTemplates(); if (!confirm('done stripLongTemplates(). Continue?\n---\n' + p.html)) { return; }
 4164+ alert('finished preview - end result follows.\n---\n' + p.html);
 4165+}
 4166+//</NOLITE>
 4167+
 4168+/**
 4169+ Works around a quoting bug in livepreview.
 4170+ <code>wiki2html('[[Foo\'s "bar"]]')</code> gives @literal{<a href='Foo's "bar"'>}
 4171+ which doesn't do very well. We change this into @literal{<a href="Foo's %22bar%22">}
 4172+ @private
 4173+*/
 4174+Previewmaker.prototype.fixHTML = function() {
 4175+ if(!this.html) return;
 4176+ // all links seem to have potential issues with quotation marks
 4177+ var splitted=this.html.parenSplit(/href='([^>]*)'/g);
 4178+ var ret='';
 4179+ for (var i=0; i<splitted.length; ++i) {
 4180+ if(i%2==0) { ret += splitted[i]; continue; }
 4181+ if(i%2==1) { ret += 'href="' + splitted[i].split('"').join('%22') + '"'; }
 4182+ }
 4183+ // fix question marks in wiki links
 4184+ // maybe this'll break some stuff :-(
 4185+ ret=ret.replace(RegExp('\(<a href="https://www.mediawiki.org/' + pg.wiki.articlePath + '/[^"]*\)[?]\(.*?"\)', 'g'), '$1%3F$2');
 4186+ // FIXME fix up % too
 4187+ this.html=ret;
 4188+};
 4189+/**
 4190+ Generates the preview and displays it in the current popup.
 4191+
 4192+ Does nothing if the generated preview is invalid or consists of whitespace only.
 4193+ Also activates wikilinks in the preview for subpopups if the popupSubpopups option is true.
 4194+*/
 4195+Previewmaker.prototype.showPreview = function () {
 4196+ this.makePreview();
 4197+ if (typeof this.html != typeof '') return;
 4198+ if (RegExp('^\\s*$').test(this.html)) return;
 4199+ setPopupHTML('<hr>', 'popupPrePreviewSep', this.owner.idNumber);
 4200+ setPopupTipsAndHTML(this.html, 'popupPreview', this.owner.idNumber, { owner: this.owner });
 4201+ var more = (this.fullLength > this.data.length) ? this.moreLink() : '';
 4202+ setPopupHTML(more, 'popupPreviewMore', this.owner.idNumber);
 4203+};
 4204+/**
 4205+ @private
 4206+*/
 4207+Previewmaker.prototype.moreLink=function() {
 4208+ var a=document.createElement('a');
 4209+ a.className='popupMoreLink';
 4210+ a.innerHTML=popupString('more...');
 4211+ var savedThis=this;
 4212+ a.onclick=function() {
 4213+ savedThis.maxCharacters+=2000;
 4214+ savedThis.maxSentences+=20;
 4215+ savedThis.setData();
 4216+ savedThis.showPreview();
 4217+ }
 4218+ return a;
 4219+}
 4220+
 4221+/**
 4222+ @private
 4223+*/
 4224+Previewmaker.prototype.stripLongTemplates = function() {
 4225+ // operates on the HTML!
 4226+ this.html=this.html.replace(RegExp('^.{0,1000}[{][{][^}]*?(<(p|br)( /)?>\\s*){2,}([^{}]*?[}][}])?', 'gi'), '');
 4227+ this.html=this.html.split('\n').join(' '); // workaround for <pre> templates
 4228+ this.html=this.html.replace(RegExp('[{][{][^}]*<pre>[^}]*[}][}]','gi'), '');
 4229+};
 4230+/**
 4231+ @private
 4232+*/
 4233+Previewmaker.prototype.killMultilineTemplates = function() {
 4234+ this.kill('{{{', '}}}');
 4235+ this.kill(RegExp('\\s*[{][{][^{}]*\\n'), '}}', '{{');
 4236+};
 4237+// ENDFILE: previewmaker.js
 4238+// STARTFILE: querypreview.js
 4239+function loadAPIPreview(queryType, article, navpop) {
 4240+ var art=new Title(article).urlString();
 4241+ var url=pg.wiki.wikibase + '/api.php?format=json&action=query&';
 4242+ var htmlGenerator=function(a,d){alert('invalid html generator');};
 4243+ switch (queryType) {
 4244+ case 'history':
 4245+ url += 'meta=userinfo&uiprop=options&titles=' + art + '&prop=revisions&rvlimit=' +
 4246+ getValueOf('popupHistoryPreviewLimit');
 4247+ htmlGenerator=APIhistoryPreviewHTML;
 4248+ break;
 4249+ case 'category':
 4250+ url += 'list=categorymembers&cmtitle=' + art;
 4251+ htmlGenerator=APIcategoryPreviewHTML;
 4252+ break;
 4253+ case 'userinfo':
 4254+ var usernameart = encodeURIComponent( new Title( article ).userName() );
 4255+ url += 'list=users&usprop=blockinfo|groups|editcount|registration&ususers=' + usernameart;
 4256+ htmlGenerator=APIuserInfoPreviewHTML;
 4257+ break;
 4258+ case 'contribs':
 4259+ var usernameart = encodeURIComponent( new Title( article ).userName() );
 4260+ url += 'list=usercontribs&meta=userinfo&uiprop=options&ucuser=' + usernameart +
 4261+ '&uclimit=' + getValueOf('popupContribsPreviewLimit');
 4262+ htmlGenerator=APIcontribsPreviewHTML;
 4263+ break;
 4264+ case 'imagepagepreview':
 4265+ var trail='';
 4266+ if (getValueOf('popupImageLinks')) { trail = '&list=imageusage&iutitle=' + art; }
 4267+ url += 'titles=' + art + '&prop=revisions|imageinfo&rvprop=content' + trail;
 4268+ htmlGenerator=APIimagepagePreviewHTML;
 4269+ break;
 4270+ case 'backlinks':
 4271+ url += 'list=backlinks&bltitle=' + art;
 4272+ htmlGenerator=APIbacklinksPreviewHTML;
 4273+ break;
 4274+ }
 4275+ pendingNavpopTask(navpop);
 4276+ if( !window.wgEnableAPI || !wgEnableAPI ) {
 4277+ /* The API is not available */
 4278+ htmlGenerator=function(a,d){
 4279+ return 'This function of navigation popups now requires a MediaWiki ' +
 4280+ 'installation with the <a href="http://www.mediawiki.org/wiki/API">API</a> enabled.'; };
 4281+ }
 4282+ var callback=function(d){
 4283+ log( "callback of API functions was hit" );
 4284+ showAPIPreview(queryType, htmlGenerator(article,d,navpop), navpop.idNumber, navpop, d);
 4285+ };
 4286+ var go = function(){
 4287+ getPageWithCaching(url, callback, navpop);
 4288+ return true;
 4289+ }
 4290+ if (navpop.visible || !getValueOf('popupLazyDownloads')) { go(); }
 4291+ else { navpop.addHook(go, 'unhide', 'before', 'DOWNLOAD_'+queryType+'_QUERY_DATA'); }
 4292+}
 4293+
 4294+function linkList(list) {
 4295+ list.sort(function(x,y) { return (x==y ? 0 : (x<y ? -1 : 1)); });
 4296+ var buf=[];
 4297+ for (var i=0; i<list.length; ++i) {
 4298+ buf.push(wikiLink({article: new Title(list[i]),
 4299+ text: list[i].split(' ').join('&nbsp;'),
 4300+ action: 'view'}));
 4301+ }
 4302+ return buf.join(', ');
 4303+}
 4304+
 4305+function getTimeOffset(tz) {
 4306+ if( tz ) {
 4307+ if( tz.indexOf('|') > -1 ) {
 4308+ // New format
 4309+ return parseInt(tz.split('|')[1],10);
 4310+ } else if ( tz.indexOf(':') > -1 ) {
 4311+ // Old format
 4312+ return( parseInt(tz,10)*60 + parseInt(tz.split(':')[1],10) );
 4313+ }
 4314+ }
 4315+ return 0;
 4316+}
 4317+
 4318+function editPreviewTable(article, h, reallyContribs, timeOffset) {
 4319+ var html=['<table>'];
 4320+ var day=null;
 4321+ var curart=article;
 4322+ for (var i=0; i<h.length; ++i) {
 4323+ if (reallyContribs) {
 4324+ var page=h[i]['title']; curart = new Title(page);
 4325+ }
 4326+ var minor=typeof h[i]['minor']=='undefined' ? '' : '<b>m </b>';
 4327+ var editDate=adjustDate(getDateFromTimestamp(h[i].timestamp), timeOffset);
 4328+ var thisDay = dayFormat(editDate);
 4329+ var thisTime = timeFormat(editDate);
 4330+ if (thisDay==day) { thisDay=''; }
 4331+ else { day=thisDay; }
 4332+ if (thisDay) {
 4333+ html.push( '<tr><td colspan=3><span class="popup_history_date">' +
 4334+ thisDay+'</span></td></tr>' );
 4335+ }
 4336+ html.push('<tr class="popup_history_row_' + ( (i%2) ? 'odd' : 'even') + '">');
 4337+ html.push('<td>(<a href="' + pg.wiki.titlebase + new Title(curart).urlString() +
 4338+ '&diff=prev&oldid=' + h[i]['revid'] + '">' + popupString('last') + '</a>)</td>');
 4339+ html.push('<td>' +
 4340+ '<a href="' + pg.wiki.titlebase + new Title(curart).urlString() +
 4341+ '&oldid=' + h[i]['revid'] + '">' + thisTime + '</a></td>');
 4342+ var col3url='', col3txt='';
 4343+ if (!reallyContribs) {
 4344+ var user=h[i]['user'];
 4345+ col3url=pg.wiki.titlebase + pg.ns.user + ':' + new Title(user).urlString();
 4346+ col3txt=user;
 4347+ } else {
 4348+ col3url=pg.wiki.titlebase + curart.urlString();
 4349+ col3txt=escapeQuotesHTML(page);
 4350+ }
 4351+ html.push('<td>' + (reallyContribs ? minor : '') +
 4352+ '<a href="' + col3url + '">' + col3txt + '</a></td>');
 4353+ var comment='';
 4354+ var c=h[i].comment || h[i]['*'];
 4355+ if (c) {
 4356+ comment=new Previewmaker(c, new Title(curart).toUrl()).editSummaryPreview();
 4357+ }
 4358+ html.push('<td>' + (!reallyContribs ? minor : '') + comment + '</td>');
 4359+ html.push('</tr>');
 4360+ html=[html.join('')];
 4361+ }
 4362+ html.push('</table>');
 4363+ return html.join('');
 4364+}
 4365+
 4366+function getDateFromTimestamp(t) {
 4367+ var s=t.split(/[^0-9]/);
 4368+ switch(s.length) {
 4369+ case 0: return null;
 4370+ case 1: return new Date(s[0]);
 4371+ case 2: return new Date(s[0], s[1]-1);
 4372+ case 3: return new Date(s[0], s[1]-1, s[2]);
 4373+ case 4: return new Date(s[0], s[1]-1, s[2], s[3]);
 4374+ case 5: return new Date(s[0], s[1]-1, s[2], s[3], s[4]);
 4375+ case 6: return new Date(s[0], s[1]-1, s[2], s[3], s[4], s[5]);
 4376+ default: return new Date(s[0], s[1]-1, s[2], s[3], s[4], s[5], s[6]);
 4377+ }
 4378+}
 4379+
 4380+function adjustDate(d, offset) {
 4381+ // offset is in minutes
 4382+ var o=offset * 60 * 1000;
 4383+ return new Date( +d + o);
 4384+}
 4385+
 4386+function dayFormat(editDate, utc) {
 4387+ if (utc) { return map(zeroFill, [editDate.getUTCFullYear(), editDate.getUTCMonth()+1, editDate.getUTCDate()]).join('-'); }
 4388+ return map(zeroFill, [editDate.getFullYear(), editDate.getMonth()+1, editDate.getDate()]).join('-');
 4389+}
 4390+
 4391+function timeFormat(editDate, utc) {
 4392+ if (utc) { return map(zeroFill, [editDate.getUTCHours(), editDate.getUTCMinutes(), editDate.getUTCSeconds()]).join(':'); }
 4393+ return map(zeroFill, [editDate.getHours(), editDate.getMinutes(), editDate.getSeconds()]).join(':');
 4394+}
 4395+
 4396+function showAPIPreview(queryType, html, id, navpop, download) {
 4397+ // DJ: done
 4398+ var target='popupPreview';
 4399+ switch (queryType) {
 4400+ case 'imagelinks':
 4401+ case 'category':
 4402+ case 'userinfo':
 4403+ target='popupPostPreview'; break;
 4404+ }
 4405+ setPopupTipsAndHTML(html, target, id);
 4406+ completedNavpopTask(navpop);
 4407+}
 4408+
 4409+function APIbacklinksPreviewHTML(article, download, navpop) {
 4410+ try {
 4411+ var jsObj=getJsObj(download.data);
 4412+ var list=jsObj.query.backlinks;
 4413+ } catch (someError) { return 'backlinksPreviewHTML went wonky'; }
 4414+ var html=[];
 4415+ if (!list) { return popupString('No backlinks found'); }
 4416+ for ( i in list ) {
 4417+ var t=new Title(list[i]['title']);
 4418+ html.push('<a href="' + pg.wiki.titlebase + t.urlString() + '">' + t + '</a>');
 4419+ }
 4420+ html=html.join(', ');
 4421+ if (jsObj['query-continue'] && jsObj['query-continue'].backlinks && jsObj['query-continue'].backlinks.blcontinue) {
 4422+ html += popupString(' and more');
 4423+ }
 4424+ return html;
 4425+}
 4426+
 4427+function APIsharedImagePagePreviewHTML(obj) {
 4428+ log( "APIsharedImagePagePreviewHTML" );
 4429+ var popupid = obj['requestid'];
 4430+ if( obj['query'] && obj['query']['pages'] )
 4431+ {
 4432+ var page=anyChild(obj['query']['pages']);
 4433+ var content=(page && page.revisions ) ? page.revisions[0]['*'] : null;
 4434+ if( content )
 4435+ {
 4436+ /* Not entirely safe, but the best we can do */
 4437+ var p=new Previewmaker(content, pg.current.link.navpopup.article, pg.current.link.navpopup);
 4438+ p.makePreview();
 4439+ setPopupHTML( p.html, "popupSecondPreview", popupid );
 4440+ }
 4441+ }
 4442+}
 4443+
 4444+function APIimagepagePreviewHTML(article, download, navpop) {
 4445+ try {
 4446+ var jsObj=getJsObj(download.data);
 4447+ var page=anyChild(jsObj.query.pages);
 4448+ var content=(page && page.revisions ) ? page.revisions[0]['*'] : null;
 4449+ } catch (someError) {
 4450+ return 'API imagepage preview failed :(';
 4451+ }
 4452+ var ret='';
 4453+ if (content) {
 4454+ var p=prepPreviewmaker(content, article, navpop);
 4455+ p.makePreview();
 4456+ if (p.html) { ret += '<hr>' + p.html; }
 4457+ }
 4458+ if (content!==null && getValueOf('popupSummaryData')) {
 4459+ var info=getPageInfo(content, download);
 4460+ log(info);
 4461+ setPopupTrailer(info, navpop.idNumber);
 4462+ }
 4463+ if (page && page.imagerepository == "shared" ) {
 4464+ var art=new Title(article).urlString();
 4465+ var shared_url = pg.wiki.commonsbase + '/api.php?format=json&callback=APIsharedImagePagePreviewHTML' +
 4466+ '&requestid=' + navpop.idNumber +
 4467+ '&action=query&prop=revisions&rvprop=content&titles=' + art;
 4468+ ret = ret +'<hr>' + popupString( 'Image from Commons') +
 4469+ ': <a href="' + pg.wiki.commonsbase + '/index.php?title=' + art + '">' +
 4470+ popupString( 'Description page') + '</a>';
 4471+ importScriptURI( shared_url );
 4472+ }
 4473+ showAPIPreview('imagelinks', APIimagelinksPreviewHTML(article,download), navpop.idNumber, download);
 4474+ return ret;
 4475+}
 4476+
 4477+function APIimagelinksPreviewHTML(article, download) {
 4478+ try {
 4479+ var jsobj=getJsObj(download.data);
 4480+ var list=jsobj.query.imageusage;
 4481+ if (!list) { return popupString('No image links found'); }
 4482+ } catch(someError) { return 'Image links preview generation failed :('; }
 4483+ var ret=[];
 4484+ for (var i=0; i < list.length; i++) {
 4485+ ret.push(list[i]['title']);
 4486+ }
 4487+ if (ret.length === 0) { return popupString('No image links found'); }
 4488+ return '<h2>' + popupString('File links') + '</h2>' + linkList(ret);
 4489+}
 4490+
 4491+function APIcategoryPreviewHTML(article, download) {
 4492+ try{
 4493+ var jsobj=getJsObj(download.data);
 4494+ var list=jsobj.query.categorymembers;
 4495+ } catch(someError) { return 'Category preview failed :('; }
 4496+ var ret=[];
 4497+ for (var p=0; p < list.length; p++) {
 4498+ ret.push(list[p]['title']);
 4499+ }
 4500+ if (ret.length === 0) { return popupString('Empty category'); }
 4501+ ret = '<h2>' + tprintf('Category members (%s shown)', [ret.length]) + '</h2>' +linkList(ret);
 4502+ if (jsobj['query-continue'] && jsobj['query-continue'].categorymembers && jsobj['query-continue'].categorymembers.cmcontinue) {
 4503+ ret += popupString(' and more');
 4504+ }
 4505+ return ret;
 4506+}
 4507+
 4508+function APIuserInfoPreviewHTML(article, download) {
 4509+ try{
 4510+ var jsobj=getJsObj(download.data);
 4511+ var user=anyChild(jsobj.query.users);
 4512+ } catch(someError) { return 'Userinfo preview failed :('; }
 4513+ if (!user || user.invalid == '') {
 4514+ return '<hr>' + popupString( 'Invalid or IP user');
 4515+ } else if (user.missing == '') {
 4516+ return '<hr>' + popupString( 'Not a registered username');
 4517+ }
 4518+ var ret=[];
 4519+ if( user.blockedby )
 4520+ ret.push('<b>' + popupString('BLOCKED') + '</b>');
 4521+ for( var i=0; (user.groups && i < user.groups.length); i++)
 4522+ {
 4523+ ret.push( user.groups[i] );
 4524+ }
 4525+ if( user.editcount && user.registration )
 4526+ ret.push( user.editcount + popupString(' edits since: ') + dayFormat(getDateFromTimestamp(user.registration)) );
 4527+ ret = '<hr>' + ret.join( ', ' );
 4528+ return ret;
 4529+}
 4530+
 4531+function APIcontribsPreviewHTML(article, download, navpop) {
 4532+ return APIhistoryPreviewHTML(article, download, navpop, true);
 4533+}
 4534+
 4535+function APIhistoryPreviewHTML(article, download, navpop, reallyContribs) {
 4536+ try {
 4537+ var jsobj=getJsObj(download.data);
 4538+ var tz=jsobj.query.userinfo.options.timecorrection;
 4539+ if( reallyContribs )
 4540+ var edits=jsobj.query.usercontribs;
 4541+ else
 4542+ var edits=anyChild(jsobj.query.pages)['revisions'];
 4543+ } catch (someError) {
 4544+ return 'History preview failed :-(';
 4545+ }
 4546+ var timeOffset = getTimeOffset(tz);
 4547+ Cookie.create('popTz', timeOffset, 1);
 4548+
 4549+ var ret=editPreviewTable(article, edits, reallyContribs, timeOffset);
 4550+ return ret;
 4551+}
 4552+
 4553+
 4554+//</NOLITE>
 4555+// ENDFILE: querypreview.js
 4556+// STARTFILE: debug.js
 4557+////////////////////////////////////////////////////////////////////
 4558+// Debugging functions
 4559+////////////////////////////////////////////////////////////////////
 4560+
 4561+function log(){}; // dummy to stop errors
 4562+function setupDebugging() {
 4563+//<NOLITE>
 4564+ if (window.popupDebug) { // popupDebug is set from .version
 4565+ window.log=function(x) { //if(gMsg!='')gMsg += '\n'; gMsg+=time() + ' ' + x; };
 4566+ window.console.log(x);
 4567+ }
 4568+ window.errlog=function(x) {
 4569+ window.console.error(x);
 4570+ }
 4571+ log('Initializing logger');
 4572+ } else {
 4573+//</NOLITE>
 4574+ window.log = function(x) {};
 4575+ window.errlog = function(x) {};
 4576+//<NOLITE>
 4577+ }
 4578+//</NOLITE>
 4579+}
 4580+// ENDFILE: debug.js
 4581+// STARTFILE: images.js
 4582+//<NOLITE>
 4583+// FIXME rewrite ALL of this
 4584+// How the URLs for images in the popup come about
 4585+
 4586+// loadPreview
 4587+// |
 4588+// getWiki
 4589+// |<----------------see other schematic for details
 4590+// insertPreview (insertPreview = onComplete)
 4591+// |
 4592+// | insertPreview gets a wikiText fragment from
 4593+// | the wikiText downloaded by getWiki
 4594+// |
 4595+// [wikiMarkupToAddressFragment]
 4596+// |
 4597+// | mouseOverWikiLink (gets an "address fragment",
 4598+// | | no processing needed)
 4599+// \->-*loadThisImage---<----loadImages
 4600+// |
 4601+// [image(Thumb)URL]-->--hopefully valid image urls
 4602+
 4603+// FIXME get rid of pg.idNumber
 4604+
 4605+function sequentialLoadThisImage (image) {
 4606+ if (!getValueOf('popupImages')) { return false; }
 4607+ if (!isValidImageName(image)) { return false; }
 4608+
 4609+ var imageUrls=getImageUrls(image);
 4610+ if (!imageUrls) { return null; }
 4611+
 4612+ var img=new Image();
 4613+ img.isNew=true;
 4614+ img.pg.idNumber=pg.idNumber;
 4615+ img.counter=1;
 4616+
 4617+ img.onload = function () {
 4618+ // clear status thingy
 4619+ setImageStatus('');
 4620+
 4621+ var i=findThis(imageUrls, this.src);
 4622+ var goodSrc=this.src;
 4623+
 4624+ var setPopupImage=function () {
 4625+ var popupImage=document.getElementById("popupImage"+this.pg.idNumber);
 4626+ if (popupImage && typeof popupImage.src != 'undefined') {
 4627+ clearInterval(pg.timer.image);
 4628+ popupImage.src=goodSrc;
 4629+ popupImage.width=getValueOf('popupImageSize');
 4630+ popupImage.style.display='inline';
 4631+ setPopupImageLink(image, pg.wiki.imageSources[i].wiki);
 4632+ return true;
 4633+ } else { return false; }
 4634+ };
 4635+ pg.timer.image=setInterval(setPopupImage, 250);
 4636+ pg.cache.images.push(goodSrc);
 4637+ };
 4638+
 4639+ img.onerror = function () {
 4640+ pg.cache.badImageUrls.push(this.src);
 4641+ };
 4642+
 4643+ img.setNext = function () {
 4644+ var currentSrc=null;
 4645+ var newSrc;
 4646+ if (!this.isNew) { currentSrc=this.src; }
 4647+ this.isNew=false;
 4648+
 4649+ newSrc= (currentSrc) ? nextOne(imageUrls, currentSrc) : imageUrls[0];
 4650+
 4651+ while (findThis(pg.cache.badImageUrls, newSrc)) {
 4652+ newSrc=nextOne(imageUrls, newSrc);
 4653+ if (!newSrc) {
 4654+ setImageStatus (' :-(');
 4655+ return;
 4656+ }
 4657+ }
 4658+ setImageStatus(' '+findThis(imageUrls, newSrc));
 4659+ this.src=newSrc;
 4660+ };
 4661+
 4662+ // start the ball rolling
 4663+ img.setNext();
 4664+
 4665+}
 4666+
 4667+function loadThisImageAtThisUrl(image, url) {
 4668+ log('loading "best" image:\n'+url);
 4669+ pg.misc.gImage=new Title(image.toString());
 4670+ pg.misc.imageArray = [];
 4671+ pg.misc.imageArray[0] = new Image();
 4672+ pg.misc.imageArray[0].src=url;
 4673+ if (pg.timer.image || pg.timer.image===0) {
 4674+ clearInterval(pg.timer.image);
 4675+ pg.counter.checkImages=0;
 4676+ }
 4677+ pg.timer.image=setInterval(checkImages, 250);
 4678+ return;
 4679+}
 4680+
 4681+// methinks this is unbelievably silly
 4682+// it dovetails with the parallel image loader function
 4683+function checkImages() {
 4684+ //log('checkImages: pg.counter.loop='+pg.counter.loop+'; pg.counter.checkImages='+pg.counter.checkImages);
 4685+ if (pg.timer.checkImages || pg.timer.checkImages===0) {
 4686+ clearInterval(pg.timer.checkImages);
 4687+ pg.timer.checkImages=null;
 4688+ if (pg.counter.loop > 10) {pg.counter.loop=0; log('too many iterations of checkImages'); return;}
 4689+ pg.counter.loop++;
 4690+ } else pg.counter.checkImages++;
 4691+
 4692+ var status = ( pg.counter.checkImages % 2 ) ? ':' : '.' ;
 4693+ setImageStatus(status);
 4694+
 4695+ if (pg.counter.checkImages > 100) {
 4696+ pg.counter.checkImages = 0;
 4697+ log ('pg.counter.checkImages too big in checkImages; returning');
 4698+ clearInterval(pg.timer.image);
 4699+ }
 4700+
 4701+ var popupImage=null;
 4702+ popupImage=document.getElementById("popupImg"+pg.idNumber);
 4703+ if (popupImage == null) {
 4704+ // this doesn't seem to happen any more in practise for some reason
 4705+ // still, I'll leave it in
 4706+ log('checkImages: document.getElementById("popupImg'+pg.idNumber+'") is null! retrying in 333ms...');
 4707+ pg.timer.checkImages=setInterval("checkImages()",333);
 4708+ return;
 4709+ }
 4710+
 4711+ log('checkImages: found element popupImg'+pg.idNumber+', and src='+popupImage.src);
 4712+
 4713+ // get the first image to successfully load
 4714+ // and put it in the popupImage
 4715+ for(var i = 0; i < pg.misc.imageArray.length; ++i) {
 4716+ if(isImageOk(pg.misc.imageArray[i])) {
 4717+ // stop all the gubbins, assign the image and return
 4718+
 4719+ log('checkImages: got at pos '+i+', src='+pg.misc.imageArray[i].src);
 4720+ clearInterval(pg.timer.image);
 4721+
 4722+ if(pg.misc.gImage && pg.misc.gImage.namespace() == pg.ns.image) {
 4723+ popupImage.src=pg.misc.imageArray[i].src;
 4724+ popupImage.width=getValueOf('popupImageSize');
 4725+ popupImage.style.display='inline';
 4726+ // should we check to see if it's already there? maybe...
 4727+ pg.cache.images.push(pg.misc.imageArray[i].src);
 4728+
 4729+ setPopupImageLink(pg.misc.gImage, pg.wiki.imageSources[i].wiki);
 4730+ stopImagesDownloading();
 4731+ }
 4732+
 4733+ setImageStatus('');
 4734+
 4735+ // reset evil nonconstant globals
 4736+ delete pg.misc.imageArray; pg.misc.imageArray=[];
 4737+ pg.timer.image=null;
 4738+
 4739+ pg.counter.checkImages=0;
 4740+ pg.counter.loop=0;
 4741+
 4742+ return popupImage.src;
 4743+ }
 4744+ }
 4745+ log('checkImages: no good image found. retrying in a tic...');
 4746+ pg.timer.checkImages=setInterval("checkImages()",333);
 4747+}
 4748+
 4749+function stopImagesDownloading() {
 4750+ pg.misc.gImage=null;
 4751+ if (pg.misc.imageArray == null) { return null; }
 4752+ for (var i=0; i<pg.misc.imageArray.length; ++i) {
 4753+ //pg.misc.imageArray[i].src=''; // this is a REALLY BAD IDEA
 4754+ delete pg.misc.imageArray[i];
 4755+ //pg.misc.imageArray[i] = new Image();
 4756+ }
 4757+ pg.misc.imageArray = [];
 4758+}
 4759+
 4760+function toggleSize() {
 4761+ var imgContainer=this;
 4762+ if (!imgContainer) { alert('imgContainer is null :/'); return;}
 4763+ img=imgContainer.firstChild;
 4764+ if (!img) { alert('img is null :/'); return;}
 4765+ if (!img.style.width || img.style.width=='') { img.style.width='100%'; }
 4766+ else { img.style.width=''; }
 4767+}
 4768+
 4769+function setPopupImageLink (img, wiki) {
 4770+ if( wiki === null || img === null ) { return null; }
 4771+
 4772+ var a=document.getElementById("popupImageLink"+pg.idNumber);
 4773+ if (a === null) { return null; }
 4774+
 4775+ switch (getValueOf('popupThumbAction')) {
 4776+ case 'imagepage':
 4777+ if (pg.current.article.namespace()!=pg.ns.image) {
 4778+ a.href=pg.wiki.titlebase + img.urlString();
 4779+ // FIXME: unreliable pg.idNumber
 4780+ popTipsSoonFn('popupImage' + pg.idNumber)();
 4781+ break;
 4782+ } // else fall through
 4783+ case 'sizetoggle':
 4784+ a.onclick=toggleSize;
 4785+ a.title=popupString('Toggle image size');
 4786+ return;
 4787+ case 'linkfull':
 4788+ var linkURL = imageURL(img, wiki);
 4789+ if (linkURL) {
 4790+ a.href = linkURL;
 4791+ a.title=popupString('Open full-size image');
 4792+ }
 4793+ return;
 4794+ }
 4795+}
 4796+
 4797+function isImageOk(img) {
 4798+ // IE test
 4799+ if (!img.complete) { return false; }
 4800+
 4801+ // gecko test
 4802+ if (typeof img.naturalWidth != "undefined" && img.naturalWidth == 0) { return false; }
 4803+
 4804+ // test for konqueror and opera
 4805+
 4806+ // note that img.width must not be defined in the html with a width="..."
 4807+ // for this to work.
 4808+
 4809+ // konq seems to give "broken images" width 16, presumably an icon width
 4810+ // this test would probably work in gecko too, *except for very small images*
 4811+ if (typeof img.width == 'undefined' || img.width <= 16) { return false; }
 4812+
 4813+ // No other way of checking: assume it's ok.
 4814+ return true;
 4815+}
 4816+
 4817+// those odd a/a5/ bits of image urls
 4818+function imagePathComponent(article) { // article is string, no namespace
 4819+ // FIXME needs testing with odd characters
 4820+ var forhash=article.split(' ').join('_');
 4821+ var hash=hex_md5(forhash);
 4822+ return hash.substring(0,1) + '/' + hash.substring(0,2) + '/';
 4823+}
 4824+
 4825+function getImageUrlStart(wiki) { // this returns a trailing slash
 4826+ switch (wiki) {
 4827+ case 'en.wikipedia.org': return 'http://upload.wikimedia.org/wikipedia/en/';
 4828+ case pg.wiki.commons: return 'http://upload.wikimedia.org/wikipedia/commons/';
 4829+ case 'en.wiktionary.org': return 'http://en.wiktionary.org/upload/en/';
 4830+ case 'secure.wikimedia.org':
 4831+ return joinPath(['http://upload.wikimedia.org', pg.wiki.prePath]) + '/'; break;
 4832+ default: // unsupported - take a guess
 4833+ if (pg.wiki.wikimedia) {
 4834+ return 'http://upload.wikimedia.org/wikipedia/' + pg.wiki.lang +'/';
 4835+ }
 4836+ /* this should work for wikicities */
 4837+ return 'http://' + wiki + '/images/';
 4838+ }
 4839+}
 4840+
 4841+function imageURL(img, wiki) {
 4842+ if (getValueOf('popupImagesFromThisWikiOnly') && wiki != pg.wiki.hostname) return null;
 4843+ var imgurl=null;
 4844+ var pathcpt = imagePathComponent(img.stripNamespace());
 4845+ imgurl=getImageUrlStart(wiki) + pathcpt + img.stripNamespace().split(' ').join('_');
 4846+ return imgurl;
 4847+}
 4848+
 4849+function imageThumbURL(img, wiki, width) {
 4850+ //
 4851+ // eg http://upload.wikimedia.org/wikipedia/en/thumb/6/61/
 4852+ // Rubiks_cube_solved.jpg/120px-Rubiks_cube_solved.jpg
 4853+ // ^^^^^^^^^^^^^^^^^^^^^^^
 4854+ // wikicities omits this bit
 4855+ // AND wikicities needs a new pathcpt for each filename including thumbs
 4856+
 4857+ if (getValueOf('popupImagesFromThisWikiOnly') && wiki != pg.wiki.hostname) return null;
 4858+ if (getValueOf('popupNeverGetThumbs')) return null;
 4859+
 4860+ var imgurl=null;
 4861+ var stripped=img.stripNamespace();
 4862+ var pathcpt;
 4863+ if (pg.wiki.wikimedia) pathcpt = imagePathComponent(stripped);
 4864+ else pathcpt = imagePathComponent(width+'px-'+stripped);
 4865+ imgurl=getImageUrlStart(wiki) + "thumb/" + pathcpt;
 4866+ if (pg.wiki.wikimedia) imgurl += stripped + '/';
 4867+ imgurl += width +"px-" + stripped;
 4868+ return imgurl;
 4869+}
 4870+
 4871+function loadImages(image) {
 4872+ if (typeof image.stripNamespace != 'function') { alert('loadImages bad'); }
 4873+ if (getValueOf('popupLoadImagesSequentially')) { return sequentialLoadThisImage(image); }
 4874+ return parallelLoadThisImage(image);
 4875+}
 4876+
 4877+function getImageUrls(image) {
 4878+ if (typeof image.stripNamespace != 'function') { alert('getImageUrls bad'); }
 4879+ var imageUrls=[];
 4880+ for (var i=0; i<pg.wiki.imageSources.length; ++i) {
 4881+ var url;
 4882+ if (pg.wiki.imageSources[i].thumb) {
 4883+ url=imageThumbURL(image, pg.wiki.imageSources[i].wiki, pg.wiki.imageSources[i].width);
 4884+ } else { url=imageURL(image, pg.wiki.imageSources[i].wiki); }
 4885+ for (var j=0; j<pg.cache.images.length; ++j) {
 4886+ if (url == pg.cache.images[j]) {
 4887+ loadThisImageAtThisUrl(image, url);
 4888+ return null;
 4889+ }
 4890+ }
 4891+ if (url!=null) imageUrls.push(url);
 4892+ }
 4893+ return imageUrls;
 4894+}
 4895+
 4896+
 4897+// this is probably very wasteful indeed of bandwidth
 4898+// hey ho
 4899+
 4900+function parallelLoadThisImage (image) {
 4901+ if (typeof image.stripNamespace != 'function') { alert('parallelLoadThisImage bad'); }
 4902+ if (!getValueOf('popupImages')) return;
 4903+ if (!isValidImageName(image)) return false;
 4904+
 4905+ var imageUrls=getImageUrls(image);
 4906+ if (!imageUrls) return null;
 4907+
 4908+ for (var i=0; i<imageUrls.length; ++i) {
 4909+ var url = imageUrls[i];
 4910+ pg.misc.imageArray[i]=new Image();
 4911+ pg.misc.imageArray[i].src=url;
 4912+ }
 4913+ if (pg.timer.image != null) {
 4914+ clearInterval(pg.timer.image);
 4915+ pg.counter.checkImages=0;
 4916+ }
 4917+ pg.misc.gImage=new Title(image.toString());
 4918+ pg.timer.image=setInterval("checkImages()", 250);
 4919+ return true;
 4920+}
 4921+
 4922+function getValidImageFromWikiText(wikiText) {
 4923+ var imagePage=null;
 4924+ // nb in pg.re.image we're interested in the second bracketed expression
 4925+ // this may change if the regex changes :-(
 4926+ //var match=pg.re.image.exec(wikiText);
 4927+ var matched=null;
 4928+ var match;
 4929+ // strip html comments, used by evil bots :-(
 4930+ var t = removeMatchesUnless(wikiText, RegExp('(<!--[\\s\\S]*?-->)'), 1,
 4931+ RegExp('^<!--[^[]*popup', 'i'));
 4932+
 4933+ while ( match = pg.re.image.exec(t) ) {
 4934+ // now find a sane image name - exclude templates by seeking {
 4935+ var m = match[2] || match[6];
 4936+ var pxWidth=match[4];
 4937+ if ( isValidImageName(m) &&
 4938+ (!pxWidth || parseInt(pxWidth,10) >= getValueOf('popupMinImageWidth')) ) {
 4939+ matched=m;
 4940+ break;
 4941+ }
 4942+ }
 4943+ pg.re.image.lastIndex=0;
 4944+ if (!matched) { return null; }
 4945+ return pg.ns.image+':'+upcaseFirst(matched);
 4946+}
 4947+
 4948+function removeMatchesUnless(str, re1, parencount, re2) {
 4949+ var split=str.parenSplit(re1);
 4950+ var c=parencount + 1;
 4951+ for (var i=0; i<split.length; ++i) {
 4952+ if ( i%c === 0 || re2.test(split[i]) ) { continue; }
 4953+ split[i]='';
 4954+ }
 4955+ return split.join('');
 4956+}
 4957+
 4958+//</NOLITE>
 4959+// ENDFILE: images.js
 4960+// STARTFILE: namespaces.js
 4961+// Set up namespaces and other non-strings.js localization
 4962+// (currently that means redirs too)
 4963+
 4964+// Put the right namespace list into pg.ns.list, based on pg.wiki.lang
 4965+// Default to english if nothing seems to fit
 4966+function setNamespaceList() {
 4967+ var m="Media";
 4968+ var list = [m, "Special", "Talk", "User", "User talk", "Wikipedia", "Wikipedia talk", "File", "File talk", "MediaWiki", "MediaWiki talk", "Template", "Template talk", "Help", "Help talk", "Category", "Category talk", "Portal", "Portal talk"];
 4969+ var nsIndex = { '': 0, 'Special': 1,
 4970+ 'Talk': 2, 'User': 3, 'User talk': 4, 'Wikipedia': 5,
 4971+ 'Wikipedia talk': 6, 'Image': 7, 'File': 7, 'Image talk': 8, 'File talk' : 8, 'MediaWiki': 9,
 4972+ 'MediaWiki talk': 10, 'Template': 11, 'Template talk': 12,
 4973+ 'Help': 13, 'Help talk': 14, 'Category': 15, 'Category talk':16,
 4974+ 'Portal': 17, 'Portal talk': 18};
 4975+ var nsLists = {
 4976+//<NOLITE>
 4977+ "af": [m, "Spesiaal", "Bespreking", "Gebruiker", "Gebruikerbespreking", "Wikipedia", "Wikipediabespreking", "Beeld", "Beeldbespreking", "MediaWiki", "MediaWikibespreking", "Sjabloon", "Sjabloonbespreking", "Hulp", "Hulpbespreking", "Kategorie", "Kategoriebespreking"],
 4978+ "als": [m, "Spezial", "Diskussion", "Benutzer", "Benutzer Diskussion", "Wikipedia", "Wikipedia Diskussion", "Bild", "Bild Diskussion", "MediaWiki", "MediaWiki Diskussion", "Vorlage", "Vorlage Diskussion", "Hilfe", "Hilfe Diskussion", "Kategorie", "Kategorie Diskussion"],
 4979+ "ar": ["ملف", "خاص", "نقاش", "مستخدم", "نقاش المستخدم", "ويكيبيديا", "نقاش ويكيبيديا", "صورة", "نقاش الصورة", "ميدياويكي", "نقاش ميدياويكي", "Template", "نقاش Template", "مساعدة", "نقاش المساعدة", "تصنيف", "نقاش التصنيف"],
 4980+ "ast": [m, "Especial", "Discusión", "Usuariu", "Usuariu discusión", "Uiquipedia", "Uiquipedia discusión", "Imaxen", "Imaxen discusión", "MediaWiki", "MediaWiki discusión", "Plantilla", "Plantilla discusión", "Ayuda", "Ayuda discusión", "Categoría", "Categoría discusión"],
 4981+ "be": ["Мэдыя", "Спэцыяльныя", "Абмеркаваньне", "Удзельнік", "Гутаркі ўдзельніка", "Вікіпэдыя", "Абмеркаваньне Вікіпэдыя", "Выява", "Абмеркаваньне выявы", "MediaWiki", "Абмеркаваньне MediaWiki", "Шаблён", "Абмеркаваньне шаблёну", "Дапамога", "Абмеркаваньне дапамогі", "Катэгорыя", "Абмеркаваньне катэгорыі"],
 4982+ "bg": ["Медия", "Специални", "Беседа", "Потребител", "Потребител беседа", "Уикипедия", "Уикипедия беседа", "Картинка", "Картинка беседа", "МедияУики", "МедияУики беседа", "Шаблон", "Шаблон беседа", "Помощ", "Помощ беседа", "Категория", "Категория беседа"],
 4983+ "bm": [m, "Special", "Discuter", "Utilisateur", "Discussion Utilisateur", "Wikipedia", "Discussion Wikipedia", "Image", "Discussion Image", "MediaWiki", "Discussion MediaWiki", "Modèle", "Discussion Modèle", "Aide", "Discussion Aide", "Catégorie", "Discussion Catégorie"],
 4984+ "bn": ["বিশেষ", "আলাপ", "ব্যবহারকারী", "ব্যবহারকারী আলাপ", "উইকিপেডিয়া", "উইকিপেডিয়া আলাপ", "চিত্র", "চিত্র আলাপ", "MediaWik i আলাপ", m, "MediaWiki", "Template", "Template talk", "Help", "Help talk", "Category", "Category talk"],
 4985+ "br": [m, "Dibar", "Kaozeal", "Implijer", "Kaozeadenn Implijer", "Wikipedia", "Kaozeadenn Wikipedia", "Skeudenn", "Kaozeadenn Skeudenn", "MediaWiki", "Kaozeadenn MediaWiki", "Patrom", "Kaozeadenn Patrom", "Skoazell", "Kaozeadenn Skoazell", "Rummad", "Kaozeadenn Rummad"],
 4986+ "ca": [m, "Especial", "Discussió", "Usuari", "Usuari Discussió", "Viquipèdia", "Viquipèdia Discussió", "Imatge", "Imatge Discussió", "MediaWiki", "MediaWiki Discussió", "Template", "Template Discussió", "Ajuda", "Ajuda Discussió", "Categoria", "Categoria Discussió"],
 4987+ "cs": ["Média", "Speciální", "Diskuse", "Wikipedista", "Wikipedista diskuse", "Wikipedie", "Wikipedie diskuse", "Soubor", "Soubor diskuse", "MediaWiki", "MediaWiki diskuse", "Šablona", "Šablona diskuse", "Nápověda", "Nápověda diskuse", "Kategorie", "Kategorie diskuse"],
 4988+ "csb": [m, "Specjalnô", "Diskùsëjô", "Brëkòwnik", "Diskùsëjô brëkòwnika", "Wiki", "Diskùsëjô Wiki", "Òbrôzk", "Diskùsëjô òbrôzków", "MediaWiki", "Diskùsëjô MediaWiki", "Szablóna", "Diskùsëjô Szablónë", "Pòmòc", "Diskùsëjô Pòmòcë", "Kategòrëjô", "Diskùsëjô Kategòrëji"],
 4989+ "cv": ["Медиа", "Ятарлă", "Сӳтсе явасси", "Хутшăнакан", "Хутшăнаканăн канашлу страници", "Wikipedia", "0", "Ӳкерчĕк", "Ӳкерчĕке сӳтсе явмалли", "MediaWiki", "MediaWiki сӳтсе явмалли", "Шаблон", "Шаблона сӳтсе явмалли", "Пулăшу", "Пулăшăва сӳтсе явмалли", "Категори", "Категорине сӳтсе явмалли"],
 4990+ "cy": [m, "Arbennig", "Sgwrs", "Defnyddiwr", "Sgwrs Defnyddiwr", "Wicipedia", "Sgwrs Wicipedia", "Delwedd", "Sgwrs Delwedd", "MediaWiki", "Sgwrs MediaWiki", "Nodyn", "Sgwrs Nodyn", "Help", "Help talk", "Category", "Category talk"],
 4991+ "da": [m, "Speciel", "Diskussion", "Bruger", "Brugerdiskussion", "Wikipedia", "Wikipedia-diskussion", "Billede", "Billeddiskussion", "MediaWiki", "MediaWiki-diskussion", "Skabelon", "Skabelondiskussion", "Hjælp", "Hjælpdiskussion", "Kategori", "Kategoridiskussion", "Portal", "Portaldiskussion"],
 4992+ "de": [m, "Spezial", "Diskussion", "Benutzer", "Benutzer Diskussion", "Wikipedia", "Wikipedia Diskussion", "Bild", "Bild Diskussion", "MediaWiki", "MediaWiki Diskussion", "Vorlage", "Vorlage Diskussion", "Hilfe", "Hilfe Diskussion", "Kategorie", "Kategorie Diskussion", "Portal", "Portal Diskussion"],
 4993+ "el": ["Μέσον", "Ειδικό", "Συζήτηση", "Χρήστης", "Συζήτηση χρήστη", "Βικιπαίδεια", "Βικιπαίδεια συζήτηση", "Εικόνα", "Συζήτηση εικόνας", "MediaWiki", "MediaWiki talk", "Πρότυπο", "Συζήτηση προτύπου", "Βοήθεια", "Συζήτηση βοήθειας", "Κατηγορία", "Συζήτηση κατηγορίας"],
 4994+ "eo": [m, "Speciala", "Diskuto", "Vikipediisto", "Vikipediista diskuto", "Vikipedio", "Vikipedio diskuto", "Dosiero", "Dosiera diskuto", "MediaWiki", "MediaWiki diskuto", "Ŝablono", "Ŝablona diskuto", "Helpo", "Helpa diskuto", "Kategorio", "Kategoria diskuto"],
 4995+ "es": [m, "Especial", "Discusión", "Usuario", "Usuario Discusión", "Wikipedia", "Wikipedia Discusión", "Imagen", "Imagen Discusión", "MediaWiki", "MediaWiki Discusión", "Plantilla", "Plantilla Discusión", "Ayuda", "Ayuda Discusión", "Categoría", "Categoría Discusión"],
 4996+ "et": ["Meedia", "Eri", "Arutelu", "Kasutaja", "Kasutaja arutelu", "Vikipeedia", "Vikipeedia arutelu", "Pilt", "Pildi arutelu", "MediaWiki", "MediaWiki arutelu", "Mall", "Malli arutelu", "Juhend", "Juhendi arutelu", "Kategooria", "Kategooria arutelu"],
 4997+ "eu": [m, "Aparteko", "Eztabaida", "Lankide", "Lankide eztabaida", "Wikipedia", "Wikipedia eztabaida", "Irudi", "Irudi eztabaida", "MediaWiki", "MediaWiki eztabaida", "Template", "Template talk", "Help", "Help talk", "Category", "Category talk"],
 4998+ "fa": ["مدیا", "ویژه", "بحث", "کاربر", "بحث کاربر", "ویکی‌پدیا", "بحث ویکی‌پدیا", "تصویر", "بحث تصویر", "مدیاویکی", "بحث مدیاویکی", "الگو", "بحث الگو", "راهنما", "بحث راهنما", "رده", "بحث رده"],
 4999+ "fi": [m, "Toiminnot", "Keskustelu", "Käyttäjä", "Keskustelu käyttäjästä", "Wikipedia", "Keskustelu Wikipediasta", "Kuva", "Keskustelu kuvasta", "MediaWiki", "MediaWiki talk", "Malline", "Keskustelu mallineesta", "Ohje", "Keskustelu ohjeesta", "Luokka", "Keskustelu luokasta"],
 5000+ "fo": ["Miðil", "Serstakur", "Kjak", "Brúkari", "Brúkari kjak", "Wikipedia", "Wikipedia kjak", "Mynd", "Mynd kjak", "MidiaWiki", "MidiaWiki kjak", "Fyrimynd", "Fyrimynd kjak", "Hjálp", "Hjálp kjak", "Bólkur", "Bólkur kjak"],
 5001+ "fr": [m, "Spécial", "Discuter", "Utilisateur", "Discussion Utilisateur", "Wikipédia", "Discussion Wikipédia", "Image", "Discussion Image", "MediaWiki", "Discussion MediaWiki", "Modèle", "Discussion Modèle", "Aide", "Discussion Aide", "Catégorie", "Discussion Catégorie", "Portail", "Discussion Portail"],
 5002+ "fur": [m, "Speciâl", "Discussion", "Utent", "Discussion utent", "Vichipedie", "Discussion Vichipedie", "Figure", "Discussion figure", "MediaWiki", "Discussion MediaWiki", "Model", "Discussion model", "Jutori", "Discussion jutori", "Categorie", "Discussion categorie"],
 5003+ "fy": [m, "Wiki", "Oerlis", "Meidogger", "Meidogger oerlis", "Wikipedy", "Wikipedy oerlis", "Ofbyld", "Ofbyld oerlis", "MediaWiki", "MediaWiki oerlis", "Berjocht", "Berjocht oerlis", "Hulp", "Hulp oerlis", "Kategory", "Kategory oerlis"],
 5004+ "ga": ["Meán", "Speisialta", "Plé", "Úsáideoir", "Plé úsáideora", "Vicipéid", "Plé Vicipéide", "Íomhá", "Plé íomhá", "MediaWiki", "Plé MediaWiki", "Teimpléad", "Plé teimpléid", "Cabhair", "Plé cabhrach", "Catagóir", "Plé catagóire"],
 5005+ "gu": [m, "Special", "Talk", "User", "User talk", "વિકિપીડિયા", "વિકિપીડિયા talk", "Image", "Image talk", "MediaWiki", "MediaWiki talk", "Template", "Template talk", "Help", "Help talk", "Category", "Category talk"],
 5006+ "he": [m, "מיוחד", "שיחה", "משתמש", "שיחת משתמש", "ויקיפדיה", "שיחת ויקיפדיה", "תמונה", "שיחת תמונה", "MediaWiki", "שיחת MediaWiki", "תבנית", "שיחת תבנית", "עזרה", "שיחת עזרה", "קטגוריה", "שיחת קטגוריה"],
 5007+ "hi": [m, "विशेष", "वार्ता", "सदस्य", "सदस्य वार्ता", "विकिपीडिया", "विकिपीडिया वार्ता", "चित्र", "चित्र वार्ता", "MediaWiki", "MediaWiki talk", "Template", "Template talk", "श्रेणी", "श्रेणी वार्ता", "Help", "Help talk"],
 5008+ "hr": ["Mediji", "Posebno", "Razgovor", "Suradnik", "Razgovor sa suradnikom", "Wikipedia", "Razgovor Wikipedia", "Slika", "Razgovor o slici", "MediaWiki", "MediaWiki razgovor", "Predložak", "Razgovor o predlošku", "Pomoć", "Razgovor o pomoći", "Kategorija", "Razgovor o kategoriji"],
 5009+ "hu": [ "Média", "Speciális", "Vita", "Szerkesztő", "Szerkesztővita", "Wikipédia", "Wikipédia-vita", "Kép", "Képvita", "MediaWiki", "MediaWiki-vita", "Sablon", "Sablonvita", "Segítség", "Segítségvita", "Kategória", "Kategóriavita", "Portál", "Portálvita"],
 5010+ "ia": [m, "Special", "Discussion", "Usator", "Discussion Usator", "Wikipedia", "Discussion Wikipedia", "Imagine", "Discussion Imagine", "MediaWiki", "Discussion MediaWiki", "Template", "Template talk", "Help", "Help talk", "Category", "Category talk"],
 5011+ "id": [m, "Istimewa", "Bicara", "Pengguna", "Bicara Pengguna", "Wikipedia", "Pembicaraan Wikipedia", "Gambar", "Pembicaraan Gambar", "MediaWiki", "Pembicaraan MediaWiki", "Templat", "Pembicaraan Templat", "Bantuan", "Pembicaraan Bantuan", "Kategori", "Pembicaraan Kategori"],
 5012+ "is": ["Miðill", "Kerfissíða", "Spjall", "Notandi", "Notandaspjall", "Wikipedia", "Wikipediaspjall", "Mynd", "Myndaspjall", "Melding", "Meldingarspjall", "Snið", "Sniðaspjall", "Hjálp", "Hjálparspjall", "Flokkur", "Flokkaspjall"],
 5013+ "it": [m, "Speciale", "Discussione", "Utente", "Discussioni utente", "Wikipedia", "Discussioni Wikipedia", "File", "Discussioni file", "MediaWiki", "Discussioni MediaWiki", "Template", "Discussioni template", "Aiuto", "Discussioni aiuto", "Categoria", "Discussioni categoria", "Portale", "Discussioni portale", "Progetto", "Discussioni progetto"],
 5014+ "ja": [m, "特別", "ノート", "利用者", "利用者‐会話", "Wikipedia", "Wikipedia‐ノート", "画像", "画像‐ノート", "MediaWiki", "MediaWiki‐ノート", "Template", "Template‐ノート", "Help", "Help‐ノート", "Category", "Category‐ノート"],
 5015+ "ka": ["მედია", "სპეციალური", "განხილვა", "მომხმარებელი", "მომხმარებელი განხილვა", "ვიკიპედია", "ვიკიპედია განხილვა", "სურათი", "სურათი განხილვა", "მედიავიკი", "მედიავიკი განხილვა", "თარგი", "თარგი განხილვა", "დახმარება", "დახმარება განხილვა", "კატეგორია", "კატეგორია განხილვა"],
 5016+ "ko": [m, "특수기능", "토론", "사용자", "사용자토론", "위키백과", "위키백과토론", "그림", "그림토론", "분류", "분류토론", "MediaWiki", "MediaWiki talk", "Template", "Template talk", "Help", "Help talk"],
 5017+ "ku": ["Medya", "Taybet", "Nîqaş", "Bikarhêner", "Bikarhêner nîqaş", "Wîkîpediya", "Wîkîpediya nîqaş", "Wêne", "Wêne nîqaş", "MediaWiki", "MediaWiki nîqaş", "Şablon", "Şablon nîqaş", "Alîkarî", "Alîkarî nîqaş", "Kategorî", "Kategorî nîqaş"],
 5018+ "la": ["Specialis", "Disputatio", "Usor", "Disputatio Usoris", "Vicipaedia", "Disputatio Vicipaediae", "Imago", "Disputatio Imaginis", "MediaWiki", "Disputatio MediaWiki", "Formula", "Disputatio Formulae", "Auxilium", "Disputatio Auxilii", "Categoria", "Disputatio Categoriae", m],
 5019+ "li": [m, "Speciaal", "Euverlik", "Gebroeker", "Euverlik gebroeker", "Wikipedia", "Euverlik Wikipedia", "Aafbeilding", "Euverlik afbeelding", "MediaWiki", "Euverlik MediaWiki", "Sjabloon", "Euverlik sjabloon", "Help", "Euverlik help", "Kategorie", "Euverlik kategorie"],
 5020+ "lt": ["Medija", "Specialus", "Aptarimas", "Naudotojas", "Naudotojo aptarimas", "Wikipedia", "Wikipedia aptarimas", "Vaizdas", "Vaizdo aptarimas", "MediaWiki", "MediaWiki aptarimas", "Šablonas", "Šablono aptarimas", "Pagalba", "Pagalbos aptarimas", "Kategorija", "Kategorijos aptarimas"],
 5021+ "mk": ["Медија", "Специјални", "Разговор", "Корисник", "Корисник разговор", "Wikipedia", "Wikipedia разговор", "Слика", "Слика разговор", "МедијаВики", "МедијаВики разговор", "Шаблон", "Шаблон разговор", "Помош", "Помош разговор", "Категорија", "Категорија разговор"],
 5022+ "ms": [m, "Istimewa", "Perbualan", "Pengguna", "Perbualan Pengguna", "Wikipedia", "Perbualan Wikipedia", "Imej", "Imej Perbualan", "MediaWiki", "MediaWiki Perbualan", "Template", "Template talk", "Help", "Help talk", "Category", "Category talk"],
 5023+ "mt": [m, "Special", "Talk", "User", "User talk", "Wikipedija", "Wikipedija talk", "Image", "Image talk", "MediaWiki", "MediaWiki talk", "Template", "Template talk", "Help", "Help talk", "Category", "Category talk"],
 5024+ "nap": [m, "Speciale", "Discussione", "Utente", "Discussioni utente", "Wikipedia", "Discussioni Wikipedia", "Immagine", "Discussioni immagine", "MediaWiki", "Discussioni MediaWiki", "Template", "Discussioni template", "Aiuto", "Discussioni aiuto", "Categoria", "Discussioni categoria"],
 5025+ "nds": [m, "Spezial", "Diskuschoon", "Bruker", "Bruker Diskuschoon", "Wikipedia", "Wikipedia Diskuschoon", "Bild", "Bild Diskuschoon", "MediaWiki", "MediaWiki Diskuschoon", "Vörlaag", "Vörlaag Diskuschoon", "Hülp", "Hülp Diskuschoon", "Kategorie", "Kategorie Diskuschoon"],
 5026+ "nl": [m, "Speciaal", "Overleg", "Gebruiker", "Overleg gebruiker", "Wikipedia", "Overleg Wikipedia", "Afbeelding", "Overleg afbeelding", "MediaWiki", "Overleg MediaWiki", "Sjabloon", "Overleg sjabloon", "Help", "Overleg help", "Categorie", "Overleg categorie"],
 5027+ "nn": ["Filpeikar", "Spesial", "Diskusjon", "Brukar", "Brukardiskusjon", "Wikipedia", "Wikipedia-diskusjon", "Fil", "Fildiskusjon", "MediaWiki", "MediaWiki-diskusjon", "Mal", "Maldiskusjon", "Hjelp", "Hjelpdiskusjon", "Kategori", "Kategoridiskusjon"],
 5028+ "no": ["Medium", "Spesial", "Diskusjon", "Bruker", "Brukerdiskusjon", "Wikipedia", "Wikipedia-diskusjon", "Bilde", "Bildediskusjon", "MediaWiki", "MediaWiki-diskusjon", "Mal", "Maldiskusjon", "Hjelp", "Hjelpdiskusjon", "Kategori", "Kategoridiskusjon"],
 5029+ "nv": [m, "Special", "Naaltsoos baa yinísht'į́", "Choinish'įįhí", "Choinish'įįhí baa yinísht'į́", "Wikiibíídiiya", "Wikiibíídiiya baa yinísht'į́", "E'elyaaígíí", "E'elyaaígíí baa yinísht'į́", "MediaWiki", "MediaWiki baa yinísht'į́", "Template", "Template talk", "Aná'álwo'", "Aná'álwo' baa yinísht'į́", "T'ááłáhági át'éego", "T'ááłáhági át'éego baa yinísht'į́"],
 5030+ "oc": ["Especial", "Discutir", "Utilisator", "Discutida Utilisator", "Oiquipedià", "Discutida Oiquipedià", "Image", "Discutida Image", "MediaWiki", "MediaWiki talk", "Template", "Template talk", m, "Help", "Help talk", "Category", "Category talk"],
 5031+ "os": [m, "Сæрмагонд", "Дискусси", "Архайæг", "Архайæджы дискусси", "Wikipedia", "0", "Ныв", "Нывы тыххæй дискусси", "MediaWiki", "Дискусси MediaWiki", "Шаблон", "Шаблоны тыххæй дискусси", "Æххуыс", "Æххуысы тыххæй дискусси", "Категори", "Категорийы тыххæй дискусси"],
 5032+ "pa": ["ਮੀਡੀਆ", "ਖਾਸ", "ਚਰਚਾ", "ਮੈਂਬਰ", "ਮੈਂਬਰ ਚਰਚਾ", "Wikipedia", "Wikipedia ਚਰਚਾ", "ਤਸਵੀਰ", "ਤਸਵੀਰ ਚਰਚਾ", "ਮੀਡੀਆਵਿਕਿ", "ਮੀਡੀਆਵਿਕਿ ਚਰਚਾ", "ਨਮੂਨਾ", "ਨਮੂਨਾ ਚਰਚਾ", "ਮਦਦ", "ਮਦਦ ਚਰਚਾ", "ਸ਼੍ਰੇਣੀ", "ਸ਼੍ਰੇਣੀ ਚਰਚਾ"],
 5033+ "pl": [m, "Specjalna", "Dyskusja", "Wikipedysta", "Dyskusja Wikipedysty", "Wikipedia", "Dyskusja Wikipedii", "Grafika", "Dyskusja grafiki", "MediaWiki", "Dyskusja MediaWiki", "Szablon", "Dyskusja szablonu", "Pomoc", "Dyskusja pomocy", "Kategoria", "Dyskusja kategorii", "Portal", "Dyskusja portalu"],
 5034+ "pt": [m, "Especial", "Discussão", "Usuário", "Usuário Discussão", "Wikipedia", "Wikipedia Discussão", "Imagem", "Imagem Discussão", "MediaWiki", "MediaWiki Discussão", "Predefinição", "Predefinição Discussão", "Ajuda", "Ajuda Discussão", "Categoria", "Categoria Discussão"],
 5035+ "ro": [m, "Special", "Discuţie", "Utilizator", "Discuţie Utilizator", "Wikipedia", "Discuţie Wikipedia", "Imagine", "Discuţie Imagine", "MediaWiki", "Discuţie MediaWiki", "Format", "Discuţie Format", "Ajutor", "Discuţie Ajutor", "Categorie", "Discuţie Categorie"],
 5036+ "ru": ["Медиа", "Служебная", "Обсуждение", "Участник", "Обсуждение участника", "Википедия", "Обсуждение Википедии", "Изображение", "Обсуждение изображения", "MediaWiki", "Обсуждение MediaWiki", "Шаблон", "Обсуждение шаблона", "Справка", "Обсуждение справки", "Категория", "Обсуждение категории"],
 5037+ "sc": ["Speciale", "Contièndha", "Utente", "Utente discussioni", "Wikipedia", "Wikipedia discussioni", "Immàgini", "Immàgini contièndha", m, "MediaWiki", "MediaWiki talk", "Template", "Template talk", "Help", "Help talk", "Category", "Category talk"],
 5038+ "sk": ["Médiá", "Špeciálne", "Diskusia", "Redaktor", "Diskusia s redaktorom", "Wikipédia", "Diskusia k Wikipédii", "Obrázok", "Diskusia k obrázku", "MediaWiki", "Diskusia k MediaWiki", "Šablóna", "Diskusia k šablóne", "Pomoc", "Diskusia k pomoci", "Kategória", "Diskusia ku kategórii"],
 5039+ "sl": [m, "Posebno", "Pogovor", "Uporabnik", "Uporabniški pogovor", "Wikipedija", "Pogovor k Wikipediji", "Slika", "Pogovor k sliki", "MediaWiki", "MediaWiki talk", "Template", "Template talk", "Help", "Help talk", "Category", "Category talk"],
 5040+ "sq": [m, "Speciale", "Diskutim", "Përdoruesi", "Përdoruesi diskutim", "Wikipedia", "Wikipedia diskutim", "Figura", "Figura diskutim", "MediaWiki", "MediaWiki diskutim", "Stampa", "Stampa diskutim", "Ndihmë", "Ndihmë diskutim", "Category", "Category talk"],
 5041+ "sr": [m, "Посебно", "Разговор", "Корисник", "Разговор са корисником", "Википедија", "Разговор о Википедији", "Слика", "Разговор о слици", "МедијаВики", "Разговор о МедијаВикију", "Шаблон", "Разговор о шаблону", "Помоћ", "Разговор о помоћи", "Категорија", "Разговор о категорији", "Портал", "Разговор о порталу"],
 5042+ "sv": [m, "Special", "Diskussion", "Användare", "Användardiskussion", "Wikipedia", "Wikipediadiskussion", "Bild", "Bilddiskussion", "MediaWiki", "MediaWiki diskussion", "Mall", "Malldiskussion", "Hjälp", "Hjälp diskussion", "Kategori", "Kategoridiskussion"],
 5043+ "ta": ["ஊடகம்", "சிறப்பு", "பேச்சு", "பயனர்", "பயனர் பேச்சு", "Wikipedia", "Wikipedia பேச்சு", "படிமம்", "படிமப் பேச்சு", "மீடியாவிக்கி", "மீடியாவிக்கி பேச்சு", "வார்ப்புரு", "வார்ப்புரு பேச்சு", "உதவி", "உதவி பேச்சு", "பகுப்பு", "பகுப்பு பேச்சு"],
 5044+ "th": [m, "พิเศษ", "พูดคุย", "ผู้ใช้", "คุยเกี่ยวกับผู้ใช้", "Wikipedia", "Wikipedia talk", "ภาพ", "คุยเกี่ยวกับภาพ", "MediaWiki", "คุยเกี่ยวกับ MediaWiki", "Template", "Template talk", "Help", "Help talk", "Category", "Category talk"],
 5045+ "tlh": ["Doch", "le'", "ja'chuq", "lo'wI'", "lo'wI' ja'chuq", "wIqIpe'DIya", "wIqIpe'DIya ja'chuq", "nagh beQ", "nagh beQ ja'chuq", "MediaWiki", "MediaWiki ja'chuq", "chen'ay'", "chen'ay' ja'chuq", "QaH", "QaH ja'chuq", "Segh", "Segh ja'chuq"],
 5046+ "tr": [m, "Özel", "Tartışma", "Kullanıcı", "Kullanıcı mesaj", "Vikipedi", "Vikipedi tartışma", "Resim", "Resim tartışma", "MedyaViki", "MedyaViki tartışma", "Şablon", "Şablon tartışma", "Yardım", "Yardım tartışma", "Kategori", "Kategori tartışma"],
 5047+ "tt": [m, "Maxsus", "Bäxäs", "Äğzä", "Äğzä bäxäse", "Wikipedia", "Wikipedia bäxäse", "Räsem", "Räsem bäxäse", "MediaWiki", "MediaWiki bäxäse", "Ürnäk", "Ürnäk bäxäse", "Yärdäm", "Yärdäm bäxäse", "Törkem", "Törkem bäxäse"],
 5048+ "uk": ["Медіа", "Спеціальні", "Обговорення", "Користувач", "Обговорення користувача", "Wikipedia", "Обговорення Wikipedia", "Зображення", "Обговорення зображення", "MediaWiki", "Обговорення MediaWiki", "Шаблон", "Обговорення шаблону", "Довідка", "Обговорення довідки", "Категорія", "Обговорення категорії"],
 5049+ "vi": ["Phương tiện", "Đặc biệt", "Thảo luận", "Thành viên", "Thảo luận Thành viên", "Wikipedia", "Thảo luận Wikipedia", "Hình", "Thảo luận Hình", "MediaWiki", "Thảo luận MediaWiki", "Tiêu bản", "Thảo luận Tiêu bản", "Trợ giúp", "Thảo luận Trợ giúp", "Thể loại", "Thảo luận Thể loại"],
 5050+ "wa": [m, "Sipeciås", "Copene", "Uzeu", "Uzeu copene", "Wikipedia", "Wikipedia copene", "Imådje", "Imådje copene", "MediaWiki", "MediaWiki copene", "Modele", "Modele copene", "Aidance", "Aidance copene", "Categoreye", "Categoreye copene"]
 5051+//</NOLITE>
 5052+ };
 5053+ pg.ns.list = nsLists[pg.wiki.lang] || list;
 5054+ pg.ns.index = nsIndex;
 5055+}
 5056+
 5057+function namespaceListToRegex(list) {return RegExp('^('+list.join('|').split(' ').join('[ _]')+'):');};
 5058+// function setNamespaceList is ugly as sin, moved to later in the code
 5059+
 5060+function setNamespaces() {
 5061+ setNamespaceList();
 5062+ pg.ns.withTalkList=[null]; // NB root (article) corresponds with this entry, null
 5063+ pg.ns.talkList=[pg.ns.list[2]];
 5064+
 5065+ // if the number of namespaces changes then this will have to be changed
 5066+ // maybe the easiest way is to specify the arrays by hand as in the comments following the loop
 5067+
 5068+ for (var i=3; i+1<pg.ns.list.length; i=i+2) {
 5069+ pg.ns.withTalkList.push(pg.ns.list[i]);
 5070+ pg.ns.talkList.push(pg.ns.list[i+1]);
 5071+ }
 5072+
 5073+ // ALERT! SILLY HARDCODED VALUES FOLLOW!
 5074+ pg.ns.special = pg.ns.list[pg.ns.index.Special];
 5075+ pg.ns.image = pg.ns.list[pg.ns.index.File];
 5076+ pg.ns.user = pg.ns.list[pg.ns.index.User];
 5077+ pg.ns.usertalk = pg.ns.list[pg.ns.index['User talk']];
 5078+ pg.ns.category = pg.ns.list[pg.ns.index.Category];
 5079+ pg.ns.template = pg.ns.list[pg.ns.index.Template];
 5080+ pg.ns.nonArticleList=pg.ns.list.slice(0,2).concat(pg.ns.list.slice(2));
 5081+}
 5082+
 5083+
 5084+function setRedirs() {
 5085+ var r='redirect';
 5086+ var R='REDIRECT';
 5087+ var redirLists={
 5088+//<NOLITE>
 5089+ 'ar': [ R, 'تحويل' ],
 5090+ 'be': [ r, 'перанакіраваньне' ],
 5091+ 'bg': [ r, 'пренасочване', 'виж' ],
 5092+ 'bs': [ r, 'Preusmjeri', 'preusmjeri', 'PREUSMJERI' ],
 5093+ 'cs': [ R, 'PŘESMĚRUJ' ],
 5094+ 'cy': [ r, 'ail-cyfeirio' ],
 5095+ 'et': [ r, 'suuna' ],
 5096+ 'ga': [ r, 'athsheoladh' ],
 5097+ 'he': [ R, 'הפניה' ],
 5098+ 'hu': [ R, 'ÁTIRÁNYÍTÁS' ],
 5099+ 'is': [ r, 'tilvísun', 'TILVÍSUN' ],
 5100+ 'mk': [ r, 'пренасочување', 'види' ],
 5101+ 'nds': [ r, 'wiederleiden' ],
 5102+ 'nn': [ r, 'omdiriger' ],
 5103+ 'pt': [ R, 'redir' ],
 5104+ 'ru': [ R, 'ПЕРЕНАПРАВЛЕНИЕ', 'ПЕРЕНАПР' ],
 5105+ 'sk': [ r, 'presmeruj' ],
 5106+ 'sr': [ r, 'Преусмери', 'преусмери', 'ПРЕУСМЕРИ', 'Preusmeri', 'preusmeri', 'PREUSMERI' ],
 5107+ 'tt': [ 'yünältü' ],
 5108+ 'vi': [ r, 'đổi' ] // no comma
 5109+//</NOLITE>
 5110+ };
 5111+ var redirList=redirLists[ pg.wiki.lang ] || [r, R];
 5112+ // Mediawiki is very tolerant about what comes after the #redirect at the start
 5113+ pg.re.redirect=RegExp('^\\s*[#](' + redirList.join('|') + ').*?\\[{2}([^\\|\\]]*)(|[^\\]]*)?\\]{2}\\s*(.*)', 'i');
 5114+}
 5115+
 5116+function setInterwiki() {
 5117+ if (pg.wiki.wikimedia) {
 5118+ pg.wiki.interwiki='aa|ab|af|ak|als|am|an|ang|ar|arc|arz|as|ast|av|ay|az|ba|be|ber|bg|bh|bi|bm|bn|bdf|bo|br|bs|ca|ce|ceb|ch|cho|chr|chy|co|commons|cr|cs|csb|cu|cv|cy|da|de|dsb|dv|dz|el|en|eo|es|et|eu|fa|ff|fi|fiu-vro|fj|fo|fr|fur|fy|ga|gd|gil|gl|gn|got|gu|gv|ha|haw|he|hi|ho|hr|hsb|ht|hu|hy|hz|ia|id|ie|ig|ii|ik|ilo|io|is|it|iu|ja|jbo|jv|ka|kg|ki|kj|kk|kl|km|kn|ko|kr|ks|ksh|ku|kv|kw|ky|la|lad|lan|lb|lg|li|ln|lmo|lo|lt|lu|lv|map-bms|mg|mh|mi|mk|ml|mn|mo|mr|ms|mt|stq|mus|my|na|nah|nap|nb|nd|nds|nds-nl|ne|new|ng|nl|nn|no|nr|nv|ny|oc|oj|om|or|os|pa|pam|pi|pl|pms|ps|pt|qu|rm|rn|ro|roa-rup|ru|rw|sa|sc|scn|sco|sd|se|sg|sh|si|simple|sk|sl|sm|smg|sn|so|sq|sr|ss|st|stq|su|sv|sw|szl|ta|te|tg|th|ti|tk|tl|tlh|tn|to|tpi|tr|ts|tt|tum|tw|ty|ug|uk|ur|uz|ve|vi|vk|vo|wa|war|wen|wo|xh|yi|yo|za|zh|zh-min-nan|zh-yue|zu';
 5119+ pg.re.interwiki=RegExp('^'+pg.wiki.interwiki+':');
 5120+ } else {
 5121+ pg.wiki.interwiki=null;
 5122+ pg.re.interwiki=RegExp('^$');
 5123+ }
 5124+}
 5125+
 5126+function nsRe(label) {
 5127+ var l=upcaseFirst(label);
 5128+ return nsRegexString(pg.ns.list[pg.ns.index[l]], l);
 5129+}
 5130+
 5131+function nsReImage() {
 5132+ var str = pg.ns.list[pg.ns.index["File"]];
 5133+ return '(?:' + str + '|' + encodeURI(str) + '|' + upcaseFirst(str) + '|Image|' + upcaseFirst('Image') + ')';
 5134+}
 5135+
 5136+function nsRegexString(str, extra) {
 5137+ return '(?:' + str + '|' + encodeURI(str) + (extra ? '|' + extra : '') + ')';
 5138+}
 5139+
 5140+function nsRegex(str, extra) {
 5141+ return RegExp(nsRegexString(str, extra));
 5142+}
 5143+// ENDFILE: namespaces.js
 5144+// STARTFILE: selpop.js
 5145+//<NOLITE>
 5146+function getEditboxSelection() {
 5147+ // see http://www.webgurusforum.com/8/12/0
 5148+ try {
 5149+ var editbox=document.editform.wpTextbox1;
 5150+ } catch (dang) { return; }
 5151+ // IE, Opera
 5152+ if (document.selection) { return document.selection.createRange().text; }
 5153+ // Mozilla
 5154+ var selStart = editbox.selectionStart;
 5155+ var selEnd = editbox.selectionEnd;
 5156+ return (editbox.value).substring(selStart, selEnd);
 5157+}
 5158+
 5159+function doSelectionPopup() {
 5160+ // popup if the selection looks like [[foo|anything afterwards at all
 5161+ // or [[foo|bar]]text without ']]'
 5162+ // or [[foo|bar]]
 5163+ var sel=getEditboxSelection();
 5164+ var open=sel.indexOf('[[');
 5165+ var pipe=sel.indexOf('|');
 5166+ var close=sel.indexOf(']]');
 5167+ if (open == -1 || ( pipe == -1 && close == -1) ) { return; }
 5168+ if (pipe != -1 && open > pipe || close != -1 && open > close) { return; }
 5169+ if (getValueOf('popupOnEditSelection')=='boxpreview') {
 5170+ return doSeparateSelectionPopup(sel);
 5171+ }
 5172+ var article=new Title(sel.substring(open+2, (pipe < 0) ? close : pipe)).urlString();
 5173+ if (close > 0 && sel.substring(close+2).indexOf('[[') >= 0) {
 5174+ return;
 5175+ }
 5176+ var a=document.createElement('a');
 5177+ a.href=pg.wiki.titlebase + article;
 5178+ mouseOverWikiLink2(a);
 5179+ if (a.navpopup) {
 5180+ a.navpopup.addHook(function(){runStopPopupTimer(a.navpopup);}, 'unhide', 'after');
 5181+ }
 5182+}
 5183+
 5184+function doSeparateSelectionPopup(str) {
 5185+ var div=document.getElementById('selectionPreview');
 5186+ if (!div) {
 5187+ div = document.createElement('div');
 5188+ div.id='selectionPreview';
 5189+ try { var box=document.editform.wpTextbox1; }
 5190+ catch (oopsie) { return; }
 5191+ box.parentNode.insertBefore(div, box);
 5192+ }
 5193+ div.innerHTML=wiki2html(str);
 5194+ div.ranSetupTooltipsAlready = false;
 5195+ popTipsSoonFn('selectionPreview')();
 5196+}
 5197+//</NOLITE>
 5198+// ENDFILE: selpop.js
 5199+// STARTFILE: navpopup.js
 5200+/**
 5201+ @fileoverview Defines two classes: {@link Navpopup} and {@link Mousetracker}.
 5202+
 5203+ <code>Navpopup</code> describes popups: when they appear, where, what
 5204+ they look like and so on.
 5205+
 5206+ <code>Mousetracker</code> "captures" the mouse using
 5207+ <code>document.onmousemove</code>.
 5208+*/
 5209+
 5210+
 5211+/**
 5212+ Creates a new Mousetracker.
 5213+ @constructor
 5214+ @class The Mousetracker class. This monitors mouse movements and manages associated hooks.
 5215+*/
 5216+function Mousetracker() {
 5217+ /**
 5218+ Interval to regularly run the hooks anyway, in milliseconds.
 5219+ @type Integer
 5220+ */
 5221+ this.loopDelay=400;
 5222+
 5223+ /**
 5224+ Timer for the loop.
 5225+ @type Timer
 5226+ */
 5227+ this.timer=null;
 5228+
 5229+ /**
 5230+ Flag - are we switched on?
 5231+ @type Boolean
 5232+ */
 5233+ this.active=false;
 5234+ /**
 5235+ Flag - are we probably inaccurate, i.e. not reflecting the actual mouse position?
 5236+ */
 5237+ this.dirty=true;
 5238+ /**
 5239+ Array of hook functions.
 5240+ @private
 5241+ @type Array
 5242+ */
 5243+ this.hooks=[];
 5244+}
 5245+
 5246+/**
 5247+ Adds a hook, to be called when we get events.
 5248+ @param {Function} f A function which is called as
 5249+ <code>f(x,y)</code>. It should return <code>true</code> when it
 5250+ wants to be removed, and <code>false</code> otherwise.
 5251+*/
 5252+Mousetracker.prototype.addHook = function (f) {
 5253+ this.hooks.push(f);
 5254+};
 5255+
 5256+/**
 5257+ Runs hooks, passing them the x
 5258+ and y coords of the mouse. Hook functions that return true are
 5259+ passed to {@link Mousetracker#removeHooks} for removal.
 5260+ @private
 5261+*/
 5262+Mousetracker.prototype.runHooks = function () {
 5263+ if (!this.hooks || !this.hooks.length) { return; }
 5264+ //log('Mousetracker.runHooks; we got some hooks to run');
 5265+ var remove=false;
 5266+ var removeObj={};
 5267+ // this method gets called a LOT -
 5268+ // pre-cache some variables
 5269+ var x=this.x, y=this.y, len = this.hooks.length;
 5270+
 5271+ for (var i=0; i<len; ++i) {
 5272+ //~ run the hook function, and remove it if it returns true
 5273+ if (this.hooks[i](x, y)===true) {
 5274+ remove=true;
 5275+ removeObj[i]=true;
 5276+ }
 5277+ }
 5278+ if (remove) { this.removeHooks(removeObj); }
 5279+};
 5280+
 5281+/**
 5282+ Removes hooks.
 5283+ @private
 5284+ @param {Object} removeObj An object whose keys are the index
 5285+ numbers of functions for removal, with values that evaluate to true
 5286+*/
 5287+Mousetracker.prototype.removeHooks = function(removeObj) {
 5288+ var newHooks=[];
 5289+ var len = this.hooks.length;
 5290+ for (var i=0; i<len; ++i) {
 5291+ if (! removeObj[i]) { newHooks.push(this.hooks[i]); }
 5292+ }
 5293+ this.hooks=newHooks;
 5294+};
 5295+
 5296+
 5297+/**
 5298+ Event handler for mouse wiggles.
 5299+ We simply grab the event, set x and y and run the hooks.
 5300+ This makes the cpu all hot and bothered :-(
 5301+ @private
 5302+ @param {Event} e Mousemove event
 5303+*/
 5304+Mousetracker.prototype.track=function (e) {
 5305+ //~ Apparently this is needed in IE.
 5306+ e = e || window.event;
 5307+ var x, y;
 5308+ if (e) {
 5309+ if (e.pageX) { x=e.pageX; y=e.pageY; }
 5310+ else if (typeof e.clientX!='undefined') {
 5311+ var left, top, docElt = window.document.documentElement;
 5312+
 5313+ if (docElt) { left=docElt.scrollLeft; }
 5314+ left = left || window.document.body.scrollLeft || window.document.scrollLeft || 0;
 5315+
 5316+ if (docElt) { top=docElt.scrollTop; }
 5317+ top = top || window.document.body.scrollTop || window.document.scrollTop || 0;
 5318+
 5319+ x=e.clientX + left;
 5320+ y=e.clientY + top;
 5321+ } else { return; }
 5322+ this.setPosition(x,y);
 5323+ }
 5324+};
 5325+
 5326+/**
 5327+ Sets the x and y coordinates stored and takes appropriate action,
 5328+ running hooks as appropriate.
 5329+ @param {Integer} x, y Screen coordinates to set
 5330+*/
 5331+
 5332+Mousetracker.prototype.setPosition=function(x,y) {
 5333+ this.x = x;
 5334+ this.y = y;
 5335+ if (this.dirty || this.hooks.length === 0) { this.dirty=false; return; }
 5336+ if (typeof this.lastHook_x != 'number') { this.lastHook_x = -100; this.lastHook_y=-100; }
 5337+ var diff = (this.lastHook_x - x)*(this.lastHook_y - y);
 5338+ diff = (diff >= 0) ? diff : -diff;
 5339+ if ( diff > 1 ) {
 5340+ this.lastHook_x=x;
 5341+ this.lastHook_y=y;
 5342+ if (this.dirty) { this.dirty = false; }
 5343+ else { this.runHooks(); }
 5344+ }
 5345+}
 5346+
 5347+/**
 5348+ Sets things in motion, unless they are already that is, registering an event handler on <code>document.onmousemove</code>.
 5349+ A half-hearted attempt is made to preserve the old event handler if there is one.
 5350+*/
 5351+Mousetracker.prototype.enable = function () {
 5352+ if (this.active) { return; }
 5353+ this.active=true;
 5354+ //~ Save the current handler for mousemove events. This isn't too
 5355+ //~ robust, of course.
 5356+ this.savedHandler=document.onmousemove;
 5357+ //~ Gotta save @tt{this} again for the closure, and use apply for
 5358+ //~ the member function.
 5359+ var savedThis=this;
 5360+ document.onmousemove=function (e) {savedThis.track.apply(savedThis, [e]);};
 5361+ if (this.loopDelay) { this.timer = setInterval(function() { //log('loop delay in mousetracker is working');
 5362+ savedThis.runHooks();}, this.loopDelay); }
 5363+};
 5364+
 5365+/**
 5366+ Disables the tracker, removing the event handler.
 5367+*/
 5368+Mousetracker.prototype.disable = function () {
 5369+ if (!this.active) { return; }
 5370+ if (typeof this.savedHandler=='function') {
 5371+ document.onmousemove=this.savedHandler;
 5372+ } else { delete document.onmousemove; }
 5373+ if (this.timer) { clearInterval(this.timer); }
 5374+ this.active=false;
 5375+};
 5376+
 5377+/**
 5378+ Creates a new Navpopup.
 5379+ Gets a UID for the popup and
 5380+ @param init Contructor object. If <code>init.draggable</code> is true or absent, the popup becomes draggable.
 5381+ @constructor
 5382+ @class The Navpopup class. This generates popup hints, and does some management of them.
 5383+*/
 5384+function Navpopup(init) {
 5385+ //alert('new Navpopup(init)');
 5386+ /** UID for each Navpopup instance.
 5387+ Read-only.
 5388+ @type integer
 5389+ */
 5390+ this.uid=Navpopup.uid++;
 5391+ /**
 5392+ Read-only flag for current visibility of the popup.
 5393+ @type boolean
 5394+ @private
 5395+ */
 5396+ this.visible=false;
 5397+ /** Flag to be set when we want to cancel a previous request to
 5398+ show the popup in a little while.
 5399+ @private
 5400+ @type boolean
 5401+ */
 5402+ this.noshow=false;
 5403+ /** Categorised list of hooks.
 5404+ @see #runHooks
 5405+ @see #addHook
 5406+ @private
 5407+ @type Object
 5408+ */
 5409+ this.hooks={
 5410+ 'create': [],
 5411+ 'unhide': [],
 5412+ 'hide': []
 5413+ };
 5414+ /** list of unique IDs of hook functions, to avoid duplicates
 5415+ @private
 5416+ */
 5417+ this.hookIds={};
 5418+ /** List of downloads associated with the popup.
 5419+ @private
 5420+ @type Array
 5421+ */
 5422+ this.downloads=[];
 5423+ /** Number of uncompleted downloads.
 5424+ @type integer
 5425+ */
 5426+ this.pending=null;
 5427+ /** Tolerance in pixels when detecting whether the mouse has left the popup.
 5428+ @type integer
 5429+ */
 5430+ this.fuzz=5;
 5431+ /** Flag to toggle running {@link #limitHorizontalPosition} to regulate the popup's position.
 5432+ @type boolean
 5433+ */
 5434+ this.constrained=true;
 5435+ /** The popup width in pixels.
 5436+ @private
 5437+ @type integer
 5438+ */
 5439+ this.width=0;
 5440+ /** The popup width in pixels.
 5441+ @private
 5442+ @type integer
 5443+ */
 5444+ this.height=0;
 5445+ /** The main content DIV element.
 5446+ @type HTMLDivElement
 5447+ */
 5448+ this.mainDiv=null;
 5449+ this.createMainDiv();
 5450+
 5451+// if (!init || typeof init.draggable=='undefined' || init.draggable) {
 5452+// this.makeDraggable(true);
 5453+// }
 5454+}
 5455+
 5456+/**
 5457+ A UID for each Navpopup. This constructor property is just a counter.
 5458+ @type integer
 5459+ @private
 5460+*/
 5461+Navpopup.uid=0;
 5462+
 5463+/**
 5464+ Retrieves the {@link #visible} attribute, indicating whether the popup is currently visible.
 5465+ @type boolean
 5466+*/
 5467+Navpopup.prototype.isVisible=function() {
 5468+ return this.visible;
 5469+};
 5470+
 5471+/**
 5472+ Repositions popup using CSS style.
 5473+ @private
 5474+ @param {integer} x x-coordinate (px)
 5475+ @param {integer} y y-coordinate (px)
 5476+ @param {boolean} noLimitHor Don't call {@link #limitHorizontalPosition}
 5477+*/
 5478+Navpopup.prototype.reposition= function (x,y, noLimitHor) {
 5479+ log ('reposition('+x+','+y+','+noLimitHor+')');
 5480+ if (typeof x != 'undefined' && x!==null) { this.left=x; }
 5481+ if (typeof y != 'undefined' && y!==null) { this.top=y; }
 5482+ if (typeof this.left != 'undefined' && typeof this.top != 'undefined') {
 5483+ this.mainDiv.style.left=this.left + 'px';
 5484+ this.mainDiv.style.top=this.top + 'px';
 5485+ }
 5486+ if (!noLimitHor) { this.limitHorizontalPosition(); }
 5487+ //console.log('navpop'+this.uid+' - (left,top)=(' + this.left + ',' + this.top + '), css=('
 5488+ //+ this.mainDiv.style.left + ',' + this.mainDiv.style.top + ')');
 5489+};
 5490+
 5491+/**
 5492+ Prevents popups from being in silly locations. Hopefully.
 5493+ Should not be run if {@link #constrained} is true.
 5494+ @private
 5495+*/
 5496+Navpopup.prototype.limitHorizontalPosition=function() {
 5497+ if (!this.constrained || this.tooWide) { return; }
 5498+ this.updateDimensions();
 5499+ var x=this.left;
 5500+ var w=this.width;
 5501+ var cWidth=document.body.clientWidth;
 5502+
 5503+
 5504+// log('limitHorizontalPosition: x='+x+
 5505+// ', this.left=' + this.left +
 5506+// ', this.width=' + this.width +
 5507+// ', cWidth=' + cWidth);
 5508+
 5509+
 5510+ if ( (x+w) >= cWidth ||
 5511+ ( x > 0 && this.maxWidth && this.width < this.maxWidth && this.height > this.width
 5512+ && x > cWidth - this.maxWidth ) ) {
 5513+ // This is a very nasty hack. There has to be a better way!
 5514+ // We find the "natural" width of the div by positioning it at the far left
 5515+ // then reset it so that it should be flush right (well, nearly)
 5516+ this.mainDiv.style.left='-10000px';
 5517+ this.mainDiv.style.width = this.maxWidth + 'px';
 5518+ var naturalWidth=parseInt(this.mainDiv.offsetWidth, 10);
 5519+ var newLeft=cWidth - naturalWidth - 1;
 5520+ if (newLeft < 0) { newLeft = 0; this.tooWide=true; } // still unstable for really wide popups?
 5521+ log ('limitHorizontalPosition: moving to ('+newLeft + ','+ this.top+');' + ' naturalWidth=' + naturalWidth + ', clientWidth=' + cWidth);
 5522+ this.reposition(newLeft, null, true);
 5523+ }
 5524+};
 5525+
 5526+/**
 5527+ Counter indicating the z-order of the "highest" popup.
 5528+ We start the z-index at 1000 so that popups are above everything
 5529+ else on the screen.
 5530+ @private
 5531+ @type integer
 5532+*/
 5533+Navpopup.highest=1000;
 5534+
 5535+/**
 5536+ Brings popup to the top of the z-order.
 5537+ We increment the {@link #highest} property of the contructor here.
 5538+ @private
 5539+*/
 5540+Navpopup.prototype.raise = function () {
 5541+ this.mainDiv.style.zIndex=Navpopup.highest + 1;
 5542+ ++Navpopup.highest;
 5543+};
 5544+
 5545+/**
 5546+ Shows the popup provided {@link #noshow} is not true.
 5547+ Updates the position, brings the popup to the top of the z-order and unhides it.
 5548+*/
 5549+Navpopup.prototype.show = function () {
 5550+ //document.title+='s';
 5551+ if (this.noshow) { return; }
 5552+ //document.title+='t';
 5553+ this.reposition();
 5554+ this.raise();
 5555+ this.unhide();
 5556+};
 5557+
 5558+
 5559+/**
 5560+ Runs the {@link #show} method in a little while, unless we're
 5561+ already visible.
 5562+ @param {integer} time Delay in milliseconds
 5563+ @see #showSoonIfStable
 5564+*/
 5565+Navpopup.prototype.showSoon = function (time) {
 5566+ if (this.visible) { return; }
 5567+ this.noshow=false;
 5568+ //~ We have to save the value of @tt{this} so that the closure below
 5569+ //~ works.
 5570+ var savedThis=this;
 5571+ //this.start_x = Navpopup.tracker.x;
 5572+ //this.start_y = Navpopup.tracker.y;
 5573+ setTimeout(function () {
 5574+ if (Navpopup.tracker.active) {
 5575+ savedThis.reposition.apply(savedThis, [Navpopup.tracker.x + 2, Navpopup.tracker.y + 2]);
 5576+ }
 5577+ //~ Have to use apply to invoke his member function here
 5578+ savedThis.show.apply(savedThis, []);
 5579+ }, time);
 5580+};
 5581+
 5582+/**
 5583+ Checks to see if the mouse pointer has
 5584+ stabilised (checking every <code>time</code>/2 milliseconds) and runs the
 5585+ {@link #show} method if it has. This method makes {@link #showSoon} redundant.
 5586+ @param {integer} time The minimum time (ms) before the popup may be shown.
 5587+*/
 5588+Navpopup.prototype.showSoonIfStable = function (time) {
 5589+ log ('showSoonIfStable, time='+time);
 5590+ if (this.visible) { return; }
 5591+ this.noshow = false;
 5592+
 5593+ //~ initialize these variables so that we never run @tt{show} after
 5594+ //~ just half the time
 5595+ this.stable_x = -10000; this.stable_y = -10000;
 5596+
 5597+ var stableShow = function() {
 5598+ log('stableShow called');
 5599+ var new_x = Navpopup.tracker.x, new_y = Navpopup.tracker.y;
 5600+ var dx = savedThis.stable_x - new_x, dy = savedThis.stable_y - new_y;
 5601+ var fuzz2 = 0; // savedThis.fuzz * savedThis.fuzz;
 5602+ //document.title += '[' + [savedThis.stable_x,new_x, savedThis.stable_y,new_y, dx, dy, fuzz2].join(',') + '] ';
 5603+ if ( dx * dx <= fuzz2 && dy * dy <= fuzz2 ) {
 5604+ log ('mouse is stable');
 5605+ clearInterval(savedThis.showSoonStableTimer);
 5606+ savedThis.reposition.apply(savedThis, [new_x + 2, new_y + 2]);
 5607+ savedThis.show.apply(savedThis, []);
 5608+ return;
 5609+ }
 5610+ savedThis.stable_x = new_x; savedThis.stable_y = new_y;
 5611+ };
 5612+ var savedThis = this;
 5613+ this.showSoonStableTimer = setInterval(stableShow, time/2);
 5614+};
 5615+
 5616+/**
 5617+ Makes the popup unhidable until we call {@link #unstick}.
 5618+*/
 5619+Navpopup.prototype.stick=function() {
 5620+ this.noshow=false;
 5621+ this.sticky=true;
 5622+};
 5623+
 5624+/**
 5625+ Allows the popup to be hidden.
 5626+*/
 5627+Navpopup.prototype.unstick=function() {
 5628+ this.sticky=false;
 5629+};
 5630+
 5631+/**
 5632+ Sets the {@link #noshow} flag and hides the popup. This should be called
 5633+ when the mouse leaves the link before
 5634+ (or after) it's actually been displayed.
 5635+*/
 5636+Navpopup.prototype.banish = function () {
 5637+ log ('banish called');
 5638+ // hide and prevent showing with showSoon in the future
 5639+ this.noshow=true;
 5640+ if (this.showSoonStableTimer) {
 5641+ log('clearing showSoonStableTimer');
 5642+ clearInterval(this.showSoonStableTimer);
 5643+ }
 5644+ this.hide();
 5645+};
 5646+
 5647+/**
 5648+ Runs hooks added with {@link #addHook}.
 5649+ @private
 5650+ @param {String} key Key name of the {@link #hooks} array - one of 'create', 'unhide', 'hide'
 5651+ @param {String} when Controls exactly when the hook is run: either 'before' or 'after'
 5652+*/
 5653+Navpopup.prototype.runHooks = function (key, when) {
 5654+ if (!this.hooks[key]) { return; }
 5655+ var keyHooks=this.hooks[key];
 5656+ var len=keyHooks.length;
 5657+ for (var i=0; i< len; ++i) {
 5658+ if (keyHooks[i] && keyHooks[i].when == when) {
 5659+ if (keyHooks[i].hook.apply(this, [])) {
 5660+ // remove the hook
 5661+ if (keyHooks[i].hookId) {
 5662+ delete this.hookIds[keyHooks[i].hookId];
 5663+ }
 5664+ keyHooks[i]=null;
 5665+ }
 5666+ }
 5667+ }
 5668+};
 5669+
 5670+/**
 5671+ Adds a hook to the popup. Hook functions are run with <code>this</code> set to refer to the Navpopup instance, and no arguments.
 5672+ @param {Function} hook The hook function. Functions that return true are deleted.
 5673+ @param {String} key Key name of the {@link #hooks} array - one of 'create', 'unhide', 'hide'
 5674+ @param {String} when Controls exactly when the hook is run: either 'before' or 'after'
 5675+ @param {String} uid A truthy string identifying the hook function; if it matches another hook in this position, it won't be added again.
 5676+*/
 5677+Navpopup.prototype.addHook = function ( hook, key, when, uid ) {
 5678+ when = when || 'after';
 5679+ if (!this.hooks[key]) { return; }
 5680+ // if uid is specified, don't add duplicates
 5681+ var hookId=null;
 5682+ if (uid) {
 5683+ hookId=[key,when,uid].join('|');
 5684+ if (this.hookIds[hookId]) {
 5685+ return;
 5686+ }
 5687+ this.hookIds[hookId]=true;
 5688+ }
 5689+ this.hooks[key].push( {hook: hook, when: when, hookId: hookId} );
 5690+};
 5691+
 5692+/**
 5693+ Creates the main DIV element, which contains all the actual popup content.
 5694+ Runs hooks with key 'create'.
 5695+ @private
 5696+*/
 5697+Navpopup.prototype.createMainDiv = function () {
 5698+ if (this.mainDiv) { return; }
 5699+ this.runHooks('create', 'before');
 5700+ var mainDiv=document.createElement('div');
 5701+
 5702+ var savedThis=this;
 5703+ mainDiv.onclick=function(e) {savedThis.onclickHandler(e);};
 5704+ mainDiv.className=(this.className) ? this.className : 'navpopup_maindiv';
 5705+ mainDiv.id=mainDiv.className + this.uid;
 5706+
 5707+ mainDiv.style.position='absolute';
 5708+ mainDiv.style.display='none';
 5709+ mainDiv.className='navpopup';
 5710+
 5711+ // easy access to javascript object through DOM functions
 5712+ mainDiv.navpopup=this;
 5713+
 5714+ this.mainDiv=mainDiv;
 5715+ document.body.appendChild(mainDiv);
 5716+ this.runHooks('create', 'after');
 5717+};
 5718+/**
 5719+ Calls the {@link #raise} method.
 5720+ @private
 5721+*/
 5722+Navpopup.prototype.onclickHandler=function(e) {
 5723+ this.raise();
 5724+};
 5725+/**
 5726+ Makes the popup draggable, using a {@link Drag} object.
 5727+ @private
 5728+*/
 5729+Navpopup.prototype.makeDraggable=function(handleName) {
 5730+ if (!this.mainDiv) { this.createMainDiv(); }
 5731+ var drag=new Drag();
 5732+ if (!handleName) {
 5733+ drag.startCondition=function(e) {
 5734+ try { if (!e.shiftKey) { return false; } } catch (err) { return false; }
 5735+ return true;
 5736+ };
 5737+ }
 5738+ var dragHandle = document.getElementById(handleName) || this.mainDiv;
 5739+ var np=this;
 5740+ drag.endHook=function(x,y) {
 5741+ Navpopup.tracker.dirty=true;
 5742+ np.reposition(x,y);
 5743+ };
 5744+ drag.init(dragHandle,this.mainDiv);
 5745+};
 5746+
 5747+/** Hides the popup using CSS. Runs hooks with key 'hide'.
 5748+ Sets {@link #visible} appropriately. {@link #banish} should be called externally instead of this method.
 5749+
 5750+ @private
 5751+*/
 5752+Navpopup.prototype.hide = function () {
 5753+ this.runHooks('hide', 'before');
 5754+ this.abortDownloads();
 5755+ if (this.sticky) { return; }
 5756+ if (typeof this.visible != 'undefined' && this.visible) {
 5757+ this.mainDiv.style.display='none';
 5758+ this.visible=false;
 5759+ }
 5760+ this.runHooks('hide', 'after');
 5761+};
 5762+
 5763+/** Shows the popup using CSS. Runs hooks with key 'unhide'.
 5764+ Sets {@link #visible} appropriately. {@link #show} should be called externally instead of this method.
 5765+ @private
 5766+*/
 5767+Navpopup.prototype.unhide = function () {
 5768+ this.runHooks('unhide', 'before');
 5769+ if (typeof this.visible != 'undefined' && !this.visible) {
 5770+ this.mainDiv.style.display='inline';
 5771+ this.visible=true;
 5772+ }
 5773+ this.runHooks('unhide', 'after');
 5774+};
 5775+
 5776+/**
 5777+ Sets the <code>innerHTML</code> attribute of the main div containing the popup content.
 5778+ @param {String} html The HTML to set.
 5779+*/
 5780+Navpopup.prototype.setInnerHTML = function (html) {
 5781+ this.mainDiv.innerHTML = html;
 5782+};
 5783+
 5784+/**
 5785+ Updates the {@link #width} and {@link #height} attributes with the CSS properties.
 5786+ @private
 5787+*/
 5788+Navpopup.prototype.updateDimensions = function () {
 5789+ this.width=parseInt(this.mainDiv.offsetWidth, 10);
 5790+ this.height=parseInt(this.mainDiv.offsetHeight, 10);
 5791+};
 5792+
 5793+/**
 5794+ Checks if the point (x,y) is within {@link #fuzz} of the
 5795+ {@link #mainDiv}.
 5796+ @param {integer} x x-coordinate (px)
 5797+ @param {integer} y y-coordinate (px)
 5798+ @type boolean
 5799+*/
 5800+Navpopup.prototype.isWithin = function(x,y) {
 5801+ //~ If we're not even visible, no point should be considered as
 5802+ //~ being within the popup.
 5803+ if (!this.visible) { return false; }
 5804+ this.updateDimensions();
 5805+ var fuzz=this.fuzz || 0;
 5806+ //~ Use a simple box metric here.
 5807+ return (x+fuzz >= this.left && x-fuzz <= this.left + this.width &&
 5808+ y+fuzz >= this.top && y-fuzz <= this.top + this.height);
 5809+};
 5810+
 5811+/**
 5812+ Adds a download to {@link #downloads}.
 5813+ @param {Downloader} download
 5814+*/
 5815+Navpopup.prototype.addDownload=function(download) {
 5816+ if (!download) { return; }
 5817+ this.downloads.push(download);
 5818+};
 5819+/**
 5820+ Aborts the downloads listed in {@link #downloads}.
 5821+ @see Downloader#abort
 5822+*/
 5823+Navpopup.prototype.abortDownloads=function() {
 5824+ for(var i=0; i<this.downloads.length; ++i) {
 5825+ var d=this.downloads[i];
 5826+ if (d && d.abort) { d.abort(); }
 5827+ }
 5828+ this.downloads=[];
 5829+};
 5830+
 5831+
 5832+/**
 5833+ A {@link Mousetracker} instance which is a property of the constructor (pseudo-global).
 5834+*/
 5835+Navpopup.tracker=new Mousetracker();
 5836+// ENDFILE: navpopup.js
 5837+// STARTFILE: diff.js
 5838+//<NOLITE>
 5839+/*
 5840+ * Javascript Diff Algorithm
 5841+ * By John Resig (http://ejohn.org/) and [[:en:User:Lupin]]
 5842+ *
 5843+ * More Info:
 5844+ * http://ejohn.org/projects/javascript-diff-algorithm/
 5845+ */
 5846+
 5847+function delFmt(x) {
 5848+ if (!x.length) { return ''; }
 5849+ return "<del class='popupDiff'>" + x.join('') +"</del>";
 5850+}
 5851+function insFmt(x) {
 5852+ if (!x.length) { return ''; }
 5853+ return "<ins class='popupDiff'>" + x.join('') +"</ins>";
 5854+}
 5855+
 5856+function countCrossings(a, b, i, eject) {
 5857+ // count the crossings on the edge starting at b[i]
 5858+ if (!b[i].row && b[i].row !== 0) { return -1; }
 5859+ var count=0;
 5860+ for (var j=0; j<a.length; ++j) {
 5861+ if (!a[j].row && a[j].row !== 0) { continue; }
 5862+ if ( (j-b[i].row)*(i-a[j].row) > 0) {
 5863+ if(eject) { return true; }
 5864+ count++;
 5865+ }
 5866+ }
 5867+ return count;
 5868+}
 5869+
 5870+function shortenDiffString(str, context) {
 5871+ var re=RegExp('(<del[\\s\\S]*?</del>|<ins[\\s\\S]*?</ins>)');
 5872+ var splitted=str.parenSplit(re);
 5873+ var ret=[''];
 5874+ for (var i=0; i<splitted.length; i+=2) {
 5875+ if (splitted[i].length < 2*context) {
 5876+ ret[ret.length-1] += splitted[i];
 5877+ if (i+1<splitted.length) { ret[ret.length-1] += splitted[i+1]; }
 5878+ continue;
 5879+ }
 5880+ else {
 5881+ if (i > 0) { ret[ret.length-1] += splitted[i].substring(0,context); }
 5882+ if (i+1 < splitted.length) {
 5883+ ret.push(splitted[i].substring(splitted[i].length-context) +
 5884+ splitted[i+1]);
 5885+ }
 5886+ }
 5887+ }
 5888+ while (ret.length > 0 && !ret[0]) { ret = ret.slice(1); }
 5889+ return ret;
 5890+}
 5891+
 5892+
 5893+function diffString( o, n, simpleSplit ) {
 5894+ var splitRe=RegExp('([[]{2}|[\]]{2}|[{]{2,3}|[}]{2,3}|[|]|=|[*:]+|\\s|\\b)');
 5895+
 5896+ o=o.entify(); n=n.entify();
 5897+ var out, i;
 5898+ if (simpleSplit) { out = diff( o.split(/\b/), n.split(/\b/) ); }
 5899+ else { out = diff( o.parenSplit(splitRe), n.parenSplit(splitRe) ); }
 5900+ var str = "";
 5901+ var acc=[]; // accumulator for prettier output
 5902+
 5903+ // crossing pairings -- eg 'A B' vs 'B A' -- cause problems, so let's iron them out
 5904+ // this doesn't always do things optimally but it should be fast enough
 5905+ var maxOutputPair=0;
 5906+ for (i=0; i<out.n.length; ++i) {
 5907+ if ( out.n[i].paired ) {
 5908+ if( maxOutputPair > out.n[i].row ) {
 5909+ // tangle - delete pairing
 5910+ out.o[ out.n[i].row ]=out.o[ out.n[i].row ].text;
 5911+ out.n[i]=out.n[i].text;
 5912+ }
 5913+ if (maxOutputPair < out.n[i].row) { maxOutputPair = out.n[i].row; }
 5914+ }
 5915+ }
 5916+
 5917+ // output the stuff preceding the first paired old line
 5918+ for (i=0; i<out.o.length && !out.o[i].paired; ++i) { acc.push( out.o[i] ); }
 5919+ str += delFmt(acc); acc=[];
 5920+
 5921+ // main loop
 5922+ for ( i = 0; i < out.n.length; ++i ) {
 5923+ // output unpaired new "lines"
 5924+ while ( i < out.n.length && !out.n[i].paired ) { acc.push( out.n[i++] ); }
 5925+ str += insFmt(acc); acc=[];
 5926+ if ( i < out.n.length ) { // this new "line" is paired with the (out.n[i].row)th old "line"
 5927+ str += out.n[i].text;
 5928+ // output unpaired old rows starting after this new line's partner
 5929+ var m = out.n[i].row + 1;
 5930+ while ( m < out.o.length && !out.o[m].paired ) { acc.push ( out.o[m++] ); }
 5931+ str += delFmt(acc); acc=[];
 5932+ }
 5933+ }
 5934+ return str;
 5935+}
 5936+
 5937+// see http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Object
 5938+// FIXME: use obj.hasOwnProperty instead of this kludge!
 5939+window.jsReservedProperties=RegExp('^(constructor|prototype|__((define|lookup)[GS]etter)__' +
 5940+ '|eval|hasOwnProperty|propertyIsEnumerable' +
 5941+ '|to(Source|String|LocaleString)|(un)?watch|valueOf)$');
 5942+function diffBugAlert(word) {
 5943+ if (!diffBugAlert.list[word]) {
 5944+ diffBugAlert.list[word]=1;
 5945+ alert('Bad word: '+word+'\n\nPlease report this bug.');
 5946+ }
 5947+}
 5948+diffBugAlert.list={};
 5949+
 5950+function makeDiffHashtable(src) {
 5951+ var ret={};
 5952+ for ( var i = 0; i < src.length; i++ ) {
 5953+ if ( jsReservedProperties.test(src[i]) ) { src[i] += '<!-- -->'; }
 5954+ if ( !ret[ src[i] ] ) { ret[ src[i] ] = []; }
 5955+ try { ret[ src[i] ].push( i ); } catch (err) { diffBugAlert(src[i]); }
 5956+ }
 5957+ return ret;
 5958+}
 5959+
 5960+function diff( o, n ) {
 5961+
 5962+ // pass 1: make hashtable ns with new rows as keys
 5963+ var ns = makeDiffHashtable(n);
 5964+
 5965+ // pass 2: make hashtable os with old rows as keys
 5966+ var os = makeDiffHashtable(o);
 5967+
 5968+ // pass 3: pair unique new rows and matching unique old rows
 5969+ var i;
 5970+ for ( i in ns ) {
 5971+ if ( ns[i].length == 1 && os[i] && os[i].length == 1 ) {
 5972+ n[ ns[i][0] ] = { text: n[ ns[i][0] ], row: os[i][0], paired: true };
 5973+ o[ os[i][0] ] = { text: o[ os[i][0] ], row: ns[i][0], paired: true };
 5974+ }
 5975+ }
 5976+
 5977+ // pass 4: pair matching rows immediately following paired rows (not necessarily unique)
 5978+ for ( i = 0; i < n.length - 1; i++ ) {
 5979+ if ( n[i].paired && ! n[i+1].paired && n[i].row + 1 < o.length && ! o[ n[i].row + 1 ].paired &&
 5980+ n[i+1] == o[ n[i].row + 1 ] ) {
 5981+ n[i+1] = { text: n[i+1], row: n[i].row + 1, paired: true };
 5982+ o[n[i].row+1] = { text: o[n[i].row+1], row: i + 1, paired: true };
 5983+ }
 5984+ }
 5985+
 5986+ // pass 5: pair matching rows immediately preceding paired rows (not necessarily unique)
 5987+ for ( i = n.length - 1; i > 0; i-- ) {
 5988+ if ( n[i].paired && ! n[i-1].paired && n[i].row > 0 && ! o[ n[i].row - 1 ].paired &&
 5989+ n[i-1] == o[ n[i].row - 1 ] ) {
 5990+ n[i-1] = { text: n[i-1], row: n[i].row - 1, paired: true };
 5991+ o[n[i].row-1] = { text: o[n[i].row-1], row: i - 1, paired: true };
 5992+ }
 5993+ }
 5994+
 5995+ return { o: o, n: n };
 5996+}
 5997+//</NOLITE>
 5998+// ENDFILE: diff.js
 5999+// STARTFILE: init.js
 6000+function setSiteInfo() {
 6001+ if (window.popupLocalDebug) {
 6002+ pg.wiki.hostname = 'en.wikipedia.org';
 6003+ } else {
 6004+ pg.wiki.hostname = location.hostname; // use in preference to location.hostname for flexibility (?)
 6005+ }
 6006+ pg.wiki.wikimedia=RegExp('(wiki([pm]edia|source|books|news|quote|versity)|wiktionary)[.]org').test(pg.wiki.hostname);
 6007+ pg.wiki.wikia=RegExp('[.]wikia[.]com$', 'i').test(pg.wiki.hostname);
 6008+ pg.wiki.isLocal=RegExp('^localhost').test(pg.wiki.hostname);
 6009+ pg.wiki.commons=( pg.wiki.wikimedia && pg.wiki.hostname != 'commons.wikimedia.org') ? 'commons.wikimedia.org' : null;
 6010+ pg.wiki.commonslang = pg.wiki.commons ? pg.wiki.commons.split('.')[0] : null;
 6011+ pg.wiki.lang = pg.wiki.hostname.split('.')[0];
 6012+ // toolDbName needs pg.wiki.lang and pg.wiki.hostname
 6013+ pg.wiki.prePath='';
 6014+ if (pg.wiki.hostname == 'secure.wikimedia.org') {
 6015+ var s=document.location.href.split('/');
 6016+ pg.wiki.prePath=s.slice(3,5).join('/');
 6017+ pg.wiki.lang=s[4];
 6018+ }
 6019+ var port = location.port ? ':' + location.port : '';
 6020+ pg.wiki.sitebase = joinPath([pg.wiki.hostname + port, pg.wiki.prePath]);
 6021+}
 6022+
 6023+function getArticlePath() {
 6024+ if (isFunction(window.siteArticlePath)) {
 6025+ return siteArticlePath();
 6026+ }
 6027+ return 'wiki';
 6028+}
 6029+
 6030+function getBotInterfacePath() {
 6031+ if (isFunction(window.siteBotInterfacePath)) {
 6032+ return siteBotInterfacePath();
 6033+ }
 6034+ var botInterfacePath = pg.wiki.articlePath.replace(/\/index[.]php$/, '');
 6035+ if (pg.wiki.wikimedia) { botInterfacePath = 'w'; } // as in http://some.thing.com/w/index.php?title=foo
 6036+ else if (pg.wiki.wikia) { botInterfacePath = ''; }
 6037+ return botInterfacePath;
 6038+}
 6039+
 6040+function setTitleBase() {
 6041+ var protocol = ( window.popupLocalDebug ? 'http:' : location.protocol );
 6042+ pg.wiki.articlePath = getArticlePath(); // as in http://some.thing.com/wiki/Article
 6043+ pg.wiki.botInterfacePath = getBotInterfacePath();
 6044+ // default mediawiki setting is paths like http://some.thing.com/articlePath/index.php?title=foo
 6045+
 6046+ var titletail = joinPath([pg.wiki.botInterfacePath, 'index.php?title=']);
 6047+ var titletail2 = joinPath([pg.wiki.botInterfacePath, 'wiki.phtml?title=']);
 6048+
 6049+ // other sites may need to add code here to set titletail depending on how their urls work
 6050+
 6051+ pg.wiki.titlebase = protocol + '//' + joinPath([pg.wiki.sitebase, titletail]);
 6052+ pg.wiki.titlebase2 = protocol + '//' + joinPath([pg.wiki.sitebase, titletail2]);
 6053+ pg.wiki.wikibase = protocol + '//' + joinPath([pg.wiki.sitebase, pg.wiki.botInterfacePath]);
 6054+ pg.wiki.articlebase = protocol + '//' + joinPath([pg.wiki.sitebase, pg.wiki.articlePath]);
 6055+ pg.wiki.commonsbase = protocol + '//' + joinPath([pg.wiki.commons, pg.wiki.botInterfacePath]);
 6056+ pg.re.basenames = RegExp( '^(' +
 6057+ map( literalizeRegex, [ pg.wiki.titlebase, pg.wiki.titlebase2,
 6058+ pg.wiki.articlebase ]).join('|') + ')' );
 6059+}
 6060+
 6061+
 6062+//////////////////////////////////////////////////
 6063+// Global regexps
 6064+
 6065+function setMainRegex() {
 6066+ var reStart='[^:]*://';
 6067+ var preTitles = joinPath([literalizeRegex(pg.wiki.botInterfacePath), '(?:index[.]php|wiki[.]phtml)[?]title=']);
 6068+ // slightly ugly hack when pg.wiki.articlePath is empty
 6069+ preTitles += '|' + literalizeRegex( ( pg.wiki.articlePath ? pg.wiki.articlePath + '/' : ''));
 6070+
 6071+ var reEnd='/(' + preTitles + ')([^&?#]*)[^#]*(?:#(.+))?';
 6072+ pg.re.main = RegExp(reStart + literalizeRegex(pg.wiki.sitebase) + reEnd);
 6073+}
 6074+
 6075+function setRegexps() {
 6076+ setMainRegex();
 6077+ var sp=nsRe('Special');
 6078+ pg.re.urlNoPopup=RegExp('((title=|/)' + sp + '(?:%3A|:)|section=[0-9])') ;
 6079+ pg.re.contribs =RegExp('(title=|/)' + sp + '(?:%3A|:)Contributions' + '(&target=|/|/' + pg.ns.user+':)(.*)') ;
 6080+ pg.re.email =RegExp('(title=|/)' + sp + '(?:%3A|:)Emailuser' + '(&target=|/|/(?:' + pg.ns.user+':)?)(.*)') ;
 6081+ pg.re.backlinks =RegExp('(title=|/)' + sp + '(?:%3A|:)Whatlinkshere' + '(&target=|/)([^&]*)');
 6082+
 6083+//<NOLITE>
 6084+ var im=nsReImage();
 6085+ // note: tries to get images in infobox templates too, e.g. movie pages, album pages etc
 6086+ // (^|\[\[)image: *([^|\]]*[^|\] ]) *
 6087+ // (^|\[\[)image: *([^|\]]*[^|\] ])([^0-9\]]*([0-9]+) *px)?
 6088+ // $4 = 120 as in 120px
 6089+ pg.re.image = RegExp('(^|\\[\\[)' + im + ': *([^|\\]]*[^|\\] ])' +
 6090+ '([^0-9\\]]*([0-9]+) *px)?|(?:\\n *[|]?|[|]) *' +
 6091+ '(' + getValueOf('popupImageVarsRegexp') + ')' +
 6092+ ' *= *(?:\\[\\[ *)?(?:' + im + ':)?' +
 6093+ '([^|]*?)(?:\\]\\])? *[|]? *\\n', 'img') ;
 6094+ pg.re.imageBracketCount = 6;
 6095+
 6096+ pg.re.category = RegExp('\\[\\[' +nsRe('Category') +
 6097+ ': *([^|\\]]*[^|\\] ]) *', 'i');
 6098+ pg.re.categoryBracketCount = 1;
 6099+
 6100+ pg.re.ipUser=RegExp('('+nsRe('User')+':)?' +
 6101+ '((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\\.){3}' +
 6102+ '(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])');
 6103+
 6104+ pg.re.stub= RegExp(getValueOf('popupStubRegexp'), 'im');
 6105+ pg.re.disambig=RegExp(getValueOf('popupDabRegexp'), 'im');
 6106+
 6107+//</NOLITE>
 6108+ // FIXME replace with general parameter parsing function, this is daft
 6109+ pg.re.oldid=RegExp('[?&]oldid=([^&]*)');
 6110+ pg.re.diff=RegExp('[?&]diff=([^&]*)');
 6111+}
 6112+
 6113+
 6114+//<NOLITE>
 6115+//////////////////////////////////////////////////
 6116+// Image sources
 6117+
 6118+function setImageSources() {
 6119+ pg.wiki.imageSources=[];
 6120+
 6121+ // frequently seen thumbs
 6122+ pg.wiki.imageSources.push(
 6123+ {wiki: pg.wiki.hostname, thumb: true, width: 180}, // default
 6124+ {wiki: pg.wiki.hostname, thumb: true, width: 120} // gallery
 6125+ );
 6126+
 6127+ // frequently seen thumbs on commons
 6128+ if (pg.wiki.commons) {
 6129+ pg.wiki.imageSources.push(
 6130+ {wiki: pg.wiki.commons, thumb: true, width: 180},
 6131+ {wiki: pg.wiki.commons, thumb: true, width: 120}
 6132+ );
 6133+ }
 6134+
 6135+ // unusual thumb sizes and full-size
 6136+ pg.wiki.imageSources.push(
 6137+ {wiki: pg.wiki.hostname, thumb: true, width: 200}, // common?
 6138+ {wiki: pg.wiki.hostname, thumb: true, width: 250}, // common?
 6139+ {wiki: pg.wiki.hostname, thumb: true, width: 300},
 6140+ {wiki: pg.wiki.hostname, thumb: true, width: 210},
 6141+ {wiki: pg.wiki.hostname, thumb: true, width: 230},
 6142+ {wiki: pg.wiki.hostname, thumb: false, width: 0} // no comma
 6143+ );
 6144+
 6145+ // full-size on commons
 6146+ if (pg.wiki.commons) {
 6147+ pg.wiki.imageSources.push({wiki: pg.wiki.commons, thumb: false, width: 0});
 6148+ }
 6149+}
 6150+//</NOLITE>
 6151+
 6152+//////////////////////////////////////////////////
 6153+// miscellany
 6154+
 6155+function setupCache() {
 6156+ // page caching
 6157+ pg.cache.pages = [];
 6158+ pg.cache.images = [];
 6159+
 6160+ // global array for 404'ed image urls
 6161+ pg.cache.badImageUrls=[];
 6162+}
 6163+
 6164+function setMisc() {
 6165+ pg.current.link=null;
 6166+ pg.current.links=[];
 6167+ pg.current.linksHash={};
 6168+
 6169+ // downloading images are put here
 6170+ pg.misc.imageArray=[];
 6171+
 6172+ setupCache();
 6173+ // FIXME what is this for?
 6174+ pg.misc.gImage=null; // global for image
 6175+
 6176+ // check to see if images are done with this timer
 6177+ pg.timer.image=null;
 6178+
 6179+ // These are for checkImages()
 6180+ pg.counter.checkImages=0;
 6181+ pg.timer.checkImages=null;
 6182+ pg.timer.checkPopupPosition=null;
 6183+ pg.counter.loop=0;
 6184+
 6185+ // ids change with each popup: popupImage0, popupImage1 etc
 6186+ pg.idNumber=0;
 6187+
 6188+ // for myDecodeURI
 6189+ pg.misc.decodeExtras = [
 6190+ {from: '%2C', to: ',' },
 6191+ {from: '_', to: ' ' },
 6192+ {from: '%24', to: '$'},
 6193+ {from: '%26', to: '&' } // no ,
 6194+ ];
 6195+
 6196+}
 6197+
 6198+function leadingInteger(s){
 6199+ var n=s.match(/^(\d*)/)[1];
 6200+ if (n) { return +n; }
 6201+ return null;
 6202+}
 6203+
 6204+function setBrowserHacks() {
 6205+ var useOriginal=false;
 6206+ // browser-specific hacks
 6207+ if (typeof window.opera != 'undefined') {
 6208+ //if (leadingInteger(opera.version()) < 9)
 6209+ { useOriginal=true; } // v9 beta still seems to have buggy css
 6210+ setDefault('popupNavLinkSeparator', ' &#183; ');
 6211+ } else if (navigator.appName=='Konqueror') {
 6212+ setDefault('popupNavLinkSeparator', ' &bull; ');
 6213+ pg.flag.isKonq=true;
 6214+ } else if ( navigator.vendor && navigator.vendor.toLowerCase().indexOf('apple computer')===0) {
 6215+ pg.flag.isSafari=true;
 6216+ var webkit=+navigator.userAgent.replace(RegExp('^.*AppleWebKit[/](\\d+).*', 'i'), '$1');
 6217+ if (webkit < 420) { useOriginal=true; }
 6218+ } else if (navigator.appName.indexOf("Microsoft")!=-1) {
 6219+ setDefault('popupNavLinkSeparator', ' &#183; ');
 6220+ useOriginal=true;
 6221+ var ver=+navigator.userAgent.replace(RegExp('^.*MSIE (\\d+).*'), '$1');
 6222+ pg.flag.isIE=true;
 6223+ pg.flag.IEVersion=ver;
 6224+ }
 6225+ if (pg.flag.isIE && pg.flag.IEVersion < 7 || pg.flag.isKonq || webkit < 420 ) {
 6226+ pg.flag.linksLikeIE6=true;
 6227+ }
 6228+ if (useOriginal && pg.structures.original) {
 6229+ setDefault('popupStructure','original');
 6230+ }
 6231+}
 6232+
 6233+function setupPopups() {
 6234+ // NB translatable strings should be set up first (strings.js)
 6235+ // basics
 6236+ setupDebugging();
 6237+ setSiteInfo();
 6238+ setTitleBase();
 6239+ setOptions(); // see options.js
 6240+
 6241+ // namespaces etc
 6242+ setNamespaces();
 6243+ setInterwiki();
 6244+
 6245+ // regexps
 6246+ setRegexps();
 6247+ setRedirs();
 6248+
 6249+ // other stuff
 6250+ window.setImageSources && setImageSources();
 6251+ setBrowserHacks();
 6252+ setMisc();
 6253+ setupLivePreview();
 6254+
 6255+ // main deal here
 6256+ setupTooltips();
 6257+ Navpopup.tracker.enable();
 6258+
 6259+ setupPopups.completed = true;
 6260+}
 6261+// ENDFILE: init.js
 6262+// STARTFILE: navlinks.js
 6263+//<NOLITE>
 6264+//////////////////////////////////////////////////
 6265+// navlinks... let the fun begin
 6266+//
 6267+
 6268+function defaultNavlinkSpec() {
 6269+ var str='';
 6270+ str += '<b><<mainlink|shortcut= >></b>';
 6271+ if (getValueOf('popupLastEditLink')) {
 6272+ str += '*<<lastEdit|shortcut=/>>|<<lastContrib>>|<<sinceMe>>if(oldid){|<<oldEdit>>|<<diffCur>>}';
 6273+ }
 6274+
 6275+ // user links
 6276+ // contribs - log - count - email - block
 6277+ // count only if applicable; block only if popupAdminLinks
 6278+ str += 'if(user){<br><<contribs|shortcut=c>>*<<userlog|shortcut=L|log>>';
 6279+ str+='if(ipuser){*<<arin>>}if(wikimedia){*<<count|shortcut=#>>}';
 6280+ str+='if(ipuser){}else{*<<email|shortcut=E>>}if(admin){*<<block|shortcut=b>>|<<blocklog|log>>}}';
 6281+
 6282+ // editing links
 6283+ // talkpage -> edit|new - history - un|watch - article|edit
 6284+ // other page -> edit - history - un|watch - talk|edit|new
 6285+ var editstr='<<edit|shortcut=e>>';
 6286+ var editOldidStr='if(oldid){<<editOld|shortcut=e>>|<<revert|shortcut=v|rv>>|<<edit|cur>>}else{' + editstr + '}'
 6287+ var historystr='<<history|shortcut=h>>if(mainspace_en){|<<editors|shortcut=E|>>}';
 6288+ var watchstr='<<unwatch|unwatchShort>>|<<watch|shortcut=w|watchThingy>>';
 6289+
 6290+ str+='<br>if(talk){' +
 6291+ editOldidStr+'|<<new|shortcut=+>>' + '*' + historystr+'*'+watchstr + '*' +
 6292+ '<b><<article|shortcut=a>></b>|<<editArticle|edit>>' +
 6293+ '}else{' + // not a talk page
 6294+ editOldidStr + '*' + historystr + '*' + watchstr + '*' +
 6295+ '<b><<talk|shortcut=t>></b>|<<editTalk|edit>>|<<newTalk|shortcut=+|new>>'
 6296+ + '}';
 6297+
 6298+ // misc links
 6299+ str += '<br><<whatLinksHere|shortcut=l>>*<<relatedChanges|shortcut=r>>*<<move|shortcut=m>>';
 6300+
 6301+ // admin links
 6302+ str += 'if(admin){<br><<unprotect|unprotectShort>>|<<protect|shortcut=p>>|<<protectlog|log>>*' +
 6303+ '<<undelete|undeleteShort>>|<<delete|shortcut=d>>|<<deletelog|log>>}';
 6304+ return str;
 6305+}
 6306+
 6307+function navLinksHTML (article, hint, params) { //oldid, rcid) {
 6308+ var str = '<span class="popupNavLinks">' + defaultNavlinkSpec() + '</span>';
 6309+ // BAM
 6310+ return navlinkStringToHTML(str, article, params);
 6311+}
 6312+
 6313+function expandConditionalNavlinkString(s,article,z,recursionCount) {
 6314+ var oldid=z.oldid, rcid=z.rcid, diff=z.diff;
 6315+ // nested conditionals (up to 10 deep) are ok, hopefully! (work from the inside out)
 6316+ if (typeof recursionCount!=typeof 0) { recursionCount=0; }
 6317+ var conditionalSplitRegex=RegExp(
 6318+ //(1 if \\( (2 2) \\) {(3 3)} (4 else {(5 5)} 4)1)
 6319+ '(;?\\s*if\\s*\\(\\s*([\\w]*)\\s*\\)\\s*\\{([^{}]*)\\}(\\s*else\\s*\\{([^{}]*?)\\}|))', 'i');
 6320+ var splitted=s.parenSplit(conditionalSplitRegex);
 6321+ // $1: whole conditional
 6322+ // $2: test condition
 6323+ // $3: true expansion
 6324+ // $4: else clause (possibly empty)
 6325+ // $5: false expansion (possibly null)
 6326+ var numParens=5;
 6327+ var ret = splitted[0];
 6328+ for (var i=1; i<splitted.length; i=i+numParens+1) {
 6329+
 6330+ var testString=splitted[i+2-1];
 6331+ var trueString=splitted[i+3-1];
 6332+ var falseString=splitted[i+5-1];
 6333+ if (typeof falseString=='undefined' || !falseString) { falseString=''; }
 6334+ var testResult=null;
 6335+
 6336+ switch (testString) {
 6337+ case 'user':
 6338+ testResult=(article.userName())?true:false;
 6339+ break;
 6340+ case 'talk':
 6341+ testResult=(article.talkPage())?false:true; // talkPage converts _articles_ to talkPages
 6342+ break;
 6343+ case 'admin':
 6344+ testResult=getValueOf('popupAdminLinks')?true:false;
 6345+ break;
 6346+ case 'oldid':
 6347+ testResult=(typeof oldid != 'undefined' && oldid)?true:false;
 6348+ break;
 6349+ case 'rcid':
 6350+ testResult=(typeof rcid != 'undefined' && rcid)?true:false;
 6351+ break;
 6352+ case 'ipuser':
 6353+ testResult=(article.isIpUser())?true:false;
 6354+ break;
 6355+ case 'mainspace_en':
 6356+ testResult=isInMainNamespace(article) &&
 6357+ pg.wiki.hostname=='en.wikipedia.org';
 6358+ break;
 6359+ case 'wikimedia':
 6360+ testResult=(pg.wiki.wikimedia) ? true : false;
 6361+ break;
 6362+ case 'diff':
 6363+ testResult=(typeof diff != 'undefined' && diff)?true:false;
 6364+ break;
 6365+ }
 6366+
 6367+ switch(testResult) {
 6368+ case null: ret+=splitted[i]; break;
 6369+ case true: ret+=trueString; break;
 6370+ case false: ret+=falseString; break;
 6371+ }
 6372+
 6373+ // append non-conditional string
 6374+ ret += splitted[i+numParens];
 6375+ }
 6376+ if (conditionalSplitRegex.test(ret) && recursionCount < 10) {
 6377+ return expandConditionalNavlinkString(ret,article,z,recursionCount+1);
 6378+ }
 6379+ return ret;
 6380+}
 6381+
 6382+function navlinkStringToArray(s, article, params) {
 6383+ s=expandConditionalNavlinkString(s,article,params);
 6384+ var splitted=s.parenSplit(RegExp('<<(.*?)>>'));
 6385+ var ret=[];
 6386+ for (var i=0; i<splitted.length; ++i) {
 6387+ if (i%2) { // i odd, so s is a tag
 6388+ var t=new navlinkTag();
 6389+ var ss=splitted[i].split('|');
 6390+ t.id=ss[0];
 6391+ for (var j=1; j<ss.length; ++j) {
 6392+ var sss=ss[j].split('=');
 6393+ if (sss.length>1) {
 6394+ t[sss[0]]=sss[1];
 6395+ }
 6396+ else { // no assignment (no "="), so treat this as a title (overwriting the last one)
 6397+ t.text=popupString(sss[0]);
 6398+ }
 6399+ }
 6400+ t.article=article;
 6401+ var oldid=params.oldid, rcid=params.rcid, diff=params.diff;
 6402+ if (typeof oldid != 'undefined' && oldid != null) { t.oldid=oldid; }
 6403+ if (typeof rcid != 'undefined' && rcid != null) { t.rcid=rcid; }
 6404+ if (typeof diff != 'undefined' && diff != null) { t.diff=diff; }
 6405+ if (!t.text && t.id != 'mainlink') { t.text=popupString(t.id); }
 6406+ ret.push(t);
 6407+ }
 6408+ else { // plain HTML
 6409+ ret.push(splitted[i]);
 6410+ }
 6411+ }
 6412+ return ret;
 6413+}
 6414+
 6415+
 6416+function navlinkSubstituteHTML(s) {
 6417+ return s.split('*').join(getValueOf('popupNavLinkSeparator'))
 6418+ .split('<menurow>').join('<li class="popup_menu_row">')
 6419+ .split('</menurow>').join('</li>')
 6420+ .split('<menu>').join('<ul class="popup_menu">')
 6421+ .split('</menu>').join('</ul>');
 6422+
 6423+}
 6424+
 6425+function navlinkDepth(magic,s) {
 6426+ return s.split('<' + magic + '>').length - s.split('</' + magic + '>').length;
 6427+}
 6428+
 6429+
 6430+// navlinkString: * becomes the separator
 6431+// <<foo|bar=baz|fubar>> becomes a foo-link with attribute bar='baz'
 6432+// and visible text 'fubar'
 6433+// if(test){...} and if(test){...}else{...} work too (nested ok)
 6434+
 6435+function navlinkStringToHTML(s,article,params) {
 6436+ //limitAlert(navlinkStringToHTML, 5, 'navlinkStringToHTML\n' + article + '\n' + (typeof article));
 6437+ var p=navlinkStringToArray(s,article,params);
 6438+ var html='';
 6439+ var menudepth = 0; // nested menus not currently allowed, but doesn't do any harm to code for it
 6440+ var menurowdepth = 0;
 6441+ var wrapping = null;
 6442+ for (var i=0; i<p.length; ++i) {
 6443+ if (typeof p[i] == typeof '') {
 6444+ html+=navlinkSubstituteHTML(p[i]);
 6445+ menudepth += navlinkDepth('menu', p[i]);
 6446+ menurowdepth += navlinkDepth('menurow', p[i]);
 6447+// if (menudepth === 0) {
 6448+// tagType='span';
 6449+// } else if (menurowdepth === 0) {
 6450+// tagType='li';
 6451+// } else {
 6452+// tagType = null;
 6453+// }
 6454+ } else if (typeof p[i].type != 'undefined' && p[i].type=='navlinkTag') {
 6455+ if (menudepth > 0 && menurowdepth === 0) {
 6456+ html += '<li class="popup_menu_item">' + p[i].html() + '</li>';
 6457+ } else {
 6458+ html+=p[i].html();
 6459+ }
 6460+ }
 6461+ }
 6462+ return html;
 6463+}
 6464+
 6465+function navlinkTag() {
 6466+ this.type='navlinkTag';
 6467+}
 6468+
 6469+navlinkTag.prototype.html=function () {
 6470+ this.getNewWin();
 6471+ this.getPrintFunction();
 6472+ var html='';
 6473+ var opening, closing;
 6474+ var tagType='span';
 6475+ if (!tagType) {
 6476+ opening = ''; closing = '';
 6477+ } else {
 6478+ opening = '<' + tagType + ' class="popup_' + this.id + '">';
 6479+ closing = '</' + tagType + '>';
 6480+ }
 6481+ if (typeof this.print!='function') {
 6482+ errlog ('Oh dear - invalid print function for a navlinkTag, id='+this.id);
 6483+ } else {
 6484+ html=this.print(this);
 6485+ if (typeof html != typeof '') {html='';}
 6486+ else if (typeof this.shortcut!='undefined') html=addPopupShortcut(html, this.shortcut);
 6487+ }
 6488+ return opening + html + closing;
 6489+};
 6490+
 6491+navlinkTag.prototype.getNewWin=function() {
 6492+ getValueOf('popupLinksNewWindow');
 6493+ if (typeof pg.option.popupLinksNewWindow[this.id] === 'undefined') { this.newWin=null; }
 6494+ this.newWin=pg.option.popupLinksNewWindow[this.id];
 6495+}
 6496+
 6497+navlinkTag.prototype.getPrintFunction=function() { //think about this some more
 6498+ // this.id and this.article should already be defined
 6499+ if (typeof this.id!=typeof '' || typeof this.article!=typeof {} ) { return; }
 6500+ var html='';
 6501+ var a,t;
 6502+
 6503+ this.noPopup=1;
 6504+ switch (this.id) {
 6505+ case 'contribs': case 'history': case 'whatLinksHere':
 6506+ case 'userPage': case 'monobook': case 'userTalk':
 6507+ case 'talk': case 'article': case 'lastEdit':
 6508+ this.noPopup=null;
 6509+ }
 6510+ switch (this.id) {
 6511+ case 'email': case 'contribs': case 'block': case 'unblock':
 6512+ case 'userlog': case 'userSpace': case 'deletedContribs':
 6513+ this.article=this.article.userName();
 6514+ }
 6515+
 6516+ switch (this.id) {
 6517+ case 'userTalk': case 'newUserTalk': case 'editUserTalk':
 6518+ case 'userPage': case 'monobook': case 'editMonobook': case 'blocklog':
 6519+ this.article=this.article.userName(true);
 6520+ // fall through; no break
 6521+ case 'pagelog': case 'deletelog': case 'protectlog':
 6522+ delete this.oldid;
 6523+ }
 6524+
 6525+ if (this.id=='editMonobook' || this.id=='monobook') { this.article.append('/monobook.js'); }
 6526+
 6527+ if (this.id != 'mainlink') {
 6528+ // FIXME anchor handling should be done differently with Title object
 6529+ this.article=this.article.removeAnchor();
 6530+ // if (typeof this.text=='undefined') this.text=popupString(this.id);
 6531+ }
 6532+
 6533+ switch (this.id) {
 6534+ case 'undelete': this.print=specialLink; this.specialpage='Undelete'; this.sep='/'; break;
 6535+ case 'whatLinksHere': this.print=specialLink; this.specialpage='Whatlinkshere'; break;
 6536+ case 'relatedChanges': this.print=specialLink; this.specialpage='Recentchangeslinked'; break;
 6537+ case 'move': this.print=specialLink; this.specialpage='Movepage'; break;
 6538+ case 'contribs': this.print=specialLink; this.specialpage='Contributions'; break;
 6539+ case 'deletedContribs':this.print=specialLink; this.specialpage='Deletedcontributions'; break;
 6540+ case 'email': this.print=specialLink; this.specialpage='Emailuser'; break;
 6541+ case 'block': this.print=specialLink; this.specialpage='Blockip'; this.sep='&ip='; break;
 6542+ case 'unblock': this.print=specialLink; this.specialpage='Ipblocklist'; this.sep='&action=unblock&ip='; break;
 6543+ case 'userlog': this.print=specialLink; this.specialpage='Log'; this.sep='&user='; break;
 6544+ case 'blocklog': this.print=specialLink; this.specialpage='Log'; this.sep='&type=block&page='; break;
 6545+ case 'pagelog': this.print=specialLink; this.specialpage='Log'; this.sep='&page='; break;
 6546+ case 'protectlog': this.print=specialLink; this.specialpage='Log'; this.sep='&type=protect&page='; break;
 6547+ case 'deletelog': this.print=specialLink; this.specialpage='Log'; this.sep='&type=delete&page='; break;
 6548+ case 'userSpace': this.print=specialLink; this.specialpage='Prefixindex'; this.sep='&namespace=2&from='; break;
 6549+ case 'search': this.print=specialLink; this.specialpage='Search'; this.sep='&fulltext=Search&search='; break;
 6550+ case 'history': case 'historyfeed': case 'unwatch': case 'watch':
 6551+ case 'unprotect': case 'protect':
 6552+ this.print=wikiLink; this.action=this.id; break;
 6553+
 6554+ case 'delete':
 6555+ this.print=wikiLink; this.action='delete';
 6556+ if (this.article.namespace()==pg.ns.image) {
 6557+ var img=this.article.stripNamespace();
 6558+ this.action+='&image='+img;
 6559+ }
 6560+ break;
 6561+
 6562+ case 'markpatrolled':
 6563+ case 'edit': // editOld should keep the oldid, but edit should not.
 6564+ delete this.oldid; // fall through
 6565+ case 'view': case 'purge': case 'render':
 6566+ this.print=wikiLink;
 6567+ this.action=this.id; break;
 6568+ case 'raw':
 6569+ this.print=wikiLink; this.action='raw&ctype=text/css'; break;
 6570+ case 'new':
 6571+ this.print=wikiLink; this.action='edit&section=new'; break;
 6572+ case 'mainlink':
 6573+ if (typeof this.text=='undefined') { this.text=this.article.toString().entify(); }
 6574+ if (getValueOf('popupSimplifyMainLink') && isInStrippableNamespace(this.article)) {
 6575+ var s=this.text.split('/'); this.text=s[s.length-1];
 6576+ if (this.text=='' && s.length > 1) { this.text=s[s.length-2]; }
 6577+ }
 6578+ this.print=titledWikiLink;
 6579+ if (typeof this.title=='undefined' && pg.current.link && typeof pg.current.link.href != 'undefined') {
 6580+ this.title=safeDecodeURI((pg.current.link.originalTitle)?pg.current.link.originalTitle:this.article);
 6581+ if (typeof this.oldid != 'undefined' && this.oldid) {
 6582+ this.title=tprintf('Revision %s of %s', [this.oldid, this.title]);
 6583+ }
 6584+ }
 6585+ this.action='view'; break;
 6586+ case 'userPage':
 6587+ case 'article':
 6588+ case 'monobook':
 6589+ case 'editMonobook':
 6590+ case 'editArticle':
 6591+ delete this.oldid;
 6592+ //alert(this.id+'\n'+this.article + '\n'+ typeof this.article);
 6593+ this.article=this.article.articleFromTalkOrArticle();
 6594+ //alert(this.id+'\n'+this.article + '\n'+ typeof this.article);
 6595+ this.print=wikiLink;
 6596+ if (this.id.indexOf('edit')==0) {
 6597+ this.action='edit';
 6598+ } else { this.action='view';}
 6599+ break;
 6600+ case 'userTalk':
 6601+ case 'talk':
 6602+ this.article=this.article.talkPage();
 6603+ delete this.oldid;
 6604+ this.print=wikiLink;
 6605+ this.action='view'; break;
 6606+ case 'arin':
 6607+ this.print=arinLink; break;
 6608+ case 'count':
 6609+ this.print=editCounterLink; break;
 6610+ case 'google':
 6611+ this.print=googleLink; break;
 6612+ case 'editors':
 6613+ this.print=editorListLink; break;
 6614+ case 'globalsearch':
 6615+ this.print=globalSearchLink; break;
 6616+ case 'lastEdit':
 6617+ this.print=titledDiffLink;
 6618+ this.title=popupString('Show the last edit');
 6619+ this.from='prev'; this.to='cur'; break;
 6620+ case 'oldEdit':
 6621+ this.print=titledDiffLink;
 6622+ this.title=popupString('Show the edit made to get revision') + ' ' + this.oldid;
 6623+ this.from='prev'; this.to=this.oldid; break;
 6624+ case 'editOld':
 6625+ this.print=wikiLink; this.action='edit'; break;
 6626+ case 'undo':
 6627+ this.print=wikiLink; this.action='edit&undo='; break;
 6628+ case 'markpatrolled':
 6629+ this.print=wikiLink; this.action='markpatrolled';
 6630+ case 'revert':
 6631+ this.print=wikiLink; this.action='revert'; break;
 6632+ case 'nullEdit':
 6633+ this.print=wikiLink; this.action='nullEdit'; break;
 6634+ case 'diffCur':
 6635+ this.print=titledDiffLink;
 6636+ this.title=tprintf('Show changes since revision %s', [this.oldid]);
 6637+ this.from=this.oldid; this.to='cur'; break;
 6638+ case 'editUserTalk':
 6639+ case 'editTalk':
 6640+ delete this.oldid;
 6641+ this.article=this.article.talkPage();
 6642+ this.action='edit'; this.print=wikiLink; break;
 6643+ case 'newUserTalk':
 6644+ case 'newTalk':
 6645+ this.article=this.article.talkPage();
 6646+ this.action='edit&section=new'; this.print=wikiLink; break;
 6647+ case 'lastContrib':
 6648+ case 'sinceMe':
 6649+ this.print=magicHistoryLink;
 6650+ break;
 6651+ case 'togglePreviews':
 6652+ this.text=popupString(pg.option.simplePopups ? 'enable previews' : 'disable previews');
 6653+ case 'disablePopups': case 'purgePopups':
 6654+ this.print=popupMenuLink;
 6655+ break;
 6656+ default:
 6657+ this.print=function () {return 'Unknown navlink type: '+this.id+''};
 6658+ }
 6659+};
 6660+//
 6661+// end navlinks
 6662+//////////////////////////////////////////////////
 6663+//</NOLITE>
 6664+// ENDFILE: navlinks.js
 6665+// STARTFILE: shortcutkeys.js
 6666+//<NOLITE>
 6667+function popupHandleKeypress(evt) {
 6668+ var keyCode = window.event ? window.event.keyCode : ( evt.keyCode ? evt.keyCode : evt.which);
 6669+ if (!keyCode || !pg.current.link || !pg.current.link.navpopup) { return; }
 6670+ if (keyCode==27) { // escape
 6671+ killPopup();
 6672+ return false; // swallow keypress
 6673+ }
 6674+
 6675+ var letter=String.fromCharCode(keyCode);
 6676+ var links=pg.current.link.navpopup.mainDiv.getElementsByTagName('A');
 6677+ var startLink=0;
 6678+ var i,j;
 6679+
 6680+ if (popupHandleKeypress.lastPopupLinkSelected) {
 6681+ for (i=0; i<links.length; ++i) {
 6682+ if (links[i]==popupHandleKeypress.lastPopupLinkSelected) { startLink=i; }
 6683+ }
 6684+ }
 6685+ for (j=0; j<links.length; ++j) {
 6686+ i=(startLink + j + 1) % links.length;
 6687+ if (links[i].getAttribute('popupkey')==letter) {
 6688+ if (evt && evt.preventDefault) evt.preventDefault();
 6689+ links[i].focus();
 6690+ popupHandleKeypress.lastPopupLinkSelected=links[i];
 6691+ return false; // swallow keypress
 6692+ }
 6693+ }
 6694+
 6695+ // pass keypress on
 6696+ if (document.oldPopupOnkeypress) { return document.oldPopupOnkeypress(evt); }
 6697+ return true;
 6698+}
 6699+
 6700+function addPopupShortcuts() {
 6701+ if (document.onkeypress!=popupHandleKeypress) {
 6702+ document.oldPopupOnkeypress=document.onkeypress;
 6703+ }
 6704+ document.onkeypress=popupHandleKeypress;
 6705+}
 6706+
 6707+function rmPopupShortcuts() {
 6708+ popupHandleKeypress.lastPopupLinkSelected=null;
 6709+ try {
 6710+ if (document.oldPopupOnkeypress && document.oldPopupOnkeypress==popupHandleKeypress) {
 6711+ // panic
 6712+ document.onkeypress=null; //function () {};
 6713+ return;
 6714+ }
 6715+ document.onkeypress=document.oldPopupOnkeypress;
 6716+ } catch (nasties) { /* IE goes here */ }
 6717+}
 6718+
 6719+
 6720+function addLinkProperty(html, property) {
 6721+ // take "<a href=...>...</a> and add a property
 6722+ // not sophisticated at all, easily broken
 6723+ var i=html.indexOf('>');
 6724+ if (i<0) { return html; }
 6725+ return html.substring(0,i) + ' ' + property + html.substring(i);
 6726+}
 6727+
 6728+function addPopupShortcut(html, key) {
 6729+ if (!getValueOf('popupShortcutKeys')) { return html; }
 6730+ var ret= addLinkProperty(html, 'popupkey="'+key+'"');
 6731+ if (key==' ') { key=popupString('spacebar'); }
 6732+ return ret.replace(RegExp('^(.*?)(title=")(.*?)(".*)$', 'i'),'$1$2$3 ['+key+']$4');
 6733+}
 6734+//</NOLITE>
 6735+// ENDFILE: shortcutkeys.js
 6736+// STARTFILE: diffpreview.js
 6737+//<NOLITE>
 6738+function loadDiff(article, oldid, diff, navpop) {
 6739+ navpop.diffData={};
 6740+ var oldRev, newRev;
 6741+ switch (diff) {
 6742+ case 'cur':
 6743+ switch ( oldid ) {
 6744+ case null:
 6745+ case '':
 6746+ case 'prev':
 6747+ // eg newmessages diff link
 6748+ oldRev='0&direction=prev';
 6749+ newRev=0;
 6750+ break;
 6751+ default:
 6752+ oldRev = oldid;
 6753+ newRev = 0;
 6754+ }
 6755+ break;
 6756+ case 'prev':
 6757+ oldRev = ( oldid || 0 ) + '&direction=prev'; newRev = oldid; break;
 6758+ case 'next':
 6759+ oldRev = oldid; newRev = oldid + '&direction=next';
 6760+ break;
 6761+ default:
 6762+ oldRev = oldid || 0; newRev = diff || 0; break;
 6763+ }
 6764+ oldRev = oldRev || 0;
 6765+ newRev = newRev || 0;
 6766+
 6767+ var go = function() {
 6768+ pendingNavpopTask(navpop);
 6769+ getWiki(article, doneDiffNew, newRev, navpop);
 6770+
 6771+ pendingNavpopTask(navpop);
 6772+ getWiki(article, doneDiffOld, oldRev, navpop);
 6773+
 6774+ var tz = Cookie.read('popTz');
 6775+ if ( (window.wgEnableAPI || wgEnableAPI) && getValueOf('popupAdjustDiffDates') && tz===null) {
 6776+ pendingNavpopTask(navpop);
 6777+ getPageWithCaching(pg.wiki.wikibase + '/api.php?format=json&action=query&meta=userinfo&uiprop=options',
 6778+ function(d) {
 6779+ completedNavpopTask(navpop);
 6780+ setTimecorrectionCookie(d);
 6781+ if (diffDownloadsComplete(navpop)) { insertDiff(navpop); }
 6782+ }, navpop);
 6783+ }
 6784+ return true; // remove hook once run
 6785+ }
 6786+ if (navpop.visible || !getValueOf('popupLazyDownloads')) { go(); }
 6787+ else { navpop.addHook(go, 'unhide', 'before', 'DOWNLOAD_DIFFS'); }
 6788+}
 6789+
 6790+function setTimecorrectionCookie(d) {
 6791+ try {
 6792+ var jsobj=getJsObj(d.data);
 6793+ var tz=jsobj.query.userinfo.options.timecorrection;
 6794+ } catch (someError) {
 6795+ logerr( 'setTimecorretion failed' );
 6796+ return;
 6797+ }
 6798+ Cookie.create( 'popTz', getTimeOffset(tz), 1);
 6799+}
 6800+
 6801+function doneDiff(download, isOld) {
 6802+ if (!download.owner || !download.owner.diffData) { return; }
 6803+ var navpop=download.owner;
 6804+ var label= (isOld) ? 'Old' : 'New';
 6805+ var otherLabel=(isOld) ? 'New' : 'Old';
 6806+ navpop.diffData[label]=download;
 6807+ completedNavpopTask(download.owner);
 6808+ if (diffDownloadsComplete(navpop)) { insertDiff(navpop); }
 6809+}
 6810+
 6811+function diffDownloadsComplete(navpop) {
 6812+ if ( Cookie.read('popTz')===null) { return false; }
 6813+ return navpop.diffData.Old && navpop.diffData.New;
 6814+}
 6815+
 6816+function doneDiffNew(download) { doneDiff(download, false); }
 6817+function doneDiffOld(download) { doneDiff(download, true); }
 6818+
 6819+function rmBoringLines(a,b,context) {
 6820+
 6821+ if (typeof context == 'undefined') { context=2; }
 6822+ // this is fairly slow... i think it's quicker than doing a word-based diff from the off, though
 6823+ var aa=[], aaa=[];
 6824+ var bb=[], bbb=[];
 6825+ var i, j;
 6826+
 6827+ // first, gather all disconnected nodes in a and all crossing nodes in a and b
 6828+ for (i=0; i<a.length; ++i ) {
 6829+ if(!a[i].paired) { aa[i]=1; }
 6830+ else if (countCrossings(b,a,i, true)) {
 6831+ aa[i]=1;
 6832+ bb[ a[i].row ] = 1;
 6833+ }
 6834+ }
 6835+
 6836+ // pick up remaining disconnected nodes in b
 6837+ for (i=0; i<b.length; ++i ) {
 6838+ if (bb[i]==1) { continue; }
 6839+ if(!b[i].paired) { bb[i]=1; }
 6840+ }
 6841+
 6842+ // another pass to gather context: we want the neighbours of included nodes which are not yet included
 6843+ // we have to add in partners of these nodes, but we don't want to add context for *those* nodes in the next pass
 6844+ for (i=0; i<b.length; ++i) {
 6845+ if ( bb[i] == 1 ) {
 6846+ for (j=max(0,i-context); j < min(b.length, i+context); ++j) {
 6847+ if ( !bb[j] ) { bb[j] = 1; aa[ b[j].row ] = 0.5; }
 6848+ }
 6849+ }
 6850+ }
 6851+
 6852+ for (i=0; i<a.length; ++i) {
 6853+ if ( aa[i] == 1 ) {
 6854+ for (j=max(0,i-context); j < min(a.length, i+context); ++j) {
 6855+ if ( !aa[j] ) { aa[j] = 1; bb[ a[j].row ] = 0.5; }
 6856+ }
 6857+ }
 6858+ }
 6859+
 6860+ for (i=0; i<bb.length; ++i) {
 6861+ if (bb[i] > 0) { // it's a row we need
 6862+ if (b[i].paired) { bbb.push(b[i].text); } // joined; partner should be in aa
 6863+ else {
 6864+ bbb.push(b[i]);
 6865+ }
 6866+ }
 6867+ }
 6868+ for (i=0; i<aa.length; ++i) {
 6869+ if (aa[i] > 0) { // it's a row we need
 6870+ if (a[i].paired) { aaa.push(a[i].text); } // joined; partner should be in aa
 6871+ else {
 6872+ aaa.push(a[i]);
 6873+ }
 6874+ }
 6875+ }
 6876+
 6877+ return { a: aaa, b: bbb};
 6878+}
 6879+
 6880+function stripOuterCommonLines(a,b,context) {
 6881+ var i=0;
 6882+ while (i<a.length && i < b.length && a[i]==b[i]) { ++i; }
 6883+ var j=a.length-1; var k=b.length-1;
 6884+ while ( j>=0 && k>=0 && a[j]==b[k] ) { --j; --k; }
 6885+
 6886+ return { a: a.slice(max(0,i - 1 - context), min(a.length+1, j + context+1)),
 6887+ b: b.slice(max(0,i - 1 - context), min(b.length+1, k + context+1)) };
 6888+}
 6889+
 6890+function insertDiff(navpop) {
 6891+ // for speed reasons, we first do a line-based diff, discard stuff that seems boring, then do a word-based diff
 6892+ // FIXME: sometimes this gives misleading diffs as distant chunks are squashed together
 6893+ var oldlines=navpop.diffData.Old.data.split('\n');
 6894+ var newlines=navpop.diffData.New.data.split('\n');
 6895+ var inner=stripOuterCommonLines(oldlines,newlines,getValueOf('popupDiffContextLines'));
 6896+ oldlines=inner.a; newlines=inner.b;
 6897+ var truncated=false;
 6898+ getValueOf('popupDiffMaxLines');
 6899+ if (oldlines.length > pg.option.popupDiffMaxLines || newlines.length > pg.option.popupDiffMaxLines) {
 6900+ // truncate
 6901+ truncated=true;
 6902+ inner=stripOuterCommonLines(oldlines.slice(0,pg.option.popupDiffMaxLines),
 6903+ newlines.slice(0,pg.option.popupDiffMaxLines),
 6904+ pg.option.popupDiffContextLines);
 6905+ oldlines=inner.a; newlines=inner.b;
 6906+ }
 6907+
 6908+ var lineDiff=diff(oldlines, newlines);
 6909+ var lines2=rmBoringLines(lineDiff.o, lineDiff.n);
 6910+ var oldlines2=lines2.a; var newlines2=lines2.b;
 6911+
 6912+ var simpleSplit = !String.prototype.parenSplit.isNative;
 6913+ var html='<hr>';
 6914+ if (getValueOf('popupDiffDates')) {
 6915+ html += diffDatesTable(navpop.diffData.Old, navpop.diffData.New);
 6916+ html += '<hr>';
 6917+ }
 6918+ html += shortenDiffString(
 6919+ diffString(oldlines2.join('\n'), newlines2.join('\n'), simpleSplit),
 6920+ getValueOf('popupDiffContextCharacters') ).join('<hr>');
 6921+ setPopupTipsAndHTML(html.split('\n').join('<br>') +
 6922+ (truncated ? '<hr><b>'+popupString('Diff truncated for performance reasons')+'</b>' : '') ,
 6923+ 'popupPreview', navpop.idNumber);
 6924+}
 6925+
 6926+function diffDatesTable( oldDl, newDl ) {
 6927+ var html='<table class="popup_diff_dates">';
 6928+ html += diffDatesTableRow( newDl, tprintf('New revision'));
 6929+ html += diffDatesTableRow( oldDl, tprintf('Old revision'));
 6930+ html += '</table>';
 6931+ return html;
 6932+}
 6933+function diffDatesTableRow( dl, label ) {
 6934+ var txt='';
 6935+ if (!dl) {
 6936+ txt=popupString('Something went wrong :-(');
 6937+ } else if (!dl.lastModified) {
 6938+ txt= (/^\s*$/.test(dl.data)) ?
 6939+ popupString('Empty revision, maybe non-existent') : popupString('Unknown date');
 6940+ } else {
 6941+ var datePrint=getValueOf('popupDiffDatePrinter');
 6942+ if (typeof dl.lastModified[datePrint] == 'function') {
 6943+ if (getValueOf('popupAdjustDiffDates')) {
 6944+ var off;
 6945+ if (off=Cookie.read('popTz')) {
 6946+ var d2=adjustDate(dl.lastModified, off);
 6947+ txt = dayFormat(d2, true) + ' ' + timeFormat(d2, true);
 6948+ }
 6949+ } else {
 6950+ txt = dl.lastModified[datePrint]();
 6951+ }
 6952+ } else {
 6953+ txt = tprintf('Invalid %s %s', ['popupDiffDatePrinter', datePrint]);
 6954+ }
 6955+ }
 6956+ var revlink = generalLink({url: dl.url.replace(/&.*?(oldid=[0-9]+(?:&direction=[^&]*)?).*/, '&$1'),
 6957+ text: label, title: label});
 6958+ return simplePrintf('<tr><td>%s</td><td>%s</td></tr>', [ revlink, txt ]);
 6959+}
 6960+//</NOLITE>
 6961+// ENDFILE: diffpreview.js
 6962+// STARTFILE: links.js
 6963+//<NOLITE>
 6964+/////////////////////
 6965+// LINK GENERATION //
 6966+/////////////////////
 6967+
 6968+// titledDiffLink --> titledWikiLink --> generalLink
 6969+// wikiLink --> titledWikiLink --> generalLink
 6970+// editCounterLink --> generalLink
 6971+
 6972+function titledDiffLink(l) { // article, text, title, from, to) {
 6973+ return titledWikiLink({article: l.article, action: l.to + '&oldid=' + l.from,
 6974+ newWin: l.newWin,
 6975+ noPopup: l.noPopup,
 6976+ text: l.text, title: l.title,
 6977+ /* hack: no oldid here */
 6978+ actionName: 'diff'});
 6979+}
 6980+
 6981+
 6982+function wikiLink(l) {
 6983+ //{article:article, action:action, text:text, oldid, newid}) {
 6984+ if (! (typeof l.article == typeof {}
 6985+ && typeof l.action == typeof '' && typeof l.text==typeof '')) return null;
 6986+ if (typeof l.oldid == 'undefined') { l.oldid=null; }
 6987+ var savedOldid = l.oldid;
 6988+ if (!/^(edit|view|revert|render)$|^raw/.test(l.action)) { l.oldid=null; }
 6989+ var hint=popupString(l.action + 'Hint'); // revertHint etc etc etc
 6990+ var oldidData=[l.oldid, safeDecodeURI(l.article)];
 6991+ var revisionString = tprintf('revision %s of %s', oldidData);
 6992+ log('revisionString='+revisionString);
 6993+ switch (l.action) {
 6994+ case 'edit&section=new': hint = popupString('newSectionHint'); break;
 6995+ case 'edit&undo=':
 6996+ if (l.diff && l.diff != 'prev' && savedOldid ) {
 6997+ l.action += l.diff + '&undoafter=' + savedOldid;
 6998+ } else if (savedOldid) {
 6999+ l.action += savedOldid;
 7000+ }
 7001+ hint = popupString('undoHint');
 7002+ break;
 7003+ case 'raw&ctype=text/css': hint=popupString('rawHint'); break;
 7004+ case 'revert':
 7005+ if (!window.wgEnableAPI || !wgEnableAPI) {
 7006+ alert( 'This function of navigation popups now requires a MediaWiki ' +
 7007+ 'installation with the API enabled.');
 7008+ break;
 7009+ }
 7010+ var p=parseParams(pg.current.link.href);
 7011+ l.action='edit&autoclick=wpSave&actoken=' + autoClickToken() + '&autosummary=' + revertSummary(l.oldid, p.diff);
 7012+ if (p.diff=='prev') {
 7013+ l.action += '&direction=prev';
 7014+ revisionString = tprintf('the revision prior to revision %s of %s', oldidData);
 7015+ }
 7016+ if (getValueOf('popupRevertSummaryPrompt')) { l.action += '&autosummaryprompt=true'; }
 7017+ if (getValueOf('popupMinorReverts')) { l.action += '&autominor=true'; }
 7018+ log('revisionString is now '+revisionString);
 7019+ break;
 7020+ case 'nullEdit':
 7021+ l.action='edit&autoclick=wpSave&actoken=' + autoClickToken() + '&autosummary=null';
 7022+ break;
 7023+ case 'historyfeed':
 7024+ l.action='history&feed=rss';
 7025+ break;
 7026+ case 'markpatrolled':
 7027+ l.action='markpatrolled&rcid='+l.rcid;
 7028+ }
 7029+
 7030+ if (hint) {
 7031+ if (l.oldid) {
 7032+ hint = simplePrintf(hint, [revisionString]);
 7033+ }
 7034+ else {
 7035+ hint = simplePrintf(hint, [safeDecodeURI(l.article)]);
 7036+ }
 7037+ }
 7038+ else {
 7039+ hint = safeDecodeURI(l.article + '&action=' + l.action) + (l.oldid) ? '&oldid='+l.oldid : '';
 7040+ }
 7041+
 7042+ return titledWikiLink({article: l.article, action: l.action, text: l.text, newWin:l.newWin,
 7043+ title: hint, oldid: l.oldid, noPopup: l.noPopup});
 7044+}
 7045+
 7046+function revertSummary(oldid, diff) {
 7047+ var ret='';
 7048+ if (diff == 'prev') {
 7049+ ret=getValueOf('popupQueriedRevertToPreviousSummary');
 7050+ } else { ret = getValueOf('popupQueriedRevertSummary'); }
 7051+ return ret + '&autorv=' + oldid;
 7052+}
 7053+
 7054+function titledWikiLink(l) {
 7055+ // possible properties of argument:
 7056+ // article, action, text, title, oldid, actionName, className, noPopup
 7057+ // oldid = null is fine here
 7058+
 7059+ // article and action are mandatory args
 7060+
 7061+ if (typeof l.article == 'undefined' || typeof l.action=='undefined') {
 7062+ errlog('got undefined article or action in titledWikiLink');
 7063+ return null;
 7064+ }
 7065+
 7066+ var base = pg.wiki.titlebase + l.article.urlString();
 7067+ var url=base;
 7068+
 7069+ if (typeof l.actionName=='undefined' || !l.actionName) { l.actionName='action'; }
 7070+
 7071+ // no need to add &action=view, and this confuses anchors
 7072+ if (l.action != 'view') { url = base + '&' + l.actionName + '=' + l.action; }
 7073+
 7074+ if (typeof l.oldid!='undefined' && l.oldid) { url+='&oldid='+l.oldid; }
 7075+
 7076+ var cssClass=pg.misc.defaultNavlinkClassname;
 7077+ if (typeof l.className!='undefined' && l.className) { cssClass=l.className; }
 7078+
 7079+ return generalNavLink({url: url, newWin: l.newWin,
 7080+ title: (typeof l.title != 'undefined') ? l.title : null,
 7081+ text: (typeof l.text!='undefined')?l.text:null,
 7082+ className: cssClass, noPopup:l.noPopup});
 7083+}
 7084+
 7085+function getLastContrib(wikipage, newWin) {
 7086+ getHistoryInfo(wikipage, function(x){processLastContribInfo(x,{page: wikipage, newWin: newWin})});
 7087+}
 7088+function processLastContribInfo(info, stuff) {
 7089+ if(!info.edits || !info.edits.length) { alert('Popups: an odd thing happened. Please retry.'); return; }
 7090+ if(!info.firstNewEditor) {
 7091+ alert(tprintf('Only found one editor: %s made %s edits', [info.edits[0].editor,info.edits.length]));
 7092+ return;
 7093+ }
 7094+ var newUrl=pg.wiki.titlebase + new Title(stuff.page).urlString() + '&diff=cur&oldid='+info.firstNewEditor.oldid;
 7095+ displayUrl(newUrl, stuff.newWin);
 7096+}
 7097+function getDiffSinceMyEdit(wikipage, newWin) {
 7098+ getHistoryInfo(wikipage, function(x){processDiffSinceMyEdit(x,{page: wikipage, newWin: newWin})});
 7099+}
 7100+function processDiffSinceMyEdit(info, stuff) {
 7101+ if(!info.edits || !info.edits.length) { alert('Popups: something fishy happened. Please try again.'); return; }
 7102+ var friendlyName=stuff.page.split('_').join(' ');
 7103+ if(!info.myLastEdit) {
 7104+ alert(tprintf('Couldn\'t find an edit by %s\nin the last %s edits to\n%s',
 7105+ [info.userName, getValueOf('popupHistoryLimit'), friendlyName]));
 7106+ return;
 7107+ }
 7108+ if(info.myLastEdit.index==0) {
 7109+ alert(tprintf("%s seems to be the last editor to the page %s", [info.userName, friendlyName]));
 7110+ return;
 7111+ }
 7112+ var newUrl=pg.wiki.titlebase + new Title(stuff.page).urlString() + '&diff=cur&oldid='+ info.myLastEdit.oldid;
 7113+ displayUrl(newUrl, stuff.newWin);
 7114+}
 7115+function displayUrl(url, newWin){
 7116+ if(newWin) { window.open(url); }
 7117+ else { document.location=url; }
 7118+}
 7119+
 7120+function purgePopups() {
 7121+ processAllPopups(true);
 7122+ setupCache(); // deletes all cached items (not browser cached, though...)
 7123+ pg.option={};
 7124+ abortAllDownloads();
 7125+}
 7126+
 7127+function processAllPopups(nullify, banish) {
 7128+ for (var i=0; i<pg.current.links.length; ++i) {
 7129+ if (!pg.current.links[i].navpopup) { continue; }
 7130+ (nullify || banish) && pg.current.links[i].navpopup.banish();
 7131+ pg.current.links[i].simpleNoMore=false;
 7132+ nullify && (pg.current.links[i].navpopup=null);
 7133+ }
 7134+}
 7135+
 7136+function disablePopups(){
 7137+ processAllPopups(false, true);
 7138+ setupTooltips(null, true);
 7139+}
 7140+
 7141+function togglePreviews() {
 7142+ processAllPopups(true, true);
 7143+ pg.option.simplePopups=!pg.option.simplePopups;
 7144+ abortAllDownloads();
 7145+}
 7146+
 7147+function magicHistoryLink(l) {
 7148+ // FIXME use onclick change href trick to sort this out instead of window.open
 7149+
 7150+ var jsUrl='', title='';
 7151+ switch(l.id) {
 7152+ case 'lastContrib':
 7153+ jsUrl=simplePrintf('javascript:getLastContrib(\'%s\',%s)',
 7154+ [l.article.toString(true).split("'").join("\\'"), l.newWin]);
 7155+ title=popupString('lastContribHint');
 7156+ break;
 7157+ case 'sinceMe':
 7158+ jsUrl=simplePrintf('javascript:getDiffSinceMyEdit(\'%s\',%s)',
 7159+ [l.article.toString(true).split("'").join("\\'"), l.newWin]);
 7160+ title=popupString('sinceMeHint');
 7161+ break;
 7162+ }
 7163+
 7164+ return generalNavLink({url: jsUrl, newWin: false, // can't have new windows with JS links, I think
 7165+ title: title, text: l.text, noPopup: l.noPopup});
 7166+}
 7167+
 7168+function popupMenuLink(l) {
 7169+ var jsUrl=simplePrintf('javascript:%s()', [l.id]);
 7170+ var title=popupString(simplePrintf('%sHint', [l.id]));
 7171+ return generalNavLink({url: jsUrl, newWin:false, title:title, text:l.text, noPopup:l.noPopup});
 7172+}
 7173+
 7174+function specialLink(l) {
 7175+ // properties: article, specialpage, text, sep
 7176+ if (typeof l.specialpage=='undefined'||!l.specialpage) return null;
 7177+ var base = pg.wiki.titlebase + pg.ns.special+':'+l.specialpage;
 7178+ if (typeof l.sep == 'undefined' || l.sep===null) l.sep='&target=';
 7179+ var article=l.article.urlString({keepSpaces: l.specialpage=='Search'});
 7180+ var hint=popupString(l.specialpage+'Hint');
 7181+ switch (l.specialpage) {
 7182+ case 'Log':
 7183+ switch (l.sep) {
 7184+ case '&user=': hint=popupString('userLogHint'); break;
 7185+ case '&type=block&page=': hint=popupString('blockLogHint'); break;
 7186+ case '&page=': hint=popupString('pageLogHint'); break;
 7187+ case '&type=protect&page=': hint=popupString('protectLogHint'); break;
 7188+ case '&type=delete&page=': hint=popupString('deleteLogHint'); break;
 7189+ default: log('Unknown log type, sep=' + l.sep); hint='Missing hint (FIXME)';
 7190+ }
 7191+ break;
 7192+ case 'Prefixindex': article += '/'; break;
 7193+ }
 7194+ if (hint) hint = simplePrintf(hint, [safeDecodeURI(l.article)]);
 7195+ else hint = safeDecodeURI(l.specialpage+':'+l.article) ;
 7196+
 7197+ var url = base + l.sep + article;
 7198+ return generalNavLink({url: url, title: hint, text: l.text, newWin:l.newWin, noPopup:l.noPopup});
 7199+}
 7200+
 7201+function generalLink(l) {
 7202+ // l.url, l.text, l.title, l.newWin, l.className, l.noPopup
 7203+ if (typeof l.url=='undefined') return null;
 7204+
 7205+ // only quotation marks in the url can screw us up now... I think
 7206+ var url=l.url.split('"').join('%22');
 7207+
 7208+ var ret='<a href="' + url + '"';
 7209+ if (typeof l.title!='undefined' && l.title) { ret += ' title="' + l.title + '"'; }
 7210+ if (l.noPopup) { ret += ' noPopup=1'; }
 7211+ var newWin;
 7212+ if (typeof l.newWin=='undefined' || l.newWin===null) { newWin=getValueOf('popupNewWindows'); }
 7213+ else { newWin=l.newWin; }
 7214+ if (newWin) { ret += ' target="_blank"'; }
 7215+ if (typeof l.className!='undefined'&&l.className) { ret+=' class="'+l.className+'"'; }
 7216+ ret += '>';
 7217+ if (typeof l.text==typeof '') { ret+= l.text; }
 7218+ ret +='</a>';
 7219+ return ret;
 7220+}
 7221+
 7222+function appendParamsToLink(linkstr, params) {
 7223+ var sp=linkstr.parenSplit(RegExp('(href="[^"]+?)"', 'i'));
 7224+ if (sp.length<2) return null;
 7225+ var ret=sp.shift() + sp.shift();
 7226+ ret += '&' + params + '"';
 7227+ ret += sp.join('');
 7228+ return ret;
 7229+}
 7230+
 7231+function changeLinkTargetLink(x) { // newTarget, text, hint, summary, clickButton, minor, title (optional) {
 7232+ if (x.newTarget) {
 7233+ log ('changeLinkTargetLink: newTarget=' + x.newTarget);
 7234+ }
 7235+ // optional: oldTarget (in wikitext)
 7236+ // if x.newTarget omitted or null, remove the link
 7237+
 7238+ //x.text=encodeURI(x.text); // this buggers things up on zh.wikipedia.org and doesn't seem necessary
 7239+ x.clickButton=encodeURI(x.clickButton);
 7240+
 7241+ // FIXME: first character of page title as well as namespace should be case insensitive
 7242+ // eg [[category:foo]] and [[Category:Foo]] are equivalent
 7243+ // this'll break if charAt(0) is nasty
 7244+ var cA=literalizeRegex(x.oldTarget);
 7245+ var chs=cA.charAt(0).toUpperCase();
 7246+ chs='['+chs + chs.toLowerCase()+']';
 7247+ var currentArticleRegexBit=encodeURIComponent(chs+cA.substring(1));
 7248+ currentArticleRegexBit=currentArticleRegexBit
 7249+ .split(RegExp('[_ ]+', 'g')).join('[_ ]+')
 7250+ .split('\\(').join('(?:%2528|\\()')
 7251+ .split('\\)').join('(?:%2529|\\))');
 7252+ // leading and trailing space should be ignored, and anchor bits optional:
 7253+ currentArticleRegexBit = '\\s*(' + currentArticleRegexBit + '(?:#[^\\[\\|]*)?)\\s*';
 7254+ // e.g. Computer (archaic) -> \s*([Cc]omputer[_ ](?:%2528|\()archaic(?:%2528|\)))\s*
 7255+
 7256+ // autoedit=s~\[\[([Cc]ad)\]\]~[[Computer-aided%20design|$1]]~g;s~\[\[([Cc]AD)[|]~[[Computer-aided%20design|~g
 7257+
 7258+ var title=x.title || wgPageName.split('_').join(' ');
 7259+ var lk=titledWikiLink({article: new Title(title), newWin:x.newWin,
 7260+ action: 'edit',
 7261+ text: x.text,
 7262+ title: x.hint,
 7263+ className: 'popup_change_title_link'
 7264+ });
 7265+ var cmd='';
 7266+ if (x.newTarget) {
 7267+ // escape '&' and other nasties
 7268+ var t=encodeURIComponent(x.newTarget);
 7269+ var s=encodeURIComponent(literalizeRegex(x.newTarget));
 7270+ cmd += 's~\\[\\['+currentArticleRegexBit+'\\]\\]~[['+t+'|$1]]~g;';
 7271+ cmd += 's~\\[\\['+currentArticleRegexBit+'[|]~[['+t+'|~g;';
 7272+ cmd += 's~\\[\\['+s + '\\|' + s + '\\]\\]~[[' + t + ']]~g';
 7273+ } else {
 7274+ cmd += 's~\\[\\['+currentArticleRegexBit+'\\]\\]~$1~g;';
 7275+ cmd += 's~\\[\\['+currentArticleRegexBit+'[|](.*?)\\]\\]~$2~g';
 7276+ }
 7277+ cmd += '&autoclick='+x.clickButton + '&actoken=' + autoClickToken();
 7278+ cmd += ( x.minor == null ) ? '' : '&autominor='+x.minor;
 7279+ cmd += ( x.watch == null ) ? '' : '&autowatch='+x.watch;
 7280+ cmd += '&autosummary='+encodeURIComponent(x.summary);
 7281+ return appendParamsToLink(lk, 'autoedit='+cmd);
 7282+}
 7283+
 7284+
 7285+function redirLink(redirMatch, article) {
 7286+ // NB redirMatch is in wikiText
 7287+ var ret='';
 7288+
 7289+ if (getValueOf('popupAppendRedirNavLinks') && getValueOf('popupNavLinks')) {
 7290+ ret += '<hr>';
 7291+ if (getValueOf('popupFixRedirs') && typeof autoEdit != 'undefined' && autoEdit) {
 7292+ log('redirLink: newTarget=' + redirMatch);
 7293+ ret += addPopupShortcut(
 7294+ changeLinkTargetLink(
 7295+ {newTarget: redirMatch, text: popupString('Redirects'),
 7296+ hint: popupString('Fix this redirect'),
 7297+ summary: simplePrintf(getValueOf('popupFixRedirsSummary'),
 7298+ [article.toString(), redirMatch ]),
 7299+ oldTarget: article.toString(),
 7300+ clickButton: getValueOf('popupRedirAutoClick'), minor: true,
 7301+ watch: getValueOf('popupWatchRedirredPages')})
 7302+ , 'R');
 7303+ ret += popupString(' to ');
 7304+ }
 7305+ else ret += popupString('Redirects') + popupString(' to ');
 7306+ return ret;
 7307+ }
 7308+
 7309+ else return '<br> ' + popupString('Redirects') + popupString(' to ') +
 7310+ titledWikiLink({article: new Title().fromWikiText(redirMatch), action: 'view', /* FIXME: newWin */
 7311+ text: safeDecodeURI(redirMatch), title: popupString('Bypass redirect')});
 7312+}
 7313+
 7314+function arinLink(l) {
 7315+ if (!saneLinkCheck(l)) { return null; }
 7316+ if ( ! l.article.isIpUser() || ! pg.wiki.wikimedia) return null;
 7317+
 7318+ var uN=l.article.userName();
 7319+
 7320+ return generalNavLink({url:'http://ws.arin.net/cgi-bin/whois.pl?queryinput=' + encodeURIComponent(uN), newWin:l.newWin,
 7321+ title: tprintf('Look up %s in ARIN whois database', [uN]),
 7322+ text: l.text, noPopup:1});
 7323+}
 7324+
 7325+function toolDbName(cookieStyle) {
 7326+ var ret=null;
 7327+ var theWiki=pg.wiki.hostname.split('.')[1];
 7328+ if (pg.wiki.hostname==pg.wiki.commons) {
 7329+ ret = 'commonswiki';
 7330+ } else {
 7331+ switch(theWiki) {
 7332+ case 'wikipedia':
 7333+ case 'wikimedia':
 7334+ ret = pg.wiki.lang + 'wiki';
 7335+ break;
 7336+ default:
 7337+ ret = pg.wiki.lang + theWiki;
 7338+ break;
 7339+ }
 7340+ }
 7341+ if (!cookieStyle) { ret+= '_p'; }
 7342+ return ret;
 7343+}
 7344+
 7345+function saneLinkCheck(l) {
 7346+ if (typeof l.article != typeof {} || typeof l.text != typeof '') { return false; }
 7347+ return true;
 7348+}
 7349+function editCounterLink(l) {
 7350+ if(!saneLinkCheck(l)) return null;
 7351+ if (! pg.wiki.wikimedia) return null;
 7352+ var uN=l.article.userName();
 7353+ var tool=getValueOf('popupEditCounterTool');
 7354+ var url;
 7355+ var soxredToolUrl='http://toolserver.org/~soxred93/count/index.php?name=$1&lang=$2&wiki=$3';
 7356+ var kateToolUrl='http://toolserver.org/~$3/cgi-bin/Tool1/wannabe_kate?username=$1&site=en.wikipedia.org&$2';
 7357+
 7358+ switch(tool) {
 7359+ case 'custom':
 7360+ url=simplePrintf(getValueOf('popupEditCounterUrl'), [ encodeURIcomponent(uN), toolDbName() ]);
 7361+ break;
 7362+ case 'kate':
 7363+ case 'interiot':
 7364+ url=simplePrintf(kateToolUrl, [ encodeURIComponent(uN), toolDbName(), tool ]);
 7365+ break;
 7366+ default:
 7367+ var theWiki=pg.wiki.hostname.split('.');
 7368+ url=simplePrintf(soxredToolUrl, [ encodeURIComponent(uN), theWiki[0], theWiki[1] ]);
 7369+ }
 7370+ return generalNavLink({url:url, title: tprintf('editCounterLinkHint', [uN]),
 7371+ newWin:l.newWin, text: l.text, noPopup:1});
 7372+}
 7373+
 7374+
 7375+function globalSearchLink(l) {
 7376+ if(!saneLinkCheck(l)) return null;
 7377+
 7378+ var base='http://vs.aka-online.de/cgi-bin/globalwpsearch.pl?timeout=120&search=';
 7379+ var article=l.article.urlString({keepSpaces:true});
 7380+
 7381+ return generalNavLink({url:base + article, newWin:l.newWin,
 7382+ title: tprintf('globalSearchHint', [article]),
 7383+ text: l.text, noPopup:1});
 7384+}
 7385+
 7386+function googleLink(l) {
 7387+ if(!saneLinkCheck(l)) return null;
 7388+
 7389+ var base='http://www.google.com/search?q=';
 7390+ var article=l.article.urlString({keepSpaces:true});
 7391+
 7392+ return generalNavLink({url:base + '%22' + article + '%22', newWin:l.newWin,
 7393+ title: tprintf('googleSearchHint', [article]),
 7394+ text: l.text, noPopup:1});
 7395+}
 7396+
 7397+function editorListLink(l) {
 7398+ if(!saneLinkCheck(l)) return null;
 7399+ var article= l.article.articleFromTalkPage() || l.article;
 7400+ var base='http://toolserver.org/~tim/cgi-bin/contribution-counter?page=';
 7401+ return generalNavLink({url:base+article.urlString(),
 7402+ title: tprintf('editorListHint', [article]),
 7403+ newWin:l.newWin, text: l.text, noPopup:1});
 7404+}
 7405+
 7406+function generalNavLink(l) {
 7407+ l.className = (l.className==null) ? 'popupNavLink' : l.className;
 7408+ return generalLink(l);
 7409+}
 7410+
 7411+//////////////////////////////////////////////////
 7412+// magic history links
 7413+//
 7414+
 7415+function getHistoryInfo(wikipage, whatNext) {
 7416+ log('getHistoryInfo');
 7417+ getHistory(wikipage, whatNext ? function(d){whatNext(processHistory(d));} : processHistory);
 7418+}
 7419+
 7420+// FIXME eliminate pg.idNumber ... how? :-(
 7421+
 7422+function getHistory(wikipage, onComplete) {
 7423+ log('getHistory');
 7424+ if( !window.wgEnableAPI || !wgEnableAPI ) {
 7425+ alert( 'This function of navigation popups now requires a MediaWiki ' +
 7426+ 'installation with the API enabled.');
 7427+ return false;
 7428+ }
 7429+ var url = pg.wiki.wikibase + '/api.php?format=json&action=query&prop=revisions&titles=' +
 7430+ new Title(wikipage).urlString() + '&rvlimit=' + getValueOf('popupHistoryLimit');
 7431+ log('getHistory: url='+url);
 7432+ return startDownload(url, pg.idNumber+'history', onComplete);
 7433+}
 7434+
 7435+function processHistory(download) {
 7436+ var jsobj = getJsObj(download.data);
 7437+ try {
 7438+ window.x=jsobj;
 7439+ var p=jsobj['query']['pages']
 7440+ for (var pageid in p) {
 7441+ var revisions=p[pageid]['revisions'];
 7442+ // we only get the first one
 7443+ break;
 7444+ }
 7445+ } catch (someError) {
 7446+ log('Something went wrong with JSON business');
 7447+ return finishProcessHistory([]);
 7448+ }
 7449+ var edits=[];
 7450+ for (var i=0; i<revisions.length; ++i) {
 7451+ edits.push({ oldid: revisions[i]['revid'], editor: revisions[i]['user'] });
 7452+ }
 7453+ log('processed ' + edits.length + ' edits');
 7454+ return finishProcessHistory(edits, wgUserName);
 7455+}
 7456+
 7457+
 7458+function finishProcessHistory(edits, userName) {
 7459+ var histInfo={};
 7460+
 7461+ histInfo.edits=edits;
 7462+ histInfo.userName=userName;
 7463+
 7464+ for (var i=0; i<edits.length; ++i) {
 7465+ if (typeof histInfo.myLastEdit == 'undefined' && userName && edits[i].editor==userName) {
 7466+ histInfo.myLastEdit={index: i, oldid: edits[i].oldid, previd: (i==0 ? null : edits[i-1].oldid)};
 7467+ }
 7468+ if (typeof histInfo.firstNewEditor == 'undefined' && edits[i].editor != edits[0].editor) {
 7469+ histInfo.firstNewEditor={index:i, oldid:edits[i].oldid, previd: (i==0 ? null : edits[i-1].oldid)};
 7470+ }
 7471+ }
 7472+ //pg.misc.historyInfo=histInfo;
 7473+ return histInfo;
 7474+}
 7475+//</NOLITE>
 7476+// ENDFILE: links.js
 7477+// STARTFILE: options.js
 7478+//////////////////////////////////////////////////
 7479+// options
 7480+
 7481+// check for cookies and existing value, else use default
 7482+function defaultize(x) {
 7483+ var val=null;
 7484+ if (x!='popupCookies') {
 7485+ defaultize('popupCookies');
 7486+ if (pg.option.popupCookies && (val=Cookie.read(x))) {
 7487+ pg.option[x]=val;
 7488+ return;
 7489+ }
 7490+ }
 7491+ if (pg.option[x]===null || typeof pg.option[x]=='undefined') {
 7492+ if (typeof window[x] != 'undefined' ) pg.option[x]=window[x];
 7493+ else pg.option[x]=pg.optionDefault[x];
 7494+ }
 7495+}
 7496+
 7497+function newOption(x, def) {
 7498+ pg.optionDefault[x]=def;
 7499+}
 7500+
 7501+function setDefault(x, def) {
 7502+ return newOption(x, def);
 7503+}
 7504+
 7505+function getValueOf(varName) {
 7506+ defaultize(varName);
 7507+ return pg.option[varName];
 7508+}
 7509+
 7510+function useDefaultOptions() { // for testing
 7511+ for (var p in pg.optionDefault) {
 7512+ pg.option[p]=pg.optionDefault[p];
 7513+ if (typeof window[p]!='undefined') { delete window[p]; }
 7514+ }
 7515+}
 7516+
 7517+function setOptions() {
 7518+ // user-settable parameters and defaults
 7519+
 7520+ // Basic options
 7521+ newOption('popupDelay', 0.5);
 7522+ newOption('popupHideDelay', 0.5);
 7523+ newOption('simplePopups', false);
 7524+ newOption('popupStructure', 'shortmenus'); // see later - default for popupStructure is 'original' if simplePopups is true
 7525+ newOption('popupActionsMenu', true);
 7526+ newOption('popupSetupMenu', true);
 7527+ newOption('popupAdminLinks', false);
 7528+ newOption('popupShortcutKeys', false);
 7529+ newOption('popupHistoricalLinks', true);
 7530+ newOption('popupOnlyArticleLinks', true);
 7531+ newOption('removeTitles', true);
 7532+ newOption('popupMaxWidth', 350);
 7533+ newOption('popupInitialWidth', false); // integer or false
 7534+ newOption('popupSimplifyMainLink', true);
 7535+ newOption('popupAppendRedirNavLinks', true);
 7536+ newOption('popupTocLinks', false);
 7537+ newOption('popupSubpopups', true);
 7538+ newOption('popupDragHandle', false /* 'popupTopLinks'*/);
 7539+ newOption('popupLazyPreviews', true);
 7540+ newOption('popupLazyDownloads', true);
 7541+ newOption('popupAllDabsStubs', false);
 7542+ newOption('popupDebugging', false);
 7543+ newOption('popupAdjustDiffDates', true);
 7544+ newOption('popupActiveNavlinks', true);
 7545+ newOption('popupModifier', false); // ctrl, shift, alt or meta
 7546+ newOption('popupModifierAction', 'enable'); // or 'disable'
 7547+
 7548+//<NOLITE>
 7549+ // images
 7550+ newOption('popupImages', true);
 7551+ newOption('imagePopupsForImages', true);
 7552+ newOption('popupNeverGetThumbs', false);
 7553+ newOption('popupImagesFromThisWikiOnly', false);
 7554+ newOption('popupMinImageWidth', 50);
 7555+ newOption('popupLoadImagesSequentially', false);
 7556+ //newOption('popupImagesToggleSize', true);
 7557+ newOption('popupThumbAction', 'imagepage'); //'sizetoggle');
 7558+ newOption('popupImageSize', 60);
 7559+
 7560+ // redirs, dabs, reversion
 7561+ newOption('popupFixRedirs', false);
 7562+ newOption('popupRedirAutoClick', 'wpDiff');
 7563+ newOption('popupFixDabs', false);
 7564+ newOption('popupRevertSummaryPrompt', false);
 7565+ newOption('popupMinorReverts', false);
 7566+ newOption('popupRedlinkRemoval', false);
 7567+ newOption('popupWatchDisambiggedPages', null);
 7568+ newOption('popupWatchRedirredPages', null);
 7569+ newOption('popupDabWiktionary', 'last');
 7570+
 7571+ // navlinks
 7572+ newOption('popupNavLinks', true);
 7573+ newOption('popupNavLinkSeparator', ' &sdot; ');
 7574+ newOption('popupLastEditLink', true);
 7575+ newOption('popupEditCounterTool', 'soxred');
 7576+ newOption('popupEditCounterUrl', '');
 7577+ newOption('popupExtraUserMenu', '');
 7578+//</NOLITE>
 7579+
 7580+ // previews etc
 7581+ newOption('popupPreviews', true);
 7582+ newOption('popupSummaryData', true);
 7583+ newOption('popupMaxPreviewSentences', 5);
 7584+ newOption('popupMaxPreviewCharacters', 600);
 7585+ newOption('popupLastModified', true);
 7586+ newOption('popupPreviewKillTemplates', true);
 7587+ newOption('popupPreviewRawTemplates', true);
 7588+ newOption('popupPreviewFirstParOnly', true);
 7589+ newOption('popupPreviewCutHeadings', true);
 7590+ newOption('popupPreviewButton', false);
 7591+ newOption('popupPreviewButtonEvent', 'click');
 7592+
 7593+//<NOLITE>
 7594+ // diffs
 7595+ newOption('popupPreviewDiffs', true);
 7596+ newOption('popupDiffMaxLines', 100);
 7597+ newOption('popupDiffContextLines', 2);
 7598+ newOption('popupDiffContextCharacters', 40);
 7599+ newOption('popupDiffDates', true);
 7600+ newOption('popupDiffDatePrinter', 'toLocaleString');
 7601+
 7602+ // edit summaries. God, these are ugly.
 7603+ newOption('popupFixDabsSummary', popupString('defaultpopupFixDabsSummary') );
 7604+ newOption('popupExtendedRevertSummary', popupString('defaultpopupExtendedRevertSummary') );
 7605+ newOption('popupTimeOffset', null);
 7606+ newOption('popupRevertSummary', popupString('defaultpopupRevertSummary') );
 7607+ newOption('popupRevertToPreviousSummary', popupString('defaultpopupRevertToPreviousSummary') );
 7608+ newOption('popupQueriedRevertSummary', popupString('defaultpopupQueriedRevertSummary') );
 7609+ newOption('popupQueriedRevertToPreviousSummary', popupString('defaultpopupQueriedRevertToPreviousSummary') );
 7610+ newOption('popupFixRedirsSummary', popupString('defaultpopupFixRedirsSummary') );
 7611+ newOption('popupRedlinkSummary', popupString('defaultpopupRedlinkSummary') );
 7612+ newOption('popupRmDabLinkSummary', popupString('defaultpopupRmDabLinkSummary') );
 7613+//</NOLITE>
 7614+ // misc
 7615+ newOption('popupCookies', false);
 7616+ newOption('popupHistoryLimit', 50);
 7617+//<NOLITE>
 7618+ newOption('popupFilters', [popupFilterStubDetect, popupFilterDisambigDetect,
 7619+ popupFilterPageSize, popupFilterCountLinks,
 7620+ popupFilterCountImages, popupFilterCountCategories,
 7621+ popupFilterLastModified]);
 7622+ newOption('extraPopupFilters', []);
 7623+ newOption('popupOnEditSelection', 'cursor');
 7624+ newOption('popupPreviewHistory', true);
 7625+ newOption('popupImageLinks', true);
 7626+ newOption('popupCategoryMembers', true);
 7627+ newOption('popupUserInfo', true);
 7628+ newOption('popupHistoryPreviewLimit', 25);
 7629+ newOption('popupContribsPreviewLimit',25);
 7630+//</NOLITE>
 7631+
 7632+ // new windows
 7633+ newOption('popupNewWindows', false);
 7634+ newOption('popupLinksNewWindow', {'lastContrib': true, 'sinceMe': true});
 7635+
 7636+ // regexps
 7637+ newOption('popupDabRegexp', '([{][{]\\s*disambig|disambig\\s*[}][}]|disamb\\s*[}][}]|dab\\s*[}][}])|[{][{]\\s*(((geo|hn|road?|school|number)dis)|[234][lc][acw]|shipindex)(\\s*[|][^}]*)?\\s*[}][}]|is a .*disambiguation.*page');
 7638+ newOption('popupStubRegexp', '(sect)?stub[}][}]|This .*-related article is a .*stub');
 7639+ newOption('popupImageVarsRegexp', 'image|image_(?:file|skyline|name|flag|seal)|cover|badge|logo');
 7640+}
 7641+// ENDFILE: options.js
 7642+// STARTFILE: strings.js
 7643+//<NOLITE>
 7644+//////////////////////////////////////////////////
 7645+// Translatable strings
 7646+//////////////////////////////////////////////////
 7647+//
 7648+// See instructions at
 7649+// http://en.wikipedia.org/wiki/Wikipedia:Tools/Navigation_popups/Translation
 7650+
 7651+pg.string = {
 7652+ /////////////////////////////////////
 7653+ // summary data, searching etc.
 7654+ /////////////////////////////////////
 7655+ 'article': 'article',
 7656+ 'category': 'category',
 7657+ 'categories': 'categories',
 7658+ 'image': 'image',
 7659+ 'images': 'images',
 7660+ 'stub': 'stub',
 7661+ 'section stub': 'section stub',
 7662+ 'Empty page': 'Empty page',
 7663+ 'kB': 'kB',
 7664+ 'bytes': 'bytes',
 7665+ 'day': 'day',
 7666+ 'days': 'days',
 7667+ 'hour': 'hour',
 7668+ 'hours': 'hours',
 7669+ 'minute': 'minute',
 7670+ 'minutes': 'minutes',
 7671+ 'second': 'second',
 7672+ 'seconds': 'seconds',
 7673+ 'week': 'week',
 7674+ 'weeks': 'weeks',
 7675+ 'search': 'search',
 7676+ 'SearchHint': 'Find English Wikipedia articles containing %s',
 7677+ 'web': 'web',
 7678+ 'global': 'global',
 7679+ 'globalSearchHint': 'Search across Wikipedias in different languages for %s',
 7680+ 'googleSearchHint': 'Google for %s',
 7681+ /////////////////////////////////////
 7682+ // article-related actions and info
 7683+ // (some actions also apply to user pages)
 7684+ /////////////////////////////////////
 7685+ 'actions': 'actions', ///// view articles and view talk
 7686+ 'popupsMenu': 'popups',
 7687+ 'togglePreviewsHint': 'Toggle preview generation in popups on this page',
 7688+ 'enable previews': 'enable previews',
 7689+ 'disable preview': 'disable previews',
 7690+ 'toggle previews': 'toggle previews',
 7691+ 'show preview': 'show preview',
 7692+ 'reset': 'reset',
 7693+ 'more...': 'more...',
 7694+ 'disable': 'disable popups',
 7695+ 'disablePopupsHint': 'Disable popups on this page. Reload page to re-enable.',
 7696+ 'historyfeedHint': 'RSS feed of recent changes to this page',
 7697+ 'purgePopupsHint': 'Reset popups, clearing all cached popup data.',
 7698+ 'PopupsHint': 'Reset popups, clearing all cached popup data.',
 7699+ 'spacebar': 'space',
 7700+ 'view': 'view',
 7701+ 'view article': 'view article',
 7702+ 'viewHint': 'Go to %s',
 7703+ 'talk': 'talk',
 7704+ 'talk page': 'talk page',
 7705+ 'this&nbsp;revision': 'this&nbsp;revision',
 7706+ 'revision %s of %s': 'revision %s of %s',
 7707+ 'Revision %s of %s': 'Revision %s of %s',
 7708+ 'the revision prior to revision %s of %s': 'the revision prior to revision %s of %s',
 7709+ 'Toggle image size': 'Click to toggle image size',
 7710+ 'del': 'del', ///// delete, protect, move
 7711+ 'delete': 'delete',
 7712+ 'deleteHint': 'Delete %s',
 7713+ 'undeleteShort': 'un',
 7714+ 'UndeleteHint': 'Show the deletion history for %s',
 7715+ 'protect': 'protect',
 7716+ 'protectHint': 'Restrict editing rights to %s',
 7717+ 'unprotectShort': 'un',
 7718+ 'unprotectHint': 'Allow %s to be edited by anyone again',
 7719+ 'move': 'move',
 7720+ 'move page': 'move page',
 7721+ 'MovepageHint': 'Change the title of %s',
 7722+ 'edit': 'edit', ///// edit articles and talk
 7723+ 'edit article': 'edit article',
 7724+ 'editHint': 'Change the content of %s',
 7725+ 'edit talk': 'edit talk',
 7726+ 'new': 'new',
 7727+ 'new topic': 'new topic',
 7728+ 'newSectionHint': 'Start a new section on %s',
 7729+ 'null edit': 'null edit',
 7730+ 'nullEditHint': 'Submit an edit to %s, making no changes ',
 7731+ 'hist': 'hist', ///// history, diffs, editors, related
 7732+ 'history': 'history',
 7733+ 'historyHint': 'List the changes made to %s',
 7734+ 'last': 'last',
 7735+ 'lastEdit': 'lastEdit',
 7736+ 'mark patrolled': 'mark patrolled',
 7737+ 'markpatrolledHint': 'Mark this edit as patrolled',
 7738+ 'show last edit': 'most recent edit',
 7739+ 'Show the last edit': 'Show the effects of the most recent change',
 7740+ 'lastContrib': 'lastContrib',
 7741+ 'last set of edits': 'latest edits',
 7742+ 'lastContribHint': 'Show the net effect of changes made by the last editor',
 7743+ 'cur': 'cur',
 7744+ 'diffCur': 'diffCur',
 7745+ 'Show changes since revision %s': 'Show changes since revision %s',
 7746+ '%s old': '%s old', // as in 4 weeks old
 7747+ 'oldEdit': 'oldEdit',
 7748+ 'purge': 'purge',
 7749+ 'purgeHint': 'Demand a fresh copy of %s',
 7750+ 'raw': 'source',
 7751+ 'rawHint': 'Download the source of %s',
 7752+ 'render': 'simple',
 7753+ 'renderHint': 'Show a plain HTML version of %s',
 7754+ 'Show the edit made to get revision': 'Show the edit made to get revision',
 7755+ 'sinceMe': 'sinceMe',
 7756+ 'changes since mine': 'diff my edit',
 7757+ 'sinceMeHint': 'Show changes since my last edit',
 7758+ 'Couldn\'t find an edit by %s\nin the last %s edits to\n%s': 'Couldn\'t find an edit by %s\nin the last %s edits to\n%s',
 7759+ 'eds': 'eds',
 7760+ 'editors': 'editors',
 7761+ 'editorListHint': 'List the users who have edited %s',
 7762+ 'related': 'related',
 7763+ 'relatedChanges': 'relatedChanges',
 7764+ 'related changes': 'related changes',
 7765+ 'RecentchangeslinkedHint': 'Show changes in articles related to %s',
 7766+ 'editOld': 'editOld', ///// edit old version, or revert
 7767+ 'rv': 'rv',
 7768+ 'revert': 'revert',
 7769+ 'revertHint': 'Revert to %s',
 7770+ 'defaultpopupRedlinkSummary': 'Removing link to empty page [[%s]] using [[:en:Wikipedia:Tools/Navigation_popups|popups]]',
 7771+ 'defaultpopupFixDabsSummary': 'Disambiguate [[%s]] to [[%s]] using [[:en:Wikipedia:Tools/Navigation_popups|popups]]',
 7772+ 'defaultpopupFixRedirsSummary': 'Redirect bypass from [[%s]] to [[%s]] using [[:en:Wikipedia:Tools/Navigation_popups|popups]]',
 7773+ 'defaultpopupExtendedRevertSummary': 'Revert to revision dated %s by %s, oldid %s using [[:en:Wikipedia:Tools/Navigation_popups|popups]]',
 7774+ 'defaultpopupRevertToPreviousSummary': 'Revert to the revision prior to revision %s using [[:en:Wikipedia:Tools/Navigation_popups|popups]]',
 7775+ 'defaultpopupRevertSummary': 'Revert to revision %s using [[:en:Wikipedia:Tools/Navigation_popups|popups]]',
 7776+ 'defaultpopupQueriedRevertToPreviousSummary': 'Revert to the revision prior to revision $1 dated $2 by $3 using [[:en:Wikipedia:Tools/Navigation_popups|popups]]',
 7777+ 'defaultpopupQueriedRevertSummary': 'Revert to revision $1 dated $2 by $3 using [[:en:Wikipedia:Tools/Navigation_popups|popups]]',
 7778+ 'defaultpopupRmDabLinkSummary': 'Remove link to dab page [[%s]] using [[:en:Wikipedia:Tools/Navigation_popups|popups]]',
 7779+ 'Redirects': 'Redirects', // as in Redirects to ...
 7780+ ' to ': ' to ', // as in Redirects to ...
 7781+ 'Bypass redirect': 'Bypass redirect',
 7782+ 'Fix this redirect': 'Fix this redirect',
 7783+ 'disambig': 'disambig', ///// add or remove dab etc.
 7784+ 'disambigHint': 'Disambiguate this link to [[%s]]',
 7785+ 'Click to disambiguate this link to:': 'Click to disambiguate this link to:',
 7786+ 'remove this link': 'remove this link',
 7787+ 'remove all links to this page from this article': 'remove all links to this page from this article',
 7788+ 'remove all links to this disambig page from this article': 'remove all links to this disambig page from this article',
 7789+ 'mainlink': 'mainlink', ///// links, watch, unwatch
 7790+ 'wikiLink': 'wikiLink',
 7791+ 'wikiLinks': 'wikiLinks',
 7792+ 'links here': 'links here',
 7793+ 'whatLinksHere': 'whatLinksHere',
 7794+ 'what links here': 'what links here',
 7795+ 'WhatlinkshereHint': 'List the pages that are hyperlinked to %s',
 7796+ 'unwatchShort': 'un',
 7797+ 'watchThingy': 'watch', // called watchThingy because {}.watch is a function
 7798+ 'watchHint': 'Add %s to my watchlist',
 7799+ 'unwatchHint': 'Remove %s from my watchlist',
 7800+ 'Only found one editor: %s made %s edits': 'Only found one editor: %s made %s edits',
 7801+ '%s seems to be the last editor to the page %s': '%s seems to be the last editor to the page %s',
 7802+ 'rss': 'rss',
 7803+ /////////////////////////////////////
 7804+ // diff previews
 7805+ /////////////////////////////////////
 7806+ 'Diff truncated for performance reasons': 'Diff truncated for performance reasons',
 7807+ 'Old revision': 'Old revision',
 7808+ 'New revision': 'New revision',
 7809+ 'Something went wrong :-(': 'Something went wrong :-(',
 7810+ 'Empty revision, maybe non-existent': 'Empty revision, maybe non-existent',
 7811+ 'Unknown date': 'Unknown date',
 7812+ /////////////////////////////////////
 7813+ // other special previews
 7814+ /////////////////////////////////////
 7815+ 'Empty category': 'Empty category',
 7816+ 'Category members (%s shown)': 'Category members (%s shown)',
 7817+ 'No image links found': 'No image links found',
 7818+ 'File links': 'File links',
 7819+ 'No image found': 'No image found',
 7820+ 'Image from Commons': 'Image from Commons',
 7821+ 'Description page': 'Description page',
 7822+ /////////////////////////////////////
 7823+ // user-related actions and info
 7824+ /////////////////////////////////////
 7825+ 'user': 'user', ///// user page, talk, email, space
 7826+ 'user&nbsp;page': 'user&nbsp;page',
 7827+ 'user talk': 'user talk',
 7828+ 'edit user talk': 'edit user talk',
 7829+ 'leave comment': 'leave comment',
 7830+ 'email': 'email',
 7831+ 'email user': 'email user',
 7832+ 'EmailuserHint': 'Send an email to %s',
 7833+ 'space': 'space', // short form for userSpace link
 7834+ 'PrefixindexHint': 'Show pages in the userspace of %s',
 7835+ 'count': 'count', ///// contributions, log
 7836+ 'edit counter': 'edit counter',
 7837+ 'editCounterLinkHint': 'Count the contributions made by %s',
 7838+ 'contribs': 'contribs',
 7839+ 'contributions': 'contributions',
 7840+ 'deletedContribs': 'deleted contributions',
 7841+ 'DeletedcontributionsHint': 'List deleted edits made by %s',
 7842+ 'ContributionsHint': 'List the contributions made by %s',
 7843+ 'log': 'log',
 7844+ 'user log': 'user log',
 7845+ 'userLogHint': 'Show %s\'s user log',
 7846+ 'arin': 'ARIN lookup', ///// ARIN lookup, block user or IP
 7847+ 'Look up %s in ARIN whois database': 'Look up %s in the ARIN whois database',
 7848+ 'unblockShort': 'un',
 7849+ 'block': 'block',
 7850+ 'block user': 'block user',
 7851+ 'IpblocklistHint': 'Unblock %s',
 7852+ 'BlockipHint': 'Prevent %s from editing',
 7853+ 'block log': 'block log',
 7854+ 'blockLogHint': 'Show the block log for %s',
 7855+ 'protectLogHint': 'Show the protection log for %s',
 7856+ 'pageLogHint': 'Show the page log for %s',
 7857+ 'deleteLogHint': 'Show the deletion log for %s',
 7858+ 'Invalid %s %s': 'The option %s is invalid: %s',
 7859+ 'No backlinks found': 'No backlinks found',
 7860+ ' and more': ' and more',
 7861+ 'undo': 'undo',
 7862+ 'undoHint': 'undo this edit',
 7863+ 'Download preview data': 'Download preview data',
 7864+ 'Invalid or IP user': 'Invalid or IP user',
 7865+ 'Not a registered username': 'Not a registered username',
 7866+ 'BLOCKED': 'BLOCKED',
 7867+ ' edits since: ': ' edits since: ',
 7868+ /////////////////////////////////////
 7869+ // Autoediting
 7870+ /////////////////////////////////////
 7871+ 'Enter a non-empty edit summary or press cancel to abort': 'Enter a non-empty edit summary or press cancel to abort',
 7872+ 'Failed to get revision information, please edit manually.\n\n': 'Failed to get revision information, please edit manually.\n\n',
 7873+ 'The %s button has been automatically clicked. Please wait for the next page to load.': 'The %s button has been automatically clicked. Please wait for the next page to load.',
 7874+ 'Could not find button %s. Please check the settings in your javascript file.': 'Could not find button %s. Please check the settings in your javascript file.',
 7875+ /////////////////////////////////////
 7876+ // Popups setup
 7877+ /////////////////////////////////////
 7878+ 'Open full-size image': 'Open full-size image',
 7879+ 'zxy': 'zxy'
 7880+};
 7881+
 7882+
 7883+function popupString(str) {
 7884+ if (typeof popupStrings != 'undefined' && popupStrings && popupStrings[str]) { return popupStrings[str]; }
 7885+ if (pg.string[str]) { return pg.string[str]; }
 7886+ return str;
 7887+}
 7888+
 7889+
 7890+function tprintf(str,subs) {
 7891+ if (typeof subs != typeof []) { subs = [subs]; }
 7892+ return simplePrintf(popupString(str), subs);
 7893+}
 7894+
 7895+//</NOLITE>
 7896+// ENDFILE: strings.js
 7897+
 7898+
 7899+////////////////////////////////////////////////////////////////////
 7900+// Run things
 7901+////////////////////////////////////////////////////////////////////
 7902+
 7903+hookEvent('load', setupPopups);
 7904+hookEvent('load', autoEdit);
Property changes on: trunk/extensions/Collection/collection/Gadget-popups.js
___________________________________________________________________
Name: svn:eol-style
17905 + native

Comments

#Comment by Tim Starling (talk | contribs)   05:46, 2 September 2009

Needs rewrite.

Status & tagging log