Hinweis: Leere nach dem Veröffentlichen den Browser-Cache, um die Änderungen sehen zu können.
- Firefox/Safari: Umschalttaste drücken und gleichzeitig Aktualisieren anklicken oder entweder Strg+F5 oder Strg+R (⌘+R auf dem Mac) drücken
- Google Chrome: Umschalttaste+Strg+R (⌘+Umschalttaste+R auf dem Mac) drücken
- Edge: Strg+F5 drücken oder Strg drücken und gleichzeitig Aktualisieren anklicken
//Dokumentation unter [[Benutzer:Schnark/js/section-links]] <nowiki>
/*global mediaWiki*/
(function ($, mw) {
"use strict";
//jscs:disable maximumLineLength
var l10n = {
en: {
'sections-edit': 'Edit section',
'sections-edit0': 'Edit lead section',
'sections-plus': 'Add a new section',
'sections-top': 'Jump to beginning',
'sections-link': 'Link this section',
'sections-prev': 'Jump to previous section',
'sections-next': 'Jump to next section',
'sections-done': 'Mark section as done',
'sections-title-append-modern': '$1',
'sections-title-append-source': '$1 (source)',
'sections-title-append-owe': '$1 (old wikitext editor)',
'sections-title-append-nwe': '$1 (modern wikitext editor)',
'sections-title-append-ve': '$1 (VisualEditor)',
'sections-title-new-append-modern': '$1',
'sections-title-new-append-source': '$1',
'sections-title-new-append-owe': '$1 (old wikitext editor)',
'sections-title-new-append-nwe': '$1 (modern wikitext editor)',
'sections-done-reason': 'You can add a short comment, which will be shown after your signature.',
'sections-done-error': 'An error occurred!'
},
de: {
'sections-edit': 'Abschnitt bearbeiten',
'sections-edit0': 'Einleitung bearbeiten',
'sections-plus': 'Neuen Abschnitt hinzufügen',
'sections-top': 'Zum Seitenanfang springen',
'sections-link': 'Diesen Abschnitt verlinken',
'sections-prev': 'Zum vorherigen Abschnitt springen',
'sections-next': 'Zum nächsten Abschnitt springen',
'sections-done': 'Abschnitt als erledigt markieren',
'sections-title-append-source': '$1 (Quelltext)',
'sections-title-append-owe': '$1 (alter Wikitext-Editor)',
'sections-title-append-nwe': '$1 (moderner Wikitext-Editor)',
'sections-title-new-append-owe': '$1 (alter Wikitext-Editor)',
'sections-title-new-append-nwe': '$1 (moderner Wikitext-Editor)',
'sections-done-reason': 'Wenn du möchtest, kannst du noch einen kurzen Kommentar angeben, der nach deiner Unterschrift eingefügt wird.',
'sections-done-error': 'Es trat ein Fehler auf!'
},
'de-formal': {
'sections-done-reason': 'Wenn Sie möchten, können Sie noch einen kurzen Kommentar angeben, der nach Ihrer Unterschrift eingefügt wird.'
}
}, configDone = false,
/*icons = {
edit: 'data:image/gif;base64,R0lGODlhEAAQAMIFAAAAAP8AAHd3d/93AP//AP///////////yH5BAEKAAcALAAAAAAQABAAAAM0eLp88S2eMV6QaxBCodTcNmBTyJGgNmKpyIrum5KCQJ10Ta1Y7ZMKQA0ADAKIxcMxGSwmAAA7',
plus: 'data:image/gif;base64,R0lGODlhEAAQAKECAAB3AAD/AP///////yH5BAEKAAIALAAAAAAQABAAAAIulC8AyAgRVmMvTgrlNVVflXmcAkIRuVTmypbsa6HqSTalsnFZrlt8x0vsgrhGAQA7',
//top: 'data:image/gif;base64,R0lGODlhEAAQAKECAAAAdwAA/////////yH5BAEKAAIALAAAAAAQABAAAAItlC8AyAgRVnMQyvlivjRay2yVFx3iSC7nCirWBjtqy4Xg1NXYjRtbb+IBFZMCADs=',
top: 'data:image/gif;base64,R0lGODlhEAAQAKECAAAAdwAA/////////yH5BAEKAAIALAAAAAAQABAAAAIyFI6ZFu3/gFH0iIuvzRyDJnXZ54QiGZ1QyZEH6HogE0hxTIe3iU9qLWrNgjIg0WPKFAAAOw==',
//link: 'data:image/gif;base64,R0lGODlhEAAQAKECAHd3d8zMzP///////yH5BAEKAAIALAAAAAAQABAAAAIulI+ggG273FGTOlslfkyGkHTNZ23UJ0BiqqBGYHYw42ZVbedhs1ViH4JIgitHAQA7',
link: 'data:image/gif;base64,R0lGODlhEAAQAKECADw8PGZmZv///////yH5BAEKAAIALAAAAAAQABAAAAIulI+ggG273FGTOlslfkyGkHTNZ23UJ0BiqqBGYHYw42ZVbedhs1ViH4JIgitHAQA7',
prev: 'data:image/gif;base64,R0lGODlhEAAQAKECAAAAdwAA/////////yH5BAEKAAIALAAAAAAQABAAAAIrlC8AyAgRVnMQyvmqxVpfkylWeJDmRiabGiVX6nLtRM00uN7sR8O3/+MZCgA7',
next: 'data:image/gif;base64,R0lGODlhEAAQAKECAAAAdwAA/////////yH5BAEKAAIALAAAAAAQABAAAAIrlC8AyAgRVmMvTgrlNVXvvh1go4iZuIzqCbYnl3WjCdUvZltXde/95zkUAAA7',
done: 'data:image/gif;base64,R0lGODlhEAAQAKECAAB3AAD/AP///////yH5BAEKAAIALAAAAAAQABAAAAInlI+pCrAcgnsHxEmtpPVyoWGIGEJTmWgbmkaS96hw7Ir09oE2txsFADs=',
del: 'data:image/gif;base64,R0lGODlhEAAQAKECAHcAAP8AAP///////yH5BAEKAAIALAAAAAAQABAAAAIyFC6peWAB3XoRwLjsPRfT/VVdIIUjOWlnma2TooJv3LHmWNJcbUp6zAKqbB9H48VAFAAAOw=='
},*/
//jscs:enable maximumLineLength
icons = { //von [[Benutzer:TMg]] optimiert
edit: 'data:image/gif;base64,R0lGODlhEAAQALMPAPqxb/1wA/+QAtHU1v/qAP+2AP/TAH' +
'F0dp1zVOjFq/v28vyMPgAAAP8AAP//AP///yH5BAEAAA8ALAAAAAAQABAAAARU8Mk5QWuL' +
'6hnCbRu1FI53hY8SOIbgCAEaGCVRKmHiFq4AyLYVIRYCkATHREjlGLIEqFGJFsCFEAGeo5' +
'BBHbACA9F7+AZ+qAejfBikU4z1WzJguNMRADs=',
plus: 'data:image/gif;base64,R0lGODlhEAAQALMJAAd2BwF3AQF4AQBhAABeAADyAIK/gg' +
'BgAAD/AP///wAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAkALAAAAAAQABAAAARHMMlpQjAz' +
'a1IK0WByIMgRamN5Zqm5SgM5gAZx3ANAAsN9EAZBgUQsEgsCoXGJQNZ8uV3vBgTFELOXiO' +
'R6tbRblZbjAVcuoAgAOw==',
top: 'data:image/gif;base64,R0lGODlhEAAQALMPAOjs8QAZY4GXvgBa/gIqcwJN2Qc2kzV' +
'XmAAPXwBR69Pa5gAeawBi/wBe/wAUYP///yH5BAEAAA8ALAAAAAAQABAAAARmUCBHq6VIr' +
'MG6/92wSFWwEMQSVNnjugBRFATw3q6yJE2TLApcbtcYDHxAnC6RMPQMzOSQmeqdosHH7gc' +
'I9AKA7cJ1MCQdPcdDZzi8BFl0Q70WCF1y+v2V39/6fi4ITAiBLgIodjgRADs=',
link: 'data:image/gif;base64,R0lGODlhEAAQALMPACkpKcjIyIuLi+3t7Z2dnWNjY0NDQ9' +
'TU1Nzc3LW1tXx8fHJyclJSUltbWxcXF////yH5BAEAAA8ALAAAAAAQABAAAAR28Mk5RyLk' +
'0P3Oao1hCJx0FMUgNUBQFswGLNwAKIkrGTG3KIWGy6agqAQKhqGBeDAAzU5hpiAgHI6FAU' +
'AwwRRJBAGABSQkg0XhkSgYHLOHapJoqAIgbInQmAQQCw5zFAQGG1slB0toT2clAgAAW1wl' +
'fgsMClElEQA7',
prev: 'data:image/gif;base64,R0lGODlhEAAQALMPAAIqdQAZYwc2kwBc/wBP6ABEyKWzzY' +
'KXvytPkuzw8wBR69Pa5gAeawAUYABe/////yH5BAEAAA8ALAAAAAAQABAAAARZ8MmZEEoz' +
'58VKYYu2McQwEKD4cIRjOmg4KopgCnQqcTTAOA4GICcjKRiJADCQYChQEoQg1QA2VgwBYm' +
'KQVR3XlUH1+IbJEjN6ol6Xre43ON6gndEHAOAgigAAOw==',
next: 'data:image/gif;base64,R0lGODlhEAAQALMPAAIqdQAZYwc2kwBc/wBP6ABEyKWzzY' +
'KXvytPkuzw8wBR69Pa5gAeawAUYABe/////yH5BAEAAA8ALAAAAAAQABAAAARb8Ml5ADgz' +
'66ZU0+DTOM4XZmN5oqS5iu0rpa5mLHP8LMaECAwcbccQICQMgoKRCJACCYaCwJAspAoAg8' +
'QAdIKTa0cwGAi+uMyV4Cg7qGnNugxfXQsF8CuBQCRAEQA7',
done: 'data:image/gif;base64,R0lGODlhEAAQALMPAAiKCG+ybwCyANHk0QJ3Aujx6LPVsw' +
'DSAMTdxAD0AADqAABsACeNJ0+iTwD/AP///yH5BAEAAA8ALAAAAAAQABAAAARa8MlJq7Vt' +
'sVvLcgLATczhHMT4GITjEIi6KOA2BQYVAO5STAvBIidZJECBm8CRGD4aS8WCYjAyF4GWA0' +
'CcVI8JgukgsiBmrt6Ac6aBGqq2Y6p6DBYAeN1etkQAADs=',
del: 'data:image/gif;base64,R0lGODlhEAAQALMPAIMSEurc3Nm8vPoAAGUAAPLo6GsAAHY' +
'AAG4AAOYAAObT020AANW0tPQAAP8AAP///yH5BAEAAA8ALAAAAAAQABAAAARp8Mkiq7XlE' +
'HafIkAgAcmAcJViJMkhEYPTLKiaOA5BMUgjL4LACndAPRgLXwOBuDmKF6TS9zRaBAdqtSM' +
'J9HAmAdcG/lk9w+d3ZiRXBUnZ6eWEHuMDA4W0rfAGLRIKGmdHBghiFRRciw8RADs=',
//neu
note: 'data:image/gif;base64,R0lGODlhEAAQAMIEAAAAAEpKSitPkgBc//////////////' +
'///yH5BAEKAAQALAAAAAAQABAAAAM5SLpM8i26QYVcgtY79bDKI2YeGJbex5Aaa2Lst0kx' +
'dAH1uwBBUEu8AI6kIwQBIVGEh+Tsmk4FlJMAADs=',
ve: 'data:image/gif;base64,R0lGODlhEAAQAOMOAAAAAP8AAHF0dp1zVP1wAzqXwP+QAvyM' +
'Pv+2AJrMWfqxb//TAP/qAP//AP///////yH5BAEAAA8ALAAAAAAQABAAAARj8Mk5VQhnFv' +
'r2I8QVaNR2IE14SV4nEc1iNAZBusSSMmnpPjPEzKDgFDYEHoxhMz4UKEM0keC8GsyYQVKl' +
'nFK6JpcyIAgbiAN1TRGUDQtC1/oQ2MvF7lwCsAsoVFYAfXSChRMRADs='
},
css =
'h1 .mw-editsection,' +
'h2 .mw-editsection,' +
'h3 .mw-editsection,' +
'h4 .mw-editsection,' +
'h5 .mw-editsection,' +
'h6 .mw-editsection,' +
'h1 .mw-editsection-like,' +
'h2 .mw-editsection-like,' +
'h3 .mw-editsection-like,' +
'h4 .mw-editsection-like,' +
'h5 .mw-editsection-like,' +
'h6 .mw-editsection-like,' +
'.mw-headline-anchor {' +
'display: none;' +
'}' +
'.section-links {' +
'display: inline-block;' +
'margin-left: 2px;' +
'position: relative;' +
'top: 4px;' +
'-moz-user-select: none;' +
'-ms-user-select: none;' +
'-webkit-user-select: none;' +
'user-select: none;' +
'}' +
'.section-links a {' +
'height: 16px;' +
'width: 16px;' +
'overflow: hidden;' +
'text-indent: -999em;' +
'display: inline-block;' +
'margin: 2px;' +
'opacity: 0.35;' +
'-moz-transition: opacity 0.2s;' + //FF <= 15
'-webkit-transition: opacity 0.2s;' + //Chrome <= 25, Safari <= 6
'transition: opacity 0.2s;' +
'}' +
'h1:hover .section-links a,' +
'h2:hover .section-links a,' +
'h3:hover .section-links a,' +
'h4:hover .section-links a,' +
'h5:hover .section-links a,' +
'h6:hover .section-links a {' +
'-moz-transition-delay: 0.2s;' +
'-webkit-transition-delay: 0.2s;' +
'transition-delay: 0.2s;' +
'opacity: 0.6;' +
'}' +
'body .section-links a:hover,' +
'body .section-links a:focus {' +
'-moz-transition-delay: 0.1s;' +
'-webkit-transition-delay: 0.1s;' +
'transition-delay: 0.1s;' +
'opacity: 1;' +
'}' +
'html.ve-activated .section-links {' +
'display: none;' +
'}',
waitStyleSheet = false, deps;
switch (mw.config.get('wgDBname')) {
case 'dewiki':
configDone = {
selector: '#autoarchiv-erledigt-baustein, #Vorlage-Autoarchiv a[title="Vorlage:Erledigt"]',
done: 'erl.',
template: 'Erledigt'
};
break;
case 'dewiktionary':
case 'my_wiki':
configDone = {
selector: '#autoarchiv-erledigt-baustein',
done: 'erl.',
template: 'Erledigt'
};
break;
case 'commonswiki':
configDone = {
selector: '#autoarchiv-erledigt-baustein',
done: 'tagging section as resolved',
template: 'Section resolved'
};
break;
}
function initL10N (l10n) {
var i, chain = mw.language.getFallbackLanguageChain();
for (i = chain.length - 1; i >= 0; i--) {
if (chain[i] in l10n) {
mw.messages.set(l10n[chain[i]]);
}
}
}
function isModeAvailable (mode) {
if (!mw.libs.ve) {
return false;
}
switch (mode) {
case 'source': return !!mw.libs.ve.isWikitextAvailable;
case 'visual': return !!mw.libs.ve.isVisualAvailable;
default: return false;
}
}
function getEditorData (type, newSection) {
var useVeIcon = true,
msgName = 'sections-title-' + (newSection ? 'new-' : '') + 'append-' + type;
if (type === 'modern') {
if (!newSection && isModeAvailable('visual')) {
type = 've';
useVeIcon = false;
} else {
type = 'source';
}
}
if (type === 'source') {
if (isModeAvailable('source')) {
type = 'nwe';
} else {
type = 'owe';
}
}
switch (type) {
case 'owe': return {
param: isModeAvailable('source') ? {action: 'submit'} : {action: 'edit'},
title: msgName,
icon: icons.edit,
mode: false
};
case 'nwe': return isModeAvailable('source') && {
param: {veaction: 'editsource'},
title: msgName,
icon: icons.edit,
mode: 'source'
};
case 've': return !newSection && isModeAvailable('visual') && {
param: {veaction: 'edit'},
title: msgName,
icon: useVeIcon ? icons.ve : icons.edit,
mode: 'visual'
};
default: return false;
}
}
function getEditParams (url) {
try {
url = new mw.Uri(url, {strictMode: true, overrideKeys: true}).query;
} catch (e) {
url = false;
}
if (url) {
//FIXME wgActionPaths, title in path instead of query
if (url.title && url.action === 'edit' || url.veaction === 'editsource') {
delete url.action;
delete url.veaction;
} else {
url = false;
}
}
return url;
}
function formatReason (reason) {
if (reason === '' || reason.charAt(0) === '|') {
return reason;
}
return ': ' + reason;
}
function getTitleIconActionForLink (a) {
var $a = $(a), text;
if (
mw.config.get('wgDBname') === 'commonswiki' && mw.config.get('wgPageName').indexOf('Commons:Deletion_requests/') === 0
) {
if (!$a.parent('span').hasClass('reqHandlerLinks2')) {
return false;
}
text = $a.text();
if (text === 'Close: Kept') {
return [text, icons.done, clickOn(a)];
} else if (text === 'Close: Deleted') {
return [text, icons.del, clickOn(a)];
}
}
return false;
}
function clickOn (a) {
return function () {
a.click();
};
}
function scrollTop () {
window.scrollTo(0, 0);
}
function onDone (data) {
if (data && data.edit && data.edit.result === 'Success') {
window.location.reload(false);
} else {
waitStyleSheet.disabled = true;
window.alert(mw.msg('sections-done-error'));
}
}
function markDone ($button) {
var data = $button.parent('.section-links').data(),
edit = data.edit,
hash = data.hash,
reason, text, summary;
if (!edit) {
return;
}
reason = window.prompt(mw.msg('sections-done-reason'));
if (reason === null) {
return;
}
reason = reason.trim();
text = '\n\n{{' + configDone.template + '|1=~~~~' + formatReason(reason) + '}}';
summary = '/* ' +
hash.replace(/_/g, ' ')
.replace(/(\.[0-9A-F]{2})+/g, function (utf8) {
return decodeURIComponent(utf8.replace(/\./g, '%'));
}) +
' */ ' + configDone.done;
if (waitStyleSheet) {
waitStyleSheet.disabled = false;
} else {
waitStyleSheet = mw.util.addCSS('* {cursor: wait !important;}');
}
$.post(mw.util.wikiScript('api'), {
action: 'edit',
format: 'json',
formatversion: 2,
title: edit.title,
section: edit.section,
summary: summary,
minor: true,
appendtext: text,
token: mw.user.tokens.get('csrfToken')
}).always(onDone);
}
function onVEClick (mode, e, tab) {
var method = tab ? 'onEditTabClick' : 'onEditSectionLinkClick';
if (
//similar to pageCanLoadEditor in ve.init.mw.DesktopArticleTarget.init.js
mw.config.get('wgIsArticle') && mw.util.getParamValue('diff') === null &&
mw.libs.ve && mw.libs.ve[method]
) {
mw.libs.ve[method](mode, e);
}
}
function makeButton (text, icon, href) {
var isF = typeof href === 'function',
$button = $(mw.html.element('a', {
href: isF ? '#' : href,
'class': 'internal', //dont't show popups for these links
//we need to use inline-style + important to make sure
//to override all other styles (like .plainlinks)
style: 'background-image:url(' + icon + ') !important;',
title: text
}, ' ' + text));
if (isF) {
$button.on('click', function (e) {
e.preventDefault();
href($(this));
});
}
return $button;
}
function addContainers ($body) {
var canEdit = false, hasTools = false;
$body.find('h1, h2, h3, h4, h5, h6').each(function (i, h) {
var $h = $(h),
a = $h.find('.mw-editsection a, .mw-editsection-like a').get(),
hash = $h.find('.mw-headline').attr('id') || '',
edit, j;
for (j = 0; j < a.length; j++) {
edit = getEditParams(a[j].href);
if (edit) {
a.splice(j, 1);
break;
}
}
if (edit) {
canEdit = true;
}
if (a.length) {
hasTools = true;
}
if (i === 0 || hash !== '') {
$h.append($('<div>')
.addClass('section-links noprint')
.data({
hash: hash,
edit: edit,
tools: a
}));
}
});
return {canEdit: canEdit, hasTools: hasTools};
}
function addEdit ($containers, config, editorData) {
var i;
if (editorData === undefined) {
for (i = 0; i < config.editors.length; i++) {
addEdit($containers, config, getEditorData(config.editors[i]));
}
return;
}
if (!config.canEdit || !editorData) {
return;
}
$containers.each(function (i) {
var $this = $(this),
params = $this.data('edit'),
title = mw.msg('sections-edit'),
useTab = false,
button;
if (i === 0) {
if (!config.edit0) {
return;
}
params = getEditParams($('#ca-edit a').prop('href'));
if (params && editorData.mode !== 'visual') {
params.section = 0;
} else {
useTab = true;
}
title = mw.msg('sections-edit0');
}
if (params) {
button = makeButton(
mw.msg(editorData.title, title),
editorData.icon,
mw.util.getUrl('', $.extend({}, editorData.param, params))
);
if (editorData.mode) {
button.on('click', function (e) {
onVEClick(editorData.mode, e, useTab);
});
}
$this.append(button);
}
});
}
function addPlus ($containers, config, editorData) {
var i, $plus, params, button;
if (editorData === undefined) {
for (i = 0; i < config.editors.length; i++) {
addPlus($containers, config, getEditorData(config.editors[i], true));
}
return;
}
if (!config.canEdit || !editorData || !mw.config.get('wgIsArticle') || $containers.length <= 1) {
return;
}
$plus = $('#ca-addsection a');
if ($plus.length !== 1) {
return;
}
params = getEditParams($plus.prop('href'));
if (!params) {
return;
}
button = makeButton(
mw.msg(editorData.title, mw.msg('sections-plus')),
icons.plus,
mw.util.getUrl('', $.extend({}, editorData.param, params))
);
if (editorData.mode) {
button.on('click', function (e) {
onVEClick(editorData.mode, e);
});
}
$containers.last().append(button);
}
function addTop ($containers) {
$containers.each(function (i) {
if (i === 0) {
return;
}
$(this).append(makeButton(mw.msg('sections-top'), icons.top, scrollTop));
});
}
function addLink ($containers) {
$containers.each(function (i) {
if (i === 0) {
return;
}
var $this = $(this);
$this.append(makeButton(mw.msg('sections-link'), icons.link, '#' + $this.data('hash')));
});
}
function addNav ($containers) {
var $prev = false, prev = false;
$containers.each(function () {
var $this = $(this);
if ($prev) {
$prev.append(makeButton(mw.msg('sections-next'), icons.next, '#' + $this.data('hash')));
}
if (prev) {
$this.append(makeButton(mw.msg('sections-prev'), icons.prev, '#' + prev));
}
$prev = $this;
prev = $this.data('hash');
});
}
function addDone ($containers, config) {
if (!config.canEdit || !configDone || !$(configDone.selector).length) {
return;
}
$containers.each(function (i) {
var $this = $(this);
if (i === 0 || !$this.data('edit') || !$this.parent().is('h2')) {
return;
}
$this.append(makeButton(mw.msg('sections-done'), icons.done, markDone));
});
}
function addTools ($containers, config) {
if (!config.hasTools) {
return;
}
$containers.each(function () {
var $this = $(this),
tools = $this.data('tools'),
i, ret;
if (tools) {
for (i = 0; i < tools.length; i++) {
ret = getTitleIconActionForLink(tools[i]);
if (ret) {
$this.append(makeButton(ret[0], ret[1], ret[2]));
}
}
}
});
}
function addButtons ($content) {
if ($content.attr('id') !== 'mw-content-text') {
return;
}
$content = $content.add($('#firstHeading').parent()); //TODO mw.hook('wikipage.title').add(...), auch in notizen.js
$content.find('.section-links').remove();
var config = $.extend(getConfig(),
addContainers($content)
), $containers = $content.find('.section-links'),
functions = {
edit: addEdit,
plus: addPlus,
top: addTop,
link: addLink,
nav: addNav,
done: addDone
}, i;
for (i = 0; i < config.order.length; i++) {
functions[config.order[i]]($containers, config);
}
addTools($containers, config);
mw.hook('userjs.section-links').fire(function ($links, text, icon) {
$containers.each(function () {
var $this = $(this), $el = $this.parent().find($links), ret;
if (!$el.is('a')) {
$el = $el.find('a');
}
if (!icon) {
ret = getTitleIconActionForLink($el[0]);
} else {
ret = [text, icons[icon] || icon, clickOn($el[0])];
}
if (ret) {
$this.append(makeButton(ret[0], ret[1], ret[2]));
}
});
}, $content);
/*mw.hook('userjs.section-links').add(function (callback, $content) {
callback($newSectionLinks, text, icon);
});
*/
}
function getConfig () {
var edit0, normal = ['edit', 'plus', 'top', 'link', 'nav', 'done'], order, editors, i;
edit0 = mw.user.options.get('userjs-schnark-section-links-no-edit0', '') !== '1';
order = mw.user.options.get('userjs-schnark-section-links-order', '');
editors = mw.user.options.get('userjs-schnark-section-links-editors', 've/source');
if (order) {
order = order.split('/');
for (i = 0; i < order.length; i++) {
if (normal.indexOf(order[i]) === -1) {
mw.log.warn('Unknown value "' + order[i] + '" in userjs-schnark-section-links-order');
order = normal;
break;
}
}
} else {
order = normal;
}
return {order: order, edit0: edit0, editors: editors.split('/')};
}
function init () {
if (mw.config.get('wgAction') !== 'view' || mw.config.get('wgIsMainPage')) {
return;
}
var $flow = $('div.flow-component');
if ($flow.length && $flow.attr('data-flow-id')) {
return; //not on flow boards
}
mw.util.addCSS(css);
initL10N(l10n);
mw.hook('wikipage.content').add(addButtons);
}
deps = ['mediawiki.util', 'mediawiki.Uri', 'mediawiki.language', 'user.options'];
if (mw.loader.getState('ext.visualEditor.desktopArticleTarget.init')) {
deps.push('ext.visualEditor.desktopArticleTarget.init');
}
$.when(mw.loader.using(deps), $.ready).then(init);
})(jQuery, mediaWiki);
//</nowiki>