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.
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 ];▼
var nodeName = subNode.nodeName.toLowerCase();▼
if ( subNode.nodeType !== 1 ) {
Linia 26 ⟶ 29:
}
if ( nodeName !== 'dl' /*&& !subNode.className*/ ) {
if ( start < 0 ) {
Linia 32 ⟶ 35:
}
if ( end < 0 ) {
Linia 38 ⟶ 41:
}
if (
Linia 54 ⟶ 57:
hide_empty.process = function () {
var fields, subNode, start, end, i, n, text;
this.fields = {};
console.log(mw.util.$content[ 0 ]);▼
▲ this.browse( content );
this.foundEmpty = false;
for (
if ( !subNode.className ) {
Linia 74 ⟶ 72:
}
if ( start < 0 ) {
Linia 80 ⟶ 78:
}
if ( end < 0 ) {
Linia 92 ⟶ 90:
fields[ i ].parentNode.style.display = ( this.show ? 'block' : 'none' );
}
if ( n ) {
if ( n.firstChild.nodeName.toLowerCase() === 'span' ) {
Linia 107 ⟶ 104:
n.className = this.foundEmpty ? '' : 'new';
}
$.cookie( 'hideSections', ( this.show ? '0' : '1' ), {
expires: 30,
path: '/'
} );
};
Linia 120 ⟶ 116:
};
hide_empty.init = function ( node ) {
var hist, url, cookie;
if ( !( hist = document.getElementById( 'ca-history' ) ) ) return;
if ( !( url = hist.getElementsByTagName( 'a' )[ 0 ] ) ) return;
if ( !( url = url.href ) ) return;
this.contentNode = node;
this.lang = this.strings[ mw.config.get( 'wgUserLanguage' ) ];
Linia 146 ⟶ 144:
hide_empty.switchEmptyFields();
} );
this.show = ( cookie == '0' );
this.process();
// zapobiega wskokowi w niewlasciwe miejsce wskutek ukrycia pustych sekcji po zaladowaniu strony
if ( location.hash ) location.hash = location.hash;
};
Linia 160 ⟶ 157:
mw.config.get( 'wgAction' ) === 'view'
) {
mw.hook( 'sectionLinks.ready' ).add( function ( $content ) {
mw.hook( 'hideEmptyFields.ready' ).fire( $content );
} );
}
|