“MediaWiki:Gadget-backlog.js”与“MediaWiki:Gadget-mobileEdit.js”:页面之间的差异
(页面间差异)
跳到导航
跳到搜索
imported>=海豚= (创建页面,内容为“mw.loader.load("https://zh.moegirl.org/User:AnnAngela/js/backlog.js?action=raw&ctype=text/javascript");”) |
imported>=海豚= 无编辑摘要 |
||
第1行: | 第1行: | ||
//<nowiki> | |||
/** | |||
* @Source: https://llwiki.org/zh/mediawiki:gadget-mobileEdit.js | |||
* @Author: User:Bhsd | |||
* @License: CC BY-NC-SA 4.0 | |||
* @Dependencies: ext.gadget.site-lib, mediawiki.util, oojs-ui-windows, user.options | |||
*/ | |||
"use strict"; | |||
const script = mw.config.get( 'wgScript' ), | |||
pagename = mw.util.wikiUrlencode( mw.config.get( 'wgPageName' ) ), | |||
id = mw.config.get( 'wgRevisionId' ), | |||
action = mw.config.get( 'wgAction' ); | |||
$('body').on('click', 'a.new', function() { | |||
$(this).attr('href', function(i, val) { return val.replace('&action=edit', '&action=submit'); }); | |||
}); | |||
$(function() { | |||
if (action == 'view' || mw.config.get( 'wgNamespaceNumber') >= 0) { | |||
$( 'a.edit-page' ).filter(function() { return /^T-/.test( $(this).data('section') ); }).remove(); | |||
$( '#ca-edit > a' ).off( 'click' ).on('click', function(e) { | |||
e.stopImmediatePropagation(); | |||
location.href = '/index.php?action=submit&title=' + mw.util.wikiUrlencode( mw.config.get( 'wgPageName' ) ) + '&oldid=' + mw.config.get( 'wgRevisionId' ); | |||
}).removeAttr('href'); | |||
$( 'a.edit-page' ).off( 'click' ).on('click', function(e) { | |||
e.stopImmediatePropagation(); | |||
const section = $(this).data('section'), | |||
param = section ? '§ion=' + section : ''; | |||
location.href = script + '?action=submit&title=' + pagename + '&oldid=' + id + param; | |||
}).removeAttr('href'); | |||
} | |||
if (["edit", "submit"].includes( action )) { | |||
const warning = mw.user.options.get( 'useeditwarning' ), | |||
id = mw.util.getParamValue( 'oldid' ), | |||
cid = mw.config.get( 'wgCurRevisionId' ), | |||
href = script + (id && id < cid ? '?oldid=' + id : '/' + pagename), | |||
cancelBtn = new OO.ui.ButtonWidget( {label: wgULS("取消编辑", "取消編輯"), | |||
flags: ['primary', 'destructive'], href: href} ); | |||
cancelBtn.$element.appendTo( '.editButtons' ); | |||
if (warning) { | |||
cancelBtn.$element.on('click', 'a', function(e) { | |||
e.preventDefault(); | |||
OO.ui.confirm( wgULS("您要放弃这次更改吗?", "您要放棄這次更改嗎?"), {actions: [{label: "取消"}, | |||
{label: wgULS("确定", "確認"), flags: ['primary', 'destructive'], action: 'accept'}]} ) | |||
.then(function(confirm) { | |||
if (confirm) { location.href = href; } | |||
}); | |||
}); | |||
} | |||
} | |||
}); | |||
//</nowiki> |
2021年5月8日 (六) 23:26的版本
//<nowiki>
/**
* @Source: https://llwiki.org/zh/mediawiki:gadget-mobileEdit.js
* @Author: User:Bhsd
* @License: CC BY-NC-SA 4.0
* @Dependencies: ext.gadget.site-lib, mediawiki.util, oojs-ui-windows, user.options
*/
"use strict";
const script = mw.config.get( 'wgScript' ),
pagename = mw.util.wikiUrlencode( mw.config.get( 'wgPageName' ) ),
id = mw.config.get( 'wgRevisionId' ),
action = mw.config.get( 'wgAction' );
$('body').on('click', 'a.new', function() {
$(this).attr('href', function(i, val) { return val.replace('&action=edit', '&action=submit'); });
});
$(function() {
if (action == 'view' || mw.config.get( 'wgNamespaceNumber') >= 0) {
$( 'a.edit-page' ).filter(function() { return /^T-/.test( $(this).data('section') ); }).remove();
$( '#ca-edit > a' ).off( 'click' ).on('click', function(e) {
e.stopImmediatePropagation();
location.href = '/index.php?action=submit&title=' + mw.util.wikiUrlencode( mw.config.get( 'wgPageName' ) ) + '&oldid=' + mw.config.get( 'wgRevisionId' );
}).removeAttr('href');
$( 'a.edit-page' ).off( 'click' ).on('click', function(e) {
e.stopImmediatePropagation();
const section = $(this).data('section'),
param = section ? '§ion=' + section : '';
location.href = script + '?action=submit&title=' + pagename + '&oldid=' + id + param;
}).removeAttr('href');
}
if (["edit", "submit"].includes( action )) {
const warning = mw.user.options.get( 'useeditwarning' ),
id = mw.util.getParamValue( 'oldid' ),
cid = mw.config.get( 'wgCurRevisionId' ),
href = script + (id && id < cid ? '?oldid=' + id : '/' + pagename),
cancelBtn = new OO.ui.ButtonWidget( {label: wgULS("取消编辑", "取消編輯"),
flags: ['primary', 'destructive'], href: href} );
cancelBtn.$element.appendTo( '.editButtons' );
if (warning) {
cancelBtn.$element.on('click', 'a', function(e) {
e.preventDefault();
OO.ui.confirm( wgULS("您要放弃这次更改吗?", "您要放棄這次更改嗎?"), {actions: [{label: "取消"},
{label: wgULS("确定", "確認"), flags: ['primary', 'destructive'], action: 'accept'}]} )
.then(function(confirm) {
if (confirm) { location.href = href; }
});
});
}
}
});
//</nowiki>