User:Victar/common.js

//

//$('.cm-editor').append(window.getComputedStyle(document.querySelector('.cm-editor'), '::after').content.replace( /"/g, '' )); //$('.cm-editor').removeClass('pseudo'); /* $.getScript("//en.wiktionary.org/w/index.php?title=User:Erutuon/scripts/apiWrapper.js&action=raw") .done(function {    function xlit(term, callback) {        apiWrapper.callLua('require("Module:peo-translit").tr("' + term + '", nil, "Xpeo")', callback);    }

$.when(mw.loader.using("mediawiki.util"), $.ready).done(function{       jQuery(document).ready(function { var peoElements = document.querySelectorAll('span[lang="peo"]'); for (var j=0, max=peoElements.length; j < max; j++) { const elem = peoElements[j]; xlit(elem.firstChild.innerHTML, function (translit) {                   elem.append(" (" + translit + ")");                }); }       });    }); });

/*var gotElements = document.querySelectorAll('span[lang="got"]'); var gotLatnElements = document.querySelectorAll('span[lang="got-Latn"]'); for (var j=0, max=gotElements.length; j < max; j++) { var gotParent = gotElements[j].parentElement; gotElements[j].prepend(gotParent.getElementsByTagName('a').innerHTML); }*/

setTimeout(function{	var pseudoElements = document.querySelectorAll('.cite-meta li');	for (var i=0, max=pseudoElements.length; i < max; i++) {		var before = window.getComputedStyle(pseudoElements[i], '::before');		var after = window.getComputedStyle(pseudoElements[i], '::after');		if (before.content != "none") {			pseudoElements[i].parentElement.prepend(before.content.replace( /(^")|("$)/g,  ));			pseudoElements[i].style.display = 'none';		}		if (after.content != "none") {			pseudoElements[i].parentElement.append(after.content.replace( /(^")|("$)/g,  ));			pseudoElements[i].style.display = 'none';		}	} });

jQuery(document).ready(function {   jQuery('.cite-meta-2').html(jQuery(".cite-meta").html); });

var columns = 3; var rows = 3; var $rootElement = $("#example4"); var count = $rootElement.find("ul li").length; var round_split = Math.round(count/columns); var offset = 0;

if (count < (columns*rows)) { $rootElement.find(".vsToggleElement").hide; }

if (count - (round_split*columns) == 1) { offset = 1 }

var col2_start = (round_split+1)+offset; var col3_start = ((round_split*2)+1)+(offset*2);

var links = "ul li:nth-child(-n+" + rows + ")"; if (columns == 2 || columns == 3) { links += ", ul li:nth-child(+n" + col2_start + "):nth-child(-n+" + (col2_start+(rows-1)) + ")"; } if (columns == 3) { links += ", ul li:nth-child(+n" + col3_start + "):nth-child(-n+" + (col3_start+(rows-1)) + ")"; }

$rootElement.find("ul li").not(links).addClass("vsHide");

($(document).ready(function { (new mw.Api).get({		action: 'parse',		text: '',		title: mw.config.values.wgPageName,	}).done(function (data) {		console.log(data);		const result = data.parse.text['*'];		if (result)			$(result).prependTo('.ns-118.action-view #mw-content-text');	}); }));

//var element = document.querySelectorAll('[lang="ae-Latn"]');

//[].forEach.call(element, function(element) { //	var parent = element.parentElement.innerHTML.replace(/ *\([^)]*\) */g, ""); //	element.parentElement.innerHTML = parent; //});*/

var customizeToolbar = function { $('#wpTextbox1').wikiEditor('addToToolbar', {		section: 'advanced',		group: 'format',		tools: {			"references": {				label: 'Add references section',				type: 'button',				icon: '//upload.wikimedia.org/wikipedia/commons/thumb/3/32/OOjs_UI_icon_ref.svg/22px-OOjs_UI_icon_ref.svg.png',				action: {					type: 'encapsulate',					options: {						pre: "===References===\n ",						'ownline': true					}				}			},			"desc": {				label: 'Replace with ',				type: 'button',				icon: '//upload.wikimedia.org/wikipedia/commons/thumb/2/2f/D-shortcode.svg/22px-D-shortcode.svg.png',				action: {					type: 'replace',					options: {			          'regex': /\b.*\:\s*\{{l\|([^}]*)\}}/g,			           'regexReplace': "",					}				}			},			"subst": {				label: 'Add subst:chars',				type: 'button',				icon: '//upload.wikimedia.org/wikipedia/commons/thumb/4/43/OOjs_UI_icon_language-ltr.svg/22px-OOjs_UI_icon_language-ltr.svg.png', action: { type: 'encapsulate', options: { pre: "subst:chars|" }				}			},			"alter": { label: 'Add ', type: 'button', icon: '//upload.wikimedia.org/wikipedia/commons/thumb/a/a4/Gnome-face-smile.svg/22px-Gnome-face-smile.svg.png', action: { type: 'encapsulate', options: { pre: "===Alternative forms===\n\* ", 'ownline': true }				}			},			"templates": { label: 'Add Template', type: 'select', list: { 'grc-Beekes' : { label: 'grc:Beekes', action: { type: 'encapsulate', options: { pre: ' ' }						}					},                   'ira-ESIJa' : { label: 'ira:ESIJa', action: { type: 'encapsulate', options: { pre: ' ' }						}					},                   'ira-Cheung-2007' : { label: 'ira:Cheung:2007', action: { type: 'encapsulate', options: { pre: ' ' }						}					},                   'ira-Novak-2013' : { label: 'ira:Novák:2013', action: { type: 'encapsulate', options: { pre: ' ' }						}					},					'itc-De-Vaan-2008' : { label: 'itc:De Vaan:2008', action: { type: 'encapsulate', options: { pre: ' ' }						}					},					'bsl-Derksen-2015' : { label: 'bsl:Derksen:2015', action: { type: 'encapsulate', options: { pre: ' ' }						}					},					'gem-Kroonen-2013' : { label: 'gem:Kroonen:2013', action: { type: 'encapsulate', options: { pre: ' ' }						}					},					'ine:LIV' : { label: 'ine:LIV', action: { type: 'encapsulate', options: { pre: ' ' }						}					},					'cel-Matasovic-2009' : { label: 'cel:Matasovic:2009', action: { type: 'encapsulate', options: { pre: ' ' }						}					},					'TOitPIEatPIEw' : { label: 'TOitPIEatPIEw', action: { type: 'encapsulate', options: { pre: ' ' }						}					},				}			}		}	}); };

/* Check if view is in edit mode and that the required modules are available. Then, customize the toolbar … */ if ( $.inArray( mw.config.get( 'wgAction' ), [ 'edit', 'submit' ] ) !== -1 ) { mw.loader.using( 'user.options' ).then( function {		// This can be the string "0" if the user disabled the preference (T54542)		if ( mw.user.options.get( 'usebetatoolbar' ) == 1 ) {			$.when( mw.loader.using( 'ext.wikiEditor' ), $.ready ).then( customizeToolbar );		}	} ); }

//