User talk:The wub/CloseCFD.js

Latest comment: 9 years ago by Technical 13 in topic Legacy JavaScript

Sub-sections of debates edit

This script has a bug: it doesn't handle CFD debates with sub-sections well. After I growled the closing admin it turns out that it was this script which was responsible for stripping a whole sub-subsection of a CFD debate.

Looking at the code, I think I can see how this happens. The debate is split on the header string '====', and assumes that the only instances are in the header of the debate. If there is a sub-section, its heading will use five equals signs '=====' .... so the split command will produce two more strings for each sub-section. However, if this happens, they won't be pasted back into the edit box, becasuse the script doesn't check for their existence.

I think that the solution is as follows.

Replace the line

    t.value += z[2] + '\n' ;  //re-add main body

... with this block

for (i=2 ; i< z.length ; i++)
{
  t.value += z[i];
}
t.value += "\n";

I don't swear that my code is correct, but I hope this helps. --BrownHairedGirl (talk) • (contribs) 20:56, 13 March 2009 (UTC)Reply

The split method removes whatever you're splitting on (I was adding the main header ====s back in manually), so unfortunately the "=====" then becomes "=". After some false starts I eventually found out you can override that behaviour using capturing parentheses, and changed the script appropriately. Thanks for your help! the wub "?!" 00:17, 15 March 2009 (UTC)Reply

Legacy JavaScript edit

Hello! This script has been detected as using deprecated parameters that need to be replaced with the updated version. Examples include addOnloadHook( ... ) needs to be replaced with $( ... ) or $( function() { ... } ) (depending on use); all wgGlobalVariables need to be properly gotten with mw.config.get( 'wgGlobalVariable' ); and addPortletLink needs to be called with mw.util.addPortletLink. Please see MW:ResourceLoader/Legacy JavaScript for details. Thank you. — {{U|Technical 13}} (etc) 22:23, 19 January 2015 (UTC)Reply