Site Notice
hello, world
Difference between revisions of "User:机智的小鱼君/common.js"
From Project-EPB Commons
([InPageEdit] 没有编辑摘要) |
m (// Via InPageEdit-v2) |
||
(35 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
− | mw.loader.load('https:// | + | $.ajax({ |
+ | url: 'http://127.0.0.1:1005/InPageEdit.js', | ||
+ | dataType: 'script', | ||
+ | }).then( | ||
+ | function () { | ||
+ | console.log('[InPageEdit] Using local dev') | ||
+ | }, | ||
+ | function () { | ||
+ | console.log('[InPageEdit] Local dev not found') | ||
+ | mw.loader.load('https://unpkg.com/mediawiki-inpageedit') | ||
+ | } | ||
+ | ) | ||
− | /* InPageEdit | + | /** InPageEdit Preferences */ |
− | window.InPageEdit = window.InPageEdit || {} | + | ;(window.InPageEdit = window.InPageEdit || {}).myPreference = { |
− | + | editMinor: false, | |
− | + | editSummary: '$section$oldid // Via InPageEdit-v2', | |
− | + | redLinkQuickEdit: true, | |
− | + | outSideClose: false, | |
− | + | watchList: true, | |
− | + | plugins: [ | |
− | + | 'toolbox.js', | |
− | + | 'code-mirror/script.js', | |
− | + | 'color-preview.js', | |
− | + | 'edit-any-page.js', | |
− | + | 'wiki-editor.js', | |
− | + | ], | |
+ | } | ||
− | mw.hook('InPageEdit').add(function(){ | + | mw.hook('InPageEdit').add(function (ctx) { |
if (mw.config.get('wgIsArticle')) { | if (mw.config.get('wgIsArticle')) { | ||
− | + | var _msg = ctx._msg | |
− | + | $('#ca-edit, #ca-viewsource').after( | |
− | + | $('<li>', { | |
− | + | id: 'ca-quick-edit', | |
− | + | class: 'collapsible', | |
− | + | }).append( | |
− | + | $('<span>').append( | |
− | + | $('<a>', { | |
− | + | href: 'javascript:void(0)', | |
− | + | text: _msg('quick-edit'), | |
− | + | }).on('click', function () { | |
− | + | InPageEdit.edit({ | |
− | + | page: mw.config.get('wgPageName'), | |
− | + | revision: mw.config.get('wgRevisionId'), | |
− | + | }) | |
− | + | }) | |
− | + | ) | |
− | + | ) | |
− | + | ) | |
− | ) | ||
− | |||
− | |||
} | } | ||
− | }) | + | }) |
if (mw.config.get('wgIsArticle')) { | if (mw.config.get('wgIsArticle')) { | ||
Line 47: | Line 56: | ||
$('<a>', { | $('<a>', { | ||
href: 'javascript:void(0);', | href: 'javascript:void(0);', | ||
− | style: 'margin-left:2px;top: -1.2em;position: relative;font-size: 8px;' | + | style: 'margin-left:2px;top: -1.2em;position: relative;font-size: 8px;', |
− | |||
− | |||
− | |||
− | |||
}) | }) | ||
− | ) | + | .append($('<span>').html('最后更改')) |
+ | .on('click', function () { | ||
+ | InPageEdit.quickDiff({ | ||
+ | fromtitle: mw.config.get('wgPageName'), | ||
+ | torelative: 'prev', | ||
+ | }) | ||
+ | }) | ||
+ | ) | ||
} | } | ||
− | $('#firstHeading').append('<span style="font-size:12px;float:right">wgRevisionId: ' + mw.config.get('wgRevisionId') + ' | wgArticleId: ' + | + | $('#firstHeading').append( |
− | + | '<span style="font-size:12px;float:right">wgRevisionId: ' + | |
− | + | mw.config.get('wgRevisionId') + | |
− | + | ' | wgArticleId: ' + | |
− | + | mw.config.get('wgArticleId') + | |
− | + | '</span>' | |
− | + | ) | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | /** Wikiplus */ | |
− | + | mw.loader.load( | |
− | + | 'https://wikiplus.oss-cn-shanghai.aliyuncs.com/Main.development.js' | |
+ | ) | ||
+ | // 修改 IPE 文字防止抑郁 | ||
+ | InPageEdit.i18n = InPageEdit.i18n || {} | ||
+ | InPageEdit.i18n['zh-hans'] = InPageEdit.i18n['zh-hans'] || {} | ||
+ | InPageEdit.i18n['zh-hans']['quick-edit'] = 'IPE 快编' |
Latest revision as of 04:35, 10 April 2022
$.ajax({
url: 'http://127.0.0.1:1005/InPageEdit.js',
dataType: 'script',
}).then(
function () {
console.log('[InPageEdit] Using local dev')
},
function () {
console.log('[InPageEdit] Local dev not found')
mw.loader.load('https://unpkg.com/mediawiki-inpageedit')
}
)
/** InPageEdit Preferences */
;(window.InPageEdit = window.InPageEdit || {}).myPreference = {
editMinor: false,
editSummary: '$section$oldid // Via InPageEdit-v2',
redLinkQuickEdit: true,
outSideClose: false,
watchList: true,
plugins: [
'toolbox.js',
'code-mirror/script.js',
'color-preview.js',
'edit-any-page.js',
'wiki-editor.js',
],
}
mw.hook('InPageEdit').add(function (ctx) {
if (mw.config.get('wgIsArticle')) {
var _msg = ctx._msg
$('#ca-edit, #ca-viewsource').after(
$('<li>', {
id: 'ca-quick-edit',
class: 'collapsible',
}).append(
$('<span>').append(
$('<a>', {
href: 'javascript:void(0)',
text: _msg('quick-edit'),
}).on('click', function () {
InPageEdit.edit({
page: mw.config.get('wgPageName'),
revision: mw.config.get('wgRevisionId'),
})
})
)
)
)
}
})
if (mw.config.get('wgIsArticle')) {
$('#ca-history').append(
$('<a>', {
href: 'javascript:void(0);',
style: 'margin-left:2px;top: -1.2em;position: relative;font-size: 8px;',
})
.append($('<span>').html('最后更改'))
.on('click', function () {
InPageEdit.quickDiff({
fromtitle: mw.config.get('wgPageName'),
torelative: 'prev',
})
})
)
}
$('#firstHeading').append(
'<span style="font-size:12px;float:right">wgRevisionId: ' +
mw.config.get('wgRevisionId') +
' | wgArticleId: ' +
mw.config.get('wgArticleId') +
'</span>'
)
/** Wikiplus */
mw.loader.load(
'https://wikiplus.oss-cn-shanghai.aliyuncs.com/Main.development.js'
)
// 修改 IPE 文字防止抑郁
InPageEdit.i18n = InPageEdit.i18n || {}
InPageEdit.i18n['zh-hans'] = InPageEdit.i18n['zh-hans'] || {}
InPageEdit.i18n['zh-hans']['quick-edit'] = 'IPE 快编'