User:Js/ajaxPreview

The script adds and  Ajax buttons which are:
 * faster than standard buttons,
 * use less traffic,
 * retain the text cursor position and undo (Ctrl-Z) history.

Preview
Preview button updates content and edit summary previews and then executes global collapsing scripts.

Shift-clicking the button will update the previews of interwikis, categories and templates as well.

You still need regular non-Ajax preview if you insert  or.

Extra features

 * "Preview" displays references when editing a section (by adding &lt;references /&gt; to the end of the text).
 * "Preview" highlights syntax when editing .js and .css files.
 * When editing an old version shift-click on "changes" will compare your text to that old version.

Installation
Add this to your common.js (or to your skin js page)

Configuration
By default the new buttons do this: B I Ab  ... ... ... ... ... ... ... ...
 * appear on the right from the toolbar:
 * capture p and v accesskeys from the standard buttons.
 * get names from the standard buttons (using last word).

This can be changed with the following parameters added to the same JS file as above.

Position:

The "old" standard buttons are then moved to the right and marked with ">":

Accesskeys: Use empty string  to disable accesskey.

Button text:

Scrolling:

Full update:

You can make the script call any custom userscripts by defining the global  function. For example, if you use NavPopups and want popups to appear in the Ajax-updated preview, use the following code:

And if you want tables to be sortable and collapsible elements to work as usual in the Ajax-updated preview, use the following code:

Similar scripts

 * User:Cacycle/wikEd has similar functionality with "preview" and "changes" buttons.
 * User:Anomie/ajaxpreview.js adds only "preview" button but will display all references when editing a section (even defined in other sections).
 * Option "" in preferences does AJAX preview/changes (using standard buttons at the bottom) but it requests the whole HTML page from the server (no traffic savings there).

ru:Википедия:Гаджеты/Ajax-предпросмотр