User:Automatik/test.js

/** LegacyScripts **/ /*jshint maxerr:1048576, strict:true, undef:true, latedef:true, es3:true */ /*global mw, jQuery, importScript */

/*

importScript
*/

/** * importScript inserts a javascript page either *   from Wiktionary: importScript('User:Connel MacKensie/yetanother.js'); *   from another Wikimedia wiki: importScript('User:Lupin/insane.js', 'en.wikipedia.org'); * *   by specifying the third argument, an oldid can be passed to ensure that updates to the script are not included. *   by specifying the fourth argument, a specific version of JavaScript can be declared. * *   based on w:MediaWiki:Common.js 2007-11-29

window.importScript = function (page, wiki, oldid, jsver) { var url = ( wiki ? encodeURIComponent(wiki) : mw.config.get('wgScript')) + '?title=' + mw.util.wikiUrlencode(page) + (oldid ? '&oldid=' + encodeURIComponent(oldid) : '') + '&action=raw&ctype=text/javascript';

if (wiki || oldid || jsver) { mw.log.warn("importScript called with more than one argument. This is deprecated and may be unreliable. Please use mw.loader.load('" + url + "') directly"); }

if (window.importScriptURI) { // Only include scripts once return window.importScriptURI(url) ? true : false; }

var scriptElem = document.createElement("script"); scriptElem.setAttribute("src",url); scriptElem.setAttribute("type", jsver ? "application/javascript;version=" + jsver : "text/javascript"); document.getElementsByTagName("head")[0].appendChild(scriptElem); return true; };

/*

DOM creation
*/ /** * Create a new DOM node for the current document. *   Basic usage:  var mySpan = newNode('span', "Hello World!") *   Supports attributes and event handlers*: var mySpan = newNode('span', {style:"color: red", focus: function{alert(this)}, id:"hello"}, "World, Hello!") *   Also allows nesting to create trees: var myPar = newNode('p', newNode('b',{style:"color: blue"},"Hello"), mySpan) * * *event handlers, there are some issues with IE6 not registering event handlers on some nodes that are not yet attached to the DOM, * it may be safer to add event handlers later manually. var newNode = window.newNode = function newNode(tagname) { var node = document.createElement(tagname);

for (var i = 1; i < arguments.length; ++i){ if (typeof arguments[i] === 'string') { // text node.appendChild(document.createTextNode(arguments[i])); } else if (typeof arguments[i] === 'object') { if (arguments[i].nodeName) { //If it is a DOM Node node.appendChild(arguments[i]); } else { // Attributes (hopefully) for (var j in arguments[i]){ if (j === 'class') { //Classname different because... node.className = arguments[i][j]; } else if (j === 'style') { //Style is special node.style.cssText = arguments[i][j]; } else if (typeof arguments[i][j] === 'function') { //Basic event handlers newNode.addEventHandler(node, j, arguments[i][j]); } else { node.setAttribute(j, arguments[i][j]); //Normal attributes }				}			}		}	}

node.addEventHandler = function(eventName, handler) { newNode.addEventHandler(this, eventName, handler); };

return node; };

newNode.addEventHandler = function(node, eventName, handler) { try{ node.addEventListener(eventName,handler,false); //W3C }catch(e){try{ node.attachEvent('on'+eventName,handler,"Language"); //MSIE }catch(e){ node['on'+eventName]=handler; }} //Legacy };

/*

CSS
*/

window.addCSSRule = function (selector,cssText) { mw.log.warn("deprecated function addCSSRule called; use mw.util.addCSS(css) instead"); mw.util.addCSS( selector+'{' + cssText + '}' ); };

/*

Cookies


window.setCookie = function setCookie(cookieName, cookieValue) { /*global escape */ mw.log.warn("deprecated function setCookie called; use jQuery.cookie instead"); var today = new Date; var expire = new Date; var nDays = 30; expire.setTime( today.getTime + (3600000 * 24 * nDays) ); document.cookie = cookieName + "=" + escape(cookieValue) + ";path=/" + ";expires="+expire.toGMTString; };

