Site Notice

hello, world

Difference between revisions of "InPageEdit-v2/SDK"

From Project-EPB Commons
([InPageEdit] 没有编辑摘要 (第6部分))
Line 45: Line 45:
 
== 比较差异 ==   
 
== 比较差异 ==   
 
<code>InPageEdit.quickDiff(options)</code>
 
<code>InPageEdit.quickDiff(options)</code>
<ul><li><code id="fromtitle">fromtitle</code>: First title to compare.</li>
+
** <code id="fromtitle">fromtitle</code>: First title to compare.
<li><code id="fromid">fromid</code>: First page ID to compare. <b>Type:</b> integer <span style="background-color:#eeee99; font-family:monospace;">1.20+</span></li>
+
** <code id="fromid">fromid</code>: First page ID to compare. <b>Type:</b> integer  
<li><code id="fromrev">fromrev</code>: First revision to compare. <b>Type:</b> integer</li>
+
** <code id="fromrev">fromrev</code>: First revision to compare. <b>Type:</b> integer
<li><code id="fromtext">fromtext</code>: Use this text instead of the content specified by <code>fromtitle</code>, <code>fromid</code> or <code>fromrev</code>. <span style="background-color:#eeee99; font-family:monospace;">1.30+</span></li>
+
** <code id="fromtext">fromtext</code>: Use this text instead of the content specified by <code>fromtitle</code>, <code>fromid</code> or <code>fromrev</code>.  
<li><code id="frompst">frompst</code>: Do a pre-save transform on <code>fromtext</code>. <b>Type:</b> boolean <span style="background-color:#eeee99; font-family:monospace;">1.30+</span></li>
+
** <code id="frompst">frompst</code>: Do a pre-save transform on <code>fromtext</code>. <b>Type:</b> boolean  
<li><code id="totitle">totitle</code>: Second title to compare.</li>
+
** <code id="totitle">totitle</code>: Second title to compare.
<li><code id="toid">toid</code>: Second page ID to compare. <b>Type:</b> integer <span style="background-color:#eeee99; font-family:monospace;">1.20+</span></li>
+
** <code id="toid">toid</code>: Second page ID to compare. <b>Type:</b> integer  
<li><code id="torev">torev</code>: Second revision to compare. <b>Type:</b> integer</li>
+
** <code id="torev">torev</code>: Second revision to compare. <b>Type:</b> integer
<li><code id="torelative">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> <span style="background-color:#eeee99; font-family:monospace;">1.30+</span></li>
+
** <code id="torelative">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>
<li><code id="totext">totext</code>: Use this text instead of the content specified by <code>totitle</code>, <code>toid</code>, <code>torev</code>, or <code>torelative</code>. <span style="background-color:#eeee99; font-family:monospace;">1.30+</span></li>
+
** <code id="totext">totext</code>: Use this text instead of the content specified by <code>totitle</code>, <code>toid</code>, <code>torev</code>, or <code>torelative</code>.
<li><code id="topst">topst</code>: Do a pre-save transform on <code>totext</code>. <b>Type:</b> boolean <span style="background-color:#eeee99; font-family:monospace;">1.30+</span></li>
+
** <code id="topst">topst</code>: Do a pre-save transform on <code>totext</code>. <b>Type:</b> boolean
</ul>
 
  
 
== 添加编辑链接 ==
 
== 添加编辑链接 ==

Revision as of 22:53, 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)

    • fromtitle: First title to compare.
    • fromid: First page ID to compare. Type: integer
    • fromrev: First revision to compare. Type: integer
    • fromtext: Use this text instead of the content specified by fromtitle, fromid or fromrev.
    • frompst: Do a pre-save transform on fromtext. Type: boolean
    • totitle: Second title to compare.
    • toid: Second page ID to compare. Type: integer
    • torev: Second revision to compare. Type: integer
    • torelative: Compare to a relative revision of fromtitle, fromid or fromrev. All the other "to" options will be ignored. Possible values: prev, next, cur
    • totext: Use this text instead of the content specified by totitle, toid, torev, or torelative.
    • topst: Do a pre-save transform on totext. Type: boolean

添加编辑链接

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')
          });
        })
      )
    )
  );
});