User:Polygnotus/Scripts/WikiEditorToolbar.js: Difference between revisions

Content deleted Content added
No edit summary
use OOUI
 
(45 intermediate revisions by the same user not shown)
Line 2:
//colours are weird in dark mode
 
//https://www.mediawiki.org/wiki/Extension:WikiEditor/Toolbar_customization
 
// <nowiki>
if (['edit', 'submit'].indexOf(mw.config.get('wgAction')) !== -1) {
mw.hook('wikiEditor.toolbarReady').add(function($textarea) {
Line 11 ⟶ 14:
welcomeButton: {
label: 'Welcome',
filters: [ 'body.ns-3' ],
type: 'button',
icon: '//upload.wikimedia.org/wikipedia/commons/6/6f/Handshake_icon_BLACK_and_WHITE.svg',
Line 16 ⟶ 20:
type: 'encapsulate',
options: {
pre: '{{subst:' + 'User:Polygnotus/Templates/welcome}} ~~' + '~~',
}
 
}
Hi Polygnotus! I would like to welcome you to the Wikipedia community. I hope you like it here and decide to stay.
},
 
As you get started, you may find this short tutorial helpful:
refIdeas: {
 
type: 'element',
{{Clickable button 2|Help:Introduction|Learn more about editing|class=mw-ui-progressive|style=margin-left: 1.6em;}}
filters: [ 'body.ns-1' ],
 
element: function ( context ) {
Alternatively, the [[Wikipedia:Contributing to Wikipedia|contributing to Wikipedia]] page covers the same topics.
var button = new OO.ui.ButtonInputWidget( {
 
label: '',
If you have any questions, we have a friendly space where experienced editors can help you here:
icon: 'lightbulb',
 
title: 'refideas'
{{Clickable button 2|Wikipedia:Teahouse|Get help at the Teahouse|style=margin-left: 1.6em;}}
} );
 
button.connect( null, {
If you are not sure where to help out, you can find a task here:
click: function ( e ) {
 
var text = '{{refideas\n|1=\n}}';
{{Clickable button 2|Wikipedia:Task Center|Volunteer at the Task Center|style=margin-left: 1.6em;}}
 
var textarea = context.$textarea[0];
Happy editing! <!-- Template:Welcome--> [[User:Polygnotus|Polygnotus]] ([[User talk:Polygnotus|talk]]) 01:45, 25 June 2024 (UTC) ~~' + '~~',
var start = textarea.selectionStart;
var end = textarea.selectionEnd;
var currentText = textarea.value;
textarea.value = currentText.substring(0, start) + text + currentText.substring(end);
textarea.selectionStart = textarea.selectionEnd = start + text.length;
textarea.focus();
$(textarea).trigger('input');
$('#wpSummary').val('Added {{refideas}} template');
}
} );
return button.$element;
}
},
wpPolicy: {
type: 'element',
element: function ( context ) {
var button = new OO.ui.ButtonInputWidget( {
label: 'ReadThis',
icon: 'articles'
} );
button.connect( null, {
click: function ( e ) {
var policy = prompt('Enter Wikipedia policy/guideline abbreviation (e.g., NPOV, V, RS):');
if (policy !== null && policy.trim() !== '') {
var text = '== [[WP:' + policy.trim() + ']] ==\nPlease read [[WP:' + policy.trim() + ']], thanks and have a nice day, ~~~~';
context.$textarea.textSelection('encapsulateSelection', {
pre: text
});
}
}
} );
return button.$element;
}
},
exlinkInBody: {
type: 'element',
filters: [ 'body.ns-3' ],
element: function ( context ) {
var button = new OO.ui.ButtonInputWidget( {
label: 'ExternalLinkInBody',
icon: '//upload.wikimedia.org/wikipedia/commons/0/05/IUCN_EX.svg'
} );
button.connect( null, {
click: function ( e ) {
var text = '{{subst:' + 'User:Polygnotus/Templates/exlink}} ~~' + '~~';
context.$textarea.textSelection('encapsulateSelection', {
pre: text
});
}
} );
return button.$element;
}
},
uwSpam: {
type: 'element',
filters: [ 'body.ns-3' ],
element: function ( context ) {
var button = new OO.ui.ButtonInputWidget( {
label: 'Uw-Spam',
icon: '//upload.wikimedia.org/wikipedia/commons/c/c8/No-spam.svg'
} );
button.connect( null, {
click: function ( e ) {
var text = '{{subst:' + 'uw-spam}} ~~' + '~~';
context.$textarea.textSelection('encapsulateSelection', {
pre: text
});
}
} );
return button.$element;
}
},
teahouseButton: {
label: 'Teahouse',
filters: [ 'body.ns-3' ],
type: 'button',
icon: '//upload.wikimedia.org/wikipedia/commons/0/0d/Questionmark_SVG_4.svg',
action: {
type: 'encapsulate',
options: {
pre: 'If you have any questions, the [[WP:TEAHOUSE]] is a great place to get answers.',
}
}
},
vand1Button: {
label: 'Vandalism warning level 1',
filters: [ 'body.ns-3' ],
type: 'button',
icon: '//upload.wikimedia.org/wikipedia/commons/8/8a/Eo_circle_grey_number-1.svg',
Line 45 ⟶ 139:
type: 'encapsulate',
options: {
pre: '{{subst:' + 'uw-vand1}} ~~' + '~~',
pre: '[[File:Information.svg|25px|alt=Information icon]] Hello, I'm [[User:Polygnotus|Polygnotus]]. I wanted to let you know that one or more of [[Special:Contributions/Polygnotus|your recent contributions]] have been undone because they did not appear constructive. If you would like to experiment, please use the [[Wikipedia:Sandbox|sandbox]]. If you have any questions, you can ask for assistance at the [[Wikipedia:Teahouse|Teahouse]] or the [[Wikipedia:Help desk|Help desk]]. Thanks.<!-- Template:uw-vandalism1 --> ~~' + '~~',
}
}
},
vand2Button: {
label: 'Vandalism warning level 2',
filters: [ 'body.ns-3' ],
type: 'button',
icon: '//upload.wikimedia.org/wikipedia/commons/c/c7/Eo_circle_yellow_number-2.svg',
Line 56 ⟶ 152:
type: 'encapsulate',
options: {
pre: '{{subst:' + 'uw-vand2}} ~~' + '~~',
pre: '[[File:Information orange.svg|25px|alt=Information icon]] Please refrain from making unconstructive edits to Wikipedia. Your edits appear to constitute [[Wikipedia:Vandalism|vandalism]] and have been [[Help:Reverting|reverted]]. If you would like to experiment, please use the [[Wikipedia:Sandbox|sandbox]]. Repeated vandalism may result in the [[Wikipedia:Blocking policy|loss of editing privileges]]. Thank you.<!-- Template:uw-vandalism2 --> ~~' + '~~',
}
}
},
vand3Button: {
label: 'Vandalism warning level 3',
filters: [ 'body.ns-3' ],
type: 'button',
icon: '//upload.wikimedia.org/wikipedia/commons/c/c5/Eo_circle_deep-orange_number-3.svg',
Line 67 ⟶ 165:
type: 'encapsulate',
options: {
pre: '{{subst:' + 'uw-vand3}} ~~' + '~~',
pre: '[[File:Nuvola apps important.svg|25px|alt=Warning icon]] Please stop. If you continue to [[Wikipedia:Vandalism|vandalize]] Wikipedia, you may be [[Wikipedia:Blocking policy|blocked from editing]]. <!-- Template:uw-vandalism3 --> ~~' + '~~',
}
}
},
vand4Button: {
label: 'Vandalism warning level 4',
filters: [ 'body.ns-3' ],
type: 'button',
icon: '//upload.wikimedia.org/wikipedia/commons/c/cd/Eo_circle_red_number-4.svg',
Line 78 ⟶ 178:
type: 'encapsulate',
options: {
pre: '{{subst:' + 'uw-vand4}} ~~' + '~~',
pre: '[[File:Stop hand nuvola.svg|30px|alt=Stop icon]] You may be '''[[Wikipedia:Blocking policy|blocked from editing]] without further warning''' the next time you [[Wikipedia:Vandalism|vandalize]] Wikipedia. <!-- Template:uw-vandalism4 --> ~~' + '~~',
}
}
Line 87 ⟶ 187:
});
}
 
// </nowiki>