window.getCookie = function getCookie(cookieName) { /*global unescape */ mw.log.warn("deprecated function getCookie called; use jQuery.cookie instead");

cookieName = String(cookieName); var start = document.cookie.indexOf( cookieName + "=" ); if ( start === -1 ) return ""; var len = start + cookieName.length + 1; if ( ( !start ) && ( cookieName !== document.cookie.substring( 0, cookieName.length ) ) ) return ""; var end = document.cookie.indexOf( ";", len ); if ( end === -1 ) end = document.cookie.length; return unescape( document.cookie.substring( len, end ) ); };

window.deleteCookie = function deleteCookie(cookieName) { mw.log.warn("deprecated function deleteCookie called; use jQuery.cookie instead"); if (window.getCookie(cookieName)) { document.cookie = cookieName + "=" + ";path=/" + ";expires=Thu, 01-Jan-1970 00:00:01 GMT"; } };

/*

Wiktionary Customisation
*/

if ( document.getElementById('footer') ) { jQuery.ready; }

//initialize the storage for script options. Gadgets that set script //options should also include this line as they are loaded before us. if ( typeof WiktScriptPrefs == 'undefined') { window.WiktScriptPrefs = {}; }

/*

MediaWiki:Youhavenewmessages to display differently for non-newbies with JS than for others
*/ /* Suspected unresponsive page culprit: see the GP (Nov. 2010, "Blocking script execution on each page") */ /* if (mw.config.get('wgUserGroups') && mw.config.get('wgUserGroups').join("").indexOf("autoconfirmed") > -1) {	addCSSRule(".msgfornewbies", "display: none"); }else{ addCSSRule(".msgfornonnewbies", "display: none"); } */

/*

WT:FEED
*/ if (!mw.config.get('wgUserName')) { importScript('User:Conrad.Irwin/feedback.js'); }

