InPageEdit-v2/SDK/en

From Wjghj Project Static Database

Quick Edit

InPageEdit.edit(options)

  • options: {object}
    • page: Required; Page name
    • revision: Revision number
    • section: Section number

Basic calling:

InPageEdit.edit({
  page: mw.config.get('wgPageName')
});

Quick Redirect

InPageEdit.redirect(type)

  • type: "string"(to/from)
    • from: Redirect a page to current one
    • to: Redirect the current page to another

Basic calling:

InPageEdit.redirect('from');
InPageEdit.redirect('to');

Quick Delete

InPageEdit.deletepage()

  • ?

WIP

Quick Rename

InPageEdit.renamepage()

  • Open the Quick Rename window

InPageEdit Preference

InPageEdit.preference()

  • Open the Preference window

Quick Diff

InPageEdit.quickDiff(options)

  • options: {object}
    • 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

Basic calling (comeparing the latest and the previous revision):

InPageEdit.quickDiff({
  fromtitle: mw.config.get('wgPageName'),
  torelative: 'prev'
});

Add Quick Edit Link

This module will run by deafult when the page is loaded[1]

InPageEdit.articleLink(element)

  • element: <element>
    • Default value: $('#mw-content-text a:not(.new)')
    • Identify and add Quick Edit links

No examples available

Loading Box

Not recommended[2]

InPageEdit.progress(title)

  • title: "string",√boolean×
    • true: Switch the top loading box status to "done"
    • false: Close the top loading box
    • string: Create a loading box using the string as the title
function testProgress() {
  InPageEdit.progress('Testing loading box……');
  setTimeout(function(){
    InPageEdit.progress(true);
    setTimeout(function(){
      InPageEdit.progress(false);
    },3000);
  },5000);
}

Changelog

Wjghj Project server is not bandwidth-optimised or concurrency-optimised. Please DO NOT call this function TOO FREQUENTLY[3]

InPageEdit.versionInfo()

  • Open the changelog window, which allows you view the changelog without opening Wjghj Common Wiki

Version

DO NOT rewrite this variable; this is a variable, not a function

InPageEdit.version

  • Get te version number
    • Response: String → Get

Instance Demo

With IPE SDK, you can create many customized plugin. Here's some simple, useful instances

Add Quick Edit link after the edit link

This instance have been tested on Vector, Timeless and Hydra skin

Source Code
$(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')
          });
        })
      )
    )
  );
});

IPE Toolbox

Here's the source code of adding IPE Toolbox. As long as you understand the code, you can customize the toolbox as you want.

Original Code
/** IPE工具盒 **/
$('<div>', {
  id: 'ipe-edit-toolbox'
}).append($('<ul>', {
  class: 'btn-group group1'
}).append($('<li>', {
  class: 'btn-tip-group'
}).append($('<div>', {
  class: 'btn-tip',
  text: msg('quick-edit')
}), $('<button>', {
  id: 'edit-btn',
  class: 'ipe-toolbox-btn material-icons',
  text: 'edit'
})), $('<li>', {
  class: 'btn-tip-group'
}).append($('<div>', {
  class: 'btn-tip',
  text: msg('redirect-from')
}), $('<button>', {
  id: 'redirectfrom-btn',
  class: 'ipe-toolbox-btn material-icons',
  text: 'flight_land'
}), $('<li>', {
  class: 'btn-tip-group'
}).append($('<div>', {
  class: 'btn-tip',
  text: msg('redirect-to')
}), $('<button>', {
  id: 'redirectto-btn',
  class: 'ipe-toolbox-btn material-icons',
  text: 'flight_takeoff'
}))), $('<ul>', {
  class: 'btn-group group2'
}).append($('<div>', {
  style: 'display: flex;'
}).append($('<li>', {
  class: 'btn-tip-group'
}).append($('<div>', {
  class: 'btn-tip',
  text: msg('quick-delete')
}), $('<button>', {
  id: 'deletepage-btn',
  class: 'ipe-toolbox-btn material-icons',
  text: 'delete_forever'
})), $('<li>', {
  class: 'btn-tip-group'
}).append($('<div>', {
  class: 'btn-tip',
  text: msg('quick-rename')
}), $('<button>', {
  id: 'renamepage-btn',
  class: 'ipe-toolbox-btn material-icons',
  text: 'format_italic'
})), $('<li>', {
  class: 'btn-tip-group'
}).append($('<div>', {
  class: 'btn-tip',
  text: msg('ipe-preference')
}), $('<button>', {
  id: 'preference-btn',
  class: 'ipe-toolbox-btn material-icons',
  text: 'settings'
})))), $('<button>', {
  class: 'ipe-toolbox-btn material-icons',
  id: 'toolbox-toggle',
  text: 'add'
})).appendTo('body'); $('#ipe-edit-toolbox #toolbox-toggle').click(function() {
  $('#ipe-edit-toolbox #toolbox-toggle, #ipe-edit-toolbox .btn-group').toggleClass('opened');
}); $('body > *:not(#ipe-edit-toolbox)').click(function() {
  $('#ipe-edit-toolbox #toolbox-toggle, #ipe-edit-toolbox .btn-group').removeClass('opened');
}); $('#ipe-edit-toolbox .btn-group .ipe-toolbox-btn').click(function() {
  InPageEdit.analysis({
    type: 'functionCount',
    function: '工具盒'
  });
  switch ($(this).attr('id')) {
  case 'edit-btn':
    InPageEdit.edit({
      page:
      mw.config.get('wgPageName'),
      revision: mw.config.get('wgRevisionId')
    });
    break;
  case 'redirectfrom-btn':
    InPageEdit.redirect('from');
    break;
  case 'redirectto-btn':
    InPageEdit.redirect('to');
    break;
  case 'preference-btn':
    InPageEdit.preference();
    break;
  case 'deletepage-btn':
    InPageEdit.deletepage();
    break;
  case 'renamepage-btn':
    InPageEdit.renamepage();
    break;
  }
});

Note

  1. If the page is a article, the plugin will run this module automaticly via these parameter: InPageEdit.articleLink($('#mw-content-text a:not(.new)'))
  2. This is an internal module to shield the screen to block user actions, and SHOULD NOT be used independently.
    If you like IPE-style progress-bar, please use this gadget:
    <div class="ipe-progress" style="width:A WIDTH"><div class="ipe-progress-bar"></div></div>
  3. Every time calling this function will post a GET request to the Wjghj Project server, and this will stress the server