wikibits.js 37 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246
  1. // MediaWiki JavaScript support functions
  2. var clientPC = navigator.userAgent.toLowerCase(); // Get client info
  3. var is_gecko = ((clientPC.indexOf('gecko')!=-1) && (clientPC.indexOf('spoofer')==-1)
  4. && (clientPC.indexOf('khtml') == -1) && (clientPC.indexOf('netscape/7.0')==-1));
  5. var is_safari = ((clientPC.indexOf('applewebkit')!=-1) && (clientPC.indexOf('spoofer')==-1));
  6. var is_khtml = (navigator.vendor == 'KDE' || ( document.childNodes && !document.all && !navigator.taintEnabled ));
  7. // For accesskeys
  8. var is_ff2_win = (clientPC.indexOf('firefox/2')!=-1 || clientPC.indexOf('minefield/3')!=-1) && clientPC.indexOf('windows')!=-1;
  9. var is_ff2_x11 = (clientPC.indexOf('firefox/2')!=-1 || clientPC.indexOf('minefield/3')!=-1) && clientPC.indexOf('x11')!=-1;
  10. if (clientPC.indexOf('opera') != -1) {
  11. var is_opera = true;
  12. var is_opera_preseven = (window.opera && !document.childNodes);
  13. var is_opera_seven = (window.opera && document.childNodes);
  14. }
  15. // Global external objects used by this script.
  16. /*extern ta, stylepath, skin */
  17. // add any onload functions in this hook (please don't hard-code any events in the xhtml source)
  18. var doneOnloadHook;
  19. if (!window.onloadFuncts) {
  20. var onloadFuncts = [];
  21. }
  22. function addOnloadHook(hookFunct) {
  23. // Allows add-on scripts to add onload functions
  24. onloadFuncts[onloadFuncts.length] = hookFunct;
  25. }
  26. function hookEvent(hookName, hookFunct) {
  27. if (window.addEventListener) {
  28. window.addEventListener(hookName, hookFunct, false);
  29. } else if (window.attachEvent) {
  30. window.attachEvent("on" + hookName, hookFunct);
  31. }
  32. }
  33. // document.write special stylesheet links
  34. if (typeof stylepath != 'undefined' && typeof skin != 'undefined') {
  35. if (is_opera_preseven) {
  36. document.write('<link rel="stylesheet" type="text/css" href="'+stylepath+'/'+skin+'/Opera6Fixes.css">');
  37. } else if (is_opera_seven) {
  38. document.write('<link rel="stylesheet" type="text/css" href="'+stylepath+'/'+skin+'/Opera7Fixes.css">');
  39. } else if (is_khtml) {
  40. document.write('<link rel="stylesheet" type="text/css" href="'+stylepath+'/'+skin+'/KHTMLFixes.css">');
  41. }
  42. }
  43. if (wgBreakFrames) {
  44. // Un-trap us from framesets
  45. if (window.top != window) {
  46. window.top.location = window.location;
  47. }
  48. }
  49. // for enhanced RecentChanges
  50. function toggleVisibility(_levelId, _otherId, _linkId) {
  51. var thisLevel = document.getElementById(_levelId);
  52. var otherLevel = document.getElementById(_otherId);
  53. var linkLevel = document.getElementById(_linkId);
  54. if (thisLevel.style.display == 'none') {
  55. thisLevel.style.display = 'block';
  56. otherLevel.style.display = 'none';
  57. linkLevel.style.display = 'inline';
  58. } else {
  59. thisLevel.style.display = 'none';
  60. otherLevel.style.display = 'inline';
  61. linkLevel.style.display = 'none';
  62. }
  63. }
  64. function historyRadios(parent) {
  65. var inputs = parent.getElementsByTagName('input');
  66. var radios = [];
  67. for (var i = 0; i < inputs.length; i++) {
  68. if (inputs[i].name == "diff" || inputs[i].name == "oldid") {
  69. radios[radios.length] = inputs[i];
  70. }
  71. }
  72. return radios;
  73. }
  74. // check selection and tweak visibility/class onclick
  75. function diffcheck() {
  76. var dli = false; // the li where the diff radio is checked
  77. var oli = false; // the li where the oldid radio is checked
  78. var hf = document.getElementById('pagehistory');
  79. if (!hf) {
  80. return true;
  81. }
  82. var lis = hf.getElementsByTagName('li');
  83. for (var i=0;i<lis.length;i++) {
  84. var inputs = historyRadios(lis[i]);
  85. if (inputs[1] && inputs[0]) {
  86. if (inputs[1].checked || inputs[0].checked) { // this row has a checked radio button
  87. if (inputs[1].checked && inputs[0].checked && inputs[0].value == inputs[1].value) {
  88. return false;
  89. }
  90. if (oli) { // it's the second checked radio
  91. if (inputs[1].checked) {
  92. oli.className = "selected";
  93. return false;
  94. }
  95. } else if (inputs[0].checked) {
  96. return false;
  97. }
  98. if (inputs[0].checked) {
  99. dli = lis[i];
  100. }
  101. if (!oli) {
  102. inputs[0].style.visibility = 'hidden';
  103. }
  104. if (dli) {
  105. inputs[1].style.visibility = 'hidden';
  106. }
  107. lis[i].className = "selected";
  108. oli = lis[i];
  109. } else { // no radio is checked in this row
  110. if (!oli) {
  111. inputs[0].style.visibility = 'hidden';
  112. } else {
  113. inputs[0].style.visibility = 'visible';
  114. }
  115. if (dli) {
  116. inputs[1].style.visibility = 'hidden';
  117. } else {
  118. inputs[1].style.visibility = 'visible';
  119. }
  120. lis[i].className = "";
  121. }
  122. }
  123. }
  124. return true;
  125. }
  126. // page history stuff
  127. // attach event handlers to the input elements on history page
  128. function histrowinit() {
  129. var hf = document.getElementById('pagehistory');
  130. if (!hf) {
  131. return;
  132. }
  133. var lis = hf.getElementsByTagName('li');
  134. for (var i = 0; i < lis.length; i++) {
  135. var inputs = historyRadios(lis[i]);
  136. if (inputs[0] && inputs[1]) {
  137. inputs[0].onclick = diffcheck;
  138. inputs[1].onclick = diffcheck;
  139. }
  140. }
  141. diffcheck();
  142. }
  143. // generate toc from prefs form, fold sections
  144. // XXX: needs testing on IE/Mac and safari
  145. // more comments to follow
  146. function tabbedprefs() {
  147. var prefform = document.getElementById('preferences');
  148. if (!prefform || !document.createElement) {
  149. return;
  150. }
  151. if (prefform.nodeName.toLowerCase() == 'a') {
  152. return; // Occasional IE problem
  153. }
  154. prefform.className = prefform.className + 'jsprefs';
  155. var sections = [];
  156. var children = prefform.childNodes;
  157. var seci = 0;
  158. for (var i = 0; i < children.length; i++) {
  159. if (children[i].nodeName.toLowerCase() == 'fieldset') {
  160. children[i].id = 'prefsection-' + seci;
  161. children[i].className = 'prefsection';
  162. if (is_opera || is_khtml) {
  163. children[i].className = 'prefsection operaprefsection';
  164. }
  165. var legends = children[i].getElementsByTagName('legend');
  166. sections[seci] = {};
  167. legends[0].className = 'mainLegend';
  168. if (legends[0] && legends[0].firstChild.nodeValue) {
  169. sections[seci].text = legends[0].firstChild.nodeValue;
  170. } else {
  171. sections[seci].text = '# ' + seci;
  172. }
  173. sections[seci].secid = children[i].id;
  174. seci++;
  175. if (sections.length != 1) {
  176. children[i].style.display = 'none';
  177. } else {
  178. var selectedid = children[i].id;
  179. }
  180. }
  181. }
  182. var toc = document.createElement('ul');
  183. toc.id = 'preftoc';
  184. toc.selectedid = selectedid;
  185. for (i = 0; i < sections.length; i++) {
  186. var li = document.createElement('li');
  187. if (i === 0) {
  188. li.className = 'selected';
  189. }
  190. var a = document.createElement('a');
  191. a.href = '#' + sections[i].secid;
  192. a.onmousedown = a.onclick = uncoversection;
  193. a.appendChild(document.createTextNode(sections[i].text));
  194. a.secid = sections[i].secid;
  195. li.appendChild(a);
  196. toc.appendChild(li);
  197. }
  198. prefform.parentNode.insertBefore(toc, prefform.parentNode.childNodes[0]);
  199. document.getElementById('prefsubmit').id = 'prefcontrol';
  200. }
  201. function uncoversection() {
  202. var oldsecid = this.parentNode.parentNode.selectedid;
  203. var newsec = document.getElementById(this.secid);
  204. if (oldsecid != this.secid) {
  205. var ul = document.getElementById('preftoc');
  206. document.getElementById(oldsecid).style.display = 'none';
  207. newsec.style.display = 'block';
  208. ul.selectedid = this.secid;
  209. var lis = ul.getElementsByTagName('li');
  210. for (var i = 0; i< lis.length; i++) {
  211. lis[i].className = '';
  212. }
  213. this.parentNode.className = 'selected';
  214. }
  215. return false;
  216. }
  217. // Timezone stuff
  218. // tz in format [+-]HHMM
  219. function checkTimezone(tz, msg) {
  220. var localclock = new Date();
  221. // returns negative offset from GMT in minutes
  222. var tzRaw = localclock.getTimezoneOffset();
  223. var tzHour = Math.floor( Math.abs(tzRaw) / 60);
  224. var tzMin = Math.abs(tzRaw) % 60;
  225. var tzString = ((tzRaw >= 0) ? "-" : "+") + ((tzHour < 10) ? "0" : "") + tzHour + ((tzMin < 10) ? "0" : "") + tzMin;
  226. if (tz != tzString) {
  227. var junk = msg.split('$1');
  228. document.write(junk[0] + "UTC" + tzString + junk[1]);
  229. }
  230. }
  231. function unhidetzbutton() {
  232. var tzb = document.getElementById('guesstimezonebutton');
  233. if (tzb) {
  234. tzb.style.display = 'inline';
  235. }
  236. }
  237. // in [-]HH:MM format...
  238. // won't yet work with non-even tzs
  239. function fetchTimezone() {
  240. // FIXME: work around Safari bug
  241. var localclock = new Date();
  242. // returns negative offset from GMT in minutes
  243. var tzRaw = localclock.getTimezoneOffset();
  244. var tzHour = Math.floor( Math.abs(tzRaw) / 60);
  245. var tzMin = Math.abs(tzRaw) % 60;
  246. var tzString = ((tzRaw >= 0) ? "-" : "") + ((tzHour < 10) ? "0" : "") + tzHour +
  247. ":" + ((tzMin < 10) ? "0" : "") + tzMin;
  248. return tzString;
  249. }
  250. function guessTimezone(box) {
  251. document.getElementsByName("wpHourDiff")[0].value = fetchTimezone();
  252. }
  253. function showTocToggle() {
  254. if (document.createTextNode) {
  255. // Uses DOM calls to avoid document.write + XHTML issues
  256. var linkHolder = document.getElementById('toctitle');
  257. if (!linkHolder) {
  258. return;
  259. }
  260. var outerSpan = document.createElement('span');
  261. outerSpan.className = 'toctoggle';
  262. var toggleLink = document.createElement('a');
  263. toggleLink.id = 'togglelink';
  264. toggleLink.className = 'internal';
  265. toggleLink.href = 'javascript:toggleToc()';
  266. toggleLink.appendChild(document.createTextNode(tocHideText));
  267. outerSpan.appendChild(document.createTextNode('['));
  268. outerSpan.appendChild(toggleLink);
  269. outerSpan.appendChild(document.createTextNode(']'));
  270. linkHolder.appendChild(document.createTextNode(' '));
  271. linkHolder.appendChild(outerSpan);
  272. var cookiePos = document.cookie.indexOf("hidetoc=");
  273. if (cookiePos > -1 && document.cookie.charAt(cookiePos + 8) == 1) {
  274. toggleToc();
  275. }
  276. }
  277. }
  278. function changeText(el, newText) {
  279. // Safari work around
  280. if (el.innerText) {
  281. el.innerText = newText;
  282. } else if (el.firstChild && el.firstChild.nodeValue) {
  283. el.firstChild.nodeValue = newText;
  284. }
  285. }
  286. function toggleToc() {
  287. var toc = document.getElementById('toc').getElementsByTagName('ul')[0];
  288. var toggleLink = document.getElementById('togglelink');
  289. if (toc && toggleLink && toc.style.display == 'none') {
  290. changeText(toggleLink, tocHideText);
  291. toc.style.display = 'block';
  292. document.cookie = "hidetoc=0";
  293. } else {
  294. changeText(toggleLink, tocShowText);
  295. toc.style.display = 'none';
  296. document.cookie = "hidetoc=1";
  297. }
  298. }
  299. var mwEditButtons = [];
  300. var mwCustomEditButtons = []; // eg to add in MediaWiki:Common.js
  301. // this function generates the actual toolbar buttons with localized text
  302. // we use it to avoid creating the toolbar where javascript is not enabled
  303. function addButton(imageFile, speedTip, tagOpen, tagClose, sampleText, imageId) {
  304. // Don't generate buttons for browsers which don't fully
  305. // support it.
  306. mwEditButtons[mwEditButtons.length] =
  307. {"imageId": imageId,
  308. "imageFile": imageFile,
  309. "speedTip": speedTip,
  310. "tagOpen": tagOpen,
  311. "tagClose": tagClose,
  312. "sampleText": sampleText};
  313. }
  314. // this function generates the actual toolbar buttons with localized text
  315. // we use it to avoid creating the toolbar where javascript is not enabled
  316. function mwInsertEditButton(parent, item) {
  317. var image = document.createElement("img");
  318. image.width = 23;
  319. image.height = 22;
  320. image.className = "mw-toolbar-editbutton";
  321. if (item.imageId) image.id = item.imageId;
  322. image.src = item.imageFile;
  323. image.border = 0;
  324. image.alt = item.speedTip;
  325. image.title = item.speedTip;
  326. image.style.cursor = "pointer";
  327. image.onclick = function() {
  328. insertTags(item.tagOpen, item.tagClose, item.sampleText);
  329. return false;
  330. };
  331. parent.appendChild(image);
  332. return true;
  333. }
  334. function mwSetupToolbar() {
  335. var toolbar = document.getElementById('toolbar');
  336. if (!toolbar) { return false; }
  337. var textbox = document.getElementById('wpTextbox1');
  338. if (!textbox) { return false; }
  339. // Don't generate buttons for browsers which don't fully
  340. // support it.
  341. if (!document.selection && textbox.selectionStart === null) {
  342. return false;
  343. }
  344. for (var i = 0; i < mwEditButtons.length; i++) {
  345. mwInsertEditButton(toolbar, mwEditButtons[i]);
  346. }
  347. for (var i = 0; i < mwCustomEditButtons.length; i++) {
  348. mwInsertEditButton(toolbar, mwCustomEditButtons[i]);
  349. }
  350. return true;
  351. }
  352. function escapeQuotes(text) {
  353. var re = new RegExp("'","g");
  354. text = text.replace(re,"\\'");
  355. re = new RegExp("\\n","g");
  356. text = text.replace(re,"\\n");
  357. return escapeQuotesHTML(text);
  358. }
  359. function escapeQuotesHTML(text) {
  360. var re = new RegExp('&',"g");
  361. text = text.replace(re,"&amp;");
  362. re = new RegExp('"',"g");
  363. text = text.replace(re,"&quot;");
  364. re = new RegExp('<',"g");
  365. text = text.replace(re,"&lt;");
  366. re = new RegExp('>',"g");
  367. text = text.replace(re,"&gt;");
  368. return text;
  369. }
  370. // apply tagOpen/tagClose to selection in textarea,
  371. // use sampleText instead of selection if there is none
  372. // copied and adapted from phpBB
  373. function insertTags(tagOpen, tagClose, sampleText) {
  374. var txtarea;
  375. if (document.editform) {
  376. txtarea = document.editform.wpTextbox1;
  377. } else {
  378. // some alternate form? take the first one we can find
  379. var areas = document.getElementsByTagName('textarea');
  380. txtarea = areas[0];
  381. }
  382. // IE
  383. if (document.selection && !is_gecko) {
  384. var theSelection = document.selection.createRange().text;
  385. if (!theSelection) {
  386. theSelection=sampleText;
  387. }
  388. txtarea.focus();
  389. if (theSelection.charAt(theSelection.length - 1) == " ") { // exclude ending space char, if any
  390. theSelection = theSelection.substring(0, theSelection.length - 1);
  391. document.selection.createRange().text = tagOpen + theSelection + tagClose + " ";
  392. } else {
  393. document.selection.createRange().text = tagOpen + theSelection + tagClose;
  394. }
  395. // Mozilla
  396. } else if(txtarea.selectionStart || txtarea.selectionStart == '0') {
  397. var replaced = false;
  398. var startPos = txtarea.selectionStart;
  399. var endPos = txtarea.selectionEnd;
  400. if (endPos-startPos) {
  401. replaced = true;
  402. }
  403. var scrollTop = txtarea.scrollTop;
  404. var myText = (txtarea.value).substring(startPos, endPos);
  405. if (!myText) {
  406. myText=sampleText;
  407. }
  408. var subst;
  409. if (myText.charAt(myText.length - 1) == " ") { // exclude ending space char, if any
  410. subst = tagOpen + myText.substring(0, (myText.length - 1)) + tagClose + " ";
  411. } else {
  412. subst = tagOpen + myText + tagClose;
  413. }
  414. txtarea.value = txtarea.value.substring(0, startPos) + subst +
  415. txtarea.value.substring(endPos, txtarea.value.length);
  416. txtarea.focus();
  417. //set new selection
  418. if (replaced) {
  419. var cPos = startPos+(tagOpen.length+myText.length+tagClose.length);
  420. txtarea.selectionStart = cPos;
  421. txtarea.selectionEnd = cPos;
  422. } else {
  423. txtarea.selectionStart = startPos+tagOpen.length;
  424. txtarea.selectionEnd = startPos+tagOpen.length+myText.length;
  425. }
  426. txtarea.scrollTop = scrollTop;
  427. // All other browsers get no toolbar.
  428. // There was previously support for a crippled "help"
  429. // bar, but that caused more problems than it solved.
  430. }
  431. // reposition cursor if possible
  432. if (txtarea.createTextRange) {
  433. txtarea.caretPos = document.selection.createRange().duplicate();
  434. }
  435. }
  436. /**
  437. * Set the accesskey prefix based on browser detection.
  438. */
  439. var tooltipAccessKeyPrefix = 'alt-';
  440. if (is_opera) {
  441. tooltipAccessKeyPrefix = 'shift-esc-';
  442. } else if (is_safari
  443. || navigator.userAgent.toLowerCase().indexOf('mac') != -1
  444. || navigator.userAgent.toLowerCase().indexOf('konqueror') != -1 ) {
  445. tooltipAccessKeyPrefix = 'ctrl-';
  446. } else if (is_ff2_x11 || is_ff2_win) {
  447. tooltipAccessKeyPrefix = 'alt-shift-';
  448. }
  449. var tooltipAccessKeyRegexp = /\[(ctrl-)?(alt-)?(shift-)?(esc-)?.\]$/;
  450. /**
  451. * Add the appropriate prefix to the accesskey shown in the tooltip.
  452. * If the nodeList parameter is given, only those nodes are updated;
  453. * otherwise, all the nodes that will probably have accesskeys by
  454. * default are updated.
  455. *
  456. * @param Array nodeList -- list of elements to update
  457. */
  458. function updateTooltipAccessKeys( nodeList ) {
  459. if ( !nodeList ) {
  460. // skins without a "column-one" element don't seem to have links with accesskeys either
  461. var columnOne = document.getElementById("column-one");
  462. if ( columnOne )
  463. updateTooltipAccessKeys( columnOne.getElementsByTagName("a") );
  464. // these are rare enough that no such optimization is needed
  465. updateTooltipAccessKeys( document.getElementsByTagName("input") );
  466. updateTooltipAccessKeys( document.getElementsByTagName("label") );
  467. return;
  468. }
  469. for ( var i = 0; i < nodeList.length; i++ ) {
  470. var element = nodeList[i];
  471. var tip = element.getAttribute("title");
  472. var key = element.getAttribute("accesskey");
  473. if ( key && tooltipAccessKeyRegexp.exec(tip) ) {
  474. tip = tip.replace(tooltipAccessKeyRegexp,
  475. "["+tooltipAccessKeyPrefix+key+"]");
  476. element.setAttribute("title", tip );
  477. }
  478. }
  479. }
  480. /**
  481. * Add a link to one of the portlet menus on the page, including:
  482. *
  483. * p-cactions: Content actions (shown as tabs above the main content in Monobook)
  484. * p-personal: Personal tools (shown at the top right of the page in Monobook)
  485. * p-navigation: Navigation
  486. * p-tb: Toolbox
  487. *
  488. * This function exists for the convenience of custom JS authors. All
  489. * but the first three parameters are optional, though providing at
  490. * least an id and a tooltip is recommended.
  491. *
  492. * By default the new link will be added to the end of the list. To
  493. * add the link before a given existing item, pass the DOM node of
  494. * that item (easily obtained with document.getElementById()) as the
  495. * nextnode parameter; to add the link _after_ an existing item, pass
  496. * the node's nextSibling instead.
  497. *
  498. * @param String portlet -- id of the target portlet ("p-cactions", "p-personal", "p-navigation" or "p-tb")
  499. * @param String href -- link URL
  500. * @param String text -- link text (will be automatically lowercased by CSS for p-cactions in Monobook)
  501. * @param String id -- id of the new item, should be unique and preferably have the appropriate prefix ("ca-", "pt-", "n-" or "t-")
  502. * @param String tooltip -- text to show when hovering over the link, without accesskey suffix
  503. * @param String accesskey -- accesskey to activate this link (one character, try to avoid conflicts)
  504. * @param Node nextnode -- the DOM node before which the new item should be added, should be another item in the same list
  505. *
  506. * @return Node -- the DOM node of the new item (an LI element) or null
  507. */
  508. function addPortletLink(portlet, href, text, id, tooltip, accesskey, nextnode) {
  509. var node = document.getElementById(portlet);
  510. if ( !node ) return null;
  511. node = node.getElementsByTagName( "ul" )[0];
  512. if ( !node ) return null;
  513. var link = document.createElement( "a" );
  514. link.appendChild( document.createTextNode( text ) );
  515. link.href = href;
  516. var item = document.createElement( "li" );
  517. item.appendChild( link );
  518. if ( id ) item.id = id;
  519. if ( accesskey ) {
  520. link.setAttribute( "accesskey", accesskey );
  521. tooltip += " ["+accesskey+"]";
  522. }
  523. if ( tooltip ) {
  524. link.setAttribute( "title", tooltip );
  525. }
  526. if ( accesskey && tooltip ) {
  527. updateTooltipAccessKeys( new Array( link ) );
  528. }
  529. if ( nextnode && nextnode.parentNode == node )
  530. node.insertBefore( item, nextnode );
  531. else
  532. node.appendChild( item ); // IE compatibility (?)
  533. return item;
  534. }
  535. /**
  536. * Set up accesskeys/tooltips from the deprecated ta array. If doId
  537. * is specified, only set up for that id. Note that this function is
  538. * deprecated and will not be supported indefinitely -- use
  539. * updateTooltipAccessKey() instead.
  540. *
  541. * @param mixed doId string or null
  542. */
  543. function akeytt( doId ) {
  544. // A lot of user scripts (and some of the code below) break if
  545. // ta isn't defined, so we make sure it is. Explictly using
  546. // window.ta avoids a "ta is not defined" error.
  547. if (!window.ta) window.ta = new Array;
  548. // Make a local, possibly restricted, copy to avoid clobbering
  549. // the original.
  550. var ta;
  551. if ( doId ) {
  552. ta = new Array;
  553. ta[doId] = window.ta[doId];
  554. } else {
  555. ta = window.ta;
  556. }
  557. // Now deal with evil deprecated ta
  558. var watchCheckboxExists = document.getElementById( 'wpWatchthis' ) ? true : false;
  559. for (var id in ta) {
  560. var n = document.getElementById(id);
  561. if (n) {
  562. var a = null;
  563. var ak = '';
  564. // Are we putting accesskey in it
  565. if (ta[id][0].length > 0) {
  566. // Is this object a object? If not assume it's the next child.
  567. if (n.nodeName.toLowerCase() == "a") {
  568. a = n;
  569. } else {
  570. a = n.childNodes[0];
  571. }
  572. // Don't add an accesskey for the watch tab if the watch
  573. // checkbox is also available.
  574. if (a && ((id != 'ca-watch' && id != 'ca-unwatch') || !watchCheckboxExists)) {
  575. a.accessKey = ta[id][0];
  576. ak = ' ['+tooltipAccessKeyPrefix+ta[id][0]+']';
  577. }
  578. } else {
  579. // We don't care what type the object is when assigning tooltip
  580. a = n;
  581. ak = '';
  582. }
  583. if (a) {
  584. a.title = ta[id][1]+ak;
  585. }
  586. }
  587. }
  588. }
  589. function setupRightClickEdit() {
  590. if (document.getElementsByTagName) {
  591. var spans = document.getElementsByTagName('span');
  592. for (var i = 0; i < spans.length; i++) {
  593. var el = spans[i];
  594. if(el.className == 'editsection') {
  595. addRightClickEditHandler(el);
  596. }
  597. }
  598. }
  599. }
  600. function addRightClickEditHandler(el) {
  601. for (var i = 0; i < el.childNodes.length; i++) {
  602. var link = el.childNodes[i];
  603. if (link.nodeType == 1 && link.nodeName.toLowerCase() == 'a') {
  604. var editHref = link.getAttribute('href');
  605. // find the enclosing (parent) header
  606. var prev = el.parentNode;
  607. if (prev && prev.nodeType == 1 &&
  608. prev.nodeName.match(/^[Hh][1-6]$/)) {
  609. prev.oncontextmenu = function(e) {
  610. if (!e) { e = window.event; }
  611. // e is now the event in all browsers
  612. var targ;
  613. if (e.target) { targ = e.target; }
  614. else if (e.srcElement) { targ = e.srcElement; }
  615. if (targ.nodeType == 3) { // defeat Safari bug
  616. targ = targ.parentNode;
  617. }
  618. // targ is now the target element
  619. // We don't want to deprive the noble reader of a context menu
  620. // for the section edit link, do we? (Might want to extend this
  621. // to all <a>'s?)
  622. if (targ.nodeName.toLowerCase() != 'a'
  623. || targ.parentNode.className != 'editsection') {
  624. document.location = editHref;
  625. return false;
  626. }
  627. return true;
  628. };
  629. }
  630. }
  631. }
  632. }
  633. var checkboxes;
  634. var lastCheckbox;
  635. function setupCheckboxShiftClick() {
  636. checkboxes = [];
  637. lastCheckbox = null;
  638. var inputs = document.getElementsByTagName('input');
  639. addCheckboxClickHandlers(inputs);
  640. }
  641. function addCheckboxClickHandlers(inputs, start) {
  642. if ( !start) start = 0;
  643. var finish = start + 250;
  644. if ( finish > inputs.length )
  645. finish = inputs.length;
  646. for ( var i = start; i < finish; i++ ) {
  647. var cb = inputs[i];
  648. if ( !cb.type || cb.type.toLowerCase() != 'checkbox' )
  649. continue;
  650. cb.index = checkboxes.push(cb) - 1;
  651. cb.onmouseup = checkboxMouseupHandler;
  652. }
  653. if ( finish < inputs.length ) {
  654. setTimeout( function () {
  655. addCheckboxClickHandlers(inputs, finish);
  656. }, 200 );
  657. }
  658. }
  659. function checkboxMouseupHandler(e) {
  660. if (typeof e == 'undefined') {
  661. e = window.event;
  662. }
  663. if ( !e.shiftKey || lastCheckbox === null ) {
  664. lastCheckbox = this.index;
  665. return true;
  666. }
  667. var endState = !this.checked;
  668. if ( is_opera ) { // opera has already toggled the checkbox by this point
  669. endState = !endState;
  670. }
  671. var start, finish;
  672. if ( this.index < lastCheckbox ) {
  673. start = this.index + 1;
  674. finish = lastCheckbox;
  675. } else {
  676. start = lastCheckbox;
  677. finish = this.index - 1;
  678. }
  679. for (var i = start; i <= finish; ++i ) {
  680. checkboxes[i].checked = endState;
  681. }
  682. lastCheckbox = this.index;
  683. return true;
  684. }
  685. function toggle_element_activation(ida,idb) {
  686. if (!document.getElementById) {
  687. return;
  688. }
  689. document.getElementById(ida).disabled=true;
  690. document.getElementById(idb).disabled=false;
  691. }
  692. function toggle_element_check(ida,idb) {
  693. if (!document.getElementById) {
  694. return;
  695. }
  696. document.getElementById(ida).checked=true;
  697. document.getElementById(idb).checked=false;
  698. }
  699. function fillDestFilename(id) {
  700. if (!document.getElementById) {
  701. return;
  702. }
  703. var path = document.getElementById(id).value;
  704. // Find trailing part
  705. var slash = path.lastIndexOf('/');
  706. var backslash = path.lastIndexOf('\\');
  707. var fname;
  708. if (slash == -1 && backslash == -1) {
  709. fname = path;
  710. } else if (slash > backslash) {
  711. fname = path.substring(slash+1, 10000);
  712. } else {
  713. fname = path.substring(backslash+1, 10000);
  714. }
  715. // Capitalise first letter and replace spaces by underscores
  716. fname = fname.charAt(0).toUpperCase().concat(fname.substring(1,10000)).replace(/ /g, '_');
  717. // Output result
  718. var destFile = document.getElementById('wpDestFile');
  719. if (destFile) {
  720. destFile.value = fname;
  721. }
  722. }
  723. function scrollEditBox() {
  724. var editBoxEl = document.getElementById("wpTextbox1");
  725. var scrollTopEl = document.getElementById("wpScrolltop");
  726. var editFormEl = document.getElementById("editform");
  727. if (editBoxEl && scrollTopEl) {
  728. if (scrollTopEl.value) { editBoxEl.scrollTop = scrollTopEl.value; }
  729. editFormEl.onsubmit = function() {
  730. document.getElementById("wpScrolltop").value = document.getElementById("wpTextbox1").scrollTop;
  731. };
  732. }
  733. }
  734. hookEvent("load", scrollEditBox);
  735. var allmessages_nodelist = false;
  736. var allmessages_modified = false;
  737. var allmessages_timeout = false;
  738. var allmessages_running = false;
  739. function allmessagesmodified() {
  740. allmessages_modified = !allmessages_modified;
  741. allmessagesfilter();
  742. }
  743. function allmessagesfilter() {
  744. if ( allmessages_timeout )
  745. window.clearTimeout( allmessages_timeout );
  746. if ( !allmessages_running )
  747. allmessages_timeout = window.setTimeout( 'allmessagesfilter_do();', 500 );
  748. }
  749. function allmessagesfilter_do() {
  750. if ( !allmessages_nodelist )
  751. return;
  752. var text = document.getElementById('allmessagesinput').value;
  753. var nodef = allmessages_modified;
  754. allmessages_running = true;
  755. for ( var name in allmessages_nodelist ) {
  756. var nodes = allmessages_nodelist[name];
  757. var display = ( name.indexOf( text ) == -1 ? 'none' : '' );
  758. for ( var i = 0; i < nodes.length; i++)
  759. nodes[i].style.display =
  760. ( nodes[i].className == "def" && nodef
  761. ? 'none' : display );
  762. }
  763. if ( text != document.getElementById('allmessagesinput').value ||
  764. nodef != allmessages_modified )
  765. allmessagesfilter_do(); // repeat
  766. allmessages_running = false;
  767. }
  768. function allmessagesfilter_init() {
  769. if ( allmessages_nodelist )
  770. return;
  771. var nodelist = new Array();
  772. var templist = new Array();
  773. var table = document.getElementById('allmessagestable');
  774. if ( !table ) return;
  775. var rows = document.getElementsByTagName('tr');
  776. for ( var i = 0; i < rows.length; i++ ) {
  777. var id = rows[i].getAttribute('id')
  778. if ( id && id.substring(0,16) != 'sp-allmessages-r' ) continue;
  779. templist[ id ] = rows[i];
  780. }
  781. var spans = table.getElementsByTagName('span');
  782. for ( var i = 0; i < spans.length; i++ ) {
  783. var id = spans[i].getAttribute('id')
  784. if ( id && id.substring(0,17) != 'sp-allmessages-i-' ) continue;
  785. if ( !spans[i].firstChild || spans[i].firstChild.nodeType != 3 ) continue;
  786. var nodes = new Array();
  787. var row1 = templist[ id.replace('i', 'r1') ];
  788. var row2 = templist[ id.replace('i', 'r2') ];
  789. if ( row1 ) nodes[nodes.length] = row1;
  790. if ( row2 ) nodes[nodes.length] = row2;
  791. nodelist[ spans[i].firstChild.nodeValue ] = nodes;
  792. }
  793. var k = document.getElementById('allmessagesfilter');
  794. if (k) { k.style.display = ''; }
  795. allmessages_nodelist = nodelist;
  796. }
  797. hookEvent( "load", allmessagesfilter_init );
  798. /*
  799. Written by Jonathan Snook, http://www.snook.ca/jonathan
  800. Add-ons by Robert Nyman, http://www.robertnyman.com
  801. Author says "The credit comment is all it takes, no license. Go crazy with it!:-)"
  802. From http://www.robertnyman.com/2005/11/07/the-ultimate-getelementsbyclassname/
  803. */
  804. function getElementsByClassName(oElm, strTagName, oClassNames){
  805. var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
  806. var arrReturnElements = new Array();
  807. var arrRegExpClassNames = new Array();
  808. if(typeof oClassNames == "object"){
  809. for(var i=0; i<oClassNames.length; i++){
  810. arrRegExpClassNames.push(new RegExp("(^|\\s)" + oClassNames[i].replace(/\-/g, "\\-") + "(\\s|$)"));
  811. }
  812. }
  813. else{
  814. arrRegExpClassNames.push(new RegExp("(^|\\s)" + oClassNames.replace(/\-/g, "\\-") + "(\\s|$)"));
  815. }
  816. var oElement;
  817. var bMatchesAll;
  818. for(var j=0; j<arrElements.length; j++){
  819. oElement = arrElements[j];
  820. bMatchesAll = true;
  821. for(var k=0; k<arrRegExpClassNames.length; k++){
  822. if(!arrRegExpClassNames[k].test(oElement.className)){
  823. bMatchesAll = false;
  824. break;
  825. }
  826. }
  827. if(bMatchesAll){
  828. arrReturnElements.push(oElement);
  829. }
  830. }
  831. return (arrReturnElements)
  832. }
  833. function redirectToFragment(fragment) {
  834. var match = navigator.userAgent.match(/AppleWebKit\/(\d+)/);
  835. if (match) {
  836. var webKitVersion = parseInt(match[1]);
  837. if (webKitVersion < 420) {
  838. // Released Safari w/ WebKit 418.9.1 messes up horribly
  839. // Nightlies of 420+ are ok
  840. return;
  841. }
  842. }
  843. if (is_gecko) {
  844. // Mozilla needs to wait until after load, otherwise the window doesn't scroll
  845. addOnloadHook(function () {
  846. if (window.location.hash == "")
  847. window.location.hash = fragment;
  848. });
  849. } else {
  850. if (window.location.hash == "")
  851. window.location.hash = fragment;
  852. }
  853. }
  854. /*
  855. * Table sorting script by Joost de Valk, check it out at http://www.joostdevalk.nl/code/sortable-table/.
  856. * Based on a script from http://www.kryogenix.org/code/browser/sorttable/.
  857. * Distributed under the MIT license: http://www.kryogenix.org/code/browser/licence.html .
  858. *
  859. * Copyright (c) 1997-2006 Stuart Langridge, Joost de Valk.
  860. *
  861. * @todo don't break on colspans/rowspans (bug 8028)
  862. * @todo language-specific digit grouping/decimals (bug 8063)
  863. * @todo support all accepted date formats (bug 8226)
  864. */
  865. var ts_image_path = stylepath+"/common/images/";
  866. var ts_image_up = "sort_up.gif";
  867. var ts_image_down = "sort_down.gif";
  868. var ts_image_none = "sort_none.gif";
  869. var ts_europeandate = wgContentLanguage != "en"; // The non-American-inclined can change to "true"
  870. var ts_alternate_row_colors = true;
  871. var SORT_COLUMN_INDEX;
  872. function sortables_init() {
  873. var idnum = 0;
  874. // Find all tables with class sortable and make them sortable
  875. var tables = getElementsByClassName(document, "table", "sortable");
  876. for (var ti = 0; ti < tables.length ; ti++) {
  877. if (!tables[ti].id) {
  878. tables[ti].setAttribute('id','sortable_table_id_'+idnum);
  879. ++idnum;
  880. }
  881. ts_makeSortable(tables[ti]);
  882. }
  883. }
  884. function ts_makeSortable(table) {
  885. var firstRow;
  886. if (table.rows && table.rows.length > 0) {
  887. if (table.tHead && table.tHead.rows.length > 0) {
  888. firstRow = table.tHead.rows[table.tHead.rows.length-1];
  889. } else {
  890. firstRow = table.rows[0];
  891. }
  892. }
  893. if (!firstRow) return;
  894. // We have a first row: assume it's the header, and make its contents clickable links
  895. for (var i = 0; i < firstRow.cells.length; i++) {
  896. var cell = firstRow.cells[i];
  897. if ((" "+cell.className+" ").indexOf(" unsortable ") == -1) {
  898. cell.innerHTML += '&nbsp;&nbsp;<a href="#" class="sortheader" onclick="ts_resortTable(this);return false;"><span class="sortarrow"><img src="'+ ts_image_path + ts_image_none + '" alt="&darr;"/></span></a>';
  899. }
  900. }
  901. if (ts_alternate_row_colors) {
  902. ts_alternate(table);
  903. }
  904. }
  905. function ts_getInnerText(el) {
  906. if (typeof el == "string") return el;
  907. if (typeof el == "undefined") { return el };
  908. if (el.innerText) return el.innerText; // Not needed but it is faster
  909. var str = "";
  910. var cs = el.childNodes;
  911. var l = cs.length;
  912. for (var i = 0; i < l; i++) {
  913. switch (cs[i].nodeType) {
  914. case 1: //ELEMENT_NODE
  915. str += ts_getInnerText(cs[i]);
  916. break;
  917. case 3: //TEXT_NODE
  918. str += cs[i].nodeValue;
  919. break;
  920. }
  921. }
  922. return str;
  923. }
  924. function ts_resortTable(lnk) {
  925. // get the span
  926. var span = lnk.getElementsByTagName('span')[0];
  927. var td = lnk.parentNode;
  928. var tr = td.parentNode;
  929. var column = td.cellIndex;
  930. var table = tr.parentNode;
  931. while (table && !(table.tagName && table.tagName.toLowerCase() == 'table'))
  932. table = table.parentNode;
  933. if (!table) return;
  934. // Work out a type for the column
  935. if (table.rows.length <= 1) return;
  936. // Skip the first row if that's where the headings are
  937. var rowStart = (table.tHead && table.tHead.rows.length > 0 ? 0 : 1);
  938. var itm = "";
  939. for (var i = rowStart; i < table.rows.length; i++) {
  940. if (table.rows[i].cells.length > column) {
  941. itm = ts_getInnerText(table.rows[i].cells[column]);
  942. itm = itm.replace(/^[\s\xa0]+/, "").replace(/[\s\xa0]+$/, "");
  943. if (itm != "") break;
  944. }
  945. }
  946. sortfn = ts_sort_caseinsensitive;
  947. if (itm.match(/^\d\d[\/. -][a-zA-Z]{3}[\/. -]\d\d\d\d$/))
  948. sortfn = ts_sort_date;
  949. if (itm.match(/^\d\d[\/.-]\d\d[\/.-]\d\d\d\d$/))
  950. sortfn = ts_sort_date;
  951. if (itm.match(/^\d\d[\/.-]\d\d[\/.-]\d\d$/))
  952. sortfn = ts_sort_date;
  953. if (itm.match(/^[\u00a3$\u20ac]/)) // pound dollar euro
  954. sortfn = ts_sort_currency;
  955. if (itm.match(/^[\d.,]+\%?$/))
  956. sortfn = ts_sort_numeric;
  957. var reverse = (span.getAttribute("sortdir") == 'down');
  958. var newRows = new Array();
  959. for (var j = rowStart; j < table.rows.length; j++) {
  960. var row = table.rows[j];
  961. var keyText = ts_getInnerText(row.cells[column]);
  962. var oldIndex = (reverse ? -j : j);
  963. newRows[newRows.length] = new Array(row, keyText, oldIndex);
  964. }
  965. newRows.sort(sortfn);
  966. var arrowHTML;
  967. if (reverse) {
  968. arrowHTML = '<img src="'+ ts_image_path + ts_image_down + '" alt="&darr;"/>';
  969. newRows.reverse();
  970. span.setAttribute('sortdir','up');
  971. } else {
  972. arrowHTML = '<img src="'+ ts_image_path + ts_image_up + '" alt="&uarr;"/>';
  973. span.setAttribute('sortdir','down');
  974. }
  975. // We appendChild rows that already exist to the tbody, so it moves them rather than creating new ones
  976. // don't do sortbottom rows
  977. for (var i = 0; i < newRows.length; i++) {
  978. if ((" "+newRows[i][0].className+" ").indexOf(" sortbottom ") == -1)
  979. table.tBodies[0].appendChild(newRows[i][0]);
  980. }
  981. // do sortbottom rows only
  982. for (var i = 0; i < newRows.length; i++) {
  983. if ((" "+newRows[i][0].className+" ").indexOf(" sortbottom ") != -1)
  984. table.tBodies[0].appendChild(newRows[i][0]);
  985. }
  986. // Delete any other arrows there may be showing
  987. var spans = getElementsByClassName(tr, "span", "sortarrow");
  988. for (var i = 0; i < spans.length; i++) {
  989. spans[i].innerHTML = '<img src="'+ ts_image_path + ts_image_none + '" alt="&darr;"/>';
  990. }
  991. span.innerHTML = arrowHTML;
  992. ts_alternate(table);
  993. }
  994. function ts_dateToSortKey(date) {
  995. // y2k notes: two digit years less than 50 are treated as 20XX, greater than 50 are treated as 19XX
  996. if (date.length == 11) {
  997. switch (date.substr(3,3).toLowerCase()) {
  998. case "jan": var month = "01"; break;
  999. case "feb": var month = "02"; break;
  1000. case "mar": var month = "03"; break;
  1001. case "apr": var month = "04"; break;
  1002. case "may": var month = "05"; break;
  1003. case "jun": var month = "06"; break;
  1004. case "jul": var month = "07"; break;
  1005. case "aug": var month = "08"; break;
  1006. case "sep": var month = "09"; break;
  1007. case "oct": var month = "10"; break;
  1008. case "nov": var month = "11"; break;
  1009. case "dec": var month = "12"; break;
  1010. // default: var month = "00";
  1011. }
  1012. return date.substr(7,4)+month+date.substr(0,2);
  1013. } else if (date.length == 10) {
  1014. if (ts_europeandate == false) {
  1015. return date.substr(6,4)+date.substr(0,2)+date.substr(3,2);
  1016. } else {
  1017. return date.substr(6,4)+date.substr(3,2)+date.substr(0,2);
  1018. }
  1019. } else if (date.length == 8) {
  1020. yr = date.substr(6,2);
  1021. if (parseInt(yr) < 50) {
  1022. yr = '20'+yr;
  1023. } else {
  1024. yr = '19'+yr;
  1025. }
  1026. if (ts_europeandate == true) {
  1027. return yr+date.substr(3,2)+date.substr(0,2);
  1028. } else {
  1029. return yr+date.substr(0,2)+date.substr(3,2);
  1030. }
  1031. }
  1032. return "00000000";
  1033. }
  1034. function ts_parseFloat(num) {
  1035. if (!num) return 0;
  1036. num = parseFloat(num.replace(/,/, ""));
  1037. return (isNaN(num) ? 0 : num);
  1038. }
  1039. function ts_sort_date(a,b) {
  1040. var aa = ts_dateToSortKey(a[1]);
  1041. var bb = ts_dateToSortKey(b[1]);
  1042. return (aa < bb ? -1 : aa > bb ? 1 : a[2] - b[2]);
  1043. }
  1044. function ts_sort_currency(a,b) {
  1045. var aa = ts_parseFloat(a[1].replace(/[^0-9.]/g,''));
  1046. var bb = ts_parseFloat(b[1].replace(/[^0-9.]/g,''));
  1047. return (aa != bb ? aa - bb : a[2] - b[2]);
  1048. }
  1049. function ts_sort_numeric(a,b) {
  1050. var aa = ts_parseFloat(a[1]);
  1051. var bb = ts_parseFloat(b[1]);
  1052. return (aa != bb ? aa - bb : a[2] - b[2]);
  1053. }
  1054. function ts_sort_caseinsensitive(a,b) {
  1055. var aa = a[1].toLowerCase();
  1056. var bb = b[1].toLowerCase();
  1057. return (aa < bb ? -1 : aa > bb ? 1 : a[2] - b[2]);
  1058. }
  1059. function ts_sort_default(a,b) {
  1060. return (a[1] < b[1] ? -1 : a[1] > b[1] ? 1 : a[2] - b[2]);
  1061. }
  1062. function ts_alternate(table) {
  1063. // Take object table and get all it's tbodies.
  1064. var tableBodies = table.getElementsByTagName("tbody");
  1065. // Loop through these tbodies
  1066. for (var i = 0; i < tableBodies.length; i++) {
  1067. // Take the tbody, and get all it's rows
  1068. var tableRows = tableBodies[i].getElementsByTagName("tr");
  1069. // Loop through these rows
  1070. // Start at 1 because we want to leave the heading row untouched
  1071. for (var j = 0; j < tableRows.length; j++) {
  1072. // Check if j is even, and apply classes for both possible results
  1073. var oldClasses = tableRows[j].className.split(" ");
  1074. var newClassName = "";
  1075. for (var k = 0; k < oldClasses.length; k++) {
  1076. if (oldClasses[k] != "" && oldClasses[k] != "even" && oldClasses[k] != "odd")
  1077. newClassName += oldClasses[k] + " ";
  1078. }
  1079. tableRows[j].className = newClassName + (j % 2 == 0 ? "even" : "odd");
  1080. }
  1081. }
  1082. }
  1083. /*
  1084. * End of table sorting code
  1085. */
  1086. function runOnloadHook() {
  1087. // don't run anything below this for non-dom browsers
  1088. if (doneOnloadHook || !(document.getElementById && document.getElementsByTagName)) {
  1089. return;
  1090. }
  1091. // set this before running any hooks, since any errors below
  1092. // might cause the function to terminate prematurely
  1093. doneOnloadHook = true;
  1094. histrowinit();
  1095. unhidetzbutton();
  1096. tabbedprefs();
  1097. updateTooltipAccessKeys( null );
  1098. akeytt( null );
  1099. scrollEditBox();
  1100. setupCheckboxShiftClick();
  1101. sortables_init();
  1102. // Run any added-on functions
  1103. for (var i = 0; i < onloadFuncts.length; i++) {
  1104. onloadFuncts[i]();
  1105. }
  1106. }
  1107. //note: all skins should call runOnloadHook() at the end of html output,
  1108. // so the below should be redundant. It's there just in case.
  1109. hookEvent("load", runOnloadHook);
  1110. hookEvent("load", mwSetupToolbar);