/*

WT:PREFS
*/ if ( jQuery.cookie('WiktPrefs') || mw.config.get('wgPageName') === "Wiktionary:Per-browser_preferences") { //importScript('User:Connel_MacKenzie/custom.js'); importScript('User:Hippietrail/custom.js'); }

/*

MediaWiki:Edit.js
*/ jQuery(document).ready( function { if ( mw.config.get('wgAction') === 'edit' || mw.config.get('wgAction') === 'submit' || document.getElementById('editpage-specialchars') ) {	importScript('MediaWiki:Edit.js'); } });

/*

Page specific extensions
*/

/*

Main Page
*/ // Hide the title and "Redirected from" (maybe we should keep the redirected from so's people update their bookmarks ;) // Broken in IE! if ( mw.config.get('wgPageName') === 'Wiktionary:Main_Page' && !( mw.config.get('wgAction') === 'view' || mw.config.get('wgAction') === 'submit' ) ){ mw.util.addCSS( '.firstHeading { display: block !important; }' ); mw.util.addCSS( '#contentSub { display: inline !important; }' ); }

if (mw.config.get('wgPageName') === 'Wiktionary:Main_Page') { jQuery(function {		mw.util.addPortletLink('p-lang', '//meta.wikimedia.org/wiki/Wiktionary#List_of_Wiktionaries', 'Complete list', 'interwiki-completelist', 'Complete list of Wiktionaries');	}); }

/*

Special:Search
*/

if ( mw.config.get('wgPageName') === 'Special:Search') { importScript('MediaWiki:SpecialSearch.js'); importScript('User:Yair rand/FindTrans.js'); } else { jQuery(function {		if (document.getElementById('preloadGuide')) {			importScript('MediaWiki:SpecialSearch.js');		}	}); }

/*

Custom search engines
*/

if( mw.config.get('wgPageName') === 'Help:Tips_and_tricks' ){ importScript('MediaWiki:CustomSearch.js'); }

/*

Geonotice
*/ /*Ended December 2009 else if (mw.config.get('wgPageName') == "Special:Watchlist") //watchlist scripts {	mw.loader.load('http://toolserver.org/~para/geoip.fcgi'); jQuery(function { mw.loader.load('http://en.wiktionary.org/w/index.php?title=MediaWiki:Geonotice.js&action=raw&ctype=text/javascript&maxage=3600'); }); }

/*

Add User:Conrad.Irwin/editor.js for editing translations
*/

importScript('User:Automatik/editor.js');

/*

Import User:Yair rand/newentrywiz.js
*/ jQuery(document).ready(function{ if(document.getElementById('necblah')){ importScript('User:Yair rand/newentrywiz.js'); } });

/*

Import User:Yair rand/adddefinition.js
*/ importScript('User:Yair rand/adddefinition.js'); /*

Import User:Yair rand/rhymesedit.js
*/ mw.config.get('wgNamespaceNumber') === 106 && importScript("User:Yair rand/rhymesedit.js"); /*

Import User:Yair rand/TargetedTranslations.js
*/ importScript("User:Yair rand/TargetedTranslations.js"); /*

URL Fixes
*/

/** * doRedirect will redirect if a did you mean box is found, and create a * "redirected from X" if a rdfrom is passed in the get parameters * The first half is an ugly workaround for 3339, :( * The second half is an ugly workaround for not having serverware support :(

/*

Did you mean ____ redirects
*/

window.setTimeout(function {	// REDIRECTED FROM	if( location.href.indexOf('rdfrom=') !== -1 ) {		var wiktDYMfrom = decodeURIComponent(location.href.replace(/^(.+[&\?]rdfrom=([^&#]+).*|.*)?$/,"$2"));

jQuery('#siteSub').after(			newNode('div', {id: 'contentSub'}, '(Auto-redirected from ',				newNode('a', {href: mw.util.getUrl(wiktDYMfrom) + '?redirect=no', 'class': 'new'}, wiktDYMfrom),		')'));

} else { // DID YOU MEAN var target = jQuery('#did-you-mean a').html, pagetitle = jQuery('h1').first.text.replace(/^\s+|\s+$/g, '');

if (target && target !== pagetitle			&& !location.href.match(/[&\?]redirect=no|[&\?]action=(?!view)/)			&& (jQuery.cookie('WiktionaryDisableAutoRedirect') != 'true')			&& mw.config.get('wgArticleId') === 0			&& mw.config.get('wgNamespaceNumber') === 0			&& !/Redirected from/.test(jQuery('#contentSub').html)		) { location = mw.util.getUrl( target, { "rdfrom": pagetitle } ); }	}

// Random page in a given language location.href.replace(/[?&]rndlang=([^&#]+)[^#]*(?:#(.+))?/, function (m, lang, headlang) {		var script = 'http://toolserver.org/~hippietrail/randompage.fcgi';

var insert = document.getElementById('contentSub'); if (headlang) { var heading = document.getElementById(headlang); if (heading) heading = heading.parentNode; if (heading) { insert = newNode('div', {style: 'font-size: 84%; line-height: 1.2em;'}); heading.parentNode.insertBefore(insert, heading.nextSibling); }		}

if (!insert || (insert.innerHTML !== "")) return;

insert.appendChild(newNode('span', {style: 'color: #888;'}, "Another ", newNode('a', {href: script + '?langs=1'}, "Random"), " word in ", newNode('a', {href: script + '?langname=' + lang}, decodeURIComponent(lang)) ));	}); }, 3000);

