Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Press Ctrl-F5.
mw.loader.using('mediawiki.util').then(function() {
// Import codes from Dev Wiki
mw.loader.using([
'mediawiki.Uri',
// Make sure importArticle is loaded as a dependency
'ext.fandom.ContentReview.legacyLoaders.js'
], function() {
const devLoad = new mw.Uri( 'https://dev.fandom.com/load.php' );
devLoad.query = {
mode: 'articles', only: 'scripts',
articles: [
'MediaWiki:QuickDiff/code.js',
'MediaWiki:AnchoredRollback/code.js',
'MediaWiki:AllPagesHideRedirect/code.js',
'MediaWiki:AjaxBatchDelete.js',
'MediaWiki:AjaxRedirect/code.js',
'MediaWiki:PurgeButton/code.js',
'MediaWiki:CacheCheck/code.js',
'MediaWiki:RecentChangesMultiple/code.2.js',
'MediaWiki:RedirectManagement/code.js',
'MediaWiki:MultiUpload.js',
//'MediaWiki:CategoryRenameAuto-update/code.js',
'MediaWiki:AjaxEditPreview.js',
].join('|')
};
mw.loader.load( devLoad.toString() );
});
/* dev.fandom.com/wiki/MediaWiki:View_Source/code.js?oldid=134639
* View Source
* © Peter Coester 2013 [[User_talk:Pecoes|Pecoes]]
* documentation and examples at:
* https://dev.fandom.com/wiki/View_Source
*/
(function (module, mw, $) {
'use strict';
if (module.loadSource) return;
var config = mw.config.get([
'wgAction',
'wgArticleId',
'wgArticlePath',
'wgContentLanguage',
'wgCurRevisionId',
'wgFormattedNamespaces',
'wgPageName',
'wgUserLanguage',
'wgVersion'
]),
isUCP = config.wgVersion !== '1.19.24',
parserFunctions = {
'#expr': 'Help:Extension:ParserFunctions#.23expr',
'#if': 'Help:Extension:ParserFunctions#.23if',
'#ifeq': 'Help:Extension:ParserFunctions#.23ifeq',
'#iferror': 'Help:Extension:ParserFunctions#.23iferror',
'#ifexpr': 'Help:Extension:ParserFunctions#.23ifexpr',
'#ifexist': 'Help:Extension:ParserFunctions#.23ifexist',
'#rel2abs': 'Help:Extension:ParserFunctions#.23rel2abs',
'#switch': 'Help:Extension:ParserFunctions#.23switch',
'#time': 'Help:Extension:ParserFunctions#.23time',
'#timel': 'Help:Extension:ParserFunctions#.23timel',
'#titleparts': 'Help:Extension:ParserFunctions#.23titleparts',
'subst': 'Help:Substitution',
'safesubst': 'Help:Substitution',
'#len': 'Extension:StringFunctions#.23len:',
'#pos': 'Extension:StringFunctions#.23pos:',
'#rpos': 'Extension:StringFunctions#.23rpos:',
'#sub': 'Extension:StringFunctions#.23sub:',
'#pad': 'Extension:StringFunctions#.23pad:',
'#replace': 'Extension:StringFunctions#.23replace:',
'#explode': 'Extension:StringFunctions#.23explode:',
'#urlencode': 'Extension:StringFunctions#.23urlencode:_and_.23urldecode:',
'#urldecode': 'Extension:StringFunctions#.23urlencode:_and_.23urldecode:',
'#invoke': 'Extension:Scribunto#Usage',
'#lst': 'Extension:Labeled_Section_Transclusion#How_it_works',
'#lsth': 'Extension:Labeled_Section_Transclusion#How_it_works',
'#lstx': 'Extension:Labeled_Section_Transclusion#How_it_works',
'#var': 'Extension:Variables#.23var',
'#var_final': 'Extension:Variables#.23var_final',
'#vardefine': 'Extension:Variables#.23vardefine',
'#vardefineecho': 'Extension:Variables#.23vardefineecho',
'#varexists': 'Extension:Variables#.varexists',
'#dpl': 'Extension:DynamicPageList_(third-party)',
// -> https://www.mediawiki.org/wiki/Help:Magic_words
'#dateformat': 'Help:Magic_words#Formatting',
'#formatdate': 'Help:Magic_words#Formatting',
'lc': 'Help:Magic_words#Formatting',
'lcfirst': 'Help:Magic_words#Formatting',
'uc': 'Help:Magic_words#Formatting',
'ucfirst': 'Help:Magic_words#Formatting',
'#language': 'Help:Magic_words#Miscellaneous',
'#special': 'Help:Magic_words#Miscellaneous',
'#tag': 'Help:Magic_words#Miscellaneous',
'ns': 'Help:Magic_words#Namespaces',
'PAGESINCAT': 'Help:Magic_words#Statistics',
'PAGESINCATEGORY': 'Help:Magic_words#Statistics',
'DEFAULTSORT': 'Help:Magic_words#Technical_metadata',
'DISPLAYTITLE': 'Help:Magic_words#Technical_metadata',
'int': 'Help:Magic_words#Transclusion_modifiers'
},
parserTags = {
activityfeed: 'https://community.fandom.com/wiki/Help:Wiki_Activity',
aoaudio: 'https://community.fandom.com/wiki/Help:Video',
aovideo: 'https://community.fandom.com/wiki/Help:Video',
bloglist: 'https://community.fandom.com/wiki/Help:Blog_article/Bloglist',
categorytree: 'https://www.mediawiki.org/wiki/Categorytree',
charinsert: 'https://www.mediawiki.org/wiki/Extension:CharInsert',
chat: 'https://community.fandom.com/wiki/Help:Chat',
choose: 'https://www.mediawiki.org/wiki/Extension:RandomSelection',
createbox: 'https://www.mediawiki.org/wiki/Extension:CreateBox',
dpl: 'https://community.fandom.com/wiki/Help:DynamicPageList',
'fb:facepile': 'https://community.fandom.com/wiki/Help:Social_media_integration#Adding_Facebook_widgets',
'fb:follow': 'https://community.fandom.com/wiki/Help:Social_media_integration#Adding_Facebook_widgets',
'fb:like': 'https://community.fandom.com/wiki/Help:Social_media_integration#Adding_Facebook_widgets',
'fb:likebox': 'https://community.fandom.com/wiki/Help:Social_media_integration#Adding_Facebook_widgets',
'fb:recommendations': 'https://community.fandom.com/wiki/Help:Social_media_integration#Adding_Facebook_widgets',
'fb:share-button': 'https://community.fandom.com/wiki/Help:Social_media_integration#Adding_Facebook_widgets',
forum: 'https://community.fandom.com/wiki/Help:Wiki-style_forums',
gallery: 'https://www.mediawiki.org/wiki/Gallery#Rendering_a_gallery_of_images',
ggtube: 'https://community.fandom.com/wiki/Help:Video',
googlespreadsheet: 'https://www.mediawiki.org/wiki/Extension:GoogleDocs4MW',
gtrailer: 'https://community.fandom.com/wiki/Help:Video',
gvideo: 'https://community.fandom.com/wiki/Help:Video',
helper: 'https://community.fandom.com/wiki/Help:Volunteers_and_Helpers#Helpers',
hiero: 'https://www.mediawiki.org/wiki/Hiero',
imagemap: 'https://www.mediawiki.org/wiki/Imagemap',
includeonly: 'https://www.mediawiki.org/wiki/Templates',
infobox: 'https://community.fandom.com/wiki/Help:Infoboxes',
inputbox: 'https://www.mediawiki.org/wiki/Inputbox',
'mainpage-endcolumn': 'https://community.fandom.com/wiki/Help:Main_page_column_tags',
'mainpage-leftcolumn-start': 'https://community.fandom.com/wiki/Help:Main_page_column_tags',
'mainpage-rightcolumn-start': 'https://community.fandom.com/wiki/Help:Main_page_column_tags',
math: 'https://www.mediawiki.org/wiki/Math',
nicovideo: 'https://community.fandom.com/wiki/Help:Video',
noinclude: 'https://www.mediawiki.org/wiki/Templates',
nowiki: 'https://meta.wikimedia.org/wiki/Help:Wikitext_examples#Just_show_what_I_typed',
onlyinclude: 'https://www.mediawiki.org/wiki/Templates',
poem: 'https://www.mediawiki.org/wiki/Extension:Poem',
poll: 'https://www.mediawiki.org/wiki/Extension:AJAXPoll',
pre: 'https://meta.wikimedia.org/wiki/Help:Wikitext_examples#Just_show_what_I_typed',
randomimage: 'https://www.mediawiki.org/wiki/Extension:RandomImage',
ref: 'https://www.mediawiki.org/wiki/Ref',
references: 'https://www.mediawiki.org/wiki/Ref',
rss: 'https://community.fandom.com/wiki/Help:Feeds',
section: 'https://www.mediawiki.org/wiki/Extension:Labeled_Section_Transclusion',
source: 'https://www.mediawiki.org/wiki/Extension:SyntaxHighlight_GeSHi',
syntaxhighlight: 'https://www.mediawiki.org/wiki/Extension:SyntaxHighlight_GeSHi',
staff: 'https://community.fandom.com/wiki/Community_Central:Staff',
tabber: 'https://community.fandom.com/wiki/Help:Tabber',
tabview: 'https://community.fandom.com/wiki/Help:Tab_view',
tangler: 'https://community.fandom.com/wiki/Help:Video',
timeline: 'https://www.mediawiki.org/wiki/Extension:Timeline',
twitter: 'https://community.fandom.com/wiki/Help:Social_media_integration#Adding_a_Twitter_timeline',
verbatim: 'https://community.fandom.com/wiki/Help:Verbatim_tags',
videogallery: 'https://community.fandom.com/wiki/Help:Video',
wegame: 'https://community.fandom.com/wiki/Help:Video',
youtube: 'https://community.fandom.com/wiki/Help:Video'
},
interwikiMap = {
w: 'https://community.fandom.com/wiki/$1',
community: 'https://community.fandom.com/wiki/$1',
bugzilla: 'https://bugzilla.wikimedia.org/show_bug.cgi?id=$1',
commons: 'https://commons.wikimedia.org/wiki/$1',
creativecommons: 'https://creativecommons.org/licenses/$1',
creativecommonswiki: 'https://wiki.creativecommons.org/$1',
dictionary: 'http://www.dict.org/bin/Dict?Database=*&Form=Dict1&Strategy=*&Query=$1', // http only
dict: 'http://www.dict.org/bin/Dict?Database=*&Form=Dict1&Strategy=*&Query=$1', // http only
docbook: 'http://wiki.docbook.org/topic/$1', // http only
download: 'https://download.wikimedia.org/$1',
dbdump: 'https://download.wikimedia.org/$1/latest/',
dreamhost: 'http://wiki.dreamhost.com/index.php/$1', // http only
finalfantasy: 'https://finalfantasy.wikia.com/wiki/$1',
flickruser: 'https://www.flickr.com/people/$1',
flickrphoto: 'https://www.flickr.com/photo.gne?id=$1',
foundation: 'https://wikimediafoundation.org/wiki/$1',
gerrit: 'https://gerrit.wikimedia.org/r/$1',
it: 'https://gerrit.wikimedia.org/r/gitweb?p=mediawiki/$1;a=log;h=refs/heads/master',
google: 'https://www.google.com/search?q=$1',
googledefine: 'https://www.google.com/search?q=define:$1',
googlegroups: 'https://groups.google.com/groups?q=$1',
guildwiki: 'https://guildwars.wikia.com/wiki/$1',
gutenberg: 'https://www.gutenberg.org/etext/$1',
gutenbergwiki: 'https://www.gutenberg.org/wiki/$1',
h2wiki: 'http://halowiki.net/p/$1', // http only, site parked
imdbname: 'https://www.imdb.com/name/nm$1/',
imdbtitle: 'https://www.imdb.com/title/tt$1/',
imdbcompany: 'https://www.imdb.com/company/co$1/',
imdbcharacter: 'https://www.imdb.com/character/ch$1/',
incubator: 'https://incubator.wikimedia.org/wiki/$1',
infosecpedia: 'http://infosecpedia.org/wiki/$1', // site down
irc: 'irc://irc.freenode.net/$1',
ircrc: 'irc://irc.wikimedia.org/$1',
rcirc: 'irc://irc.wikimedia.org/$1',
'iso639-3': 'https://www.sil.org/iso639-3/documentation.asp?id=$1',
issn: 'https://www.worldcat.org/issn/$1',
javanet: 'http://wiki.java.net/bin/view/Main/$1', // site down
javapedia: 'http://wiki.java.net/bin/view/Javapedia/$1', // site down
lostpedia: 'https://lostpedia.wikia.com/wiki/$1',
mail: 'https://lists.wikimedia.org/mailman/listinfo/$1',
mailarchive: 'https://lists.wikimedia.org/pipermail/$1',
mariowiki: 'https://www.mariowiki.com/$1',
marveldatabase: 'http://www.marveldatabase.com/wiki/index.php/$1', // http only
mediawikiwiki: 'https://www.mediawiki.org/wiki/$1',
mediazilla: 'https://bugzilla.wikimedia.org/$1',
memoryalpha: 'http://memory-alpha.org/wiki/$1', // http only
metawiki: 'http://sunir.org/apps/meta.pl?$1', // http only
metawikipedia: 'https://meta.wikimedia.org/wiki/$1',
mozcom: 'https://mozilla.wikia.com/wiki/$1',
mozillawiki: 'https://wiki.mozilla.org/$1',
mozillazinekb: 'http://kb.mozillazine.org/$1', // http only
musicbrainz: 'https://musicbrainz.org/doc/$1',
mw: 'https://www.mediawiki.org/wiki/$1',
mwod: 'https://www.merriam-webster.com/cgi-bin/dictionary?book=Dictionary&va=$1',
mwot: 'https://www.merriam-webster.com/cgi-bin/thesaurus?book=Thesaurus&va=$1',
nost: 'https://nostalgia.wikipedia.org/wiki/$1',
nostalgia: 'https://nostalgia.wikipedia.org/wiki/$1',
openfacts: 'http://openfacts.berlios.de/index-en.phtml?title=$1', // site down
openlibrary: 'https://openlibrary.org/$1',
openstreetmap: 'https://wiki.openstreetmap.org/wiki/$1',
openwetware: 'https://openwetware.org/wiki/$1',
openwiki: 'http://openwiki.com/?$1', // http only, site parked
osmwiki: 'https://wiki.openstreetmap.org/wiki/$1',
otrs: 'https://ticket.wikimedia.org/otrs/index.pl?Action=AgentTicketZoom&TicketID=$1',
otrswiki: 'https://otrs-wiki.wikimedia.org/wiki/$1',
perlnet: 'http://perl.net.au/wiki/$1', // http only, site parked
phpwiki: 'http://phpwiki.sourceforge.net/phpwiki/index.php?$1', // http only
pyrev: 'https://www.mediawiki.org/wiki/Special:Code/pywikipedia/$1',
pythoninfo: 'https://www.python.org/cgi-bin/moinmoin/$1',
pythonwiki: 'http://www.pythonwiki.de/$1', // http only
pywiki: 'http://c2.com/cgi/wiki?$1', // http only
rev: 'https://www.mediawiki.org/wiki/Special:Code/MediaWiki/$1',
revo: 'https://purl.org/NET/voko/revo/art/$1.html',
rfc: 'https://tools.ietf.org/html/rfc$1',
robowiki: 'http://robowiki.net/?$1', // http only
reuterswiki: 'http://glossary.reuters.com/index.php/$1', // http only
slashdot: 'https://slashdot.org/article.pl?sid=$1',
sourceforge: 'https://sourceforge.net/$1',
species: 'https://species.wikimedia.org/wiki/$1',
strategy: 'https://strategy.wikimedia.org/wiki/$1',
strategywiki: 'https://strategywiki.org/wiki/$1',
sulutil: 'https://toolserver.org/~quentinv57/sulinfo/$1',
svn: 'https://svn.wikimedia.org/viewvc/mediawiki/$1?view=log',
svgwiki: 'http://wiki.svg.org/index.php/$1', // http only
technorati: 'http://www.technorati.com/search/$1', // http only, site parked
tenwiki: 'https://ten.wikipedia.org/wiki/$1',
testwiki: 'https://test.wikipedia.org/wiki/$1',
ticket: 'https://ticket.wikimedia.org/otrs/index.pl?Action=AgentTicketZoom&TicketNumber=$1',
tools: 'https://toolserver.org/$1',
tswiki: 'https://wiki.toolserver.org/view/$1',
translatewiki: 'https://translatewiki.net/wiki/$1',
tvtropes: 'https://www.tvtropes.org/pmwiki/pmwiki.php/Main/$1',
unreal: 'https://wiki.beyondunreal.com/wiki/$1',
urbandict: 'https://www.urbandictionary.com/define.php?term=$1',
usemod: 'http://www.usemod.com/cgi-bin/wiki.pl?$1', // http only
usability: 'https://usability.wikimedia.org/wiki/$1',
webisodes: 'http://www.webisodes.org/$1', // http only, site parked
wg: 'https://wg.en.wikipedia.org/wiki/$1',
wiki: 'http://c2.com/cgi/wiki?$1', // http only
wikia: 'https://www.wikia.com/wiki/c:$1',
wikiasite: 'https://www.wikia.com/wiki/c:$1',
wikibooks: 'https://en.wikibooks.org/wiki/$1',
wikichat: 'http://www.wikichat.org/$1', // http only
wikicities: 'https://www.wikia.com/wiki/$1',
wikicity: 'https://www.wikia.com/wiki/c:$1',
wikihow: 'https://www.wikihow.com/$1',
wikiindex: 'https://wikiindex.org/$1',
wikimedia: 'https://wikimediafoundation.org/wiki/$1',
wikinews: 'https://en.wikinews.org/wiki/$1',
wikipedia: 'https://en.wikipedia.org/wiki/$1',
wikipediawikipedia: 'https://en.wikipedia.org/wiki/Wikipedia:$1',
wikiquote: 'https://en.wikiquote.org/wiki/$1',
wikischool: 'https://www.wikischool.de/wiki/$1',
wikisource: 'https://en.wikisource.org/wiki/$1',
wikispecies: 'https://species.wikimedia.org/wiki/$1',
wikispot: 'http://wikispot.org/?action=gotowikipage&v=$1', // http only
wikitech: 'https://wikitech.wikimedia.org/view/$1',
wikiversity: 'https://en.wikiversity.org/wiki/$1',
betawikiversity: 'https://beta.wikiversity.org/wiki/$1',
wiktionary: 'https://en.wiktionary.org/wiki/$1',
wmar: 'https://www.wikimedia.org.ar/wiki/$1',
wmau: 'https://wikimedia.org.au/wiki/$1',
wmbd: 'https://bd.wikimedia.org/wiki/$1',
wmbe: 'https://be.wikimedia.org/wiki/$1',
wmbr: 'https://br.wikimedia.org/wiki/$1',
wmca: 'https://wikimedia.ca/wiki/$1',
wmch: 'https://www.wikimedia.ch/$1',
wmcz: 'https://meta.wikimedia.org/wiki/Wikimedia_Czech_Republic/$1',
wmdc: 'https://wikimediadc.org/wiki/$1',
securewikidc: 'https://secure.wikidc.org/$1',
wmde: 'https://wikimedia.de/wiki/$1',
wmfi: 'https://fi.wikimedia.org/wiki/$1',
wmfr: 'https://wikimedia.fr/$1',
wmhk: 'https://wikimedia.hk/index.php/$1',
wmhu: 'http://wiki.media.hu/wiki/$1', // http only
wmid: 'https://www.wikimedia.or.id/wiki/$1',
wmil: 'https://www.wikimedia.org.il/$1',
wmin: 'https://wiki.wikimedia.in/$1',
wmit: 'https://wiki.wikimedia.it/wiki/$1',
wmmx: 'https://mx.wikimedia.org/wiki/$1',
wmnl: 'https://nl.wikimedia.org/wiki/$1',
wmnyc: 'https://nyc.wikimedia.org/wiki/$1',
wmno: 'https://no.wikimedia.org/wiki/$1',
wmpl: 'https://pl.wikimedia.org/wiki/$1',
wmrs: 'https://rs.wikimedia.org/wiki/$1',
wmru: 'https://ru.wikimedia.org/wiki/$1',
wmse: 'https://se.wikimedia.org/wiki/$1',
wmtw: 'https://wikimedia.tw/wiki/index.php5/$1',
wmua: 'https://ua.wikimedia.org/wiki/$1',
wmuk: 'https://uk.wikimedia.org/wiki/$1',
wmf: 'https://wikimediafoundation.org/wiki/$1',
wmfblog: 'https://blog.wikimedia.org/$1',
wookieepedia: 'https://starwars.wikia.com/wiki/$1',
wowwiki: 'http://www.wowwiki.com/$1' // http only
},
i18n, $content, $list, $source, $a, $toc, headers = [];
if (!window.dev || !window.dev.i18n) {
if (isUCP) {
mw.loader.load('https://dev.fandom.com/load.php?mode=articles&only=styles&articles=MediaWiki:View_Source.css', 'text/css');
} else {
importArticle({
type: 'style',
article: 'u:dev:MediaWiki:View_Source.css'
});
}
}
function addButton () {
$a = $('<a>', {
id: 'view-source-button',
//class: 'wds-button',
text: 'Source'
}).data('source', false).click(function () {
$a.closest('.wikia-menu-button')
.removeClass('active');
module[$a.data('source') ? 'hideSource' : 'loadSource']();
});
$($list).prepend($a);
}
function init (i18nInstance) {
i18n = i18nInstance;
$content = $('#mw-content-text');
$list = $('.page-header__contribution-buttons, .UserProfileActionButton, .page-header__actions');
if ($content.length && $list.length) {
addButton();
if (mw.util.getParamValue('view') === 'source') {
module.loadSource();
}
}
}
function joinHrefParts (parts) {
for (var i = 0; i < parts.length; i++) {
parts[i] = encodeURIComponent(parts[i]);
}
return parts.join(':').replace(/ /g, '_');
}
function createHref (link) {
var parts, hash = '';
if (link.indexOf('#') !== -1) {
parts = link.split(/\#/);
link = parts.shift();
if (!link.length) link = config.wgPageName;
hash = '#' + parts.pop();
}
if (link[0] === '/') link = config.wgPageName + link;
parts = link.split(/\:/);
/*if ( parts.length > 2 && parts[0] === 'w' && parts[1] === 'c') {
parts = parts.slice(2);
return '//' + parts.shift() + '.wikia.com/wiki/' + joinHrefParts(parts) + hash;
} else*/ if (parts.length > 1 && interwikiMap[parts[0].toLowerCase()]) {
return interwikiMap[parts.shift().toLowerCase()].replace(/\$1/, joinHrefParts(parts) + hash);
}
return config.wgArticlePath.replace('$1', joinHrefParts(parts) + hash);
}
function replaceTag (all, delim, tag) {
if (!parserTags[tag])
if (/\//g.test(all)) return '</' + tag;
else return '<' + tag;
return delim + '<a href="' + parserTags[tag] + '">' + tag + '</a>';
}
function replaceHeaders (m) {
headers.push(m);
return '<a name="h' + (headers.length-1) + '"></a>' + m;
}
function replaceWikiLink (all, link, title) {
title = title || '';
return '[[<a href="' + createHref(link) + '">' + link + '</a>'+ title + ']]';
}
function replaceTemplates (all, delim, name) {
var href, m = name.match(/^(\#?)(\w+)(\:.*)/),
fn = m && parserFunctions[m[1] + m[2]];
if (fn) {
return delim + m[1] + '<a href="https://www.mediawiki.org/wiki/' + fn + '">' + m[2] + '</a>' + m[3];
}
// remove <!--.*--> from template name. otherwise .match will failed
name = name.replace(/<\!\-\-[\s\S]*\-\->/, '');
m = name.match(/^(\s*)(.+)(\s*)$/);
if (m[2][0] === ':') {
href = m[2].substring(1);
} else if(m[2].indexOf('w:') === 0) {
href = 'w:' + (m[2][2] === ':' ?
m[2].substring(3) :
'Template:' + m[2].substring(2));
console.log(href);
} else {
href = m[2];
var templ = config.wgFormattedNamespaces[10] + ':';
if(href.indexOf('Template:') !== 0 && href.indexOf(templ) !== 0) {
href = templ + href;
}
}
return delim + m[1] + '<a href="' + createHref(href) + '">' + m[2] + '</a>' + m[3];
}
function replaceRegularLinks (all, link, title) {
title = title || '';
return '[<a href="' + link + '">' + link + '</a>'+ title + ']';
}
function replaceModules (all, prefix, title, postfix) {
// experimental stuff. doesn't recognize {{#invoke:module{{{var}}}}}
// /({{#invoke:)([\s\S]*?)(\||})/igm
var page = config.wgFormattedNamespaces[828] + ':' + title.trim();
return (prefix + '<a href="' + createHref(page) + '">' + title.trim() + '</a>' + postfix);
}
function createPseudoToc () {
var $rail = $('#WikiaRail'), toc, $ads;
if (headers.length && $source.height() > $(window).height() && $rail[0] && $rail.filter('.loaded')[0]) {
toc = '<ul>';
for (var i = 0; i < headers.length; i++) {
toc += '<li><a href="#h' + i + '">' + headers[i] + '</a></li>';
}
toc += '</ul>';
$toc = $('<section id="source-toc" class="rail-module">' + toc + '</section>');
$ads = $rail.find('#top-right-boxad-wrapper, #top-boxad-wrapper, #NATIVE_TABOOLA_RAIL').last();
if ($ads[0]) {
$ads.after($toc);
} else {
$rail.prepend($toc);
}
}
}
module.loadSource = function () {
$a.text('Article')
.data('source', true);
if ($source) {
$source.show();
$content.hide();
if ($toc) $toc.show();
} else {
$.get(mw.util.getUrl(config.wgPageName, {
action: 'raw',
maxage: '0',
smaxage: '0',
oldid: mw.util.getParamValue('diff') || mw.util.getParamValue('oldid') || config.wgCurRevisionId
}))
.done(function (wikitext) {
$source = $('<pre id="source-code">' +
wikitext
.replace(/&/g, '&')
.replace(/</g, '<' )
.replace(/>/g, '>' )
.replace(/({{#invoke:)([\s\S]*?)(\||})/igm, replaceModules)
.replace(/(<\/?)([\w\:\-]+)/g, replaceTag)
.replace(/^((=+)[^\[\]\{\}]+?\2)/gm, replaceHeaders)
.replace(/\[{2}([^\[\]\{\}\|]+)(\|[^\]]+)?\]{2}/g, replaceWikiLink)
.replace(/\[(https?:\/\/[^ \]]+)([^\]]*)\]/g, replaceRegularLinks)
.replace(/((?:^|[^\{])\{\{)([^\{\|\}]+)/g, replaceTemplates)
.replace(/\r\n|\r|\n/g, '<br />') +
'</pre>')
.insertBefore($content.css('display', 'none'));
createPseudoToc();
});
}
};
module.hideSource = function () {
if (!$source) return;
$a.text('Source')
.data('source', false);
$source.hide();
$content.show();
if ($toc) $toc.hide();
};
if (config.wgAction === 'view' && config.wgArticleId !== 0) {
mw.hook('dev.i18n').add(function () {
window.dev.i18n.loadMessages('View Source').done(init);
});
if (isUCP) {
mw.loader.load('https://dev.fandom.com/load.php?mode=articles&only=scripts&articles=MediaWiki:I18n-js/code.js');
} else {
importArticle({
type: 'script',
article: 'u:dev:MediaWiki:I18n-js/code.js'
});
}
}
}((window.dev = window.dev || {}).viewSource = window.dev.viewSource || {}, mediaWiki, jQuery));
/** https://dev.fandom.com/wiki/MediaWiki:MassUserRights/code.js?action=history
* @Name MassUserRights
* @Version Fork of v2.4 (https://dev.fandom.com/wiki/MediaWiki:MassUserRights/code.js?oldid=139328)
* @Author Ozuzanna
* @Author TheGoldenPatrik1
* @Description Mass add/remove usergroups from listed users
* @Protect <nowiki>
*/
mw.loader.using(['mediawiki.api','mediawiki.user'], function () {
'use strict';
var config = mw.config.get(['wgUserGroups','wgUserName','wgVersion'
]);
if (window.MassUserRightsLoaded) {
return;
}
window.MassUserRightsLoaded = true;
var i18n,
placement,
rightsModal,
preloads = 3,
Api = new mw.Api(),
paused = true,
groups = ['interface-admin','bureaucrat','rollback','content-moderator','sysop','threadmoderator','bot',],
messages = {},
customGroups = window.massUserRightsCustom,
isUCP = config.wgVersion !== '1.19.24';
// Message fetch by KockaAdmiralac
Api.get({
action: 'query',
meta: 'allmessages',
ammessages: groups.map(function(msg) {
return (isUCP ?
'userprofile-global-tag-' :
'user-identity-box-group-'
) + msg;
}).join('|')
}).then(function(d) {
d.query.allmessages.forEach(function(msg, i) {
messages[groups[i]] = msg['*'];
});
/**
* @method generateElement
* @description Creates an option element
* @param {String} type - The options's value
* @param {String} isI18n - If the message uses I18n-js
*/
function generateElement (type, isI18n) {
return $('<option>', {
value: type,
text: isI18n ? i18n.msg(type).plain() : messages[type]
});
}
/**
* @method formHtml
* @description Creates the modal HTML
*/
function formHtml () {
return $('<form>', {
'class': 'WikiaForm'
}).append(
$('<fieldset>').append(
$('<p>', {
text: 'Source group: '
}).append(
$('<select>', {
id: 'user-rights-source'
}).append(
$('<option>', {value:'sysop', text:'sysop'}),
$('<option>', {value:'threadmoderator', text:'threadmoderator'}),
$('<option>', {value:'content-moderator', text:'content-moderator'}),
$('<option>', {value:'bureaucrat', text:'buraucrat'}),
$('<option>', {value:'bot', text:'bot'}),
$('<option>', {value:'rollback', text:'rollback'}),
$('<option>', {value:'interface-admin', text:'interface-admin'}),
$('<option>', {value:'sysop|bureaucrat|content-moderator|threadmoderator|rollback', text:'all normal Groups'}),
$('<option>', {value:'bot|sysop|bureaucrat|content-moderator|interface-admin|threadmoderator|rollback', text:'all Groups'})
)
),
$('<p>', {
text: 'Group to remove: '
}).append(
$('<select>', {
id: 'user-rights-type'
}).append(
$('<option>', {value:'sysop', text:'sysop'}),
$('<option>', {value:'threadmoderator', text:'threadmoderator'}),
$('<option>', {value:'content-moderator', text:'content-moderator'}),
$('<option>', {value:'bureaucrat', text:'buraucrat'}),
$('<option>', {value:'bot', text:'bot'}),
$('<option>', {value:'rollback', text:'rollback'}),
$('<option>', {value:'interface-admin', text:'interface-admin'}),
$('<option>', {value:'sysop|bureaucrat|content-moderator|threadmoderator|rollback', text:'all normal groups'}),
$('<option>', {value:'bot|sysop|bureaucrat|content-moderator|interface-admin|threadmoderator|rollback', text:'all groups'})
)
),
$('<p>', {
text: 'Reason: '
}).append (
$('<input>', {
type: 'text',
id: 'user-rights-reason'
})
),
$('<textarea>', {
id: 'text-mass-user-rights'
}),
$('<div>', {
id: 'text-error-output',
text: i18n.msg('errors').plain()
}).append(
$('<br/>')
)
)
).prop('outerHTML');
}
/**
* @method preload
* @description Preloads the script and the hooks
*/
function preload () {
if (--preloads === 0) {
placement = window.dev.placement.loader;
window.dev.i18n.loadMessages('MassUserRights').then(init);
}
}
/**
* @method init
* @description Initiates the script
* @param {String} i18nData - Variable for I18n-js
*/
function init (i18nData) {
i18n = i18nData;
placement.script('MassUserRights');
$(placement.element('tools'))[placement.type('prepend')](
$('<li>', {
'class': 'custom'
}).append(
$('<a>', {
id: 't-mu',
text: i18n.msg('title').plain(),
click: click
})
)
);
}
/**
* @method click
* @description Opens the MassUserRights modal
*/
function click () {
if (rightsModal) {
rightsModal.show();
show();
return;
}
rightsModal = new window.dev.modal.Modal({
content: formHtml(),
id: 'form-mass-user-rights',
size: 'medium',
title: 'Mass rights remove',
buttons: [
{
id: 'mur-start',
text: i18n.msg('initiate').escape(),
primary: true,
event: 'start'
},
{
id: 'mur-pause',
text: i18n.msg('pause').escape(),
primary: true,
event: 'pause',
disabled: true
},
{
text: i18n.msg('group').escape(),
primary: true,
event: 'addGroupContents'
},
{
text: i18n.msg('cancel').escape(),
event: 'close'
}
],
events: {
addGroupContents: addGroupContents,
pause: pause,
start: start
}
});
rightsModal.create().then(show);
rightsModal.show();
}
/**
* @method show
* @description Handles some aspects of the modal
*/
function show () {
// Support for custom groups
if (customGroups) {
$.each(customGroups, function(i,v) {
if (
document.domain.split('.')[0] === v.split('|')[0]
) {
$('#user-rights-type').append(
$('<option>', {
value: v.split('|')[1],
text: v.split('|')[2]
})
);
}
});
}
}
/**
* @method pause
* @description Pauses the operation
*/
function pause () {
paused = true;
document.getElementById('mur-pause').setAttribute('disabled', '');
document.getElementById('mur-start').removeAttribute('disabled');
}
/**
* @method start
* @description Starts the operation
*/
function start () {
paused = false;
document.getElementById('mur-start').setAttribute('disabled', '');
document.getElementById('mur-pause').removeAttribute('disabled');
process();
}
/**
* @method process
* @description Analyzes the inputted data
*/
function process () {
if (paused) {
return;
}
var txt = document.getElementById("text-mass-user-rights");
var pages = txt.value.split('\n');
var currentUser = pages[0];
if (!currentUser) {
pause();
$('#text-error-output').append(
i18n.msg('finished').escape() +
' ' +
i18n.msg('done').escape() +
'<br/>'
);
}
else {
changeRights(currentUser);
}
pages = pages.slice(1,pages.length);
txt.value = pages.join('\n');
}
/**
* @method addGroupContents
* @description Inputs users from a certain usergroup
*/
function addGroupContents () {
var group = $('#user-rights-source').val();
if (!group) {
return;
}
Api.get({
action: 'query',
list: 'allusers|groupmembers',
augroup: group,
aulimit: 'max',
gmgroups: group,
gmlimit: 'max',
format: 'json'
})
.done(function(d) {
if (!d.error) {
(d.users || d.query.allusers).forEach(function(user) {
$('#text-mass-user-rights').val($('#text-mass-user-rights').val() + user.name + '\n');
});
}
else {
sendError(i18n.msg('groupError').escape() + ' ' + group +' : '+ d.error.code);
}
})
.fail(function() {
sendError(i18n.msg('groupError').escape() + ' ' + group +'!');
});
}
/**
* @method changeRights
* @description Performs the action
* @param {String} user - The user whose rights are being changed
*/
function changeRights (user) {
Api.get({
action: 'query',
list: 'users',
ustoken: 'userrights',
ususers: user,
meta: 'tokens',
type: 'userrights'
}).done(function(d) {
if (!d.error) {
var params = {
action: 'userrights',
user: user,
remove: $('#user-rights-type').val(),
reason: $('#user-rights-reason').val(),
bot: true,
token: d.query.tokens ?
d.query.tokens.userrightstoken :
d.query.users[0].userrightstoken
};
Api.post(params).done(function(d2) {
if (!d2.error) {
console.log(i18n.msg('success', user).plain());
}
else {
sendError(i18n.msg('fail1', user, d2.error.code).escape());
}
})
.fail(function(code) {
sendError(i18n.msg('fail1', user, code).escape());
});
}
else {
sendError(i18n.msg('fail3', user, d.error.code).escape());
}
});
setTimeout(process, window.massUserRightsDelay || 1000);
}
/**
* @method sendError
* @description Handles error notices
* @param {String} error - The error to input
*/
function sendError (error) {
console.log(error);
$('#text-error-output').append(error + '<br/>');
}
mw.hook('dev.i18n').add(preload);
mw.hook('dev.modal').add(preload);
mw.hook('dev.placement').add(preload);
importArticles({
type: 'script',
articles: [
'u:dev:MediaWiki:I18n-js/code.js',
'u:dev:MediaWiki:Modal.js',
'u:dev:MediaWiki:Placement.js'
]
});
importArticle({
type: 'style',
articles: ['u:dev:MediaWiki:MassUserRights.css']
});
});
});
if (wgNamespaceNumber !== -1 && wgNamespaceNumber !== wgNamespaceIds.thread && wgNamespaceNumber !== wgNamespaceIds.board_thread && wgNamespaceNumber !== wgNamespaceIds.message_wall) {
//based on dev.fandom.com/?oldid=119591
$('.page-header__contribution-buttons, .page-header__actions').prepend("<div class=\"wds-button-group\" style=\"vertical-align: top; margin-left: 5px\">" +
"<div class=\"wds-dropdown\">" +
"<div class=\"wds-button wds-is-squished wds-dropdown__toggle\" style=\"border-radius: 2px\">" +
"D</div>" +
"<div class=\"wds-dropdown__content wds-is-not-scrollable wds-is-right-aligned\">" +
"<ul class=\"wds-list wds-is-linked notwds-ul\">" +
"</ul>" +
"</div></div></div>");
}
/* dev.fandom.com/wiki/MediaWiki:FastDelete/code.js?oldid=134638
* Ajax Fast Delete
* @author Splarka
* @author Uberfuzzy
* @author Grunny
* @version 2.6
*/
window.fdButtons = [
{summary:'Veralteten [[User:Default|Import]] gelöscht', label:'Default-Import'},
{summary:'Cleanup', label:'Cleanup'},
{summary:'Löschantrag', label:'Löschantrag'}
];
;(function($, mw, window) {
window.dev = (window.dev || {});
// Don't load twice...
if (window.dev.ajaxFastDelete !== undefined) {
return false;
}
var conf = mw.config.get([
'wgNamespaceNumber',
'wgPageName',
'wgVersion'
]),
isUCP = conf.wgVersion !== '1.19.24';
function init(i18n) {
var self = {
version: '2.6',
init: function() {
if (
conf.wgNamespaceNumber === -1 ||
!window.fdButtons ||
(conf.wgNamespaceNumber === 2 && isUCP && $(".noarticletext").length) ||
(conf.wgNamespaceNumber != 2 && isUCP && !$('#ca-delete').length) ||
!isUCP && !$('#ca-delete').length
) return;
var deleteButtons = window.fdButtons.map(function(b) {
var sum = b.summary;
return '<li><a title="' + i18n.msg('delete-title', sum).escape() + '" data-summary="' + sum + '" data-id="fastdelete">' + b.label + '</a></li>';
});
$('.page-header__actions .wds-button-group .wds-dropdown__content .notwds-ul').append(deleteButtons);
// Dropdown fixes
mw.util.addCSS('ul.notwds-ul>li>#ca-purge{display:none;}');
mw.util.addCSS('ul.notwds-ul>li>#ca-view-source{display:none;}');
if ($('a[data-id="fastdelete"]').length) {
$('a[data-id="fastdelete"]').click(function() {
if (window.FastDeleteNoConfirm || confirm(i18n.msg('areyousure').plain()) === true) {
self.deletePage($(this).attr('data-summary'));
} else {
return;
}
});
}
mw.hook('fastdelete.init').fire(deleteButtons);
},
deletePage: function(deleteReason) {
(new mw.Api())
.post({
action: 'delete',
title: conf.wgPageName,
reason: deleteReason,
token: mw.user.tokens.get(isUCP ? 'csrfToken' : 'editToken')
})
.done(function(res) {
location.reload();
});
}
};
window.dev.ajaxFastDelete = self;
mw.loader.using(['mediawiki.util', 'mediawiki.api'], function() {
$(self.init);
});
}
// i18n
mw.hook('dev.i18n').add(function(i18n) {
i18n.loadMessages('FastDelete').then(init);
});
if (!window.dev || !window.dev.i18n) {
if (isUCP) {
mw.loader.load('https://dev.fandom.com/load.php?mode=articles&only=scripts&articles=MediaWiki:I18n-js/code.js');
} else {
importArticle({
type: 'script',
article: 'u:dev:MediaWiki:I18n-js/code.js'
});
}
}
})(jQuery, mediaWiki, window);
/* dev.fandom.com/wiki/MediaWiki:UserAccountAge/code2.js?oldid=136566
* UserAccountAge/code2.js
* @file Appends user tag to masthead with time since account's creation
* @author Eizen <dev.wikia.com/wiki/User_talk:Eizen>
* @license CC-BY-SA 3.0
* @external "mediawiki.api"
* @external "mediawiki.util"
*/
/* jshint -W030, undef: true, unused: true, eqnull: true, laxbreak: true */
;(function (module, window, $, mw) {
"use strict";
// Prevent double loads and respect prior double load check formatting
if (!window || !$ || !mw || module.isLoaded || window.isUAALoaded) {
return;
}
module.isLoaded = true;
// Protected namespace pseudo-enums
Object.defineProperties(this, {
Selectors: {
enumerable: true,
writable: false,
configurable: false,
value: Object.freeze({
NAMES: Object.freeze({
// UAA Id selectors
ID_TAG_SPAN: "userAccountAge-span",
ID_UAA_LINK: "userAccountAge-a",
// Tag class selectors
CLASS_LEGACY_MASTHEAD_TAG: "tag",
CLASS_UCP_MASTHEAD_TAG: "user-identity-header__tag",
}),
TARGETS: Object.freeze({
LEGACY_MASTHEAD_HEADER: ".masthead-info h1",
LEGACY_MASTHEAD_TAGS: ".masthead-info hgroup",
UCP_MASTHEAD_TAGS: ".user-identity-header__attributes",
})
}),
},
Dependencies: {
enumerable: true,
writable: false,
configurable: false,
value: Object.freeze({
GLOBALS: Object.freeze([
"profileUserName",
"wgVersion",
]),
MODULES: Object.freeze([
"mediawiki.api",
"mediawiki.util"
]),
})
},
Utility: {
enumerable: true,
writable: false,
configurable: false,
value: Object.freeze({
CHECK_RATE: 200,
DEBUG: false,
SCRIPT: "UserAccountAge",
HOOK_NAME: "dev.userAccountAge",
}),
}
});
this.assembleUserTag = function (paramText, paramTitle, paramAddress) {
return mw.html.element("span", {
"id": this.Selectors.NAMES.ID_TAG_SPAN,
"class": [
"CLASS_LEGACY_MASTHEAD_TAG",
"CLASS_UCP_MASTHEAD_TAG"
].map(function (paramName) {
return this.Selectors.NAMES[paramName];
}.bind(this)).join(" "),
}, new mw.html.Raw(
mw.html.element("a", {
"id": this.Selectors.NAMES.ID_UAA_LINK,
"href": paramAddress,
"title": paramTitle,
}, paramText)
));
};
this.getRegistrationData = function (paramUsername) {
return new mw.Api().get({
action: "query",
list: "users",
usprop: "registration",
ususers: paramUsername,
format: "json"
});
};
this.main = function () {
// Declarations
var $helper, $getEssentials, interval, target, userData, date, dateString,
dateInfo, formattedDate, tagText, address, tag;
// Definitions
$helper = new $.Deferred();
interval = null;
target = this.Selectors.TARGETS[(this.info.isUCP)
? "UCP_MASTHEAD_TAGS"
: "LEGACY_MASTHEAD_TAGS"
];
if (this.Utility.DEBUG) {
window.console.log("target:", target);
}
// Make initial call to progress before interval in case masthead exists
$getEssentials = $.when(
this.getRegistrationData(this.info.userName),
$helper.notify().promise()
);
// Continually check for presence of masthead via setInterval
if (this.info.isUCP) {
interval = window.setInterval($helper.notify, this.Utility.CHECK_RATE);
}
$helper.progress(function () {
if (this.Utility.DEBUG) {
window.console.log("$helper.progress");
}
// Check for target, or check if interval (hence UCP)
if (!$(target).length) {
return;
} else if (interval) {
window.clearInterval(interval);
}
// Resolve helper $.Deferred once masthead is found
$helper.resolve();
}.bind(this));
$getEssentials.then(function (paramData) {
if (this.Utility.DEBUG) {
window.console.log(paramData);
}
// Specific user registration data
userData = paramData[0].query.users[0];
// Reject malformed data or errors
if (
paramData.error ||
userData.registration == null ||
userData.hasOwnProperty("missing") ||
userData.hasOwnProperty("invalid")
) {
return;
}
if (this.Utility.DEBUG) {
window.console.log(userData.registration);
}
// Date definitions
date = new Date(userData.registration);
dateString = date.toString();
// Store date partials in object for piecemeal usage
dateInfo = {
dayWeek: dateString.slice(0, 3), // "Fri"
dayCalendar: dateString.slice(4, 15), // "Sep 01 2017"
time: dateString.slice(16, 24), // "19:37:07"
};
// Example: "Fri, Sep 01 2017, 19:37:07"
formattedDate = dateInfo.dayWeek + ", " + dateInfo.dayCalendar + ", " +
dateInfo.time;
tagText = formattedDate;
// Assemble link to formatted JSON data confirming registration
address = mw.util.wikiScript("api") + "?" + $.param({
format: "jsonfm",
action: "query",
list: "users",
usprop: "registration",
ususers: userData.name,
});
// Build and log custom tag
tag = this.assembleUserTag(tagText, formattedDate, address);
if (this.Utility.DEBUG) {
window.console.log(tag);
}
// Inject CSS styling after assembly and prior to appending
mw.util.addCSS(
"#" + this.Selectors.NAMES.ID_UAA_LINK + "{" +
"color: inherit !important;" +
"}"
);
// Add tag to target tags group
$(target).append(tag);
}.bind(this), window.console.error.bind(null, this.Utility.SCRIPT));
};
this.init = function () {
// Object for storage of informational data
this.info = {};
// Cache globals
this.globals = Object.freeze(mw.config.get(this.Dependencies.GLOBALS));
// Determine MW version
this.info.isUCP = window.parseFloat(this.globals.wgVersion) > 1.19;
// Either username if user page (UCP et al.) or empty string if no masthead
this.info.userName = (
this.globals.profileUserName ||
$(this.Selectors.TARGETS.LEGACY_MASTHEAD_HEADER).text()
);
// Determine if masthead exists (indicates presence of userpage)
this.info.hasMasthead = !!this.info.userName.length;
// Expose public methods for external debugging
Object.defineProperty(module, "exports", {
enumerable: true,
writable: false,
configurable: false,
value: Object.freeze({
observeScript: window.console.dir.bind(this, this),
})
});
// Return if no masthead expected to appear or if anon
if (
!this.info.hasMasthead ||
mw.util.isIPv4Address(this.info.userName) ||
mw.util.isIPv6Address(this.info.userName)
) {
if (this.Utility.DEBUG) {
window.console.log("return;");
}
return;
}
// Dispatch hook with window.dev.mediaWikiBacklink once init is complete
mw.hook(this.Utility.HOOK_NAME).fire(module).add(this.main.bind(this));
};
// Coordinate loading of all relevant dependencies
$.when(mw.loader.using(this.Dependencies.MODULES), $.ready)
.done(this.init.bind(this))
.fail(window.console.error.bind(null, this.Utility.SCRIPT));
}.call(Object.create(null), (this.dev = this.dev || {}).userAccountAge =
this.dev.userAccountAge || {}, this, this.jQuery, this.mediaWiki));
window.FastDeleteNoConfirm = true;
window.anchoredRollbackBot = true;
window.PRAoptions = {editSummary: 'Automatic page link update'};
});
//Small LastEdited, Fork of https://dev.fandom.com/wiki/MediaWiki:LastEdited/code.js?oldid=139269
//https://dev.fandom.com/wiki/MediaWiki:LastEdited/code.js?action=history
(function() {
'use strict';
importArticles({
type: 'script',
articles: [
'u:dev:MediaWiki:I18n-js/code.js',
'u:dev:MediaWiki:Modal.js'
]
});
importArticle({
type: 'style',
article: 'u:dev:MediaWiki:LastEdited.css'
});
var lastEdited = {
config: mw.config.get([
'stylepath',
'wgAction',
'wgArticleId',
'wgFormattedNamespaces',
'wgIsMainPage',
'wgMainPageTitle',
'wgNamespaceNumber',
'wgPageName',
'wgUserGroups',
'wgUserName',
'wgVersion'
]),
// Configuration options
options: $.extend({
size: true,
diffModal: true,
comment: true,
newpage: true,
mainpage: true,
time: 'timeago',
position: {
element: '',
method: ''
},
namespaces: {
exclude: [-1, 1201, 2001]
},
pages: []
}, window.lastEdited),
loaded: 2,
canRollback: /(sysop|helper)/.test(mw.config.get('wgUserGroups').join(' ')),
/* Initializes everything */
init: function() {
window.lastEditedLoaded = true;
this.isUCP = this.config.wgVersion !== '1.19.24';
this.api = new mw.Api();
this.pageName = this.config.wgPageName.replace(/_/g, ' ');
this.insert();
var preload = $.proxy(this.preload, this);
mw.hook('dev.modal').add(preload);
mw.hook('dev.i18n').add(preload);
},
preload: function() {
if (--this.loaded === 0) {
var i18nOptions = {};
if (this.options.lang) {
i18nOptions.language = this.options.lang;
}
$.when(
this.fetch(),
window.dev.i18n.loadMessages('LastEdited', i18nOptions),
mw.loader.using(
this.isUCP ?
[
'mediawiki.diff.styles',
'skin.oasis.diff.css'
] :
'mediawiki.action.history.diff'
)
).then($.proxy(this.render, this));
}
},
/**
* Checks whether the script should run further or not
* @return {Boolean} If the script should run further
*/
shouldRun: function() {
var allowed = Object.keys(this.config.wgFormattedNamespaces).map(Number),
ns = this.options.namespaces;
if (ns && ns.exclude instanceof Array) {
allowed = allowed.filter(function(elem) {
return ns.exclude.indexOf(elem) < 0;
});
}
return !mw.util.getParamValue('diff') &&
!mw.util.getParamValue('oldid') &&
allowed.indexOf(this.config.wgNamespaceNumber) !== -1 &&
this.config.wgAction === 'view' &&
!window.lastEditedLoaded &&
this.config.wgArticleId !== 0;
},
/**
* Inserts the placeholder for last edit information
*/
insert: function() {
var $loader = $('<div>', {
id: 'lastEdited',
'class': 'lastEdited'
}).append(
$('<span>', {
id: 'lastEdited-loading',
text: 'LastEdited loading'
})
);
var pos = this.options.position;
if (pos.element && pos.method) {
var $el = $(pos.element),
m = pos.method;
if ($el.length && (m === 'append' || m === 'prepend')) {
$el[m]($loader);
}
} else {
$loader.insertAfter('.page-header .page-header__title, .UserProfileActionButton');
}
this.$content = $loader;
mw.hook('LastEdited.inserted').fire($loader);
},
/**
* Fetches last edit information from the API
* @returns {jQuery.Deferred} A Promise-like object
*/
fetch: function() {
var tokentype = this.canRollback ? 'rollback' : undefined;
return this.api.get({
action: 'query',
titles: this.config.wgPageName,
meta: 'tokens',
prop: 'revisions',
rvprop: 'timestamp|user|userid|size|parsedcomment|flags',
// TODO: This has been deprecated.
rvdiffto: 'prev',
rvlimit: 2,
rvtoken: tokentype,
type: tokentype
});
},
/* Renders last edited information */
render: function(data, i18n) {
var diffData = data[0].query.pages[this.config.wgArticleId].revisions;
if (!diffData[1] && !this.options.newpage) {
this.$content.remove();
return;
}
var prev = diffData[1],
curr = diffData[0];
if (data[0].query.tokens) {
curr.rollbacktoken = data[0].query.tokens.rollbacktoken;
}
if (prev) {
this.createModal(i18n, curr);
}
this.$content.html('');
['UserContribs', 'Diff', 'Minor', 'Size', 'Comment'].forEach(function(el) {
this.$content.append(this['render' + el](curr, i18n, prev));
}, this);
mw.hook('LastEdited.render').fire(this.$content);
},
/* User contribs link and timeago */
userLink: function(prefix, user, text) {
return mw.html.element('a', { href: mw.util.getUrl(prefix + user) }, text);
},
renderUserContribs: function(data, i18n) {
var user = data.user,
contriblink = this.userLink('Special:Contributions/', user, user);
return [
contriblink
];
},
/* Renders the diff link */
renderDiff: function(data, i18n) {
var $time = $('<span>', {
'class': 'lastEdited-timeago',
title: data.timestamp
});
$time.timeago();
if($time.html() == "") {
// Custom fix since mediawiki's timeago (specifically $.timeago.inWords) doesn't seem to like values greater than 30 days?
// this is the same exact function, but without that time check
var customInWords = function(t) {
// if (t <= 2592e6) {
var e = false;
$.timeago.settings.allowFuture && (t < 0 && (e = !0), t = Math.abs(t));
var r = t / 1e3, a = r / 60, i = a / 60, n = i / 24, o = n / 365;
return r < 45 && u("second", Math.round(r)) || r < 90 && u("minute", 1) || a < 45 && u("minute", Math.round(a)) || a < 90 && u("hour", 1) || i < 24 && u("hour", Math.round(i)) || i < 48 && u("day", 1) || n < 30 && u("day", Math.floor(n)) || n < 60 && u("month", 1) || n < 365 && u("month", Math.floor(n / 30)) || o < 2 && u("year", 1) || u("year", Math.floor(o))
// }
function u(t, r) {
return mw.message(e ? "timeago-" + t + "-from-now" : "timeago-" + t, r).text()
}
};
var myDate = $.timeago.parse(data.timestamp);
var timeDistance = new Date().getTime() - myDate.getTime();
$time.html( customInWords(timeDistance) );
}
if (data.diff.from) {
var link = $('<a>', {
id: 'lastEdited-diff-link',
href: '?diff=' + data.diff.to,
text: $time.prop('innerHTML'),
title: data.timestamp + ' | Special:Diff/' + data.diff.to
});
link.attr('data-disable-quickdiff', '');
link.click($.proxy(function(e) {
e.preventDefault();
this.modal.show();
}, this));
return [' | ', link];
}
return [' | ', $time.prop('outerHTML')];
},
/* Renders the "m" sign next to minor edits */
renderMinor: function(data, i18n) {
if (data.minor === '') {
return [
$('<span>', {
id: 'lastEdited-minor',
text: ' [m]'
})
];
}
return [];
},
/* Renders the last edit summary used */
renderComment: function(data, i18n) {
var comment = data.parsedcomment;
if (this.options.comment && comment) {
return [
' | ',
comment.indexOf('Created page with') === -1 ? comment : i18n.msg('created').escape()
];
}
return [];
},
/* Renders the size of the last diff */
renderSize: function(data, i18n, prev) {
if (!this.options.size) {
return [];
}
var arr = [
' | ',
data.size,
' bytes'
];
if (prev) {
var bytes = data.size - prev.size,
classes = 'mw-plusminus-' + (bytes > 0 ?
'pos' :
bytes < 0 ?
'neg' :
'null');
if (Math.abs(bytes) > 500) {
classes += ' lastEdited-diff-major';
}
arr.push(
' ',
$('<span>', {
text: '(' + (bytes > 0 ? '+' : '') + bytes.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',') + ')',
'class': classes
})
);
}
return arr;
},
/* (Re)generates the diff modal */
createModal: function(i18n, data) {
var buttons = [
{
event: 'link',
text: i18n.msg('link').plain()
},
{
event: 'undo',
text: i18n.msg('undo').plain()
}
];
if (this.canRollback && this.config.wgUserName !== data.user) {
buttons.push({
event: 'rollback',
text: i18n.msg('rollback').plain()
});
}
this.modal = new window.dev.modal.Modal({
buttons: buttons,
content: '<div id="lastEdited-diff-changes" class="WikiaArticle diff">' +
'<table class="diff">' +
data.diff['*'] +
'</table>' +
'</div>',
context: this,
events: {
link: function() {
this.modal.close();
window.open(mw.util.getUrl('', {
diff: data.diff.to
}), '_blank');
},
rollback: function() {
this.api.post({
action: 'rollback',
title: this.config.wgPageName,
user: data.user,
token: data.rollbacktoken,
format: 'json'
}).done(function(d) {
if (!d.error) {
window.location.reload();
}
});
},
undo: function() {
this.modal.close();
window.open(mw.util.getUrl(this.config.wgPageName, {
action: 'edit',
undoafter: data.diff.from,
undo: data.diff.to
}), '_blank');
}
},
id: 'lastEdited-diff',
size: 'larger',
title: i18n.msg('changes').escape() + ': ' + this.pageName
});
this.modal.create();
}
};
mw.loader.using([
'mediawiki.api',
'mediawiki.util'
]).then(function() {
if (lastEdited.shouldRun()) {
$($.proxy(lastEdited.init, lastEdited));
}
});
})();
mw.loader.load('//internal-soap.fandom.com/index.php?title=User:GerritH/scripts-ucp.js&action=raw&ctype=text/javascript');
//Quickbar and My Tools
$(function() {
var c = mw.config.get([ 'wgPageName', 'wgScriptPath', 'wgCityId', 'wgSiteName' ]);
//Add links to My Tools
$('<li><a href="https://internal-soap.fandom.com/wiki/Special:Multiwikifinder?target=' + c.wgPageName + '">Multiwiki Title Finder</a></li>' +
'<li><a href="https://community.fandom.com/wiki/Special:MyPage/global.css">Global.css</a></li>' +
'<li><a href="https://community.fandom.com/wiki/Special:MyPage/global.js">Global.js</a></li>' +
'<li><a href="' + c.wgScriptPath + '/wiki/MediaWiki:ImportJS">MediaWiki:ImportJS</a></li>' +
'<li><a href="' + c.wgScriptPath + '/wiki/Special:JSPages">JSPages</a></li>' +
//'<li><a href="' + c.wgScriptPath + '/wiki/MediaWiki:Fandomdesktop.js">MediaWiki:Fandomdesktop.js</a></li>' +
'<li><a href="' + c.wgScriptPath + '/wiki/MediaWiki:Fandomdesktop.css?action=edit">MediaWiki:Fandomdesktop.css?action=edit</a></li>' +
'<li><a href="' + c.wgScriptPath + '/wiki/MediaWiki:Common.js">MediaWiki:Common.js</a></li>' +
'<li><a href="' + c.wgScriptPath + '/wiki/MediaWiki:Common.css?action=edit">MediaWiki:Common.css?action=edit</a></li>' +
'<li><a href="' + c.wgScriptPath + '/wiki/MediaWiki:Wikia.css?action=edit">MediaWiki:Wikia.css?action=edit</a></li>' +
'<li><a href="' + c.wgScriptPath + '/wiki/MediaWiki:Wiki-navigation?action=edit">MediaWiki:Wiki-navigation?action=edit</a></li>' +
'<li><a href="' + c.wgScriptPath + '/wiki/MediaWiki:Recentchangestext?action=history">MediaWiki:Recentchangestext?action=history</a></li>' +
'<li><a href="' + c.wgScriptPath + '/wiki/Special:ListGroupRights">ListGroupRights</a></li>' +
'<li><a href="' + c.wgScriptPath + '/wiki/Special:Log/rights">Log/rights</a></li>' +
'<li><a href="' + c.wgScriptPath + '/wiki/Special:ListUsers">ListUsers</a></li>' +
'<li><a href="' + c.wgScriptPath + '/wiki/Special:ListAdmins">ListAdmins</a></li>' +
'<li><a href="' + c.wgScriptPath + '/wiki/Special:WhatLinksHere/' + c.wgPageName + '">WhatLinksHere</a></li>').insertBefore('.WikiaBarWrapper .tools-menu li:first');
$('div.wiki-tools.wds-button-group > div > div.wds-dropdown__content.wds-is-not-scrollable.wds-is-right-aligned > ul').prepend
('<li><a href="' + c.wgScriptPath + '/wiki/Special:Statistics">Statistics</a></li>' +
'<li><a href="' + c.wgScriptPath + '/wiki/Special:PrefixIndex">PrefixIndex</a></li>' +
'<li><a href="' + c.wgScriptPath + '/wiki/Special:LongPages">LongPages</a></li>' +
'<li><a href="' + c.wgScriptPath + '/wiki/Special:ShortPages">ShortPages</a></li>' +
'<li><a href="' + c.wgScriptPath + '/wiki/Special:DoubleRedirects">DoubleRedirects</a></li>' +
'<li><a href="' + c.wgScriptPath + '/announcements">Announcement</a></li>');
//Add WikiConfig to Quickbar
$('.tools').append('<li><a href="https://community.fandom.com/wiki/Special:WikiConfig/' + c.wgCityId + '">WikiConfig</a> </li>' +
'<li><a target="_new" href="https://community.fandom.com/wiki/Special:WikiConfig/' + c.wgCityId + '/domains">domains</a></li>' +
'<li><a target="_new" href="https://community.fandom.com/wiki/Special:WikiConfig/' + c.wgCityId + '/variables?variable=3">sitename</a></li>' +
'<li><a target="_new" href="https://community.fandom.com/wiki/Special:WikiConfig/' + c.wgCityId + '/variables?variable=964">theme</a></li>' +
'<li><a target="_new" href="https://community.fandom.com/wiki/Special:WikiConfig/' + c.wgCityId + '/close">close</a></li>' +
'<li><a target="_new" href="https://community.fandom.com/wiki/Special:WikiConfig/' + c.wgCityId + '/changelog">changelog</a></li>');
$('body').append('<div class="nav-wikidata"><span>' + c.wgSiteName + '</span><span style="margin-left: 7px;">(' + c.wgCityId + ')</span></div>');
}) (this.jQuery, this.mediaWiki);