Site Notice
hello, world
Difference between revisions of "InPageEdit-v2/SDK"
From Project-EPB Commons
(→比较差异) |
m ([InPageEdit] 没有编辑摘要 (第6部分)) |
||
Line 45: | Line 45: | ||
== 比较差异 == | == 比较差异 == | ||
<code>InPageEdit.quickDiff(options)</code> | <code>InPageEdit.quickDiff(options)</code> | ||
− | ** <code | + | * <code>options</code>: {object} |
− | ** <code | + | ** <code>fromtitle</code>: First title to compare. |
− | ** <code | + | ** <code>fromid</code>: First page ID to compare. <b>Type:</b> integer |
− | ** <code | + | ** <code>fromrev</code>: First revision to compare. <b>Type:</b> integer |
− | ** <code | + | ** <code>fromtext</code>: Use this text instead of the content specified by <code>fromtitle</code>, <code>fromid</code> or <code>fromrev</code>. |
− | ** <code | + | ** <code>frompst</code>: Do a pre-save transform on <code>fromtext</code>. <b>Type:</b> boolean |
− | ** <code | + | ** <code">totitle</code>: Second title to compare. |
− | ** <code | + | ** <code>toid</code>: Second page ID to compare. <b>Type:</b> integer |
− | ** <code | + | ** <code>torev</code>: Second revision to compare. <b>Type:</b> integer |
− | ** <code | + | ** <code>torelative</code>: Compare to a relative revision of <code>fromtitle</code>, <code>fromid</code> or <code>fromrev</code>. All the other "to" options will be ignored. Possible values: <code>prev</code>, <code>next</code>, <code>cur</code> |
− | ** <code | + | ** <code>totext</code>: Use this text instead of the content specified by <code>totitle</code>, <code>toid</code>, <code>torev</code>, or <code>torelative</code>. |
+ | ** <code>topst</code>: Do a pre-save transform on <code>totext</code>. <b>Type:</b> boolean | ||
+ | |||
+ | 最简单的示例,比较本页面最后一次修改 | ||
+ | <pre class="prettyprint"> | ||
+ | InPageEdit.quickDiff({ | ||
+ | fromtitle: mw.config.get('wgPageName'), | ||
+ | torelative: 'prev' | ||
+ | }); | ||
+ | </pre> | ||
+ | <html><button onclick="InPageEdit.quickDiff({ | ||
+ | fromtitle: mw.config.get('wgPageName'), | ||
+ | torelative: 'prev' | ||
+ | });">测试</button></html> | ||
== 添加编辑链接 == | == 添加编辑链接 == |
Revision as of 22:56, 23 November 2019
快速编辑
InPageEdit.edit(options)
options
: {object}page
: 必须;编辑的页面名revision
: 修订版本号,如果与当前页面版本号不同则取代section
: 编辑的段落编号
最基础的调用
InPageEdit.edit({ page: mw.config.get('wgPageName') });
<html><button onclick="InPageEdit.edit({
page: mw.config.get('wgPageName')
});">测试</button></html>
快速重定向
InPageEdit.redirect(type)
type
: string(to,from)- from 重定向页面至此
- to 将此页面重定向到
最基础的调用
InPageEdit.redirect('from'); InPageEdit.redirect('to');
<html><button onclick="InPageEdit.redirect('from')">测试from</button> <button onclick="InPageEdit.redirect('to')">测试to</button></html>
快速删除
InPageEdit.deletepage()
快速重命名
InPageEdit.renamepage()
InPageEdit设置
InPageEdit.preference()
- 打开设置窗口
<html><button onclick="InPageEdit.preference()">InPageEdit.preference()</button></html>
比较差异
InPageEdit.quickDiff(options)
options
: {object}fromtitle
: First title to compare.fromid
: First page ID to compare. Type: integerfromrev
: First revision to compare. Type: integerfromtext
: Use this text instead of the content specified byfromtitle
,fromid
orfromrev
.frompst
: Do a pre-save transform onfromtext
. Type: boolean- <code">totitle: Second title to compare.
toid
: Second page ID to compare. Type: integertorev
: Second revision to compare. Type: integertorelative
: Compare to a relative revision offromtitle
,fromid
orfromrev
. All the other "to" options will be ignored. Possible values:prev
,next
,cur
totext
: Use this text instead of the content specified bytotitle
,toid
,torev
, ortorelative
.topst
: Do a pre-save transform ontotext
. Type: boolean
最简单的示例,比较本页面最后一次修改
InPageEdit.quickDiff({ fromtitle: mw.config.get('wgPageName'), torelative: 'prev' });
<html><button onclick="InPageEdit.quickDiff({
fromtitle: mw.config.get('wgPageName'), torelative: 'prev'
});">测试</button></html>
添加编辑链接
InPageEdit.articleLink()
示例
在编辑链接后添加快速编辑链接
此示例代码已在Vector、Timeless以及Hydra皮肤上测试可用
$(function(){ $('#ca-view').after( $('<li>',{ id:'ca-quick-edit', class:'collapsible' }).append( $('<span>').append( $('<a>',{ href: 'javascript:void(0)' }) .text('快速编辑') .click(function(){ InPageEdit.edit({ page: mw.config.get('wgPageName'), revision: mw.config.get('wgRevisionId') }); }) ) ) ); });