MediaWiki talk:Gadget-mobileEdit.js:修订间差异
跳到导航
跳到搜索
imported>Bhsd 小 (→编辑请求 - Bhsd) |
imported>Bhsd 小 (根据gadget-code-prettify.js的改动微调格式) |
||
第1行: | 第1行: | ||
==创建请求== | ==创建请求== | ||
请求创建小工具页面,内容如下: | 请求创建小工具页面,内容如下: | ||
<pre | <pre lang="js"> | ||
//<nowiki> | //<nowiki> | ||
/** | /** | ||
第61行: | 第61行: | ||
== 编辑请求 - Bhsd == | == 编辑请求 - Bhsd == | ||
[[mediawiki:gadget-mobileEdit.js#L20|第20行]]后添加<pre lang="js"> | [[mediawiki:gadget-mobileEdit.js#L20|第20行]]后添加<pre lang="js" data-start=21> | ||
$( '#ca-edit > a' ).off( 'click' ).on('click', function(e) { | $( '#ca-edit > a' ).off( 'click' ).on('click', function(e) { | ||
e.stopImmediatePropagation(); | e.stopImmediatePropagation(); | ||
第73行: | 第73行: | ||
:之前的修改失败了……不过这次经我的[[user:bhsd/common.js|个人JS测试]]能够生效:请将第21-24行(也就是上次新增的内容)替换为 | :之前的修改失败了……不过这次经我的[[user:bhsd/common.js|个人JS测试]]能够生效:请将第21-24行(也就是上次新增的内容)替换为 | ||
<pre lang="js"> | <pre lang="js" data-start=21> | ||
const editBtn = $('#ca-edit')[0]; | const editBtn = $('#ca-edit')[0]; | ||
if (editBtn) { | if (editBtn) { |
2021年5月30日 (日) 08:59的版本
创建请求
请求创建小工具页面,内容如下:
//<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();
$( '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>
使用这个小工具需要在mediawiki:gadgets-definition添加
* mobileEdit[ResourceLoader|dependencies=ext.gadget.site-lib,mediawiki.util,oojs-ui-windows,user.options|rights=edit|targets=mobile]|mobileEdit.js
如果导入后不可用,请再与我联系。谢谢!Bhsd(讨论) 2021年5月7日 (五) 23:41 (CST)
@=海豚=请来看看-- PatrollerSD hehua(聊天室) 2021年5月8日 (六) 18:40 (CST)
- 抱歉,因发现本站不遵循CC协议,以上代码需在顶部注明使用CC BY-NC-SA 4.0协议。如果因版权协议冲突造成无法搬运,请求删除此讨论串或讨论页。Bhsd(讨论) 2021年5月8日 (六) 19:13 (CST)
编辑请求 - Bhsd
第20行后添加
$( '#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');
Bhsd(讨论) 2021年5月8日 (六) 22:52 (CST)
不知为何被清空-- PatrollerSD hehua(聊天室) 2021年5月9日 (日) 09:48 (CST)
- 之前的修改失败了……不过这次经我的个人JS测试能够生效:请将第21-24行(也就是上次新增的内容)替换为
const editBtn = $('#ca-edit')[0];
if (editBtn) {
editBtn.addEventListener('click', function(e) {
e.stopPropagation();
location.href = '/index.php?title=' + pagename + '&action=submit&oldid=' + id;
}, true);
}