User:Lupin/popupOptions

From Wikipedia, the free encyclopedia

Option Values* Description
popupDelay decimal number, 0.5 The number of seconds before popups appear.
removeTitles true, false The titles (the default popup hints) of links are moved to the main link of the popup if this is true. If this is false then they're not.
simplePopups true, false If you just want the links or find the amount of bandwidth consumed too great, then set this to true. No data will be downloaded and the popups will just consist of a list of links.

There is a bug in the Opera web browser which corrupts data downloaded by this script. This variable defaults to true in that browser as a temporary workaround, although this may be fixed in the future. You can still override this default by setting the variable yourself, but the results are not pretty.

imagePopupsForImages true, false By default, preview images are loaded even when hoving over visible images. Setting this to false turns that off.
popupPreviews true, false If this is true and you haven't set simplePopups, then a preview of the first part of the article will appear. (Reports of pages for which this is done badly are most welcome). If false, then this is switched off.
popupNavLinks true, false If this is true then navigation links are displayed. If false, then these are switched off.
popupSummaryData true, false If this is true summary data for the target page is displayed. If false, then this is switched off.
popupImages true, false If this is false then images are never displayed.
popupOnlyArticleLinks true, false If true, then popups are only generated for links in the article. Otherwise, many other links (such as Edit, Help) get popups too.
Technical options
maxPreviewSentences an integer, 4 The maximum number of sentences to extract from something approximating the first meaningful paragraph of an article for the preview.
maxPreviewCharacters an integer, 600 The maximum number of characters to extract from something approximating the first meaningful paragraph of an article for the preview.
popupNavLinkSeparator string,
' ⋅ '
HTML inserted between the navigation links. This defaults to ' • ' in Konqueror as it doesn't appear to like the ⋅ character.

[edit] Advanced customization

You can define custom filters for articles. These are javascript functions which are run after the page statistics are generated, and their output is appended (as HTML) to that part of the popup. (Note that if simplePopups is true or popupSummaryData is false, then nothing will be displayed).

The way this works is to write a filter function which accepts a string (the wikitext of the article) as input, and returns a fragment of HTML. Repeat for as many filters as you want, and then create an array extraPopupFilters which contains all of the functions, in the order in which you want them to be run.

For example, let's say I want to be told whenever the wikitext of an article contains a table written using HTML tags rather than wiki markup. One way to do this is to add the following to your user javascript file:

// initialize the array
extraPopupFilters=new Array();

// define the function
function popupFilterHtmlTable (wikiText) {
  if (/<table/i.test(wikiText)) return '<table>';
  else return '';
};

// add the function to the array
extraPopupFilters.push(popupFilterHtmlTable);

Then when a popup is generated for a page containing an HTML table, you should see <table> in the popup. (It may match also appear for other pages, such as this page. Correcting this defect is left as an exercise for the reader).