Jump to content

User:TimR/misc.js

From Wikipedia, the free encyclopedia
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
function footnoteTarget(a) {
	var aTitle=Title.fromAnchor(a);
	// We want ".3A" rather than "%3A" or "?" here, so use the anchor property directly
	var anch = aTitle.anchor;
	if ( ! /^(cite_note-|_note-|endnote)/.test(anch) ) { return false;	}
 
	var lTitle=Title.fromURL(location.href);
	if ( lTitle.toString(true) != aTitle.toString(true) ) {	return false; }
 
	var el=document.getElementById(anch);
	while ( el && typeof el.nodeName == 'string') {
		var nt = el.nodeName.toLowerCase();
		if ( nt == 'li' ) { return el; }
		else if ( nt == 'body' ) { return false; }
		else if ( el.parentNode ) { el=el.parentNode; }
		else { return false; }
	}
	return false;
}