MediaWiki:Gadget-hide-empty-fields.js: Różnice pomiędzy wersjami

Usunięta treść Dodana treść
jest jakis problem z mw.util.$content[ 0 ]
niech iteruje po wezlach kolekcji $content - zdaje sie, ze zabraklo jakiejs niezbednej zaleznosci albo cos sie zmienilo ostatnio w mw.util; wlasciwosc $content wciaz ma wartosc 'null' po odswiezeniu cache strony pod Chrome, zwykle F5 dziala bez zarzutow
Linia 3:
 
window.hide_empty = {
version: '7.7dbg28',
show: false,
foundEmpty: false,
lang: {},
contentNode: null
};
 
Linia 15 ⟶ 16:
 
hide_empty.browse = function ( node ) {
var subNode, nodeName, start, end, text, j;
for ( var j = 0; j < node.childNodes.length; j++ ) {
var subNode = node.childNodes[ j ];
for ( var j = 0; j < node.childNodes.length; j++ ) {
var nodeName = subNode.nodeName.toLowerCase();
var subNode = node.childNodes[ j ];
var nodeName = subNode.nodeName.toLowerCase();
if ( subNode.nodeType !== 1 ) {
Linia 26 ⟶ 29:
}
if ( nodeName !== 'dl' /*&& !subNode.className*/ ) {
var start = subNode.className.indexOf( 'fldn-' );
if ( start < 0 ) {
Linia 32 ⟶ 35:
}
var end = ( subNode.className + ' ' ).indexOf( ' ', start );
if ( end < 0 ) {
Linia 38 ⟶ 41:
}
var text = subNode.textContent || subNode.innerText;
if (
Linia 54 ⟶ 57:
 
hide_empty.process = function () {
var fields, subNode, start, end, i, n, text;
this.fields = {};
this.browse( contentthis.contentNode );
console.log(10);
console.log(mw.util);
console.log(mw.util.$content);
console.log(mw.util.$content[ 0 ]);
var content = mw.util.$content[ 0 ];
console.log(11);
this.browse( content );
console.log(12);
this.foundEmpty = false;
var fields = document.getElementsByTagName( 'dt' );
console.log(3);
console.log(fields);
for ( var i = 0; i < fields.length; i++ ) {
var subNode = fields[ i ];
if ( !subNode.className ) {
Linia 74 ⟶ 72:
}
var start = subNode.className.indexOf( 'fldn-' );
if ( start < 0 ) {
Linia 80 ⟶ 78:
}
var end = ( subNode.className + ' ' ).indexOf( ' ', start );
if ( end < 0 ) {
Linia 92 ⟶ 90:
fields[ i ].parentNode.style.display = ( this.show ? 'block' : 'none' );
}
console.log(14);
var n = document.getElementById( 'ca-empty-fields' );
console.log(15);
console.log(n);
if ( n ) {
var text = this.lang[ this.foundEmpty ? this.show ? 0 : 1 : 2 ];
if ( n.firstChild.nodeName.toLowerCase() === 'span' ) {
Linia 107 ⟶ 104:
n.className = this.foundEmpty ? '' : 'new';
}
console.log(16);
$.cookie( 'hideSections', ( this.show ? '0' : '1' ), {
expires: 30,
path: '/'
} );
console.log(17);
};
 
Linia 120 ⟶ 116:
};
 
hide_empty.init = function ( node ) {
var hist, url, cookie;
console.log(5);
if ( !( hist = document.getElementById( 'ca-history' ) ) ) return;
if ( !( url = hist.getElementsByTagName( 'a' )[ 0 ] ) ) return;
if ( !( url = url.href ) ) return;
console.log(6);
this.contentNode = node;
this.lang = this.strings[ mw.config.get( 'wgUserLanguage' ) ];
Linia 146 ⟶ 144:
hide_empty.switchEmptyFields();
} );
console.log(7);
var cookie = $.cookie( 'hideSections' );
this.show = ( cookie == '0' );
this.process();
console.log(8);
// zapobiega wskokowi w niewlasciwe miejsce wskutek ukrycia pustych sekcji po zaladowaniu strony
if ( location.hash ) location.hash = location.hash;
console.log(9);
};
 
Linia 160 ⟶ 157:
mw.config.get( 'wgAction' ) === 'view'
) {
console.log(1);
mw.hook( 'sectionLinks.ready' ).add( function ( $content ) {
console hide_empty.loginit(mw.util. $content[ 0 ] );
console.log(2);
hide_empty.init();
console.log(3);
mw.hook( 'hideEmptyFields.ready' ).fire( $content );
console.log(4);
} );
}