MediaWiki:Common.js

/* Any JavaScript here will be loaded for all users on every page load. */

/* Display / wanted pages without real redlinks */ $( document ).ready(function { // Hilight submenus  $(".sp-menu ul li ul li:has(ul)").find("a:first").append(" &raquo;");

var dropdown = document.getElementById('tm-wantedpages'); var tmdata = $('#tm-data').data; if (!dropdown || !tmdata) { return true; }

dropdown.innerHTML = "";

var mainpage = tmdata.toplevelpage + '/'; var mainpage_uri = encodeURIComponent(mainpage); var templatetype = tmdata.template || 'work';

var sp = tmdata.wanted.split("\t"); sp.forEach( function(subpage) {   var sp_underscore = subpage.replace(" ", "_");    var sp_nospace = subpage.replace(" ", "");

var li = document.createElement('li'); var link = document.createElement('a'); link.href = '/w/index.php?title='+ mainpage_uri + sp_underscore + '&preload=Mediawiki:'+ sp_nospace + '&preloadparams[]=' + templatetype + '&action=edit&redlink=1';

var icon = document.createElement('span'); icon.id = "tm-" + sp_underscore; link.appendChild(icon); link.innerHTML += subpage; li.appendChild(link); dropdown.appendChild(li); });

var li = document.createElement('li'); li.innerHTML = ' ' + ' '; dropdown.appendChild(li); });

/* Section Hide folder functionality */

function toggleSection(toggleObj, id, showtext, hidetext) { var e = document.getElementById('sectionblock'+id); if(toggleObj.innerHTML == showtext) { toggleObj.innerHTML = hidetext; e.style.display = 'block'; } else { toggleObj.innerHTML = showtext; e.style.display = 'none'; }

}

function toggleAllSections(toggleObj, showtext, hidetext, showall, hideall) { if (toggleObj.innerHTML == hideall) { $( ".hidelink" ).each( function (i, val) {     if (val.innerHTML == hidetext) {        val.onclick;      }    }); toggleObj.innerHTML = showall; } else { $( ".hidelink" ).each( function (i, val) {     if (val.innerHTML == showtext) {        val.onclick;      }    }); toggleObj.innerHTML = hideall; } }

/* make bullets after quotes not show up with multiple bullets */ mw.hook( 'wikipage.content' ).add( function {	$('blockquote + ul > li:first-child ul:first-child').parents('li').css('list-style', 'none'); });

