User:Cameltrader/Advisor.js/Description

This script identifies common formatting and stylistic issues by examining the wikitext as you type.

Installation
Add the following to your monobook.js:

""

Then refresh. From now on, a list of suggestions will appear above your edit box while you are editing a page. Clicking on a suggestion name highlights the text it refers to. Clicking twice pops up a help message. The "fix" link next to it inserts the proposed replacement at the appropriate place.

If you are suspicious about stuff you add to your monobook.js, and suspicious you should be, you might want to review the code before using it.

Features
You might be given any of the following suggestions while editing:

Known issues
Please report new ones to |the talk page.


 * Automatic textarea scrolling in Opera seems impossible hard to implement. It ignores setting the   property.  Opera 9.5 will likely fix this issue (Opera 9.5 Beta 1 changelog, search for "scrollTop").  A workaround could be implemented by wrapping the textarea in a div element and scrolling the div instead.discuss


 * [[Image:Opera O.png|right|48px]]If you use Opera and you do not see highlighted text in the textarea, press → on your keyboard and the cursor will be right after the fixable text; you can click the suggestion link again to highlight it.


 * After clicking "Preview", the proposed summary is lost. In other words: you edit a page, you "fix" some of the suggestions on top, the names of the changes get accumulated and appear with an "Add to summary" link just above the "Edit summary" line, then you click "Preview" (without clicking "Add to summary"), and your accumulated names of changes disappear, so you have to go back.  It's a usability issue.


 * [[Image:WikEd logo64x64.gif|right|64px]] Advisor.js is incompatible with wikEd. The reason for this is that wikEd renders the wikitext not in the usual TEXTAREA but as a dynamically created DOM tree in an IFRAME ; that's because of the syntax highlighting.  What I need is to be able to select text between two certain offsets (including scrolling it into view) and to replace that text.  User:Cacycle suggested a way to do it, and I started implementing the solution.  However I've been having a hard time with it this weekend, and only highlighting is functional until now.  Scrolling to the correct offset and replacing the highlighted text do not work yet.


 * There is no easy way to switch the script on and off without modifying monobook.js—this could be useful for mobile access. The script should either be proposed for inclusion as a WP:Gadget or a toggle button should be implemented.discuss  (I already proposed its inclusion as a gadget.)


 * The "mdash" rule is undocumented and doesn't work as expected. It should only replace the hyphen with an em dash, without converting the space before it to a nbsp.  The latter should be handled by "nbsp-dash".|discuss


 * It is annoying to be warned about trailing whitespace all the time while you type.


 * After accepting a fix, the undo history is no longer functional in IE and Opera.

Further development
These are not yet in, but are worth considering:


 * ipa: Sequences of IPA characters should be enclosed like this:, in order to let MediaWiki add browser quirks.


 * AmE-BrE-bias: if there are sufficiently good hints in the article that it uses or should use American English rather than British English, or vice versa, Advisor.js should suggest conforming to the majority.


 * date-bias: same for American-style dates (" January 1, 2000 ", some other parts of the world use it, too) vs conventional dates (" 1 January 2000 "). I believe the topic of the article (e. g. if it is related to the US) should influence the balance, if there's a good heuristic to recognize Americanisms.


 * as-of, as-of-month: Suggest linking of " as of 2000 </tt>" as " as of 2000 </tt>", and converting " as of January 2000 </tt>" to " as of January 2000 " per WP:AO.


 * Suggest adding maintenance tags, such as:discuss
 * &#x7b;&#x7b;Sections&#x7d;&#x7d;</tt> to articles that have no headings
 * &#x7b;&#x7b;subst:Trivia-now&#x7d;&#x7d;</tt> below any sections labeled "Trivia" or "Miscellany"
 * &#x7b;&#x7b;Nofootnotes&#x7d;&#x7d;</tt> to any article that lacks a  </tt> tag
 * &#x7b;&#x7b;subst:dated|uncategorized&#x7d;&#x7d;</tt> to any article that does not have a category or template transcluded into it (as so many templates add articles to categories)
 * &#x7b;&#x7b;Deadend&#x7d;&#x7d;</tt> to articles that have less than three (for instance) links
 * &#x7b;&#x7b;ExcessiveLinks&#x7d;&#x7d;</tt> or &#x7b;&#x7b;Too many links&#x7d;&#x7d;</tt> to articles that have more than 20 (again, an arbitrary number) links outside of  </tt>, or to more than 20 links under a "External links" heading
 * &#x7b;&#x7b;Too many categories&#x7d;&#x7d;</tt> to articles that have more than 20 (arbitrary) categories

|Discuss these or propose a new one

Contributors
I am open for new ideas and happy to implement them. But if you have a little knowledge of JavaScript, you might consider submitting some code of your own—here is an example of how to do it:

""

One way to test this is to copy Advisor's source to some page in your private namespace, add the custom code, and do an  for the new page instead of the original. (I wasn't able to achieve my goal by putting the custom code in a separate page and importing both. Probably   imports scripts in some unpredictable order, I don't know...)

However, in order to reduce unnecessary load on Wikipedia servers, I recommend running some simple web server at localhost (such as lighttpd, Apache, Tomcat, or whichever you might be familiar with) at localhost, and replacing your monobook.js with something like:

""

Thus, you can experiment freely without cluttering your list of contributions.