MediaWiki:Gadget-AddProgrammingToolbar.js: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
(+Multilingual) |
(+nnbsp) |
||
Zeile 26: | Zeile 26: | ||
de : { | de : { | ||
'programmingtoolbar-label-blockquote': 'Zitat-Block', | 'programmingtoolbar-label-blockquote': 'Zitat-Block', | ||
+ | 'programmingtoolbar-label-nbsp': 'trenngeschütztes Leerzeichen', | ||
+ | 'programmingtoolbar-label-nnbsp-template': 'enges trenngeschütztes Leerzeichen (Vorlage)', | ||
'programmingtoolbar-label-strikethrough': 'durchgestrichen', | 'programmingtoolbar-label-strikethrough': 'durchgestrichen', | ||
+ | 'programmingtoolbar-label-syntaxhighlight': 'Syntax Hervorhebung', | ||
'programmingtoolbar-label-underline': 'unterstrichen', | 'programmingtoolbar-label-underline': 'unterstrichen', | ||
− | |||
'programmingtoolbar-peri-comment': 'Kommentar:', | 'programmingtoolbar-peri-comment': 'Kommentar:', | ||
'programmingtoolbar-peri-defInlineTerm': 'Parameter', | 'programmingtoolbar-peri-defInlineTerm': 'Parameter', | ||
Zeile 40: | Zeile 42: | ||
en : { | en : { | ||
'programmingtoolbar-label-blockquote': 'block quote', | 'programmingtoolbar-label-blockquote': 'block quote', | ||
+ | 'programmingtoolbar-label-nbsp': 'non-breaking space', | ||
+ | 'programmingtoolbar-label-nnbsp-template': 'narrow non-breaking space (template)', | ||
'programmingtoolbar-label-strikethrough': 'strike through', | 'programmingtoolbar-label-strikethrough': 'strike through', | ||
+ | 'programmingtoolbar-label-syntaxhighlight': 'syntax highlighting', | ||
'programmingtoolbar-label-underline': 'underlined', | 'programmingtoolbar-label-underline': 'underlined', | ||
− | |||
'programmingtoolbar-peri-comment': 'comment:', | 'programmingtoolbar-peri-comment': 'comment:', | ||
'programmingtoolbar-peri-defInlineTerm': 'Parameter', | 'programmingtoolbar-peri-defInlineTerm': 'Parameter', | ||
Zeile 131: | Zeile 135: | ||
'characters': [{ | 'characters': [{ | ||
label: "nbsp;", | label: "nbsp;", | ||
+ | labelMsg: mw.message('programmingtoolbar-label-nbsp'), | ||
action: { | action: { | ||
type: 'encapsulate', options: {pre: " ", post: ""} | type: 'encapsulate', options: {pre: " ", post: ""} | ||
+ | } | ||
+ | },{ | ||
+ | label: "{{nnbsp}}", | ||
+ | labelMsg: mw.message('programmingtoolbar-label-nnbsp-template'), | ||
+ | action: { | ||
+ | type: 'encapsulate', options: {pre: "{{nnbsp}}", post: ""} | ||
} | } | ||
}, { | }, { | ||
Zeile 403: | Zeile 414: | ||
label: mw.message('programmingtoolbar-pagelabel-templates'), | label: mw.message('programmingtoolbar-pagelabel-templates'), | ||
'characters': [ | 'characters': [ | ||
− | |||
{ | { | ||
label: "Keyboard", | label: "Keyboard", | ||
Zeile 409: | Zeile 419: | ||
type: 'encapsulate', options: {pre: "{{Keyboard |", post: "}}"} | type: 'encapsulate', options: {pre: "{{Keyboard |", post: "}}"} | ||
} | } | ||
− | }, { | + | },/*{ |
label: "Zitat", | label: "Zitat", | ||
action: { | action: { | ||
Zeile 423: | Zeile 433: | ||
{ | { | ||
label: "nbsp;", | label: "nbsp;", | ||
+ | labelMsg: mw.message('programmingtoolbar-label-nbsp'), | ||
+ | action: { | ||
+ | type: 'encapsulate', options: {pre: " ", post: ""} | ||
+ | } | ||
+ | },{ | ||
+ | label: "{{nnbsp}}", | ||
+ | labelMsg: mw.message('programmingtoolbar-label-nnbsp-template'), | ||
action: { | action: { | ||
− | type: 'encapsulate', | + | type: 'encapsulate', options: {pre: "{{nnbsp}}", post: ""} |
− | |||
} | } | ||
}, { | }, { |
Version vom 1. Juni 2018, 09:42 Uhr
//<pre>
/*
o ptions: { *
pre:'{|'+classStr+"\n",
peri:table,
post:'|}',
ownline:true
type: "booklet"
label string: non-localizable label string
labelMsg string: key for localizable message string
deferLoad boolean
pages object: map of name keys to further objects:
layout string required: 'table' or 'characters'
label string: non-localizable label string
labelMsg string: key for localizable message string
headings string[]: array of objects? {textMsg: key} ??
rows object[] optional?: array of objects? {'row key name': {message object?}}
characters string[] optional?: array of strings of little character bits for insertion (???!)
*/
//<source lang="javascript">
thismessages = {
de : {
'programmingtoolbar-label-blockquote': 'Zitat-Block',
'programmingtoolbar-label-nbsp': 'trenngeschütztes Leerzeichen',
'programmingtoolbar-label-nnbsp-template': 'enges trenngeschütztes Leerzeichen (Vorlage)',
'programmingtoolbar-label-strikethrough': 'durchgestrichen',
'programmingtoolbar-label-syntaxhighlight': 'Syntax Hervorhebung',
'programmingtoolbar-label-underline': 'unterstrichen',
'programmingtoolbar-peri-comment': 'Kommentar:',
'programmingtoolbar-peri-defInlineTerm': 'Parameter',
'programmingtoolbar-peri-defInlineDefinition': 'Erläuterungen',
'programmingtoolbar-peri-ref': 'Referenz/Zitat',
'programmingtoolbar-peri-tvar': 'variabler Inhalt, Text, Link o.ä.',
'programmingtoolbar-sectionlabel-programming': 'Programmierung',
'programmingtoolbar-pagelabel-templates': 'Vorlagen',
'programmingtoolbar-pagelabel-wikitags': 'Wiki/HTML Tags'
},
en : {
'programmingtoolbar-label-blockquote': 'block quote',
'programmingtoolbar-label-nbsp': 'non-breaking space',
'programmingtoolbar-label-nnbsp-template': 'narrow non-breaking space (template)',
'programmingtoolbar-label-strikethrough': 'strike through',
'programmingtoolbar-label-syntaxhighlight': 'syntax highlighting',
'programmingtoolbar-label-underline': 'underlined',
'programmingtoolbar-peri-comment': 'comment:',
'programmingtoolbar-peri-defInlineTerm': 'Parameter',
'programmingtoolbar-peri-defInlineDefinition': 'Explanations',
'programmingtoolbar-peri-ref': 'Reference/Citation',
'programmingtoolbar-peri-tvar': 'variable content, text, link etc.',
'programmingtoolbar-sectionlabel-programming': 'Programming',
'programmingtoolbar-pagelabel-templates': 'Templates',
'programmingtoolbar-pagelabel-wikitags': 'Wiki/HTML tags'
}
};
mw.messages.set(thismessages['en']);
var lang = mw.config.get('wgUserLanguage');
if (lang && lang !== 'en' && lang in thismessages) {
mw.messages.set(thismessages[lang]);
}
var customizeThisUserWikiEditorToolbar = function () {
$('#wpTextbox1').wikiEditor('addToToolbar', {
'section': 'advanced',
'group': 'format',
'tools': {
'strikethrough': {
label: mw.message('programmingtoolbar-label-strikethrough'),
type: 'button',
icon: 'https://upload.wikimedia.org/wikipedia/commons/3/30/Btn_toolbar_rayer.png',
action: {
type: 'encapsulate',
options: {
pre: "<s>",
post: "</s>"
}
}
},
'underline': {
label: mw.message('programmingtoolbar-label-underline'),
type: 'button',
icon: 'https://upload.wikimedia.org/wikipedia/commons/f/fd/Button_underline.png',
action: {
type: 'encapsulate',
options: {
pre: "<u>",
post: "</u>"
}
}
},
'syntaxhighlight': {
label: mw.message('programmingtoolbar-label-syntaxhighlight'),
type: 'button',
icon: 'https://upload.wikimedia.org/wikipedia/commons/d/d2/Button_source.png',
action: {
type: 'encapsulate',
options: {
pre: "<source lang=\"html4strict\">\n",
post: "\n</source>"
}
}
},
'blockquote': {
label: mw.message('programmingtoolbar-label-blockquote'),
type: 'button',
icon: 'https://upload.wikimedia.org/wikipedia/en/f/fd/Button_blockquote.png',
action: {
type: 'encapsulate',
options: {
pre: "<blockquote>\n",
post: "\n</blockquote>"
}
}
}
}
})
$('#wpTextbox1').wikiEditor('addToToolbar', {
'sections': {
'programming': {
type: 'booklet',
label: mw.message('programmingtoolbar-sectionlabel-programming')
}
}
})
$('#wpTextbox1').wikiEditor('addToToolbar', {
'section': 'programming',
'pages': {
'tags': {
'layout': 'characters',
label: mw.message('programmingtoolbar-pagelabel-wikitags'),
'characters': [{
label: "nbsp;",
labelMsg: mw.message('programmingtoolbar-label-nbsp'),
action: {
type: 'encapsulate', options: {pre: " ", post: ""}
}
},{
label: "{{nnbsp}}",
labelMsg: mw.message('programmingtoolbar-label-nnbsp-template'),
action: {
type: 'encapsulate', options: {pre: "{{nnbsp}}", post: ""}
}
}, {
label: "()",
action: {
type: 'encapsulate', options: {pre: "(", post: ")"}
}
}, {
label: "[]",
action: {
type: 'encapsulate', options: {pre: "[", post: "]"}
}
}, {
label: "[[]]",
action: {
type: 'encapsulate', options: {pre: "[[", post: "]]"}
}
}, {
label: "{{}}",
action: {
type: 'encapsulate', options: {pre: '{{', post: '}}'}
}
}, {
label: "{{{}}}",
action: {
type: 'encapsulate', options: {pre: "{{{", 'peri': '1', post: "}}}"}
}
}, {
label: "{{{|}}}",
action: {
type: 'encapsulate', options: {pre: "{{{|", 'peri': '1', post: "}}}"}
}
}, {
label: "[[Kategorie:]]",
action: {
type: 'encapsulate', options: {pre: '[[Kategorie: ', post: ']]'}
}
}, {
label: "[[Category:]]",
action: {
type: 'encapsulate', options: {pre: '[[Category: ', post: ']]'}
}
}, {
label: "[[Attribut:]]",
action: {
type: 'encapsulate',
options: {
/* no selection */
pre: "[[Attribut: ",
post: "]]",
/* a selection */
regex: /\s*(.+)\s*/,
regexReplace: "[[Attribut: \$1 |\$1]]"
}
}
}, {
label: "[[property:]]",
action: {
type: 'encapsulate',
options: {
/* no selection */
pre: "[[property: ",
post: "]]",
/* a selection */
regex: /\s*(.+)\s*/,
regexReplace: "[[property: \$1 |\$1]]"
}
}
}, {
label: "#WEITERLEITUNG [[]]",
action: {
type: 'encapsulate', options: {pre: "#WEITERLEITUNG [[", post: "]]"}
}
}, {
label: "#REDIRECT [[]]",
action: {
type: 'encapsulate', options: {pre: "#REDIRECT [[", post: "]]"}
}
},
"__INHALTSVERZEICHNIS__",
"__TOC__",
{
label: "{{Multilingual}}",
action: {
type: 'encapsulate', options: {pre: '{{Multilingual\n|de=', peri: 'deutscher Text', post: '\n|en=english text\n}}'}
}
},
{
label: "ref",
action: {
type: 'encapsulate', options: {pre: '<ref name="">', peri: mw.message('programmingtoolbar-peri-ref'), post: '</ref>'}
}
}, {
label: "references",
action: {
type: 'encapsulate', options: {pre: '<references/>', post: ''}
}
}, {
label: "noinclude",
action: {
type: 'encapsulate', options: {pre: "<noinclude>", post: "</noinclude>"}
}
}, {
label: "includeonly",
action: {
type: 'encapsulate', options: {pre: "<includeonly>", post: "</includeonly>"}
}
}, {
label: "onlyinclude",
action: {
type: 'encapsulate', options: {pre: "<onlyinclude>", post: "</onlyinclude>"}
}
}, {
label: "translate",
action: {
type: 'encapsulate',
options: {pre: "<translate>", post: "</translate>"}
}
}, {
label: "tvar",
action: {
type: 'encapsulate',
options: {pre: "<tvar|name>", peri: mw.message('programmingtoolbar-peri-tvar'), post: "</>"}
}
}, {
label: "code",
action: {
type: 'encapsulate', options: {pre: "<code>", post: "</code>"}
}
}, {
label: "nowiki",
action: {
type: 'encapsulate', options: {pre: "<nowiki>", post: "</nowiki>"}
}
}, {
label: "code nowiki code",
action: {
type: 'encapsulate', options: {pre: "<code><nowiki>", post: "</nowiki></code>"}
}
}, {
label: "comment",
action: {
type: 'encapsulate', options: {pre: "<!-- ", 'peri': mw.message('programmingtoolbar-peri-comment'), post: " -->"}
}
}, {
label: "comment lt--gt",
action: {
type: 'encapsulate', options: {pre: "<!-- ", 'peri': mw.message('programmingtoolbar-peri-comment'), post: " -->"}
}
}, {
label: "span",
action: {
type: 'encapsulate', options: {pre: '<span style="">', post: '</span>'}
}
}, {
label: "div",
action: {
type: 'encapsulate', options: {pre: '<div style="">', post: '</div>'}
}
}, {
label: "{{SORTIERUNG:}}",
action: {
type: 'encapsulate', options: {pre: "{{SORTIERUNG: ", post: "}}"}
}
}, {
label: "{{DEFAULTSORT:}}",
action: {
type: 'encapsulate', options: {pre: "{{DEFAULTSORT: ", post: "}}"}
}
}, {
'label': "div.definition-inline",
'action': {
'type': 'encapsulate',
'options': {
'pre': '<div class="definition-inline">\n; ',
'peri': mw.message('programmingtoolbar-peri-defInlineTerm'),
'post': ' : ' + mw.message('programmingtoolbar-peri-defInlineDefinition') + '\n</div>'
}
}
}, {
label: "{{#arraymap:}}",
action: {
type: 'encapsulate',
options: {pre: "{{#arraymap: ", peri: '{{{field|}}}', post: '|;|§|[[My property::§]] | • }}'}
}
}, {
label: "{{#arraymap:long}}",
action: {
type: 'encapsulate',
options: {
pre: "{{#arraymap: ",
peri: '{{{field|}}}',
post: '<!-- values\n-->|;<!-- split on ;\n-->|§<!-- assign temporary variable\n-->|[[My property::§]] <!-- output\n-->| • <!-- new output separator\n-->}}'
}
}
}, {
label: "if",
action: {
type: 'encapsulate', options: {pre: "{{#if: ", post: "| | }}"}
}
}, {
label: "if long",
action: {
type: 'encapsulate',
options: {pre: "<!--\n-->{{#if: ", post: "<!--\nthen-->|<!--\nelse-->|<!--\n-->}}<!-- if end\n-->"}
}
}, {
label: "switch CONTENTLANGUAGE",
action: {
type: 'encapsulate',
options: {
pre: "{{#switch: {{CONTENTLANGUAGE}}",
post: "<!--\n-->|de|de-formal= deutsch <!--\n-->| #default = english<!--\n-->}}<!-- switch end\n-->"
}
}
}, {
label: "switch",
action: {
type: 'encapsulate',
options: {
pre: "{{#switch: ",
post: "<!--\n-->| one | two = <!--\n-->| #default = <!--\n-->}}<!-- switch end\n-->"
}
}
}, {
label: "table",
action: {
type: 'encapsulate',
options: {
pre: '<table>',
peri: '<!--\n--><tr><!--\n --><td></td><!--\n--></tr><!--\n-->',
post: '</table>'
}
}
}, {
label: "tr",
action: {
type: 'encapsulate',
options: {pre: '<tr>', peri: '<!--\n --><td></td><!--\n-->', post: '</tr>'}
}
}, {
label: "th",
action: {
type: 'encapsulate',
options: {pre: '<th>', post: '</th>'}
}
}, {
label: "td",
action: {
type: 'encapsulate',
options: {pre: '<td>', post: '</td>'}
}
},
'┌',
'┬',
'┐',
'└',
'┴',
'┘',
'│',
'─',
'├',
'┼',
'┤'
/* <s></s> <sup></sup> <sub></sub> */
]
},
'templates': {
'layout': 'characters',
label: mw.message('programmingtoolbar-pagelabel-templates'),
'characters': [
{
label: "Keyboard",
action: {
type: 'encapsulate', options: {pre: "{{Keyboard |", post: "}}"}
}
},/*{
label: "Zitat",
action: {
type: 'encapsulate', options: {pre: '{{Zitat |', post: '}}'}
}
}, {
label: "Zitat versteckt",
action: {
type: 'encapsulate', options: {pre: '{{Zitat versteckt|', post: '}}'}
}
},
*/
{
label: "nbsp;",
labelMsg: mw.message('programmingtoolbar-label-nbsp'),
action: {
type: 'encapsulate', options: {pre: " ", post: ""}
}
},{
label: "{{nnbsp}}",
labelMsg: mw.message('programmingtoolbar-label-nnbsp-template'),
action: {
type: 'encapsulate', options: {pre: "{{nnbsp}}", post: ""}
}
}, {
label: "()",
action: {
type: 'encapsulate',
options: {pre: "(", post: ")"}
}
}, {
label: "[]",
action: {
type: 'encapsulate',
options: {pre: "[", post: "]"}
}
}, {
label: "[[]]",
action: {
type: 'encapsulate',
options: {pre: "[[", post: "]]"}
}
}, {
label: "{{}}",
action: {
type: 'encapsulate',
options: {pre: "{{", post: "}}"}
}
}, {
label: "{{{}}}",
action: {
type: 'encapsulate',
options: {pre: "{{{", post: "}}}"}
}
}, {
label: "{{{|}}}",
action: {
type: 'encapsulate',
options: {pre: "{{{", post: "|}}}"}
}
}, {
label: "noinclude",
action: {
type: 'encapsulate',
options: {pre: "<noinclude>", post: "</noinclude>"}
}
}, {
label: "includeonly",
action: {
type: 'encapsulate',
options: {pre: "<includeonly>", post: "</includeonly>"}
}
}, {
label: "onlyinclude",
action: {
type: 'encapsulate',
options: {pre: "<onlyinclude>", post: "</onlyinclude>"}
}
}, {
label: "nowiki",
action: {
type: 'encapsulate',
options: {pre: "<nowiki>", post: "</nowiki>"}
}
}, {
label: "comment",
action: {
type: 'encapsulate',
options: {pre: "<!-- ", post: " -->"}
}
}, {
label: "{{#arraymap:}} long",
action: {
type: 'encapsulate',
options: {
pre: "{{#arraymap: ",
peri: '{{{field|}}}',
post: "<!--\n-->|;<!-- sep\n-->|§<!-- assign temporary var\n-->|[[My property::§]] <!--output\n-->| • <!--output sep\n-->}}<!-- end arraymap \n-->"
}
}
}, {
label: "{{#arraymap:}}",
action: {
type: 'encapsulate',
options: {pre: "{{#arraymap: ", peri: '{{{field|}}}', post: "|;|§|[[My property::§]] | • }}"}
}
}, {
label: "{{#ask:table}}",
action: {
type: 'encapsulate',
options: {
pre: "{{#ask: ",
peri: '[[PAGE]] [[property::+]]',
post: " | ?displayprop |? | mainlabel=- | link=none | format = table | limit = 500}}"
}
}
}, {
label: "{{#ask:list}}",
action: {
type: 'encapsulate',
options: {
pre: "{{#ask: ",
peri: '[[PAGE]] [[property::+]]',
post: " | ?displayprop | mainlabel=- | link=none | format = list | sep= •  | limit = 500}}"
}
}
}, {
label: "{{#vardefine:}}",
action: {
type: 'encapsulate',
options: {pre: "{{#vardefine: ", peri: 'myVar', post: "| }}"}
}
}, {
label: "{{#varexist:}}",
action: {
type: 'encapsulate',
options: {pre: "{{#varexist: ", peri: 'myVar', post: "}}"}
}
}, {
label: "{{#var:}}",
action: {
type: 'encapsulate',
options: {pre: "{{#var: ", peri: 'myVar', post: "}}"}
}
}, {
label: "if",
action: {
type: 'encapsulate',
options: {pre: "{{#if: ", post: "| | }}"}
}
}, {
label: "if long",
action: {
type: 'encapsulate',
options: {pre: "<!--\n-->{{#if: ", post: "<!--\nthen-->|<!--\nelse-->|<!--\n-->}}<!-- end if\n-->"}
}
}, {
label: "ifexist",
action: {
type: 'encapsulate',
options: {pre: "{{#ifexist: ", post: "| | }}"}
}
}, {
label: "ifexist long",
action: {
type: 'encapsulate',
options: {
pre: "<!--\n-->{{#ifexist: ",
post: "<!--\nthen-->|<!--\nelse-->|<!--\n-->}}<!-- end ifexist\n-->"
}
}
}, {
label: "{{#expr:}}",
action: {
type: 'encapsulate',
options: {pre: "{{#expr: ", peri: '1 + 6', post: "}}"}
}
}, {
label: "switch",
action: {
type: 'encapsulate',
options: {
pre: "{{#switch: ",
post: "<!--\n-->| one | two = <!--\n-->| #default = <!--\n-->}}<!-- end switch\n-->"
}
}
}, {
label: "{{DEFAULTSORT:}}",
action: {
type: 'encapsulate',
options: {pre: "{{DEFAULTSORT:", post: "}}"}
}
}, {
label: "{{DISPLAYTITLE:}}",
action: {
type: 'encapsulate',
options: {pre: "{{DISPLAYTITLE:", post: "}}"}
}
},
'{{PAGENAME}}',
'{{PAGENAMEE}}',
'{{FULLPAGENAME}}',
'{{FULLPAGENAMEE}}'
]
}
}
})
}
/* Check if view is in edit mode and that the required modules are available. Then, customize the toolbar … */
if ($.inArray(mw.config.get('wgAction'), ['edit', 'submit']) !== -1) {
mw.loader.using('user.options', function () {
if (mw.user.options.get('usebetatoolbar')) {
mw.loader.using('ext.wikiEditor', function () {
$(document).ready(customizeThisUserWikiEditorToolbar);
})
}
})
}
// </source>
// </pre>