User talk:Interiot/js/RealTitle.js

Functional requirements

 * If the proposed new title is a valid wikilink version of the real underlying title (eg. if it can be copy-and-pasted into wikitext and create a valid link to the page), then change the &lt;h1&gt; (the bit that shows up below the "tabs" just above the article text)
 * Change the &lt;html&gt;&lt;title&gt; (the bit that shows up at the very top of the browser window) in all cases to the proposed title
 * If the proposed title contains HTML, remove the HTML bits from the &lt;h1&gt; title and the &lt;html&gt;&lt;title&gt; (especially the last one, because HTML doesn't render there)
 * However, if the proposed title contains only &lt;sup&gt; and/or &lt;sub&gt;, then keep those HTML tags in the &lt;h1&gt; title, but still remove them from the &lt;html&gt;&lt;title&gt;, of course
 * If the proposed title is pasteable, and it doesn't contain HTML (other than sup/sub), then hide the "due to technical restrictions" blurb because the &lt;h1&gt; title contains all the information the article author wishes to convey about the title

Caveats

 * It's probably not obvious to editors what triggers the hiding of the "due to technical restrictions" blurb... It depends solely on whether the proposed title matches the underlying database title closely enough to be pasteable.  While this is a clear technical requirement, it may be an unexpected subtlety.

To do

 * Automatically add the namespace if it's not there
 * Calculate "isPastable" on whether the name matches its canonical (what's the term they use in MediaWiki code?) version
 * "innerHTML" is not sufficient for the title or the H1, if users include HTML tags inside. We need to do something like "innerText".  CO2 rocket and It's On (Dr. Dre) 187um Killa are ones where the HTML ends up appearing in the title.
 * Is there anything we can do about things like Nano (text editor)? It's unfortunate, because looking at it, you can see that there's a clear title that should be displayed, but it's not, because in most cases, people don't want the "due to technical restrictions" blurb to include the (disambig) suffix.  Is there a third way for this?
 * Due to a bug (in MediaWiki?), pages like Lac operond don't show up because the &lt;span&gt; is actually fucked up
 * When printing, it would be good to always replace the &lt;h1&gt; title with the proposed title, even when it's not pasteable (presumably with some @media print)

Regression test-cases
Confirm these work on Firefox/Opera/MSIE whenever a change is made:
 * one of the mainspace (eg. iPod should be changed)
 * one of the non-mainspace that doesn't contain the namespace (eg. Category:x86 microprocessors should be changed)
 * a non-namespace that does contain the namespace (eg. User:interiot/Test realtitle1 should be changed)
 * one of the (eg. User:rambot should be changed)
 * one of the (eg. Ka band should be changed)
 * one of the (eg. Softimage XSI should not be changed)
 * something with HTML in the name (eg. lac operon or It's On (Dr. Dre) 187um Killa or User:Interiot/Test realtitle2 should be changed, and their title should look reasonable)
 * RealTitles with underscores in the front shouldn't be idenfied as pasteable (eg. NSAKEY should not be changed)
 * Try pages with somewhat far-out HTML title formatting, and make sure the "due to technical restictions..." blurb still appears: House of Leaves, Apple IIGS, Only Revolutions

Stable versions

 * 01:45, 25 November 2006 &mdash; add the ability to handle sub/superscripts (this version was tested thoroughly and posted to MediaWiki:Common.js)
 * 21:29, 24 November 2006 &mdash; innerHTML &rArr; innerText, handle HTML-ized titles better  (this version was tested thoroughly and posted to MediaWiki:Common.js)
 * 04:11, 21 November 2006 &mdash; isPastable is automatically calculated; the namespace is automatically added
 * 07:22, 16 November 2006 &mdash; isPastable based on hardcoded divs in templates
 * 06:54, 16 November 2006 &mdash; modification of the french version to update the title as well