User talk:Alex Smotrov/qpreview.js

From Wikipedia, the free encyclopedia

[edit] Documentation

On edit pages the script adds QPreview button for quick AJAX preview without reloading the whole page.


Comparison:

 Show preview   QPreview 
Browsers sends wiki code to Mediawiki server
Browser gets back:
  • html code of the article
  • wiki code of the article
  • html code for all the other parts of the page (around 40KB)

Also browser makes requests for external
CSS and Javascript files (usually cached)

Browser gets back:
  • html code of the article
Browser draws the whole page and executes all the scripts Browser redraws only the preview part
Editing textarea doesn't «remember» anything You can use Ctrl-Z to undo edits

In other words, QPreview button performs preview quicker and saves incoming traffic.


Notes:

  • By default, the button is located on the edit toolbar (above textarea)
  • QPreview doesn't update anything outside preview area (interwiki, categories, list of used templates, Geshi CSS rules)
  • QPreview may stop working at any time if Mediawiki developers change something
  • Tested in Internet Explorer 6/7, Firefox 1.5/2, Opera 9, Safari 3


Demo without installation:

  • make sure you have Edit toolbar enabled
  • click on the «edit this page» tab above
  • copy to your browser address field

javascript:function addOnloadHook(f){f()};importScript('User:Alex_Smotrov/qpreview.js');void 0

  • press Enter and QPreview button should appear on the toolbar
  • change the text in textarea and press QPreview


Installation: importScript('User:Alex_Smotrov/qpreview.js');your monobook.js


Optional parameters: (specified with default values)

  • qPreviewKey = '';accesskey
  • qPreviewName = 'QPreview'; — name on the button
  • qPreviewWait = 'Wait…' — name while doing AJAX request
  • qPreviewAtBottom = false; — if true, put the button below


Example:

qPreviewKey = '`'; // accesskey: ~
qPreviewName = 'Quick';  
qPreviewAtBottom = true;
importScript('User:Alex Smotrov/qpreview.js');

Result (under textarea):  Quickly   Show preview 


See also

  • wikEd, an in-browser editing tool (Firefox only) that uses QPreview techniques

License


[edit] Discussion

[edit] Other skins