注意:在发布之后,您可能需要清除浏览器缓存才能看到所作出的变更的影响。
- Firefox或Safari:按住Shift的同时单击刷新,或按Ctrl-F5或Ctrl-R(Mac为⌘-R)
- Google Chrome:按Ctrl-Shift-R(Mac为⌘-Shift-R)
- Internet Explorer或Edge:按住Ctrl的同时单击刷新,或按Ctrl-F5
- Opera:按 Ctrl-F5。
// Check if we're editing a page.
if ( [ 'edit', 'submit' ].indexOf( mw.config.get( 'wgAction' ) ) !== -1 ) {
// Add a hook handler.
mw.hook( 'wikiEditor.toolbarReady' ).add( function ( $textarea ) {
// Configure a new toolbar entry on the given $textarea jQuery object.
//题库模板的下拉菜单
$textarea.wikiEditor( 'addToToolbar', {
section: 'main',
groups: {
list: {
tools: {
templates: {
label: '题库模板',
type: 'select',
list: {
'A1-button': {
label: 'A1型题',
action: {
type: 'encapsulate',
options: {
pre: '{{A型题\n|source=\n|title=\n|choices="A":"","B":"","C":"","D":"","E":""\n|answer=\n|explain=\n}}\n\n',
post: ''
}
}
}
,'A2-button': {
label: 'A2型题',
action: {
type: 'encapsulate',
options: {
pre: '{{A2型题\n|source=\n|title=\n|choices="A":"","B":"","C":"","D":"","E":""\n|answer=\n|explain=\n}}\n\n',
post: ''
}
}
}
,'A3-button': {
label: 'A3型题',
action: {
type: 'encapsulate',
options: {
pre: '{{A3型题\n|source=\n|sourceRange=\n|title="",""\n|choices={"A":"","B":"","C":"","D":"","E":""},{"A":"","B":"","C":"","D":"","E":""}\n|answer="",""\n|explain="",""\n|info=\n}}\n\n',
post: ''
}
}
}
,'B-button': {
label: 'B型题',
action: {
type: 'encapsulate',
options: {
pre: '{{B型题\n|source=\n|sourceRange=\n|title="",""\n|choices="A":"","B":"","C":"","D":"","E":""\n|answer="",""\n|explain="",""\n}}\n\n',
post: ''
}
}
}
,'C-button': {
label: 'C型题',
action: {
type: 'encapsulate',
options: {
pre: '{{C型题\n|source=\n|sourceRange=\n|title="",""\n|choices="A":"","B":"","C":"","D":"","E":""\n|answer="",""\n|explain="",""\n}}\n\n',
post: ''
}
}
}
,'X-button': {
label: 'X型题',
action: {
type: 'encapsulate',
options: {
pre: '{{X型题\n|source=\n|title=\n|choices="A":"","B":"","C":"","D":"","E":""\n|answer=\n|explain=\n}}\n\n',
post: ''
}
}
}
,'TK-button': {
label: 'TK型题',
action: {
type: 'encapsulate',
options: {
pre: '{{TK型题\n|source=\n|pos=\n|title=\n|answer="",""\n|explain=\n}}\n\n',
post: ''
}
}
}
,'MJ-button': {
label: 'MJ型题',
action: {
type: 'encapsulate',
options: {
pre: '{{MJ型题\n|source=\n|inputbox=0\n|title=\n|answer=\n}}\n\n',
post: ''
}
}
}
,'PD-button': {
label: 'PD型题',
action: {
type: 'encapsulate',
options: {
pre: '{{PD型题\n|source=\n|title=\n|answer=\n|explain=\n}}\n\n',
post: ''
}
}
}
}
}
}
}
}
} );
$textarea.wikiEditor( 'addToToolbar', {
section: 'main',
groups: {
list: {
tools: {
templates: {
label: '词库模板',
type: 'select',
list: {
'word-button': {
label: '单词模板',
action: {
type: 'encapsulate',
options: {
pre: '{{单词\n|wordName=\n|wordPro=\n|wordZh=\n|source=\n|define=\n|relatewords={{relatewords|}}}}\n\n',
post: ''
}
}
}
,'glossary-button': {
label: '名解模板',
action: {
type: 'encapsulate',
options: {
pre: '{{名解\n|wordZh=\n|wordEng=\n|source=\n|define=\n|explain=\n|relatewords={{relatewords|}}}}\n\n',
post: ''
}
}
}
}
}
}
}
}
} );
} );
}