r68611 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r68610‎ | r68611 | r68612 >
Date:20:39, 26 June 2010
Author:siebrand
Status:ok
Tags:
Comment:
Revert r68598. Broken.

Special:Preferences tabs were no longer displayed, was shown all in one page, Gadgets didn't load any longer.
Modified paths:
  • /trunk/phase3/skins/common/wikibits.js (modified) (history)

Diff [purge]

Index: trunk/phase3/skins/common/wikibits.js
@@ -5,9 +5,9 @@
66 !/khtml|spoofer|netscape\/7\.0/.test(clientPC);
77 var webkit_match = clientPC.match(/applewebkit\/(\d+)/);
88 if (webkit_match) {
9 - var is_safari = clientPC.indexOf('applewebkit') !== -1 &&
10 - clientPC.indexOf('spoofer') === -1;
11 - var is_safari_win = is_safari && clientPC.indexOf('windows') !== -1;
 9+ var is_safari = clientPC.indexOf('applewebkit') != -1 &&
 10+ clientPC.indexOf('spoofer') == -1;
 11+ var is_safari_win = is_safari && clientPC.indexOf('windows') != -1;
1212 var webkit_version = parseInt(webkit_match[1]);
1313 // Tests for chrome here, to avoid breaking old scripts safari left alone
1414 // This is here for accesskeys
@@ -19,9 +19,9 @@
2020 var is_ff2 = /firefox\/[2-9]|minefield\/3/.test( clientPC );
2121 var ff2_bugs = /firefox\/2/.test( clientPC );
2222 // These aren't used here, but some custom scripts rely on them
23 -var is_ff2_win = is_ff2 && clientPC.indexOf('windows') !== -1;
24 -var is_ff2_x11 = is_ff2 && clientPC.indexOf('x11') !== -1;
25 -if (clientPC.indexOf('opera') !== -1) {
 23+var is_ff2_win = is_ff2 && clientPC.indexOf('windows') != -1;
 24+var is_ff2_x11 = is_ff2 && clientPC.indexOf('x11') != -1;
 25+if (clientPC.indexOf('opera') != -1) {
2626 var is_opera = true;
2727 var is_opera_preseven = window.opera && !document.childNodes;
2828 var is_opera_seven = window.opera && document.childNodes;
@@ -33,7 +33,11 @@
3434 // As recommended by <http://msdn.microsoft.com/en-us/library/ms537509.aspx>,
3535 // avoiding false positives from moronic extensions that append to the IE UA
3636 // string (bug 23171)
37 -var ie6_bugs = /MSIE ([0-9]{1,}[\.0-9]{0,})/.exec( clientPC ) && parseFloat( RegExp.$1 ) <= 6.0 );
 37+var ie6_bugs = false;
 38+if ( /MSIE ([0-9]{1,}[\.0-9]{0,})/.exec( clientPC ) != null
 39+&& parseFloat( RegExp.$1 ) <= 6.0 ) {
 40+ ie6_bugs = true;
 41+}
3842
3943 // Global external objects used by this script.
4044 /*extern ta, stylepath, skin */
@@ -69,7 +73,7 @@
7074 var loadedScripts = {}; // included-scripts tracker
7175 function importScriptURI( url ) {
7276 if ( loadedScripts[url] ) {
73 - return;
 77+ return null;
7478 }
7579 loadedScripts[url] = true;
7680 var s = document.createElement( 'script' );
@@ -109,7 +113,7 @@
110114 }
111115
112116 // Special stylesheet links for Monobook only (see bug 14717)
113 -if ( typeof stylepath !== 'undefined' && skin === 'monobook' ) {
 117+if ( typeof stylepath != 'undefined' && skin == 'monobook' ) {
114118 if ( opera6_bugs ) {
115119 importStylesheetURI( stylepath + '/' + skin + '/Opera6Fixes.css' );
116120 } else if ( opera7_bugs ) {
@@ -159,7 +163,7 @@
160164 linkHolder.appendChild( outerSpan );
161165
162166 var cookiePos = document.cookie.indexOf( "hidetoc=" );
163 - if ( cookiePos > -1 && document.cookie.charAt( cookiePos + 8 ) === 1 ) {
 167+ if ( cookiePos > -1 && document.cookie.charAt( cookiePos + 8 ) == 1 ) {
164168 toggleToc();
165169 }
166170 }
@@ -176,7 +180,7 @@
177181
178182 function killEvt( evt ) {
179183 evt = evt || window.event || window.Event; // W3C, IE, Netscape
180 - if ( typeof ( evt.preventDefault ) !== 'undefined' ) {
 184+ if ( typeof ( evt.preventDefault ) != 'undefined' ) {
181185 evt.preventDefault(); // Don't follow the link
182186 evt.stopPropagation();
183187 } else {
@@ -190,7 +194,7 @@
191195 var toc = document.getElementById('toc').getElementsByTagName('ul')[0];
192196 var toggleLink = document.getElementById( 'togglelink' );
193197
194 - if ( toc && toggleLink && toc.style.display === 'none' ) {
 198+ if ( toc && toggleLink && toc.style.display == 'none' ) {
195199 changeText( toggleLink, tocHideText );
196200 toc.style.display = 'block';
197201 document.cookie = "hidetoc=0";
@@ -238,8 +242,8 @@
239243 } else if ( !is_safari_win && is_safari && webkit_version > 526 ) {
240244 tooltipAccessKeyPrefix = 'ctrl-alt-';
241245 } else if ( !is_safari_win && ( is_safari
242 - || clientPC.indexOf('mac') !== -1
243 - || clientPC.indexOf('konqueror') !== -1 ) ) {
 246+ || clientPC.indexOf('mac') != -1
 247+ || clientPC.indexOf('konqueror') != -1 ) ) {
244248 tooltipAccessKeyPrefix = 'ctrl-';
245249 } else if ( is_ff2 ) {
246250 tooltipAccessKeyPrefix = 'alt-shift-';
@@ -317,11 +321,11 @@
318322 function addPortletLink( portlet, href, text, id, tooltip, accesskey, nextnode ) {
319323 var root = document.getElementById( portlet );
320324 if ( !root ) {
321 - return;
 325+ return null;
322326 }
323327 var node = root.getElementsByTagName( 'ul' )[0];
324328 if ( !node ) {
325 - return;
 329+ return null;
326330 }
327331
328332 // unhide portlet if it was hidden before
@@ -351,7 +355,7 @@
352356 updateTooltipAccessKeys( new Array( link ) );
353357 }
354358
355 - if ( nextnode && nextnode.parentNode === node ) {
 359+ if ( nextnode && nextnode.parentNode == node ) {
356360 node.insertBefore( item, nextnode );
357361 } else {
358362 node.appendChild( item ); // IE compatibility (?)
@@ -361,10 +365,10 @@
362366 }
363367
364368 function getInnerText( el ) {
365 - if ( typeof el === 'string' ) {
 369+ if ( typeof el == 'string' ) {
366370 return el;
367371 }
368 - if ( typeof el === 'undefined' ) {
 372+ if ( typeof el == 'undefined' ) {
369373 return el;
370374 }
371375 if ( el.textContent ) {
@@ -400,7 +404,7 @@
401405
402406 function setupCheckboxShiftClick() {
403407 checkboxes = [];
404 - lastCheckbox = undefined;
 408+ lastCheckbox = null;
405409 var inputs = document.getElementsByTagName( 'input' );
406410 addCheckboxClickHandlers( inputs );
407411 }
@@ -417,7 +421,7 @@
418422
419423 for ( var i = start; i < finish; i++ ) {
420424 var cb = inputs[i];
421 - if ( !cb.type || cb.type.toLowerCase() !== 'checkbox' ) {
 425+ if ( !cb.type || cb.type.toLowerCase() != 'checkbox' ) {
422426 continue;
423427 }
424428 var end = checkboxes.length;
@@ -434,10 +438,10 @@
435439 }
436440
437441 function checkboxClickHandler( e ) {
438 - if ( typeof e === 'undefined' ) {
 442+ if ( typeof e == 'undefined' ) {
439443 e = window.event;
440444 }
441 - if ( !e.shiftKey || lastCheckbox === undefined ) {
 445+ if ( !e.shiftKey || lastCheckbox === null ) {
442446 lastCheckbox = this.index;
443447 return true;
444448 }
@@ -452,7 +456,7 @@
453457 }
454458 for ( var i = start; i <= finish; ++i ) {
455459 checkboxes[i].checked = endState;
456 - if( i > start && typeof checkboxes[i].onchange === 'function' ) {
 460+ if( i > start && typeof checkboxes[i].onchange == 'function' ) {
457461 checkboxes[i].onchange(); // fire triggers
458462 }
459463 }
@@ -469,22 +473,22 @@
470474 */
471475 function getElementsByClassName( oElm, strTagName, oClassNames ) {
472476 var arrReturnElements = new Array();
473 - if ( typeof( oElm.getElementsByClassName ) === 'function' ) {
 477+ if ( typeof( oElm.getElementsByClassName ) == 'function' ) {
474478 /* Use a native implementation where possible FF3, Saf3.2, Opera 9.5 */
475479 var arrNativeReturn = oElm.getElementsByClassName( oClassNames );
476 - if ( strTagName === '*' ) {
 480+ if ( strTagName == '*' ) {
477481 return arrNativeReturn;
478482 }
479483 for ( var h = 0; h < arrNativeReturn.length; h++ ) {
480 - if( arrNativeReturn[h].tagName.toLowerCase() === strTagName.toLowerCase() ) {
 484+ if( arrNativeReturn[h].tagName.toLowerCase() == strTagName.toLowerCase() ) {
481485 arrReturnElements[arrReturnElements.length] = arrNativeReturn[h];
482486 }
483487 }
484488 return arrReturnElements;
485489 }
486 - var arrElements = ( strTagName === '*' && oElm.all ) ? oElm.all : oElm.getElementsByTagName( strTagName );
 490+ var arrElements = ( strTagName == '*' && oElm.all ) ? oElm.all : oElm.getElementsByTagName( strTagName );
487491 var arrRegExpClassNames = new Array();
488 - if( typeof oClassNames === 'object' ) {
 492+ if( typeof oClassNames == 'object' ) {
489493 for( var i = 0; i < oClassNames.length; i++ ) {
490494 arrRegExpClassNames[arrRegExpClassNames.length] =
491495 new RegExp("(^|\\s)" + oClassNames[i].replace(/\-/g, "\\-") + "(\\s|$)");
@@ -521,7 +525,7 @@
522526 return;
523527 }
524528 }
525 - if ( window.location.hash === '' ) {
 529+ if ( window.location.hash == '' ) {
526530 window.location.hash = fragment;
527531
528532 // Mozilla needs to wait until after load, otherwise the window doesn't
@@ -532,7 +536,7 @@
533537 // well.
534538 if ( is_gecko ) {
535539 addOnloadHook(function() {
536 - if ( window.location.hash === fragment ) {
 540+ if ( window.location.hash == fragment ) {
537541 window.location.hash = fragment;
538542 }
539543 });
@@ -555,10 +559,10 @@
556560 var ts_image_up = 'sort_up.gif';
557561 var ts_image_down = 'sort_down.gif';
558562 var ts_image_none = 'sort_none.gif';
559 -var ts_europeandate = wgContentLanguage !== 'en'; // The non-American-inclined can change to "true"
 563+var ts_europeandate = wgContentLanguage != 'en'; // The non-American-inclined can change to "true"
560564 var ts_alternate_row_colors = false;
561 -var ts_number_transform_table;
562 -var ts_number_regex;
 565+var ts_number_transform_table = null;
 566+var ts_number_regex = null;
563567
564568 function sortables_init() {
565569 var idnum = 0;
@@ -589,7 +593,7 @@
590594 // We have a first row: assume it's the header, and make its contents clickable links
591595 for ( var i = 0; i < firstRow.cells.length; i++ ) {
592596 var cell = firstRow.cells[i];
593 - if ( (' ' + cell.className + ' ').indexOf(' unsortable ') === -1 ) {
 597+ if ( (' ' + cell.className + ' ').indexOf(' unsortable ') == -1 ) {
594598 cell.innerHTML += '<a href="#" class="sortheader" '
595599 + 'onclick="ts_resortTable(this);return false;">'
596600 + '<span class="sortarrow">'
@@ -617,7 +621,7 @@
618622 var column = td.cellIndex;
619623
620624 var table = tr.parentNode;
621 - while ( table && !( table.tagName && table.tagName.toLowerCase() === 'table' ) ) {
 625+ while ( table && !( table.tagName && table.tagName.toLowerCase() == 'table' ) ) {
622626 table = table.parentNode;
623627 }
624628 if ( !table ) {
@@ -629,7 +633,7 @@
630634 }
631635
632636 // Generate the number transform table if it's not done already
633 - if ( ts_number_transform_table === undefined ) {
 637+ if ( ts_number_transform_table === null ) {
634638 ts_initTransformTable();
635639 }
636640
@@ -637,7 +641,7 @@
638642 // Skip the first row if that's where the headings are
639643 var rowStart = ( table.tHead && table.tHead.rows.length > 0 ? 0 : 1 );
640644 var bodyRows = 0;
641 - if (rowStart === 0 && table.tBodies) {
 645+ if (rowStart == 0 && table.tBodies) {
642646 for (var i=0; i < table.tBodies.length; i++ ) {
643647 bodyRows += table.tBodies[i].rows.length;
644648 }
@@ -650,7 +654,7 @@
651655 if ( table.rows[i].cells.length > column ) {
652656 itm = ts_getInnerText(table.rows[i].cells[column]);
653657 itm = itm.replace(/^[\s\xa0]+/, '').replace(/[\s\xa0]+$/, '');
654 - if ( itm !== '' ) {
 658+ if ( itm != '' ) {
655659 break;
656660 }
657661 }
@@ -672,7 +676,7 @@
673677 preprocessor = ts_parseFloat;
674678 }
675679
676 - var reverse = ( span.getAttribute( 'sortdir' ) === 'down' );
 680+ var reverse = ( span.getAttribute( 'sortdir' ) == 'down' );
677681
678682 var newRows = new Array();
679683 var staticRows = new Array();
@@ -712,13 +716,13 @@
713717 // We appendChild rows that already exist to the tbody, so it moves them rather than creating new ones
714718 // don't do sortbottom rows
715719 for ( var i = 0; i < newRows.length; i++ ) {
716 - if ( ( ' ' + newRows[i][0].className + ' ').indexOf(' sortbottom ') === -1 ) {
 720+ if ( ( ' ' + newRows[i][0].className + ' ').indexOf(' sortbottom ') == -1 ) {
717721 table.tBodies[0].appendChild( newRows[i][0] );
718722 }
719723 }
720724 // do sortbottom rows only
721725 for ( var i = 0; i < newRows.length; i++ ) {
722 - if ( ( ' ' + newRows[i][0].className + ' ').indexOf(' sortbottom ') !== -1 ) {
 726+ if ( ( ' ' + newRows[i][0].className + ' ').indexOf(' sortbottom ') != -1 ) {
723727 table.tBodies[0].appendChild( newRows[i][0] );
724728 }
725729 }
@@ -736,8 +740,8 @@
737741 }
738742
739743 function ts_initTransformTable() {
740 - if ( typeof wgSeparatorTransformTable === 'undefined'
741 - || ( wgSeparatorTransformTable[0] === '' && wgDigitTransformTable[2] === '' ) )
 744+ if ( typeof wgSeparatorTransformTable == 'undefined'
 745+ || ( wgSeparatorTransformTable[0] == '' && wgDigitTransformTable[2] == '' ) )
742746 {
743747 var digitClass = "[0-9,.]";
744748 ts_number_transform_table = false;
@@ -794,7 +798,7 @@
795799
796800 function ts_dateToSortKey( date ) {
797801 // y2k notes: two digit years less than 50 are treated as 20XX, greater than 50 are treated as 19XX
798 - if ( date.length === 11 ) {
 802+ if ( date.length == 11 ) {
799803 switch ( date.substr( 3, 3 ).toLowerCase() ) {
800804 case 'jan':
801805 var month = '01';
@@ -835,20 +839,20 @@
836840 // default: var month = '00';
837841 }
838842 return date.substr( 7, 4 ) + month + date.substr( 0, 2 );
839 - } else if ( date.length === 10 ) {
840 - if ( ts_europeandate === false ) {
 843+ } else if ( date.length == 10 ) {
 844+ if ( ts_europeandate == false ) {
841845 return date.substr( 6, 4 ) + date.substr( 0, 2 ) + date.substr( 3, 2 );
842846 } else {
843847 return date.substr( 6, 4 ) + date.substr( 3, 2 ) + date.substr( 0, 2 );
844848 }
845 - } else if ( date.length === 8 ) {
 849+ } else if ( date.length == 8 ) {
846850 var yr = date.substr( 6, 2 );
847851 if ( parseInt( yr ) < 50 ) {
848852 yr = '20' + yr;
849853 } else {
850854 yr = '19' + yr;
851855 }
852 - if ( ts_europeandate === true ) {
 856+ if ( ts_europeandate == true ) {
853857 return yr + date.substr( 3, 2 ) + date.substr( 0, 2 );
854858 } else {
855859 return yr + date.substr( 0, 2 ) + date.substr( 3, 2 );
@@ -861,7 +865,7 @@
862866 if ( !s ) {
863867 return 0;
864868 }
865 - if ( ts_number_transform_table !== false ) {
 869+ if ( ts_number_transform_table != false ) {
866870 var newNum = '', c;
867871
868872 for ( var p = 0; p < s.length; p++ ) {
@@ -900,11 +904,11 @@
901905 var oldClasses = tableRows[j].className.split(' ');
902906 var newClassName = '';
903907 for ( var k = 0; k < oldClasses.length; k++ ) {
904 - if ( oldClasses[k] !== '' && oldClasses[k] !== 'even' && oldClasses[k] !== 'odd' ) {
 908+ if ( oldClasses[k] != '' && oldClasses[k] != 'even' && oldClasses[k] != 'odd' ) {
905909 newClassName += oldClasses[k] + ' ';
906910 }
907911 }
908 - tableRows[j].className = newClassName + ( j % 2 === 0 ? 'even' : 'odd' );
 912+ tableRows[j].className = newClassName + ( j % 2 == 0 ? 'even' : 'odd' );
909913 }
910914 }
911915 }

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r68598Clean up the mess of horrid javascript in wikibits before I fix a bugdantman05:22, 26 June 2010

Status & tagging log