/*

Fix Wikified section titles
*/ jQuery(document).ready(function {	// {temp|template}	if (/\.7B\.7Btemp\.7C(.*?)\.7D\.7D/.test(location.href)) {		var url = location.href.replace(/\.7B\.7Btemp.7C/g, ".7B.7B");		location = url;	} });

jQuery(document).ready(function {	if(mw.config.get('wgAction') !== 'edit')		return;	if(!/[?&]section=\d/.test(location.href))		return;	var wpSummary = document.getElementById('wpSummary');	if(!wpSummary)		return;	if(wpSummary.value.substr(0, 3) !== '/* ')		return;	if(wpSummary.value.substr(wpSummary.value.length - 4) !== ' */ ')		return;	wpSummary.value = wpSummary.value.replace(/\{\{temp(late)?\|/g, '{{'); });

/*

Visibility toggling
*/ var VisibilityToggles = window.VisibilityToggles = { // toggles[category] = [[show, hide],...]; statuses[category] = [true, false,...]; buttons = 	toggles: {}, statuses: {}, buttons: null,

// Add a new toggle, adds a Show/Hide category button in the toolbar, // and will call show_function and hide_function once on register, and every alternate click. register: function (category, show_function, hide_function) { var id = 0; if (!this.toggles[category]) { this.toggles[category] = []; this.statuses[category] = []; } else { id = this.toggles[category].length; }		this.toggles[category].push([show_function, hide_function]); this.statuses[category].push(this.currentStatus(category)); this.addGlobalToggle(category);

(this.statuses[category][id] ? show_function : hide_function);

return function { var statuses = VisibilityToggles.statuses[category]; statuses[id] = !statuses[id]; VisibilityToggles.checkGlobalToggle(category); return (statuses[id] ? show_function : hide_function); };	},

// Add a new global toggle to the side bar addGlobalToggle: function(category) { if (document.getElementById('p-visibility-'+category)) return; if (!this.buttons) { this.buttons = newNode('ul'); var collapsed = jQuery.cookie("vector-nav-p-visibility") === "false", toolbox = newNode('div', {'class': "portal portlet "+(collapsed?"collapsed":"expanded"), 'id': 'p-visibility'},					newNode('h3', 'Visibility'),					newNode('div', {'class': "pBody body"}, collapsed ? void(0) : {'style':'display:block;'}, this.buttons)				); var sidebar = document.getElementById('mw-panel') || document.getElementById('column-one'); var insert = null; if ((insert = (document.getElementById('p-lang') || document.getElementById('p-feedback')))) sidebar.insertBefore(toolbox, insert); else sidebar.appendChild(toolbox); }		var status = this.currentStatus(category); var newToggle = newNode('li', newNode('a', { id: 'p-visibility-' + category, style: 'cursor: pointer', href: '#visibility-' + category, click: function(e) {				VisibilityToggles.toggleGlobal(category); if (e && e.preventDefault) e.preventDefault; else window.event.returnValue = false; return false; }},			(status ? 'Hide ' : 'Show ') + category)); for (var i = 0; i < this.buttons.childNodes.length; i++) { if (this.buttons.childNodes[i].id < newToggle.id) { this.buttons.insertBefore(newToggle, this.buttons.childNodes[i]); return; }		}		this.buttons.appendChild(newToggle); },

// Update the toggle-all buttons when all things are toggled one way checkGlobalToggle: function(category) { var statuses = this.statuses[category]; var status = statuses[0]; for (var i = 1; i < statuses.length; i++) { if (status != statuses[i]) return; }		document.getElementById('p-visibility-' + category).innerHTML = (status ? 'Hide ' : 'Show ') + category; },

// Toggle all un-toggled elements when the global button is clicked toggleGlobal: function(category) { var status = document.getElementById('p-visibility-' + category).innerHTML.indexOf('Show ') === 0; for (var i = 0; i < this.toggles[category].length; i++ ) { if (this.statuses[category][i] != status) { this.toggles[category][i][status ? 0 : 1];				this.statuses[category][i] = status; }		}		document.getElementById('p-visibility-' + category).innerHTML = (status ? 'Hide ' : 'Show ') + category; var current = jQuery.cookie('Visibility'); if (!current) current = ";"; current = current.replace(';' + category + ';', ';'); if (status) current = current + category + ";"; window.setCookie('Visibility', current); },

currentStatus: function(category) { if (location.hash.toLowerCase.split('_')[0] == '#' + category.toLowerCase) return true; if (location.href.search(/[?](.*&)?hidecats=/) > 0) {			var hidecats = location.href; hidecats = hidecats.replace(/^[^?]+[?]((?!hidecats=)[^&]*&)*hidecats=/, ''); hidecats = hidecats.replace(/&.*/, ''); hidecats = hidecats.split(','); for (var i = 0; i < hidecats.length; ++i) if (hidecats[i] == category || hidecats[i] == 'all') return false; else if (hidecats[i] == '!' + category || hidecats[i] == 'none') return true; }		if (jQuery.cookie('WiktionaryPreferencesShowNav') == 'true') return true; if ((jQuery.cookie('Visibility') || "").indexOf(';' + category + ';') >= 0) return true; // TODO check category-specific cookies return false; } };

/*

NavBars
*/ var NavigationBarHide = 'hide ▲'; var NavigationBarShow = 'show ▼';

function NavToggleCategory(navFrame) {	var table = navFrame.getElementsByTagName('table')[0]; if (table && table.className == "translations") return "translations";

var heading = navFrame.previousSibling; while (heading) { if (/[hH][4-6]/.test(heading.nodeName)) { if (heading.getElementsByTagName('span')[1]) heading = heading.getElementsByTagName('span')[0]; return jQuery(heading).text.toLowerCase // jQuery's .text is inconsistent about whitespace: .replace(/^\s+|\s+$/g, '').replace(/\s+/g, ' ') // remove numbers added by the "Auto-number headings" pref: .replace(/^[1-9][0-9.]+ ?/, ''); }		else if (/[hH][1-3]/.test(heading.nodeName)) break; heading = heading.previousSibling; }	return "other boxes"; }

function createNavToggle(navFrame){ var navHead, navToggle, navContent; for (var j=0; j < navFrame.childNodes.length; j++) { var div = navFrame.childNodes[j]; if (/(^|[^a-zA-Z0-9_\-])NavHead(?![a-zA-Z0-9_\-])/.test(div.className)) navHead = div; if (/(^|[^a-zA-Z0-9_\-])NavContent(?![a-zA-Z0-9_\-])/.test(div.className)) navContent = div; }	if (!navHead || !navContent) return; // Step 1, don't react when a subitem is clicked. for (var i=0; i<navHead.childNodes.length; i++) { var child = navHead.childNodes[i]; if (child.nodeName == "A") { child.onclick = function (e) { if (e && e.stopPropagation) e.stopPropagation; else window.event.cancelBubble = true; };		}	}	// Step 2, toggle visibility when bar is clicked. // NOTE This function was chosen due to some funny behaviour in Safari. navToggle = newNode('a', {href: 'javascript:(function{})'}, ''); navHead.insertBefore(newNode('span', {'class': 'NavToggle'}, '[', navToggle, ']'), navHead.firstChild);

navHead.style.cursor = "pointer"; navHead.onclick = VisibilityToggles.register(NavToggleCategory(navFrame),		function show {			navToggle.innerHTML = NavigationBarHide;			if (navContent)				navContent.style.display = "block";		},		function hide {			navToggle.innerHTML = NavigationBarShow;			if (navContent)				navContent.style.display = "none";		}); }

jQuery(document).ready( function {	var divs = jQuery(".NavFrame");	for (var i=0; i < divs.length; i++) {		// XXX: some templates use a class of NavFrame for the style, but for legacy reasons, are not NavFrames		// if (divs[i].className == "NavFrame") {		createNavToggle(divs[i]);		// }	} });

/*

Hidden Quotes
*/

function setupHiddenQuotes(li) { var HQToggle, liComp, dl; var HQShow = 'quotations ▼'; var HQHide = 'quotations ▲'; for (var k = 0; k < li.childNodes.length; k++) { // Look at each component of the definition. liComp = li.childNodes[k]; if ( liComp.nodeName.toLowerCase === "dl" && !dl ) { dl = liComp; }		// If we find a ul or dl, we have quotes or example sentences, and thus need a button. if (/^(ul|UL)$/.test(liComp.nodeName)) { HQToggle = newNode('a', {href: 'javascript:(function{})'}, ''); li.insertBefore(newNode('span', {'class': 'HQToggle'}, ' [', HQToggle, ']'), dl || liComp); HQToggle.onclick = VisibilityToggles.register('quotations',				function show {					HQToggle.innerHTML = HQHide;					for (var child = li.firstChild; child; child = child.nextSibling) {						if (/^(ul|UL)$/.test(child.nodeName)) {							child.style.display = 'block';						}					}				},				function hide {					HQToggle.innerHTML = HQShow;					for (var child = li.firstChild; child; child = child.nextSibling) {						if (/^(ul|UL)$/.test(child.nodeName)) {							child.style.display = 'none';						}					}				});

break; }	} }

jQuery(document).ready(function {	if (mw.config.get('wgNamespaceNumber') === 0) {		var ols, lis, li;		// First, find all the ordered lists, i.e. all the series of definitions.		var ols = document.getElementsByTagName('ol');		for(var i = 0; i < ols.length; i++) {		 // Then, for every set, find all the individual definitions.			for (var j = 0; j < ols[i].childNodes.length; j++) {				li = ols[i].childNodes[j];				if (li.nodeName.toUpperCase == 'LI') {					setupHiddenQuotes(li);				}			}		}	} });

jQuery(mw).bind('LivePreviewDone', function (ev, sels) {	var ols = jQuery(sels.join(',')).find('ol');	for(var i = 0; i < ols.length; i++) {		for (var j = 0; j < ols[i].childNodes.length; j++) {			var li = ols[i].childNodes[j];			if (li.nodeName.toUpperCase == 'LI') {				setupHiddenQuotes(li);			}		}	} });

/*

View Switching
*/

function viewSwitching(rootElement) { var showButtonText = 'more ▼'; var hideButtonText = 'less ▲'; var elemsToHide = rootElement.getElementsByClassName('vsHide'); var elemsToShow = rootElement.getElementsByClassName('vsShow'); // Find the element to place the toggle button in. var toggleElement = rootElement.getElementsByClassName('vsToggleElement'); //if (toggleElement.length === 0) //	return; toggleElement = toggleElement[0]; // The toggleElement becomes clickable in its entirety, but // we need to prevent this if a contained link is clicked instead. for (var i = 0; i < toggleElement.childNodes.length; ++i) { var child = toggleElement.childNodes[i]; if (child.nodeName == "A") { child.onclick = function (e) { if (e && e.stopPropagation) e.stopPropagation; else window.event.cancelBubble = true; };		}	}	// Add the toggle button. var toggleButton = newNode('a', {href: 'javascript:(function{})'}, ''); toggleElement.insertBefore(newNode('span', {'class': 'NavToggle'}, '[', toggleButton, ']'), toggleElement.firstChild); // Determine the visibility toggle category (for the links in the bar on the left). var toggleCategory = "others"; var classNames = rootElement.className.split(/\s+/); for (var i = 0; i < classNames.length; ++i) { var className = classNames[i].split('-'); if (className[0] == 'vsToggleCategory') { toggleCategory = className[1]; }	}	// Register the visibility toggle. toggleElement.style.cursor = "pointer"; toggleElement.onclick = VisibilityToggles.register(toggleCategory,		function show {			toggleButton.innerHTML = hideButtonText;			for (var i = 0; i < elemsToShow.length; ++i) {				elemsToShow[i].style.display = 'none';			}			for (var i = 0; i < elemsToHide.length; ++i) {				if (elemsToHide[i].nodeName == "TABLE")					elemsToHide[i].style.display = 'table';				else if (elemsToHide[i].nodeName == "TR")					elemsToHide[i].style.display = 'table-row';				else if (elemsToHide[i].nodeName == "TD" || elemsToHide[i].nodeName == "TH")					elemsToHide[i].style.display = 'table-cell';				else					elemsToHide[i].style.display = 'block';			}		},		function hide {			toggleButton.innerHTML = showButtonText;			for (var i = 0; i < elemsToShow.length; ++i) {				if (elemsToShow[i].nodeName == "TABLE")					elemsToShow[i].style.display = 'table';				else if (elemsToShow[i].nodeName == "TR")					elemsToShow[i].style.display = 'table-row'; else if (elemsToShow[i].nodeName == "TD" || elemsToShow[i].nodeName == "TH") elemsToShow[i].style.display = 'table-cell'; else elemsToShow[i].style.display = 'block'; }			for (var i = 0; i < elemsToHide.length; ++i) { elemsToHide[i].style.display = 'none'; }	}); }

document.getElementsByClassName && jQuery(document).ready(function {	var vsSwitchers = document.getElementsByClassName('vsSwitcher');	for (var i = 0; i < vsSwitchers.length; ++i) {		viewSwitching(vsSwitchers[i]); 	} });

/*

Interproject links
*/

/* jQuery(document).ready(function {	var elements = [];	var spans = document.getElementsByTagName('span');
 * 1) ProjectLinks
 * 2)  by user:Pathoschild (idea from an older, uncredited script)
 * 3)    * generates a sidebar list of links to other projects from
 * 1)    * generates a sidebar list of links to other projects from

// filter for projectlinks for (var i = 0, j = 0; i < spans.length; i++) { if (spans[i].className == 'interProject') { elements[j] = spans[i].getElementsByTagName('a')[0]; j++; }	}

if (j === 0) return;

// sort alphabetically function sortbylabel(a,b) { // get labels a = a.innerHTML.replace(/^.*]*>(.*)<\/a>.*$/i,'$1'); b = b.innerHTML.replace(/^.*]*>(.*)<\/a>.*$/i,'$1');

// return sort order if (a < b) return -1; if (a > b) return 1; return 0; }	elements.sort(sortbylabel);

// Create the list of project links var pllist = newNode('ul'); for (var i=0; i<elements.length; i++) { pllist.appendChild(newNode('li', elements[i])); }	var collapsed = jQuery.cookie("vector-nav-p-projects") == "false"; var projectBox = newNode('div', {'class': 'portlet portal '+(collapsed?"collapsed":"expanded"), id: 'p-projects'}, 		newNode('h3', 'In other projects'),		newNode('div', {'class': 'pBody body'}, collapsed?undefined:{'style':'display:block;'}, pllist)	);

var insert = document.getElementById('p-tb'); if (!insert) return;

if (insert.nextSibling) insert.parentNode.insertBefore(projectBox, insert.nextSibling); else insert.parentNode.appendChild(projectBox); });

/*

Scripts specific to Internet Explorer
*/ if (navigator.appName == "Microsoft Internet Explorer") { /** Internet Explorer bug fix ************************************************** *	 * Description: Fixes IE horizontal scrollbar bug * Maintainers: User:Tom-? */

var oldWidth; var docEl = document.documentElement;

var fixIEScroll = function { function doFixIEScroll { docEl.style.overflowX = (docEl.scrollWidth - docEl.clientWidth < 4) ? "hidden" : ""; }

if (!oldWidth || docEl.clientWidth > oldWidth) doFixIEScroll; else setTimeout(doFixIEScroll, 1);

oldWidth = docEl.clientWidth; };	document.attachEvent("onreadystatechange", fixIEScroll); document.attachEvent("onresize", fixIEScroll);

// In print IE (7?) does not like line-height mw.util.addCSS( '@media print { sup, sub, p, .documentDescription { line-height: normal; }}');

// IE overflow bug mw.util.addCSS('div.overflowbugx { overflow-x: scroll !important; overflow-y: hidden !important; } div.overflowbugy { overflow-y: scroll !important; overflow-x: hidden !important; }');

// IE zoomfix // Use to fix right floating div/table inside tables mw.util.addCSS('.iezoomfix div, .iezoomfix table { zoom: 1;}');

// Import scripts specific to Internet Explorer 6 if (navigator.appVersion.substr(22, 1) == "6") { importScript("MediaWiki:Common.js/IE60Fixes.js"); } }

/*

Category page fixes
*/

// Apply only to category pages if (mw.config.get('wgNamespaceNumber') === 14) {	jQuery(document).ready(function($)	{		var wrapper;		// Apply only to pages containing an element with the id "catfix"		if (!(wrapper = document.getElementById("catfix")))			return;		mw.loader.using(['mediawiki.Title'], function {			// Get the language name and script wrapper var langname = wrapper.className.split("CATFIX-")[1]; wrapper = wrapper.getElementsByTagName("*")[0] || document.createElement("span"); var anchor = ""; if (langname.length > 0) anchor = "#" + langname; // Process each link in the category listing jQuery("#mw-pages>.mw-content-ltr").find("li>a").each(function			{				try				{					var titleobj = new mw.Title(this.textContent || this.innerText);					// If the page is not in mainspace, reconstruction or not an appendix page beginning with the language name (i.e. reconstructions), then skip					if (!(titleobj.getNamespaceId === 0 || titleobj.getNamespaceId == 118 || (titleobj.getNamespaceId == 100 && titleobj.getNameText.substr(0, langname.length + 1) == langname + "/")))						return;					// Add the anchor only to mainspace pages					if (titleobj.getNamespaceId === 0)						this.setAttribute("href", this.getAttribute("href", 2) + anchor);					// Insert the wrapper around the link					var li = this.parentNode;					var clone = wrapper.cloneNode(false);					li.removeChild(this);					clone.appendChild(this);					li.appendChild(clone);				}				catch(e)				{				}			}); });	}); }

/*

Temporary button for enabling two proposed scripts
*/

if ( jQuery.cookie("YRNewStuff") || location.search.indexOf("tabbedlanguages=on") != -1 ) { importScript("User:Yair rand/editor2.js"); importScript("User:Yair rand/TabbedLanguages2.js"); }

jQuery(document).ready(function {	if(document.getElementById('YRNewStuff-enable-button'))	{		document.getElementById('YRNewStuff-enable-button').innerHTML = "";		var toggle = newNode('span', {click: function  { if( jQuery.cookie("YRNewStuff") ){ jQuery.cookie("YRNewStuff", null,{path:"/"}); toggle.innerHTML = "Enable tabbed languages and definition editing options."; }			else{ jQuery.cookie("YRNewStuff",1,{expires:30,path:"/"}); toggle.innerHTML = "Disable tabbed languages and definition editing options."; }		} }, (jQuery.cookie("YRNewStuff")?"Disable":"Enable")+" tabbed languages and definition editing options.");		document.getElementById('YRNewStuff-enable-button').appendChild(toggle);	} });

/*

WT:ES Discussion tool (User:Yair rand/DiscussionSandbox.js)
*/

mw.config.get('wgPageName') == "Wiktionary:Etymology_scriptorium" && importScript("User:Yair rand/DiscussionSandbox.js");

jQuery(document).ready(function {	jQuery("table.unit-tests th.unit-tests-img-corner").bind("click", function { var table = this; while (table.tagName !== "TABLE") table = table.parentNode; table.classList.toggle("unit-tests-hide-passing"); }); });