/** /*global jQuery, mediaWiki*/ (function ($, mw) { "use strict"; var ns = mw.config.get('wgNamespaceNumber'), cUrl = '//upload.wikimedia.org/wikipedia/commons/thumb/', //Commons /** sMirC emotions only **/ s = 'SMirC-', sMList = {}; addSmilie(s+'¹',[ ['6/69', 'smile', ':-)'], ['e/ec', 'wink', ';-)'], ['e/e3', 'beam', ':-D'], ['8/8c', 'dunno', ':-S'], ['6/66', 'grin', 'X-)'], ['9/90', 'happy', '=>'], ['5/5a', 'laugh', 'lol'], ['a/a2', 'doh', 'doh'], ['0/00', 'mmm', 'mm'], ['6/6d', 'bored', '-.-'], ['0/0b', 'whistle', '"-:'], ['9/91', 'chuckle', '^_^'], ['0/08', 'cool', 'B)'], ['e/e3', 'bearhug', 'ʕ•ᴥ•ʔ'], ['3/3f', 'angel', '0:)'], ['4/40', 'devil', '3:D'], ['c/c2', 'vamp', '*,,*'], ['b/bf', 'alien', '(.V.)'], ['b/b3', 'dead', '☠'], ['b/b3', 'stoned', '@_,@'], ['5/56', 'puke', '(ﾟ＊ﾟ)'], ['5/54', 'jealous', '(°₀°)'], ['0/0e', 'angry', '>:[]'], ['0/0d', 'hot', '♨'], ['9/93', 'freezing', ':-{}'], ['3/3d', 'spent', 'x_x'], ['5/5a', 'hi', 'hi'], ['4/47', 'beware', 'stop'], ['6/62', 'congrats', '-<-@'], ['f/f5', 'party', '*<:o)'], ['1/1f', 'thumbsup', 'yes'], ['c/c8', 'thumbsdown', 'no'], ['0/0c', 'shock', 'O_O'], ['5/5f', 'goggle', '°o°'] ]); addSmilie(s+'²',[ ['3/39', 'sad', ':-('], ['d/d5', 'medium', ':-|'], ['a/aa', 'puppyeyes', '8-('], ['6/66', 'rolleyes', '8)'], ['e/e3', 'unnerved', '(~_~)'], ['a/ae', 'cry', ';,('], ['b/b6', 'love', '<3'], ['8/80', 'kiss', ':-*'], ['3/35', 'what', '???'], ['4/4b', 'zzz', 'zZz'], ['c/c2', 'sceptic', ';-/'], ['5/58', 'silent', ':-x'], ['c/c3', 'tongue', ':-P'], ['1/1e', 'crazy', '%Þ'], ['6/64', 'horny', '<3Þ'], ['e/ec', 'greedy', '$Þ'], ['0/00', 'shy', '●^_^●'], ['7/7f', 'embarassed', '●°.°●'], ['d/d2', 'nerd', '8-)'], ['d/d8', 'wasntI', '8-°'], ['8/85', 'worry', '8-['], ['8/8b', 'wtf', 'o_O'], ['1/17', 'martial', '(-°-)'], ['a/ab', 'xmas', 'xmas'], ['3/33', 'coffeebreak', 'café'], ['9/95', 'facepalm', 'm('], ['5/5d', 'sunny', '☀'], ['3/37', 'cloudy', '☁'], ['d/d2', 'rainy', '☂'], ['2/27', 'thundery', '☈'], ['9/9e', 'snowy', '☃'], ['5/55', 'hazy', '≈'], ['d/d3', 'super', '\\S/'], ['7/78', 'asshole', '(_*_)'] ]);
 * Insert WikiEditor (sMirC) emoticons buttons
 * @created 2014-08-16
 * @source mw:Extension:WikiEditor/Toolbar customization, SMirC
 * @version 0.1.8 (06:48, 18 October 2014 (UTC))
 * @author c:User:Perhelion, 2014
 * @license released in the public domain
 * required modules: jquery, mw, mw.user, wikiEditor

function addSmilie (g, sL) { // make buttons var b = {}, i, id, src, fns = '20px|' + sL[i][2] +'' }			}		};	}	sMList[g] = { label : g,		tools : b	}; }

function emoticons { // make to toolbar $('#wpTextbox1').wikiEditor('addToToolbar', {		sections : { 			'emoticons' : {				type : 'toolbar',				groups : sMList			}		}	}); $('.tab-emoticons a').append($(' ') // made section button (hack)		.attr({ src : cUrl+'5/59/Cute_Ball_-_Games.png/22px-Cute_Ball_-_Games.png', width : 22, height : 22, title : 'Emoticons', rel : s,			role : 'button', 'class' : 'tool tool-button' })); } /* Check if view is in edit mode and that the required modules are available. Then, customize the toolbar… */ if ((ns % 2 === 1 || $.inArray(ns, [2, 4]) !== -1) && $.inArray(mw.config.get('wgAction'),['edit','submit']) !== -1 && $('#editform').length) mw.loader.using('user.options', function { 		if (mw.user.options.get('usebetatoolbar') && mw.user.options.get('showtoolbar'))			$.when(mw.loader.using(['ext.wikiEditor.toolbar', 'jquery.wikiEditor.toolbar']), $.ready).then( emoticons );		else mw.loader.using('mediawiki.notify').done(function  { mw.notify('You must enable the enhanced toolbar (WikiEditor) to show the Emoticons bar!'); });	}); else mw.hook('ext.lqt.textareaCreated').add( emoticons ); // LiquidThreads }(jQuery, mediaWiki));