User:Vorziblix/common.js

// importScript("User:Jberkel/semhide.js"); importScript("User:Erutuon/contributionsTab.js"); /* jQuery(document).ready(function($){	console.log("executing common.js");	/********* T210695 WikiHiero kludge : https://phabricator.wikimedia.org/T210695 *********/ /*	$('table.mw-hiero-outer').first.each(function { // copies (or rather moves) all child nodes from one to another var mergeElement = function(src, dst, prepend) { var el, oldFirst = dst.firstChild; while ((el = src.firstChild)) prepend ? dst.insertBefore(el, oldFirst) : dst.appendChild(el); };		var shouldWrap = function { return this.parentNode && this.parentNode.tagName == "DIV" && this.parentNode.className != ""; };		var shouldRewrap = function(node) { return (node.tagName == "SPAN" && $(node).hasClass("mention-tr")) || (["A", "B", "I"].indexOf(node.tagName) >= 0); };		$('table.mw-hiero-outer').filter(shouldWrap).wrap(' ').each(function {			var self = this.parentNode, oldSelf;			while (self.parentNode && shouldRewrap(self.parentNode)) {				// ok, there's something that should be inlined. do a swap/rotate;				// make the old parent the child of the div and not the other way around.				// we'll do this by rewrapping the element and then unwrapping the inner div				$(self.parentNode).wrap(' ');				// self is now the outer wrapper				oldSelf = self, self = self.parentNode.parentNode;				$(oldSelf.firstChild).unwrap;			}			var next = self.nextSibling, prev = self.previousSibling;			var allowNext = !!next, allowPrev = !!prev;			// text nodes if they follow or precede the hiero table			var nextText = "", prevText = "";			if (allowNext && next.nodeType == 3) // text node, extract text and disallow merge if it has a newline				allowNext = (nextText = next.textContent).indexOf('\n') < 0, next = next.nextSibling, allowNext &= !!next; if (allowPrev && prev.nodeType == 3) // text node, extract text and disallow merge if it has a newline allowPrev = (prevText = prev.textContent).indexOf('\n') < 0, prev = prev.previousSibling, allowPrev &= !!prev; if (allowNext && next.tagName == "P") // merge nextText && self.appendChild(document.createTextNode(nextText)), mergeElement(next, self, false), $(next).remove; if (allowPrev && prev.tagName == "P") // merge prevText && self.insertBefore(document.createTextNode(prevText), self.firstChild), mergeElement(prev, self, true), $(prev).remove; else if (allowPrev && prev.tagName == "SPAN") // merge to 				prevText && self.insertBefore(document.createTextNode(prevText), self.firstChild), mergeElement(self, prev, false), $(self).remove; else if (allowPrev && prev.tagName == "DIV" && $(prev).hasClass("wikt-hierokludge")) // merge to existing wrapper prevText && self.insertBefore(document.createTextNode(prevText), self.firstChild), mergeElement(self, prev, false), $(self).remove; });	}); });