Gebruiker:Husky/monobook.js
Uiterlijk
Opmerking: na het publiceren is het wellicht nodig uw browsercache te legen om de veranderingen te zien.
- Firefox / Safari: houd Shift ingedrukt terwijl u:je op Vernieuwen klikt of druk op Ctrl-F5 of Ctrl-R (⌘-Shift-R op een Mac)
- Google Chrome: druk op Ctrl-Shift-R (⌘-Shift-R op een Mac)
- Edge: houd Ctrl ingedrukt terwijl u:je op Vernieuwen klikt of druk op Ctrl-F5.
// <nowiki><pre>
/* Insert some extra buttons for handy placing of templates */
// First make an array of all possible templates with their properties
var prefix = 'subst:Gebruiker:Husky/';
var templates = [
{ "template" : "test", "arguments" : 1, "signature" : true, "prefix": true },
{ "template" : "auteur", "arguments" : 1, "signature" : true, "prefix": true },
{ "template" : "bio", "arguments" : 1, "signature" : true, "prefix": true },
{ "template" : "geencat", "arguments" : 1, "signature" : true, "prefix": true },
{ "template" : "npov", "arguments" : 1, "signature" : true, "prefix": true },
{ "template" : "npov-stuk", "arguments" : 1, "signature" : true, "prefix": true },
{ "template" : "wb", "arguments" : 1, "signature" : true, "prefix": true },
{ "template" : "beg", "arguments" : 1, "signature" : true, "prefix": true },
{ "template" : "wiu", "arguments" : 1, "signature" : true, "prefix": true },
{ "template" : "welkom", "arguments" : 0, "signature" : true, "prefix": true },
{ "template" : "welkom-sp", "arguments" : 1, "signature" : true, "prefix": true },
{ "template" : "reclame", "arguments" : 1, "signature" : true, "prefix": true },
{ "template" : "spam", "arguments" : 0, "signature" : true, "prefix": true },
{ "template" : "controle", "arguments" : 0, "signature" : true, "prefix": true },
{ "template" : "bv", "arguments" : 1, "signature" : true, "prefix": true },
{ "template" : "wikatie", "arguments" : 1, "signature" : true, "prefix": true },
{ "template" : "grap", "arguments" : 1, "signature" : true, "prefix": true },
{ "template" : "spelling", "arguments" : 1, "signature" : true, "prefix": true },
{ "template" : "ingewikkeld", "arguments" : 1, "signature" : true, "prefix": true },
{ "template" : "afbinvoeg", "arguments" : 1, "signature" : true, "prefix": true },
{ "template" : "commons", "arguments" : 0, "signature" : false, "prefix" : false, "summary" : "+commons" },
{ "template" : "fotogewenst", "arguments" : 0, "signature" : false,"prefix": false, "summary" : "fotogew" }
];
var summaries = [
['+afb', 'Afbeelding toegevoegd'],
['-afb', 'Afbeelding verwijderd (bestaat niet meer of is niet beschikbaar)'],
['+commons','Externe link naar mediabestanden op Wikimedia Commons toegevoegd'],
['interwk', 'Interwiki-links toegevoegd naar artikelen op andere Wikis'],
['+tekst', 'Tekst en nieuwe informatie toegevoegd aan het artikel'],
['+cat', 'Categorieën toegevoegd'],
['sp', 'Spelfoutjes verbeterd'],
['nieuw', 'Nieuw artikel, eerste versie'],
['rv', 'Revert van het artikel naar een oudere versie'],
['fotogew', 'Sjabloon {{Fotogewenst}} toegevoegd voor Wikiportet project'],
['wiki', 'Wikificatie van het artikel']
];
// Main function //
window.onload = function() {
// Stuff for the toolbar
var toolbar = document.getElementById("editpage-copywarn");
if (toolbar) {
toolbar.innerHTML = '';
var toolbox = document.createElement('div');
toolbox.className = 'toolbox';
// a bit dirty, but i'm too lazy to rebuild the whole summaries array to allow index
function getSummaryById(id) {
for (var i in summaries) {
if (summaries[i][0] == id) return summaries[i][1];
}
return false;
}
// only add them if there is a toolbar
function addButton(i) {
var template = templates[i];
var button = document.createElement('a');
button.className = 'fakebutton';
button.innerHTML = template.template_name || template.template; // take the template_name, otherwise simply the tag
button.onclick = function() {
// see if there need to be arguments first
var args = '';
if (template.arguments) {
args = prompt("Enter argument (enter none for {{PAGENAME}} )");
args = '|' + args || '|{{PAGENAME}}';
}
var signature = '';
if (template.signature) {
signature = '~~~~';
}
if (template.prefix) {
template.templateName = prefix + template.template;
}
var sum = document.getElementById('wpSummary');
if (template.summary) {
sum.value = getSummaryById(template.summary);
} else {
sum.value = template.template;
}
insertTags('{{' + template.templateName + args + '}} ' + signature, '', '');
}
// okay, add to the toolbar
toolbox.appendChild(button);
}
for(var i in templates) {
addButton(i);
} // for (var i in templates)
// Okay, add the toolbox to the toolbar
toolbar.appendChild(toolbox);
} // if (toolbar)
// Add summary templates
var sumTemplates = document.getElementById('wpSummaryLabel');
if (sumTemplates) {
function addSummary(i) {
var summaryAnchor = document.createElement('a');
summaryAnchor.innerHTML = summaries[i][0];
summaryAnchor.className = 'fakebutton';
summaryAnchor.onclick = function() {
// okay, put the summary in #wpSummary
var sum = document.getElementById('wpSummary');
sum.value = summaries[i][1];
}
// Build the <li>
sumTemplates.appendChild(summaryAnchor);
}
for (var i in summaries) {
addSummary(i);
}
sumTemplates += '<br clear="all" />';
} // if (sumTemplates)
} // window.onload
// </pre></nowiki>