MediaWiki talk:Common.js/Archive 18

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
Archive 15 Archive 16 Archive 17 Archive 18

Always secure Wikipedia

proposal it so add

if(wgServer == 'https://secure.wikimedia.org')
importScript( 'MediaWiki:Common.js/secure.js')

This changes any http links to interwiki or diffs on a page to links for the secure server. The script is originally User:Anakin101/alwayssecurewikipedia.js. —TheDJ (talkcontribs) 20:45, 17 January 2010 (UTC)

Go for it, imo. If you're on the secure wiki, you should stay there until you leave it, not because you've clicked a random link. Ale_Jrbtalk 20:56, 17 January 2010 (UTC)
I found issues and suggestion with the script http:\/\/([^\/]+?)\. should be http:\/\/([^a-z0-9\-]+?)\., change (page ? page : 'wiki/') to (page || 'wiki/'), \/? is unnecessary since browser automatically add this in (I think), if (sub === undefined) continue; seems to be in the wrong place. There one question, should this be supporting old links? Wikibooks use to be en.wikibook.com (no s), wikipedia.com/wiki/ redirects to the English Wikipedia, meta-wiki was meta.wikipedia.org. — Dispenser 07:43, 18 January 2010 (UTC)
I wouldn't rely on all browsers always appending a slash to URLs like http://en.wikipedia.org. Better to be safe than sorry. However, I don't think the script as written will correctly handle such valid (or at least working) URLs as http://en.wikipedia.org?title=Foo. To fix it, you could replace "\/?(.*)$" with e.g. "(\/[^?#]*|)([#?].*|)$" in the regexps and append the value of m[4] to the fixed URL unconditionally. Also, there should be some way (e.g. setting window.disableSecureLinks=true in their monobook/vector.js) for users to turn this script off if they don't want it.
Anyway, the one problem we can't fix is that one could still end up back on the insecure site in two clicks via another Wikimedia project which doesn't run this script. That's why I wrote my version as a Greasemonkey user script. Of course, merely fixing things like diff links to en.wikipedia.org itself would probably be worth having this for. —Ilmari Karonen (talk) 16:36, 18 January 2010 (UTC)
Yes please add it, we need something like this. And here's some notes and links:
When I created {{sec link auto}} I also tested User:Anakin101/alwayssecurewikipedia.js. I noticed that the script doesn't handle all the cases that {{sec link auto}} handles. I'll see if I can dig up my notes or do the tests again, but here's what I remember:
  • I think it doesn't handle all the projects listed at Wikipedia:InterWikimedia links, especially it didn't handle links to oldwikisource:. "Old Wikisource" still handles many of the Wikisource languages, so it isn't really "old".
  • And it doesn't handle cases like wikt:pt:São Paulo the way I think they should be handled. The script sends you to the English Wiktionary with a secure link, then it lets Wiktionary resolve the "pt:" part to take you to the Portuguese Wiktionary, which sends you to the normal servers. {{sec link auto}} instead resolves both the "wikt:" and "pt:" parts and gives you a secure link directly to the Portuguese Wiktionary. Although I cheat in {{sec link auto}}, I let the humans manually feed "lang=pt" so my template doesn't need to know the site matrix.
I'm sorry that I don't know enough javascript, so I can't help out with the code. But taking a look at {{sec link auto}}, or more specifically its sub-template {{sec link/secure url}} might give you some useful hints about what to resolve.
--David Göthberg (talk) 17:48, 18 January 2010 (UTC)
I have made a whole set of improvements. Many more types of links should now be recognized (at least all valid links in User:TheDJ/Sandbox2). Feedback welcome. —TheDJ (talkcontribs) 21:31, 18 January 2010 (UTC)
This seems reasonable to me to implement. I wish there were a way for this to be implemented into core MediaWiki, but that doesn't seem very possible due to parser cache issues (at least for the time being). --MZMcBride (talk) 00:30, 19 January 2010 (UTC)

 Done code deployed. —TheDJ (talkcontribs) 20:44, 21 January 2010 (UTC)

JavaScript Loading

Up in the "WikiMiniAtlas" discussion it was mentioned that "(All our other special scripts are only loaded when needed.)." I'm getting ready to implement a lot of JavaScript on my Wiki and I was just curious if this was simply a reference to doing a quick getElementById existence check in addOnloadHook for each script, or if there is some other system in place that I don't know about. I'm basically just trying to make sure that if I have 100 scripts, I don't have to do 100 checks on every page load to see if any of them apply to that page.
--Cogniac (talk) 18:11, 29 January 2010 (UTC)

simply a reference to doing a quick getElementById existence check would be my answer. But there is a more advanced scriptloader system in the making by Michael Dale. Check the Wikitech mailing list archives for details.
--Dschwen 20:43, 29 January 2010 (UTC)
I tracked this down to here: http://www.mediawiki.org/wiki/JS2_Overview in case anyone else is interested. They seem to be developing this for the upcoming 1.16 release.
--Cogniac (talk) 19:16, 4 February 2010 (UTC)

Proposal to add "withJS" feature to Common.js

Wikimedia commons has the following function in their MediaWiki:Common.js. This is useful for doing feature preview links like timed text preview. Any objections to adding the following?

/** &withJS= URL parameter *******
 * Allow to try custom scripts from MediaWiki space 
 * without editing [[Special:Mypage/monobook.js]]
 */
var extraJS = getParamValue("withJS");
if ( extraJS && extraJS.match("^MediaWiki:[^&<>=%]*\.js$") ) {
  importScript(extraJS);
}

mdale (talk) 22:42, 4 February 2010 (UTC)

Its usage will probably be pretty limited, since for security reasons it seems to be limited to only load scripts from the MediaWiki space. I think I slightly agree with this addition, but I have doubts since its usage is so limited and the code will be loaded by all users and most of those that "need" this functionality can just as well edit their personal /monobook.js. Although I see that this function can be useful for demonstration purposes when testing new scripts.
Platonides isn't the maintainer here, unless you have asked him. Here's a cleaned up version of the code: ( above )
Could someone who understands the code in the .match() part check what that code means and that it only allows loading scripts from MediaWiki space?
--David Göthberg (talk) 16:17, 5 February 2010 (UTC)
Is alert() preferred to a silent failure? --MZMcBride (talk) 16:35, 5 February 2010 (UTC)
I think the alert is useful, but not especially necessary. The alert is only shown when an invalid script name like "User:Example/myscript.js" is used. Unfortunately the alert does not show if the name is a correct but non-existing MediaWiki file name, then it silently fails which is slightly confusing.
But MZMcBride has a point. This will probably be a seldomly used function and all users always load those lines of code, so let's remove the alert to save some lines of code. I have updated my above code.
And I have read up on regular expressions and done some testing, the code in the .match() part does exactly what it should.
--David Göthberg (talk) 17:08, 5 February 2010 (UTC)
I agree with the removing the alert ( its of little value ). If people are happy with it in its present form I suggest a maintainer of Common.js plops it in there. ( I have updated the discussion to just focus on the recommended code addition) --mdale (talk) 22:28, 6 February 2010 (UTC)
I have no problem with this. I can deploy it tomorrow when I get back home, or someone else can do it in the meantime. —TheDJ (talkcontribs) 13:03, 7 February 2010 (UTC)
any updates on this? --mdale (talk) 17:39, 10 February 2010 (UTC)
I have now deployed this code. Thanks for the watchlist bump :D —TheDJ (talkcontribs) 18:15, 10 February 2010 (UTC)
OK, that was not fun. I'm so used to getParamValue being available (either trough commons or Navigation popups) it didn't occur to me it would be missing. For now I have deployed a getURLParamValue(), since i wasn't sure about potential conflicts with other tools that have their own getParamValue. I think those implementations are pretty consistent, but I'll want to run a check on that before using that name in Common.js. In the future we can use ParseURI, once the new JS2, jquery and mwEmbed tools are finally fully deployed, but that is not an option at this time of course. —TheDJ (talkcontribs) 18:49, 10 February 2010 (UTC)

Potential security issue

While, I'm sure that whoever runs http://toolserver.org/~para/geoip.fcgi is perfectly trustworthy it seems like a very weak link in the chain. Whereas scripts from Wikipedia have high cache values, publicly viewable edit histories, and notify many people when they are modified; making it likely that malicious changes can be reverted without too much damage; a modification to this script could pass unnoticed for quite some time. Are there any mechanisms in place to prevent this being horribly abused? Conrad.Irwin (on wikt) 22:55, 4 February 2010 (UTC)

As you say, the assumption that toolserver users are trustworthy. Javascript is by its very nature a potential security issue. Happymelon 23:45, 4 February 2010 (UTC)
It's not as if we allow just any external script to be included. So far those are only WikiMiniAtlas and the geolocating script. Those are maintained by trusted users on the toolserver. Users who have been around for a LONG time and who are not likely to go rogue. But it's like Happy-Melon says. —TheDJ (talkcontribs) 13:01, 7 February 2010 (UTC)
It took me some searching to find out what this is about, so in case anyone else is wondering: That toolserver script is called from the beginning of MediaWiki:Common.js/watchlist.js, the result of that then seems to be used in MediaWiki:Geonotice.js to display some watchlist notices only in some parts of the world. A little more searching turned up Wikipedia:Geonotice. (I have now added a code comment to watchlist.js and a page notice to Geonotice.js explaining what it is.)
--David Göthberg (talk) 01:00, 5 February 2010 (UTC)

hasClass

The hasClass function...variable...thing uses some fairly advanced JavaScript that I'm just trying to figure out. I'm assuming that the reason it is set up as a variable and not just straight "function hasClass(className)" is part of the caching optimization. But I'm not getting how it basically amounts to "var hasClass = ()();" with stuff happening inside the first pair of parentheses. I have no idea what the deal is with the two pairs of parentheses or why it relies on an anonymous function inside an anonymous function to do the work, and I'm looking for a basic explanation, if anyone would be so kind.
--Cogniac (talk) 21:19, 12 February 2010 (UTC)

The outer anonymous function, which is immediately called, creates a "global" variable reCache and returns another function which is assigned to the name hasClass. Due to JavaScript's scoping rules reCache is now only accessible from hasClass, but it's value still persists over multiple invocations of hasClass.
Ruud 15:37, 13 February 2010 (UTC)
I understand that it's a prime example of JavaScript closures, but what I truly don't understand is the second set of parentheses at the end. I have no clue why those are necessary and/or don't break everything. I can't find any JavaScript construct that requires such a thing.
--Cogniac (talk) 20:49, 16 February 2010 (UTC)
It's a plain function call (of the outer anymous function). So hasClass is equal to the return value of the outer function (which happens to be the inner function). Without that call hasClass would be a reference to the outer function itself, which is not the intention.
Ruud 21:19, 16 February 2010 (UTC)
Ahhhh. I get it now. It's like a standard function execution call, except the first set of parentheses stands in for the name of the function. var myVar = myFunction(); => var myVar = (function() { do stuff })();
--Cogniac (talk) 22:27, 18 February 2010 (UTC)
Actually, the first set of parenthesis just stand for the parameters (none in this case) and there is no function name before the parameters because it's anonymous.
Ruud 12:53, 19 February 2010 (UTC)
Well, based on that explanation, none of it makes any sense anymore. It would essentially be var myVar = myFunction(parameters go here)(what the hell are these parentheses for?); => var myVar = (supposedly there are no parameters, despite the fact that there's stuff in here)(still no idea what these parentheses are for); I thought that the first set of parentheses just grouped the outer anonymous function and the second set of parentheses was a call to execute that function.
--Cogniac (talk) 19:01, 26 February 2010 (UTC)

Custom Edit Buttons

I'm trying to implement some custom edit buttons on my Wiki. They work, but only when placed in Common.js. I cannot get them to work when they are placed on Common.js/edit.js like they are here. I stuck an alert() call in my Common.js/edit.js to see if it was even being loaded, and it's not. Comparing my wikibits.js with Wikipedia's wikibits.js, and thus my importScript() with Wikipedia's, I notice the following differences:

  1. Mine: var uri = wgScript + '?title=' + encodeURIComponent(page.replace(/ /g,'_')).replace('%2F','/').replace('%3A',':') + '&action=raw&ctype=text/javascript';
  2. Wikipedia: var uri = wgScript + '?title=' + encodeURIComponent(page.replace(/ /g,'_')).replace(/%2F/ig,'/').replace(/%3A/ig,':') + '&action=raw&ctype=text/javascript';

Could these subtle differences somehow be causing my problem?
--Cogniac (talk) 20:43, 26 February 2010 (UTC)

I think it's more likely that you just don't have the edit.js loader code in your Common.js. Look under the comment "/* Import more specific scripts if necessary */" of wikipedia's Common.js. —TheDJ (talkcontribs) 21:20, 26 February 2010 (UTC)
I already had the importScript calls in Common.js, but it still wasn't working. Unfortunately, after wandering off for a few days and coming back, I have a bunch of messages from contributors about a certain "alert()" call I left in Common.js/edit.js when I thought it wasn't working at all. Apparently it just wasn't working in IE7 for some reason. So now there's double the number of buttons (because I had put it back in Common.js and left what I thought was a non-working copy in /edit.js) and a JavaScript alert() box popping up on every edit. Oops. So...perhaps there is an issue with IE7? I only have IE8 on this box, so I will check this out tomorrow on an IE7 box and report back.
--Cogniac (talk) 04:58, 1 March 2010 (UTC)
Well, now it magically works in IE7, too, so I don't really know what to say. Perhaps it was some bizarre caching issue? Although, I was definitely hitting Ctrl+F5 after every time I edited the JavaScript, so I don't even know.
--Cogniac (talk) 13:59, 1 March 2010 (UTC)
The problem is called a browser cache :D WP:BYPASS. —TheDJ (talkcontribs) 14:02, 1 March 2010 (UTC)
A thing which I repeatedly cleared by hitting Ctrl+F5; a circumstance I clearly stated in my last comment. I guess I needed to "Completely clear the cache" instead. Which makes no sense, because every time before now when I've made an edit to the JavaScript, Ctrl+F5 worked perfectly. For some reason, this did not work with the creation of Common.js/edit.js. I have no idea why.
--Cogniac (talk) 15:11, 1 March 2010 (UTC)
I'm not sure if it's because I'm editing the edit bar, or because I'm doing it on Common.js/edit.js, but it seems as though you have to Ctrl+F5 + Completely clear the cache + close and reopen the browser to get it to refresh properly. Wacky.
--Cogniac (talk) 16:02, 1 March 2010 (UTC)

Collapsible rows and columns

I asked on Help whether Collapsing could be extended to cover certain rows and columns only. Then I realized I hadn’t anything to do for the rest of the day and wrote the code myself. It may need further testing (and perhaps optimizing), but the basic cases are covered alright. Collapsing columns is especially helpful for en.m.wikipedia.org. Is there any chance getting this into common.js? — Christoph Päper 11:33, 6 March 2010 (UTC)

Rank in sortable tables

On a related note to collapsible rows and columns above, it would be nice to have a class ‘rank’ on one heading cell in a ‘sortable’ table that would result in the cells below it – if they contain only whitespace, digits and punctuation – bearing a dynamically generated rank number which is updated on sorting (and perhaps restored on sorting based on that very column, otherwise ‘rank’ should imply ‘unsortable’). The workaround with two tables side by side (inside a third one) is really ugly and fails with rows of different height. — Christoph Päper 15:21, 2 March 2010 (UTC)

Update getURLParamValue per Commons common.js User:Lupo cleanup

This is essentially the same function but includes the # hash to not include #anchors when you getURLParamValues

function getURLParamValue( paramName, url) 
{
 if (typeof (url) == 'undefined' || url === null) url = document.location.href;
 var cmdRe=RegExp( '[&?]' + paramName + '=([^&#]*)' ); // Stop at hash
 var m=cmdRe.exec(url);
 if (m && m.length > 1) return decodeURIComponent(m[1]);
 return null;
}

mdale (talk) 20:41, 3 March 2010 (UTC)

Ah, you see, this is exactly why I wanted to separate getParamValue of Lupin from this one in Common.js, now we have differing implementations... Thanks for the notification ! —TheDJ (talkcontribs) 21:25, 3 March 2010 (UTC)

Adding a script to collapse template transclusion list

Please see Wikipedia:Village_pump_(proposals)#Collapse_template_transclusion_list_in_Edit_view. I'm not quite sure if the script is ready - I had some problems last time I used it and had to uninstall. But is this reasonable in principle? Rd232 talk 20:00, 8 April 2010 (UTC)

It probably needs a bit more work, but I think that in general we should consider this. —TheDJ (talkcontribs) 20:33, 8 April 2010 (UTC)

Frame breaking

Moved from WP:AN Happymelon 11:24, 13 April 2010 (UTC)

I know we once blocked a system that iframed wikipedia for it's own purposes. There is now this "ad service" http://www.magic-banner-bot.com/ which inserts images into wikipedia. It cannot be disabled, uses an iframe and insert ads into the wikipedia content, without explaining why. I think such is grounds for blocking that via Javascript. What do others think ? —TheDJ (talkcontribs) 00:35, 11 April 2010 (UTC)

I thought we already did break iframes thanks to that advertising agency that was framing Wikipedia as a part of their homepage. If we don't, then yes, we absolutely should. Of course any webmaster who purchases a spamming tool that requires disclosing their webserver FTP password to work deserves to lose at life generally. Gavia immer (talk) 01:01, 11 April 2010 (UTC)
??? Can you block people from reading wikipedia? 'Cause all that script is doing... Choyoołʼįįhí:Seb az86556 > haneʼ 02:57, 11 April 2010 (UTC)
What you can do is use Javascript to detect if the page is being served in a third-party iframe, and if it is, redirect to the Wikipedia page itself with no iframe. This won't stop anyone from reading Wikipedia, but it will prevent them from being forced to view a defaced version of our content. N.B., I haven't been able to force the "magic banner" to actually advertise to me, despite turning off many layers of anti-advertising protection, so I can't tell exactly how it's supposed to work; if it's just accomplished by redirecting through the web domain above, it's even simpler to block, since we could just detect the referer. Gavia immer (talk) 03:18, 11 April 2010 (UTC)
I don't know much about this, but it looks like it simply creates a new webpage like http://magic-banner-bot.com/468/ . I see it says (Redirected from Banner ads), so apparently the subpage "468" is linked to what is now a redirect. Maybe that gives a clue on how it works... Choyoołʼįįhí:Seb az86556 > haneʼ 03:27, 11 April 2010 (UTC)
Yeah, but I'm not sure if that example is just a canned demonstration or if it's the way their spam works in general. Gavia immer (talk) 03:44, 11 April 2010 (UTC)
Is this targeting specific pages, or all of Wikipedia in general? Noscript doesn't seem to be picking anything up, and I don't recall it doing so recently when viewing articles and/or other pages. The Thing // Talk // Contribs 04:25, 11 April 2010 (UTC)
Noscript detects it for me, but there seem to be two things going on. One is an IFRAME, which Noscript won't detect because it's just HTML, not a script of any kind; and an actual script which makes the banner that the IFRAME creates move around on the page and become generally more intrusive. I was actually looking at it with the script part turned off when I wrote what I wrote down below, confusing their banner with our own example banner, and didnt realize I was missing most of the effect until just now. Soap 17:48, 11 April 2010 (UTC)
An easy way to test would be to make an edit to the target article, then see if it shows up on the iframe. I'm going to do that now.— dαlus Contribs 06:32, 11 April 2010 (UTC)
Sadly, the test was .. well, I don't know if I could call it a success, or a failure, but the end result was certainly bad. It isn't a canned picture. It's a live frame of wikipedia. I made a small insertion of a period on that article, and refreshed the ad-bot page. The change was immediately visible. We have to find a way to prevent this.— dαlus Contribs 06:37, 11 April 2010 (UTC)
I think the way this software is supposed to work is that you, a blogger or other website designer, have to use "fake" links everywhere on your blog that go to sites that are technically still on your website, but look like they are where youre actually trying to go apart from the parasitic banner ads. I dont know from the context given on his site whether the ads will be served entirely through his own website and thus have the same referrer every time, or if youre supposed to store the ads somewhere else (in which case the referrer could be anything, or may not even exist). The code is ridiculously obfuscated, because according to the HTML source it's copyrighted and the designer of the software doesnt want people copying the source and using it without paying him. However, I think all we really need to know is whether it's an IFRAME, which it is. Soap 17:24, 11 April 2010 (UTC)
We appear to have disabled the javascript for breaking iframes about 3 years ago. Not sure why. Dragons flight (talk) 08:54, 11 April 2010 (UTC)
Well that's just evil. Both because it makes it look like various innocent websites are using banner ads and because he's charging $27 for a big-deal box of software that could fit on a floppy disk and is essentially just a few lines of obfuscated Javascript a script that generates HTML code, not really a "program" at all. I have seen other websites doing this sort of thing, though, and it's not always "bad". For about a year the homepage of Skittles (the candy) featured our article integrated into their website in a way that made it function as if it was part of Skittles' own site, but with a sort of navigation panel that made it clear that it wasn't, and that you could also see their pages on Facebook, YouTube, etc. At least to my eyes, there was no deception involved. There was also, amazingly, no spike in vandalism on our Skittles articles despite the fact that none of them were even semi-protected as far as I can tell. The Skittles homepage no longer features Wikipedia, but I think that it if we used to block out this sort of thing in the past, we must have stopped doing it sometime before Skittles started. If we start blocking it again, it'd be nice, if it is at all possible, to think about possible "legitimate" uses of the same kind of HTML trick. (While I wont say that the Skittles campaign necessarily did us any good, since we make no profits and kids eating candy arent likely to be big donors, it didnt really do us any harm either.) Soap 17:18, 11 April 2010 (UTC)
This discussion doesn't seem to concern admins. We aren't generally well versed in the technical aspects of the mediawiki software or these issues brought up here. These fixes would be nice, but if they are to be noticed by people who care, this discussion should be moved to WP:VPT and someone also should probably file a bugzilla request with the devs. --Jayron32 03:30, 12 April 2010 (UTC)
If we decided to break frames, we could do that locally with a few lines of javascript without needing to bother the devs. Dragons flight (talk) 05:42, 12 April 2010 (UTC)

The adding following code to Mediawiki:Common.js should do the trick:

if (document.referrer.indexOf("magic-banner-bot.com") != -1) {
	location.href = "http://en.wikipedia.org/w/index.php?title=User:Chris_G/Leech_detected&action=render";
}

The user will see this page with instructions on how to navigate to Wikipedia directly (someone might want to edit that page to be a bit nicer/user friendly first though). I've tested the script and it works in Firefox + Opera, but if a Windows user would please check it in IE (the older the version the better :) ) that would be good. Javascript isn't my forte so if someone could please double check that it won't break the site etc that would be great (maybe we should move it into it's own function? make it easier to add more sites as they pop up?) --Chris 12:03, 12 April 2010 (UTC)

I just tried it in IE8 and it works. I'd suggest changing the order of the two bullet points - "adverts" first, "server load" second. JohnCD (talk) 20:38, 12 April 2010 (UTC)
I would like to point out that it is probably easy to obfuscate the referrer if the agency would like to do so and that any usage of what he is selling seems to require to run from the domain the user wants to use it on. We can also block all iframes of course, but i'm not sure if that is desirable. Not sure if there are any tools that use wikipedia in a frame. I guess we could start logging that information in a way, in order to find out...
if( window != top ) {
  // this window is run inside a frame
}
The above code should detect when a page is run inside a frame. —TheDJ (talkcontribs) 01:13, 13 April 2010 (UTC)
Just as a general note, that page would need to be moved into the project-space if this code were added. --MZMcBride (talk) 18:30, 13 April 2010 (UTC)

I'd definitely support breaking frames on a general basis, assuming we don't use frames legitimately ourselves, which I don't think we do. Thoughts? Happymelon 12:42, 13 April 2010 (UTC)

I can't think of anywhere that we use frames, and if we do we should possibly stop, and I support breaking all of them. Ale_Jrbtalk 13:02, 13 April 2010 (UTC)
Breaking frames will break Toolserver tools and maybe that Google translation tool. There's a reason why the built-in frame breaking script (wgBreakFrames) been turned off. — Dispenser 15:51, 13 April 2010 (UTC)
What toolserver tools rely on frames? Ale_Jrbtalk 15:55, 13 April 2010 (UTC)
If there is no damage to important toolserver tools, I support breaking frames. Snowolf How can I help? 15:59, 13 April 2010 (UTC)
Which toolserver tools are important? Arguably none since they would've been intergrated into MediaWiki. — Dispenser 18:12, 13 April 2010 (UTC)
<AryehGregor>	Happy-melon, it used to be always true. Non-configurably.
<Happy-melon>	until Dec 2006
<AryehGregor>	A few years ago the config option was added, set to false by default in case anyone actually wanted it.
<AryehGregor>	It's never been true on Wikimedia since it's existed AFAIK.

The only reason why $wgBreakFrames is disabled is that no one ever asked for it to be turned on. There's a whitelist built into it, which has Google translate exempted by default, and other exemptions can be added. What toolserver tools would break? Happymelon 16:15, 13 April 2010 (UTC)

Before rev:18220 it was stuck to on, no way of turnning it off. And the exception code used in that revision doesn't work since it would be a security risk. On the Toolserver tools:~flacus/IWLC/ uses it as does a new tool of mine. It also breaks most translation services (Google), image searches result page (Bing, Google). It seems the only reason why we are considering breaking the website is because an obscure scumbag is selling banner software (There's a precident). Yet we have taken no steps to break about.com's banner ads and the encourghed hotlinking of our images. — Dispenser 18:12, 13 April 2010 (UTC)
Wikipedia is one of the easiest sites to proxy in the world. You shouldn't be using frames. Nevertheless, those that do can be whitelisted. Ale_Jrbtalk 16:14, 14 April 2010 (UTC)
Toolserver tools are not allow to "serve significant portions of wiki page text", this includes proxying. — Dispenser 17:16, 14 April 2010 (UTC)

Breaking a specific site that's causing a demonstrable issue is one thing. Breaking all use of frames just because is another. There may be a case here for intentionally breaking this magic-banner site, as there was for breaking modernista. But I don't see any compelling case for breaking frames in general, especially as there's a not-remote possibility of collateral damage and unintended consequences. --MZMcBride (talk) 18:30, 13 April 2010 (UTC)

The case against isn't very compelling either - it stands at 'but gooooogle!' - which can be whitelisted (and yes, so can bing). Apart from the search engines, I can't see any valid reason for putting Wikipedia in a frame. The case for means preventing this type of stupid scam in the future, because it just won't work - what if a not-very-savvy person who thought 'oh, that sounds good' actually pays for this crap? They might deserve it, depending on your opinion, but I don't think we should make it possible. Nevertheless, it doesn't bother me a huge amount either way, but we probably should put a stop to this particular one whatever we decide. Ale_Jrbtalk 16:14, 14 April 2010 (UTC)
Oh, and while we don't make any major changes to protect potential foolish people, it is just a config option. In addition, people seeing the frame (plus advertising) might be put off Wikipedia, and less likely to visit/edit/donate in the future. Just a thought. Improbable, maybe, but possible. Meh. Ale_Jrbtalk 16:16, 14 April 2010 (UTC)
How exactly do you purpose to whitelist. Is the method compatible with anonymizers? Will the method work if the frameset is on a HTTPS connection? What will the collateral damage be of application that we don't know about? Wikipedia:Wikipedia CD Selection? Whitelisting would be larger and hard to manage than a blacklist method. — Dispenser 17:16, 14 April 2010 (UTC)
Considering the enormous impact Google's results have on visits to this site, I think it's a pretty legitimate concern that we don't intentionally break them. Whitelisting isn't the answer. Blacklisting is. You can't know if you're just going to break Google and Bing, you could very well break every other search engine (and a whole host of other things that we may or may not become aware of).
There are about a million ways to take content from Wikipedia and put it on your own site. Nobody here should think (or does think) that breaking frames is going to stop any leech with any sort of dedication. As I said, if there's a specific problem with a specific site, by all means, let's work to address that. But large-scale "solutions" that will likely do more harm than good should be avoided. --MZMcBride (talk) 17:21, 14 April 2010 (UTC)

Make it possible to collapse templates used and file usage

I propose to load User:TheDJ/usagecollapse.js on edit pages and file description pages. The script allows you to collapse the sections "File usage", "Global file usage" and "Templates used" on those pages. By default the sections are shown and you can press the show/hide element in front of them to hide them. This action is then remembered with a cookie. The three sections all have their own cookie. —TheDJ (talkcontribs) 14:35, 23 April 2010 (UTC)

Nothing ? No one has an opinion on this ? —TheDJ (talkcontribs) 00:45, 12 May 2010 (UTC)
Three more cookies for a single site and a trivial feature? Seems a bit much. Is there a better way to implement it? --MZMcBride (talk) 01:00, 12 May 2010 (UTC)
I don't think it's trivial. The list substantially clutters the edit screen on heavy pages. Rd232 talk 07:40, 12 May 2010 (UTC)
Clutters? It's at the bottom of the page, below the edit window, submit buttons, etc. I don't see the issue. --MZMcBride (talk) 03:49, 13 May 2010 (UTC)
I have to agree, it seems that we are trading scrolling for extra clicks and obfuscation. — Dispenser 05:00, 13 May 2010 (UTC)
Extra clicks only apply to people actually using the list. What proportion of people do? Now compare with the proportion of people who edit long articles, and are presented with this long list which prevents the edit box being at the bottom of the page, where it generally should be. On large pages the edit box may not even be visible at all after scrolling to the page bottom, because the template list is more than a screen high. That's confusing and annoying! And of course, the list does confuse newbies. They do end up clicking templates and doing all sorts of things that have no relevance - and the clicks must happen much more often than we see, because most of the templates are protected, so they end up frustrated without any visible evidence. I think at the very least the Usability Initiative ought to look into this as a matter of urgency, but given that we have the solution right here, I don't see why should wait. Also: nobody's ever made a convincing argument to me why we have this in the first place. The list itself seems useless qua list; its utility seems to be from providing links to viewing and editing the relevant templates. Except that nobody says "ooh, what templates are in this article that I can edit. I want to edit a template!" Instead they come across a template name in an article, and copy-and-paste the name into a search box and find it - same way they'd find anything else they don't recognise or know where it is. Seriously, what use is this list really? Is that use really so great that it must be shown in full (uncollapsed) on every edit screen? I say categorically no. Rd232 talk 06:29, 13 May 2010 (UTC)
The usability team already has looked at the template issue, their solution is to collapse it too. I think we should consider getting ride of it altogeather as it is inconsitent; only showing when previewing or do full page edit. (It should really say at some point "Preview to see a list of templates") And it includes every template subcalls made. We could also just put .templatesUsed into a scrollbox. However, my option on the File page still stands. — Dispenser 15:33, 13 May 2010 (UTC)
"The usability team already has looked at the template issue..." - link? I think getting rid of it requires more input than we've had so far, whereas merely collapsing it is hopefully not so controversial and certainly less dramatic. I'm not clear what your "File page" option is. You want a different behaviour in the File namespace? I have no objection to that; the main issue is for mainspace. Rd232 talk 16:17, 13 May 2010 (UTC)
usability:File:Design-EditToolbar-2.pdf show part of it. I'm having trouble finding the original mockup/proposal discussing it, on their site (they don't link or categorizes files). The script is for the File and main namespaces. — Dispenser 20:46, 13 May 2010 (UTC)
Cool! But in the mean time, I'll settle for TheDJ's script. Rd232 talk 21:14, 13 May 2010 (UTC)

Hide/Show button in rtl Wikipedia

I am looking for some help in resolving issues with the Hide/Show button for navigation boxes in the Yiddish WP, which uses an rtl orthography. I would expect the button to appear at the end of the line, that is on the left-hand side, but it appears at the beginning (on the right-hand side), for example here.

Another problem is with the appearance of the Hide/Show button in Beta (which uses the Vector skin). In this case the button attaches itself to the title of the box instead of appearing at one end of the title bar.

Any suggestions for clearing this up? --Redaktor (talk) 22:04, 3 May 2010 (UTC)

The quick way, in your MediaWiki:common.css, set .NavToggle to float left instead of right. The better way is to add something like body.rtl .NavToggle { float:left; } but I haven't tested that. As a matter of fact, we should probably setup some rtl CSS on the English Wikipedia as well.... I'm not really seeing the Vector issue... I note you guys use NavFrame instead of collapsible tables. It might have to do something with that, I don't think the NavFrame was tested a lot with Vector yet. —TheDJ (talkcontribs) 22:46, 3 May 2010 (UTC)
Many thanks for that valuable suggestion. (The first didn't seem to work, but body.rtl .NavToggle { float:left; } has cleared up the problem in both skins. In addition another problem (wrong placing of coordinates in Vector) has gone away too. Thanks again!! --Redaktor (talk) 11:58, 4 May 2010 (UTC)

Change to collapsible tables code

Resolved

Due to bugzilla:23570, we probably need to change

ButtonLink.setAttribute( "href", "javascript:collapseTable(" + tableIndex + ");" );

into

ButtonLink.setAttribute( "href", "#" );
ButtonLink.setAttribute( "onclick", "collapseTable(" + tableIndex + "); return false;");

We can probably also do it using addHandler i guess...

ButtonLink.setAttribute( "href", "#" );
addHandler( ButtonLink,  "click", function() { collapseTable( tableIndex ); return false;} );

TheDJ (talkcontribs) 13:43, 7 June 2010 (UTC)

Last snippet looks fine. —Ruud 15:10, 7 June 2010 (UTC)
Would the last one work? I thought that you'd need to use new Function() since it would reference tableIndex at the time of execution. Also, is there something better than herf="#" for the fail through condition, I've always felt it was quite a hack. I've seen other sites using herf="javascript:// comment here" and it would be nicer if the status bar could provide something a more informative. — Dispenser 20:16, 7 June 2010 (UTC)
<a href="#">
is evil indeed, but
a.setAttribute("href", "#");
much less so. — Christoph Päper 20:57, 7 June 2010 (UTC)
Clicking on a link leading to "#" will jump to the top of the page wouldn't it? Gary King (talk) 21:05, 7 June 2010 (UTC)
Normally onclick events should override that behavior however. Do you know of browsers where this is not the case ? —TheDJ (talkcontribs) 21:31, 7 June 2010 (UTC)
Unless it's some strange case, I'm pretty sure that it will jump to the top. I just tested it, and it did indeed jump to the top, even with an onclick. Firefox 3.6.3. Gary King (talk) 21:36, 7 June 2010 (UTC)
The return false should make sure that the default action is not executed (ergo the navigating to #). —TheDJ (talkcontribs) 22:22, 7 June 2010 (UTC)
Not on FF. That "return false" thing is not universal. You have to kill the event using something like
function killEvt (evt) {
  evt = evt || window.event || window.Event; // W3C, IE, Netscape
  if (typeof (evt.preventDefault) != 'undefined') {
    evt.preventDefault(); // Don't follow the link
    evt.stopPropagation();
  } else
    evt.cancelBubble = true; // IE
  return false; // Don't follow the link (IE)
}

// Use it like this:
ButtonLink.setAttribute( "href", "#" );
addHandler( ButtonLink,  "click", function(evt) { collapseTable( tableIndex ); return killEvt( evt );} );
I've been using that code in several of the scripts I developed at the Commons, and it works (so far) on all browsers. Something similar is also in HotCat, BTW. Lupo 10:18, 8 June 2010 (UTC)
Hmm, this sucks. I'm considering adding a killEvent() to wikibits.js because we also need this for the toc collapsing code and Edittools.js —TheDJ (talkcontribs) 18:55, 9 June 2010 (UTC)
I have not actually tested the last example yet. And of course setting href to anything alla "javascript:" for href will be useless, as having "javascript:" there is the whole problem in the first place :D —TheDJ (talkcontribs) 21:29, 7 June 2010 (UTC)

killEvent() is on its way. When it is deployed, we can fix this stuff. —TheDJ (talkcontribs) 19:23, 14 June 2010 (UTC)

killEvt deployed, changes to edittools, toc and collapsible tables made. —TheDJ (talkcontribs) 22:46, 14 June 2010 (UTC)


I don't think it's related, since that code has been in that template for ages. There is a problem with the code change and scripts that expand and collapse hidden templates, though, including my own, which I'll update shortly. Gary King (talk) 02:45, 15 June 2010 (UTC)
Several intermediate changes with syntax errors broke the collapsible tables. The effect should be transient and should disappear with a purge now. T. Canens (talk) 03:04, 15 June 2010 (UTC)
Cool. I think it might have been due to the collapsible table in this template: [1]. If so, hopefully the changes will fix the problem. Dreadstar 03:07, 15 June 2010 (UTC)

I've reverted this edit because it was causing a template to expand on RfPP in edit mode, and that was hiding the toolbox on the left side of the page with the different protection tags in it. I just checked RfPP, and after reverting that edit it was back to normal. SlimVirgin talk|contribs 04:23, 15 June 2010 (UTC)

Which templates are you referring to? From what I can understand, it seems like "RFPP administrator notation templates" is expanded by default, as well as "New to RFPP? Read me!"? Gary King (talk) 04:26, 15 June 2010 (UTC)
This template [2] uses 'collapsed class', which causes it to always be initially collapsed, no matter what happens around it. Dreadstar 04:56, 15 June 2010 (UTC)
Indeed, which is why I didn't understand SlimVirgin's comment. I now realize that she is using this script and has been referring to that the entire time. Gary King (talk) 05:06, 15 June 2010 (UTC)
So, only people using that script will have a problem with the box starting off as expanded, instead of being collapsed by default as intended? Or might there be other, unintended collateral damage caused by the changes to Commons.js? Dreadstar 05:16, 15 June 2010 (UTC)
Nevermind, that script isn't the one adding those extra buttons for SlimVirgin. I don't know which script it is, after quickly sifting through her scripts. To be able to answer your question, I have to see which script is causing the problem in the first place before I can determine what the problem is, then I can determine if the problem is isolated to that one script or other scripts will have similar problems. Gary King (talk) 05:26, 15 June 2010 (UTC)

edit.js and new toolbar

The bigest part of edit.js is for the old toolbar and it is now useless for most users. It could be moved into a separate file. — AlexSm 20:56, 8 June 2010 (UTC)

Is there a special file the new toolbar uses? —Preceding unsigned comment added by 124.138.199.3 (talk) 02:14, 15 June 2010 (UTC)
No, but it can be made just like any other custom .js file. — AlexSm 17:50, 15 June 2010 (UTC)

Okay, more specifically, edit.js should contain

if (!window.wgWikiEditorEnabledModules || !wgWikiEditorEnabledModules.toolbar)
 importScript('MediaWiki:Common.js/oldtoolbar.js')

and all the mwCustomEditButtons=... statements (3.6Kb) should be moved into MediaWiki:Common.js/oldtoolbar.js. — AlexSm 17:50, 15 June 2010 (UTC)

Probably better to make this distinction in the main Common.js file, that avoids a level of conditional loading. —TheDJ (talkcontribs) 17:54, 15 June 2010 (UTC)

GA icon code by Cirt

Resolved

I don't know what Cirt didn't comment here on the new code he introduced. But the new code is just the LinkFA() function duplicated for GAs. It would be more efficient if it was added as another branch in the LinkFA function. The consensus for this change was on Wikipedia talk:WikiProject Good articles, but doesn't seem to have been advertised anywherewas listed on WP:CENT from May 7-31. — Dispenser 15:11, 31 May 2010 (UTC)

Sure, it could be added as another branch. The code was just duplicated, though, because that would ensure that it would work properly with as little hassle as possible. Combining the two would really only help in readability—which is good, but we wanted to get the functionality working ASAP at the time. Gary King (talk) 15:17, 31 May 2010 (UTC)
The common practice here is to comment here before or after major code changes. — Dispenser 15:29, 31 May 2010 (UTC)
It also matters a lot in efficiency. I'll propose a new version. —TheDJ (talkcontribs) 19:39, 31 May 2010 (UTC)
function LinkFGA() 
{
    if ( document.getElementById( "p-lang" ) ) {
        var InterwikiLinks = document.getElementById( "p-lang" ).getElementsByTagName( "li" );

        for ( var i = 0; i < InterwikiLinks.length; i++ ) {
            if ( document.getElementById( InterwikiLinks[i].className + "-fa" ) ) {
                InterwikiLinks[i].className += " FA"
                InterwikiLinks[i].title = "This is a featured article in another language.";
            } else if ( document.getElementById( InterwikiLinks[i].className + "-ga" ) ) {
                InterwikiLinks[i].className += " GA"
                InterwikiLinks[i].title = "This is a good article in another language.";
            }
        }
    }
}

addOnloadHook( LinkFGA );
PS. I wonder why it is important to get something working ASAP after it had been undesired for 4 years, and changing it would require 31 days to affect all users... but that might just be me. And there were still errors in the code I see. —TheDJ (talkcontribs) 19:41, 31 May 2010 (UTC)
Marking GA's in other languages has been rejected umpteen times already. This code should probably be removed. Also, I designed this for the Monobook skin and looks pretty awful in Vector. The star should be be aligned with the little collapse/uncollapse arrow and the graphic slightly tweaked to better fit with the rest of the interface (more bland colour instead of Monobook-yellow, blue/grey-ish perhaps?) —Ruud 15:10, 7 June 2010 (UTC)
This time is was actually introduced by consensus however :D I agree that the Vector version of the designs needs some more work. I just did a quick port of the CSS/JS a few months ago. Didn't really pay attention to the design. —TheDJ (talkcontribs) 18:30, 7 June 2010 (UTC)
Combined into a single script again. Much more efficient. —TheDJ (talkcontribs) 00:00, 17 June 2010 (UTC)

Collapsible tables not working with Wikipedia:Nominations Viewer

It looks like the new collapsible tables are not working properly with my Wikipedia:Nominations Viewer script. (For instance, when used at WP:FLC, you can't expand any of the collapsed tables there.) What my script does is it wraps all nominations, which sometimes includes collapsed tables, in &lt;div&gt;, and so this seems to disable the addHandler() for ButtonLink. How can I get my script to work properly with these new collapsible tables? Gary King (talk) 02:24, 23 June 2010 (UTC)

I've got a temporary fix going on for now, which just converts the URLs for the collapse buttons back to how they were before, as that works well. Gary King (talk) 02:34, 23 June 2010 (UTC)
Note that your script now isn't compatible with the "are you sure you want to leave this editpage" dialog, which is why the collapsible table code was changed. Your problem is probably cloneNode or something. If you clone an element, you are not moving it and thus loosing hooks and some other things attached to nodes. —TheDJ (talkcontribs) 09:19, 14 July 2010 (UTC)
The script seems to work fine with that dialog in Firefox and Chrome. Does this conflict only happen in IE? If so, my script doesn't work in IE, anyway. Gary King (talk · scripts) 18:27, 14 July 2010 (UTC)
Correct, IE thinks you are leaving the page when you use a javascript: destination for a URL. But you probably just shouldn't use cloneNode, though I'm not exactly sure how your script works. —TheDJ (talkcontribs) 19:33, 15 July 2010 (UTC)
Go to WP:FAC. I'm using cloneNode to copy each nomination into a &lt;div&gt; so I can more easily manipulate each one, such as hiding each nomination by default. I'd be happy to hear about any better ways to achieve this, as I know that cloneNode isn't the best. Gary King (talk · scripts) 20:18, 15 July 2010 (UTC)
In hindsight, I should have used removeChild to first remove the nodes, then used appendChild to append them to a new node that I created. Anyway, there doesn't seem to be any major problems yet at the moment, so I probably will not rewrite the script for this, not yet anyway. I'll tack it onto the todo list. Gary King (talk · scripts) 05:27, 16 July 2010 (UTC)
You can simply use appendChild, it will act as a 'move' action. —TheDJ (talkcontribs) 11:55, 16 July 2010 (UTC)
I have to also remove the original node otherwise I'll be duplicating every nomination rather than modifying them. Gary King (talk · scripts) 16:42, 16 July 2010 (UTC)
No if you appendChild without removing it first, it will be removed for you (One DOM element can only be in one spot of the document at a time). Like I said, it will behave like a move action. —TheDJ (talkcontribs) 17:17, 16 July 2010 (UTC)

Collapsible tables: certain rows

I asked in March whether we could introduce more sophisticated table collapsing. Since I never got an answer but also nothing happened I guess nobody except me wants to (not) collapse certain rows or columns only. Nevertheless, testing the script in practice for several months now, the feature I discovered to be the most useful is not hiding rows that have the class ‘sortbottom’ (which is a behavioral and not a semantic class name like it should have been). So if nothing else this should be implemented in common.js, luckily it’s probably the most robust part of the code. It also doesn’t require anything new to be done by authors.

Still I wonder, am I the only one who believes that many wide tables would benefit from hiding some select columns by default? Maybe the toggle button should have three states then (‘hidden’, ‘partial’, ‘complete’), which I haven’t implemented. The only problems my additions to the table collapsing script have are in combination with ‘colspan’, ‘rowspan’ and incomplete rows when collapsing columns. — Christoph Päper 06:32, 23 June 2010 (UTC)

Customise display for users who are not logged in

Similar to the user-group specific CSS which is currently loaded for administrators and accountcreators (see /Archive 17#Accountcreator CSS) I would like to know if it would be possible to add some similar code to detect whether an editor is logged in or not. This would be very handy on Wikipedia:Article wizard where irrelevant options could be hidden, and there are other places where this could be useful too. — Martin (MSGJ · talk) 09:51, 14 July 2010 (UTC)

Yeah, wgUserName can be used. And perhaps appendCSS for the extra CSS. Gary King (talk · scripts) 18:18, 14 July 2010 (UTC)
Certainly possible, especially considering "the other places" (WP:Upload) already use this functionality per uploadwizard_newusers(). I agree appendCSS is a better approach than finding specific ids. — AlexSm 20:21, 14 July 2010 (UTC)
This would be great. I think the two that would be most useful would be registered/unregistered and confirmed (or autoconfirmed)/non-confirmed. As well as showing additional content to specific users we'd also want to be able to hide content from the users - how practical would it be to have classes like confirmed-show and confirmed-hide? — Martin (MSGJ · talk) 13:21, 15 July 2010 (UTC)
Be very careful though. javascripted css additions like this, cause content to "appear/disappear" during script execution. Such behavior can be confusing, especially for novice users. Even more so when some users don't have Javascript enabled. I'm not sure if this is such a good idea. Not to long ago we had this behavior as forbidden all around. if we really want to expand on this, perhaps we should think it trough a bit more. Make sure we consider all the consequences. —TheDJ (talkcontribs) 19:42, 15 July 2010 (UTC)
Someone needs to tell Wikimedia about this. Gary King (talk · scripts) 20:19, 15 July 2010 (UTC)
Well I think the default position in the absence of javascript should probably be to show everything. What other considerations are there? Are there any performance concerns? — Martin (MSGJ · talk) 20:18, 15 July 2010 (UTC)
No performance concerns. I agree that a flashing notice doesn't look very good. Coding for MediaWiki with just access to wiki pages is very limiting in the first place, though, unfortunately. It's obviously best if we had a magic word instead. Gary King (talk · scripts) 20:21, 15 July 2010 (UTC)
"Flashing" (in most browsers) imho only happens if you use appendCSS with addOnloadHook, like currentlly in MediaWiki:Monobook.js where addOnloadHook is totally unnecessary and causes icons to 'jump' on page load. — AlexSm 20:24, 15 July 2010 (UTC)
To work around users with JS off, the system could like this:
<div class=user-logged> <div class=js-off>logged in?</div> do this
<div class=user-ip> <div class=js-off>editing as IP?</div> do that
then JS e.g. for logged in users: appendCSS('.js-off, .user-ip {display:none}'). This way users with JS off see a choice while normal users see only relevant steps. — AlexSm 20:24, 15 July 2010 (UTC)
That sounds very sensible. I'll admit I'm out of my depth in this discussion, so you guys just work out the details :) But I'll just make an obervation that when the accountcreator code was added, no one else commented on the proposal and there have since been no issues with it, so I'll guess this isn't really controversial. — Martin (MSGJ · talk) 21:00, 15 July 2010 (UTC)
Well accountcreator and admins are less than a percent of our audience, and the most experienced part of it, so then it's less of a problem. —TheDJ (talkcontribs) 11:56, 16 July 2010 (UTC)

Poke. Any chance of someone writing some code for this? Thanks — Martin (MSGJ · talk) 15:27, 24 July 2010 (UTC)

Jumping topicons on monobook

AlexSm has ushered his concerns about the current hack we have to force position of the topicons in monobook when central or sitenotices are running. These notices require that the topicons are moved, but unfortunately it is difficult to detect these notices reliably. The reason we have this hack is because otherwise we need to use the Vector method. In that method, we set bodyContent to relative and then adjust the positions of all positioned elements in the page. This is a major change to the way the monobook skin renders and might interfere with expectations of people and/or break their current settings for rendering topicon and other similar icons (on their userpages for instance), but also in many other locations.

So which way do we go, improving topicon rendering during notice periods (almost all year long these days), or supporting everyone who is still expecting the old monobook styling. —TheDJ (talkcontribs) 12:09, 16 July 2010 (UTC)

Previous discussion: MediaWiki talk:Common.js/Archive 16#topicon part deux.
First, centralNotice is "present" more often than you'd think, for example, it is present right now with both "Wikipedia is getting a new look..." and "Notice something different?...", then there is 130 lines of JS code that makes our browsers (!) check wgDBname against a long list of projects and then hide those messages. So I guess this fix was working all the time at least since May. Since there were no complains (except for IE6), I'd say this fix is safe.
Second, topicons do not look very good inside "The page ... has been added to your watchlist" message, so we need the fix even if there is no centralNotice.
I suggest replacing the current code with this:
if(navigator.userAgent.indexOf('MSIE 6') == -1) 
    appendCSS('#bodyContent { position:relative; } .topicon { top:-2em !important; } #coordinates { top:1px !important; right:0px !important; }');
AlexSm 17:06, 6 August 2010 (UTC)
I have no real objection to that. —TheDJ (talkcontribs) 20:08, 6 August 2010 (UTC)

secure.js and noc.wikimedia.org

MediaWiki:Common.js/secure.js needs another exemption for the domain noc.wikimedia.org. An example of a currently broken link is at [3].

Regards, HaeB (talk) 00:58, 20 July 2010 (UTC)

 DoneTheDJ (talkcontribs) 12:10, 20 July 2010 (UTC)

IPA font changes

Based on bugzilla:24516, and older discussion here and here, I have decided to force the IPA class upon all windows browsers, because apparently glyph fallback on Windows is simply such a hot mess. The class now forces some Windows specific fonts from MediaWiki:Common.css/WinFixes.css and is loaded with Javascript from Common.js. We have known about these problems for a long while, but have been hold back in are lack of testing abilities. I think we can afford to take a leap and see what works better. This or the old behavior. —TheDJ (talkcontribs) 21:00, 23 July 2010 (UTC)

But this is a IE specific problem, I believe? Firefox et al. use their own font rendering engines and not Windows'. At least that used to be the case 2 years ago. —Ruud 00:01, 24 July 2010 (UTC)
No it is a Windows problem. Like Amir says in bugzilla:24516, the rest is an equal mess (basically every browser has it's own fallback routines under Windows, all differing in capabilities and results, unlike Mac where CoreText takes care of it and unlike Qt and Gtk under Linux). This is also confirmed by my experiences in the VLC media player team, where we have been struggling with font selection on Windows for glyph fallback of subtitles since for ever. I think it is worth experimenting with this, because there have been many complaints on the IPA related project pages. —TheDJ (talkcontribs) 15:26, 24 July 2010 (UTC)
Thanks for fixing it. On Windows it looks well now. But for those who aren't coming from Windows, where is the IPA class defined? --Amir E. Aharoni (talk) 15:13, 24 July 2010 (UTC)
Non Windows platforms currently don't have anything defined for the IPA class. —TheDJ (talkcontribs) 15:26, 24 July 2010 (UTC)
So they just display IPA with the regular article font? It wouldn't be a bad idea to display it in Charis et al. to all users. --Amir E. Aharoni (talk) 15:33, 24 July 2010 (UTC)
They will display with the regular font, or if not supported by that font, the first font that does support the character. I'm not so much a fan of making font selections for users other than serif vs. non-serif. At the very least, we shouldn't have ANY font's in that row for anything but pure IPA fonts, if we do that. But I have had no need for specific fonts or font selections for IPA characters on Mac OS X 10.6. —TheDJ (talkcontribs) 17:24, 24 July 2010 (UTC)
Most serifs somehow have smaller glyphs than most sans-serifs, so combinations look ugly. Yes, maybe Firefox choice of Microsoft Sans Serif has poor support for combining characters, but at least it produces no combination of big sans letters and small serif letters in transcriptions. --Drundia (talk) 18:50, 24 July 2010 (UTC)
Well, that is a point. Charis is a serif font, so it will look uglier in some cases. Unfortunately, there is no way to really tackle this problem at this time. Since most of the pages are rendered as sans-serif, we probably should put DejaVu Sans in before Charis. In the future we can use CSS3's font-face system to provide online fonts, so that everything will render the same. Unfortunately, right now, that won't really work, since those fonts have to be on the same domain as the webcontent. You can also encode them, but then we have to throw those entire fonts at all users every time, which is simply not acceptable. And even THEN we are left with the serif vs. sans-serif issue compared to text surrounding the .ipa spans. Basically, the web isn't suited for accurate and reliable typograhpy. This is no secret, just google for typography in ebooks and you will find plenty people complaining. —TheDJ (talkcontribs) 20:21, 24 July 2010 (UTC)
I think that in this case correct rendering (support for more IPA characters without bugs) is more important than aesthetically pleasing (consistent use of (sans-)serif fonts is. The order of the list was carefully chosen several years ago to achieve just that. —Ruud 18:36, 25 July 2010 (UTC)
But the bug report states there is no problem in Safari, and Safari likely uses MacOS' rendering enginge even on Windows [4]. Amir could just have the wrong fonts installed or wrong defaults set (Arial Unicode has many known problems with characters in the IPA range). While I don't want to claim this problem doesn't exist on other browsers, this would at least require some further investigation into exactly which combinations of OS/browser (and probably even version of MS Office with which some of the problematic fonts ship) are affected. Otherwise you might be enabling a workaround with some very nasty side-effects for a problem that might not even exist for large majority of readers. —Ruud 18:28, 25 July 2010 (UTC)

Collapsible list template issue

With the {{Collapsible list}} template, the Show/Hide link is always blue, were as with the Navbox, the link is the same colour as the title text.

Titletext
  • BodyText
Titletext
  • BodyText

I'm thinking that a change in Common.js will be able to fix this:

Just before: NavFrame.childNodes[j].appendChild(NavToggle);
Add: NavToggle.style.color = NavFrame.childNodes[j].style.color;

Could someone confirm that this would work and also possibly implement it? Thanks -- WOSlinker (talk) 18:21, 4 August 2010 (UTC)

 DoneTheDJ (talkcontribs) 16:01, 26 August 2010 (UTC)

edit.js

Maybe I'm missing something, but it seems that with the big redesign, edit.js does absolutely nothing. Whatsoever. Is there some mysterious way to customize the new toolbar in the same way edit.js allowed customization of the old toolbar?
--Cogniac (talk) 02:30, 19 September 2010 (UTC)

Its still used by people who reverted back to the old design, and it still provides the edit tools thing underneath the edit box, as well as fixing some other thing; so it does something. But to answer the question, yes, though its not as trivial, and there isn't much documentation. What little documentation exists is here, here, and here. I wrote Wikipedia:RefToolbar 2.0 pretty much entirely by reading the source and trial and error. Mr.Z-man 04:17, 19 September 2010 (UTC)

Main page tab substitution

Wouldn't...

if (nstab.firstChild && wgUserLanguage=='en') {
   nstab.firstChild.nodeValue = 'Main Page'
}

...do the same thing as...

if (nstab && wgUserLanguage=='en') {
   while (nstab.firstChild) nstab = nstab.firstChild
   nstab.nodeValue = 'Main Page'
}

Kaldari (talk) 20:24, 1 October 2010 (UTC)

no, because Vector adds a span, that monobook does not have. —TheDJ (talkcontribs) 22:16, 1 October 2010 (UTC)

Improving collapsible tables and divs

Hi!!

I would like to propose that we make the header line of collapsible tables and divs clickable as it currently is on Wikibooks version (example). Their script is at b:MediaWiki:Common.js/Navigation.js.

This way, we can use a CSS like cursor:pointer; so that the mouse cursor changes when we put it over the header, and the content is expanded when we click on it (not only on the small button [show]).

What do you think? Helder (talk) 13:45, 7 October 2010 (UTC)

I think it is a good idea. I'm not entirely sure how that works in combination with the vde. links however. Has this been tested anywhere ? —TheDJ (talkcontribs) 14:17, 7 October 2010 (UTC)
It seems to work: here. Helder (talk) 16:33, 7 October 2010 (UTC)
OK. we need to confirm that on a few older browsers I think, and it would be best if we used a highlight color for the titlebar I think. Not sure how to do that, since navboxes can have multiple colors.... Ideas anyone ? —TheDJ (talkcontribs) 18:24, 7 October 2010 (UTC)
Maybe we can overlay a semi transparent white png, as suggested here or changing the brightness of the color used in title. Helder (talk) 19:48, 7 October 2010 (UTC)
Bleh... clicking a link expand the box and opens the page. Not very desireable behaviour. EdokterTalk 19:06, 7 October 2010 (UTC)
Humm... In my test I clicked with the middle button, and in this case it opened the link in a new tab, without expanding the content. With a normal left click (or CTRL+click) it indeed expanded the content.
It should be possible to have the same behaviour of middle button replicated to the left button as well. Helder (talk) 19:48, 7 October 2010 (UTC)
That means we have to stop propagation/bubbling of the event to the link. Requires some proper thinking and usage of the tips in http://www.quirksmode.org/js/events_order.htmlTheDJ (talkcontribs) 00:27, 13 October 2010 (UTC)

What about moving the line

			if (sub === 'www' || sub === 'mail') continue;

to above the line

			//Here
			if (main === 'wikipedia') {

to avoid the regex matches? Helder (talk) 19:46, 17 October 2010 (UTC)

Already done by TheDJ. --Bachinchi (talk) 18:39, 3 November 2010 (UTC)

TODO: Fix navframe

I haven't gotten around to it yet, but NavFrame needs to be updated to use the same onclick method as navbox now uses. Current method breaks on IE6 in a preview of the edit window. This is a reminder that I or someone else should do that at some point. —TheDJ (talkcontribs) 00:18, 13 October 2010 (UTC)

Would there be any way to cleanly roll it into the collapsible tables script? ダイノガイ千?!? · Talk⇒Dinoguy1000 06:40, 26 November 2010 (UTC)

Edit request

{{editrequested|MediaWiki:Common.js/secure.js}}

Where it says "if (sub.match(/^", please add "prototype"; see when I link to http://prototype.wikimedia.org. HeyMid (contributions) 10:58, 3 November 2010 (UTC)

More specific:

- if (sub.match(/^(lists|upload|download|bugzilla|(tech|)blog|wikitech|svn|stats|volunteer|ticket|survey|dumps|noc|nyc|status|.*?planet|.*?donate)$/)) {
+ if (sub.match(/^(lists|upload|download|bugzilla|(tech|)blog|wikitech|svn|stats|volunteer|ticket|survey|dumps|noc|nyc|status|prototype|.*?planet|.*?donate)$/)) {

--Bachinchi (talk) 18:43, 3 November 2010 (UTC)

 Not done. Prototype is not accessably via https://secure.wikimedia.org/ (or I just don't know the address... I tried every permutation possible). EdokterTalk 11:28, 4 November 2010 (UTC)
The requested edit does not add prototype to the list of projects with secure versions. It adds, however, prototype to the list of project names that should be ignored, as they don't have a secure version, and these links should thus not be translated to the secure 'language'. Projects like Wikipedia, Wikinews, etc, should not be added to this list, as they have a secure version. HeyMid (contributions) 18:07–18:11, 4 November 2010 (UTC)
 Done. Please be more descriptive in the future, so we know what the purpose of the proposed edit is. EdokterTalk 21:18, 4 November 2010 (UTC)
Why isn't this list inclusive instead of exclusive, it seems like it would be less code and maintaince? — Dispenser 22:43, 4 November 2010 (UTC)
http://ganglia.wikimedia.org/ and like other internal operations should be excluded... — Dispenser 22:55, 4 November 2010 (UTC)
Heymid: instead of just reenabling the request after it has been declined, please reply and discuss the issue. Disabled again for now. — Martin (MSGJ · talk) 17:58, 4 November 2010 (UTC)

ENGVAR editnotices

A discussion at WP:VPL made me wonder about the feasibility of using a similar system for ENGVAR editnotices as we currently have for the BLP editnotice. The latter loads via MediaWiki:Common.js based on the mere existence of Category:Living people in an article; in principle we could do something similar with Category:British English articles etc. This would be better than the current system of eg {{British-English-editnotice}}, as seen at Amnesty International, applied via the appropriate editnotice page (Template:Editnotices/Page/Amnesty International), since this needs admin permission and as a result isn't too widely used. So my question is - is there any technical reason why this would be a problem? Rd232 talk 10:17, 17 November 2010 (UTC)

No. That's it pretty much, if there were a consensus for it, it would take a few seconds as the whole system is already set up. Ale_Jrbtalk 14:23, 26 November 2010 (UTC)
Cool, thanks, but this idea now rather overlaps with Wikipedia:VPR#Editnotice_bot. Not sure which would be better, but probably the latter. Rd232 talk 14:41, 26 November 2010 (UTC)
BLPs and dab pages use edit intros, which works differently from editnotices and do not show when editing most sections; see Wikipedia:Editnotice#Edit intros. ---— Gadget850 (Ed) talk 15:15, 26 November 2010 (UTC)
Oooh, didn't know we were talking about different things. My bad. I was, of course, referring to intro things. :) Ale_Jrbtalk 15:22, 26 November 2010 (UTC)

Nested collapsible tables

I would like to make nested collapsible tables in a wiki site. I've copied the relevant code in Common.js and Common.css from the Wikipedia site; this code is the same as at meta.wikimedia.org [5]. Now why does the following example work properly at Wikipedia, but not at meta.wikimedia.org or in my wiki? In the other sites the whole contents appear when I click the topmost "show" button, and I have to click on the inner button several times for it to fold. (I've asked the same question at meta, posting the same code, you can compare the result there [6].)

--Rebollo fr (talk) 19:44, 21 December 2010 (UTC)

I'm answering to myself because I've just understood the reason: the code at meta.wikimedia.org has the line
var Rows = Table.getElementsByTagName( "tr" ); 
instead of
var Rows = Table.rows;
I thought the two codes were identical but they were not, and the code at meta is older. --Rebollo fr (talk) 20:39, 21 December 2010 (UTC)

Improve sortable tables

Sometimes we need to divide the header of a table in two lines, and use (col/row)spans for better organization of the content.

Would it be possible to improve the current script of sortable tables so that it could handle correctly cases like the following?

Wikicode
{| class="wikitable sortable"
|-
! rowspan=2 | Title 1
! colspan=2 | Title 2
|-
! Title 2.1
! Title 2.2
|-
| B || C || A
|-
| A || B || C
|-
| C || A || B
|}
Rendering (try to click on sorting buttons)
Title 1 Title 2
Title 2.1 Title 2.2
B C A
A B C
C A B

As can be noticed, only the first button is added in the right place, and even this button doesn't works as expected. Here is what we should see when the table is...

...sorted by Title 1
Title 1 Title 2
Title 2.1 Title 2.2
A B C
B C A
C A B
...sorted by Title 2.1
Title 1 Title 2
Title 2.1 Title 2.2
C A B
A B C
B C A
...sorted by Title 2.2
Title 1 Title 2
Title 2.1 Title 2.2
B C A
C A B
A B C

Any thoughts on this? Helder 17:04, 1 January 2011 (UTC)

There are several bugreports on this problem in bugzilla. However, in MediaWiki 1.18 we will probably use tablesorter.com, instead of the current sort code, so any effort is probably better spent on porting tablesorter.com to MediaWiki. —TheDJ (talkcontribs) 00:38, 2 January 2011 (UTC)
A year or two back, I wrote some enhancements to the wikibits sort functions to support a variety of rowspan and colspan that I believe also supports complex headers as above. At the time, there didn't seem to be much interest in pushing forward with the solution, so it bas been shelved. If there is renewed interest, I can dust off the code and put out another proposal. See User:Tcncv/Table_Sort_Demo for a set of demo tables. You will need to add importScript('User:Tcncv/sorttables.js'); to your monobook.js file (or appropriate xxx.js file for your chosen skin) to see the enhancements in action with the demo cases. Adding class="tsx_sortable" to your own tables will enable the demo for them as well. I added the above table to the bottom of the demo page (here) and it behaves just as you have requeested.
So is there any interest? -- Tom N (tcncv) talk/contrib 00:56, 4 January 2011 (UTC)
Like I said, since all wikibits.js code is deprecated after 1.17, any effort is probably better spent in helping with the integration of tablesorter.com code (which also supports this). —TheDJ (talkcontribs) 11:10, 5 January 2011 (UTC)

Featured and good articles in other languages

As we still have not fixed the horrible way the "featured article star" looks in the inter-language links section, may I propose that we remove the star and replace it with a more subtle "mark the inter-language link in boldface"-effect instead? I think this would fit better with Vector's visually less distracting design. I would suggest doing exactly the same for the "good article plus-sign". A featured article on a small Wikipedia is less likely to be more in-depth than a good article on, for example, the German Wikipedia. So I do not think it really justifies using any "visual bandwidth" to make this distinction (a distinction which is likely to only be confusing to casual readers in the first place anyway). —Ruud 20:27, 1 January 2011 (UTC)

Looks just fine to me. Perhaps you should make a screenshot to better point out what bothers you about it. —TheDJ (talkcontribs) 00:39, 2 January 2011 (UTC)
I'm not really sure if adding a screenshot would be that helpful, simply take a look at "Moon" ;) I designed the star to look nice in Monobook. In Vector it is misaligned, too close to the text, has the wrong proportions (compared to the triangle next to Toolbox, Languages), wrong colour (monobook-yellow :), ...
And to clarify on the featured vs. good article part. How is a causal reader to know that a "yellow" blob next to a link is better than "green-white" blob? A single visual indication would be intuitive to understand, having multiple is not and only distracts. —Ruud 05:08, 2 January 2011 (UTC)
I thought was "featured-gold", not "monobook-yellow". I agree the star is too close; the metrics don't match up with the rest of the side bar. I'll fix that in Vector.css now. I think the proportions are OK; the sidebar font in Vector is bigger that that of Monobook, so I think it is actually less disproportionate. But you can always propose a better looking icon. EdokterTalk 12:58, 2 January 2011 (UTC)

Why is there any sort of indication at all? Let's say that I go to the Dog article to read about dogs. Am I supposed to look at the interwiki links and think to myself, "oh, I should learn Catalan so I can read more about dogs"? — RockMFR 19:41, 2 January 2011 (UTC)

No, but you could be a Catalan who knows English, stumble here, learn about the Catalan Wikipedia, see the article isn't so good and decide to bring it up to feature standards... or any imaginable scenario just like it. Point is, we promote and highlight featured articles on all projects. EdokterTalk 21:22, 2 January 2011 (UTC)

WikiBugs

Moved this discussion to Wikipedia talk:Kvetch. --MZMcBride (talk) 22:00, 17 January 2011 (UTC)

Collapsible rows

Collapsible rows (in contrast to the existing collapsible tables) would be useful for taxoboxes like those in Fomes fomentarius (where an ugly hack with a table-inside-a-table is now used). I've implemented this feature in User:Ucucha/collapse.js, with an example here. Could this be added to common.js? Ucucha 23:25, 3 January 2011 (UTC)

Although the styling is a little off, nesting collapsible structures is not particularly "ugly". Collapsible tables, and collapsible divs and lists, are now included in the latest version of MediaWiki, which should hopefully be making its way onto Wikimedia wikis in the very near future. Anything we develop in the interim should be designed to be as compatible as possible with that implementation. Happymelon 00:04, 4 January 2011 (UTC)

RefTools consensus reached on VPP, need implementation

{{sudo}}

See Wikipedia:Village_pump_(proposals)#Proposal_-_Turn_on_RefTools_gadget_by_default. There is strong consensus supporting implementation; would someone please do so? --NYKevin @286, i.e. 05:51, 31 January 2011 (UTC)

In case whoever reads this doesn't know what the proposal means:
MediaWiki:Gadget-refToolbar.js <<this whole thing
should be copied to the end of MediaWiki:Common.js/edit.js
Choyoołʼįįhí:Seb az86556 > haneʼ 07:09, 31 January 2011 (UTC)
I'm reading the comments in the discussion to make sure there aren't any rough edges left to be dealt with. Meanwhile, I think this should be clarified: does the script work with all skins or only with vector? Because in the latter case, it should go in MediaWiki:vector.js instead. --Waldir talk 22:34, 31 January 2011 (UTC)
Or maybe it only works for those who have the enhanced editing toolbar enabled in the preferences. I'm sure the script can be made to activate only in that case. I assume it simply does nothing if not, but we should probably make sure it fails cleanly, without generating javascript warnings or errors. --Waldir talk 22:37, 31 January 2011 (UTC)
Update: I tried it, and I have the "Enable dialogs for inserting links, tables and more" checkbox off in my preferences. It made the old version active, which didn't work well: everything showed up as normal, but as I clicked the autofill button after pasting an url, the page reloaded into view mode. If this issue can be reproduced, I think it should be solved before activating the script wiki-wide. I'm {{tl}}ing the editprotected for now. --Waldir talk 00:05, 1 February 2011 (UTC)
I just removed that feature from that version. I'm willing to support that version to ensure that it doesn't break, but I'm not going to be adding new features to it. If someone else wants to take it, they're more than welcome. I originally only made that version as a quick hack when the new interface was switched on by default; the dialogs were disabled in IE. But that was resolved rather quickly and I pretty much forgot about it until the recent discussion. In short, if you want the newest features, turn the dialogs on, or turn the new toolbar off completely. However, I would suggest waiting until after the next MediaWiki update (scheduled for Feb 8) as it introduces some major JavaScript changes; adding new scripts at the same time could complicate debugging. Mr.Z-man 07:16, 6 February 2011 (UTC)
Thanks for the clarifications and for fixing that. However, when I turn the dialogs on, I don't see where to activate the auto-completion feature. Is it even available in that version? Will it be? I think it's very convenient :) --Waldir talk 14:41, 6 February 2011 (UTC)
It doesn't support it for Google Books URLs (at least not yet), but it does for ISBNs on the book template and DOI/PMID for journals, click the little to do the autofilling. Mr.Z-man 06:57, 7 February 2011 (UTC)
What about just fetching the page title given an url? Those "bot generated titles" we often see around usually work well, or at most require minor tweaking. And I can even foresee more complex heuristics in the future based on, for instance, common news sites' templates, to fetch date and authors. This would be a godsend for users of {{cite web}} and {{cite news}}, which I suspect are among the most used citation templates. Any chance we can expect that kind of functionality in the future? --Waldir talk 01:56, 8 February 2011 (UTC)
As suggested by Mr.Z-man above, I believe we should wait until MediaWiki 1.17 is deployed (which includes ResourceLoader) before turning this on. It was supposed to be deployed last week, but it's been delayed until this Wednesday. Kaldari (talk) 20:35, 14 February 2011 (UTC)
Also note that the version that will be turned on for everyone currently resides at MediaWiki:RefToolbar.js. Please direct all further tweaks and development there. Thanks! Kaldari (talk) 20:38, 14 February 2011 (UTC)
Update: I'm currently working out some last minute implementation details with Mr.Z-man. It should be ready to go in a day or two. The script that will actually be added to MediaWiki:Common.js/edit.js is MediaWiki:RefToolbarLoader.js (in case anyone wants to help review the code). Kaldari (talk) 03:33, 17 February 2011 (UTC)

Help Please undo whatever has been done in the last few days that has prevented me from using the reftoolbar. See User_talk:Mr.Z-man#RefTools. At least leave a gadget for the 1.0 version, that used to work for me a few days ago. Please do not overwrite existing gadgets in this way, let editors choose. -84user (talk) 10:24, 17 February 2011 (UTC)(struck through as things appear back to normal again 84user (talk) 14:25, 17 February 2011 (UTC))

Somehow the old toolbar plus cite icon are now obtainable, maybe something magical happened, see Wikipedia:Village pump (technical)#RefTools_not_working oldid. -84user (talk) 14:07, 17 February 2011 (UTC)
Myself and Mr.Z-man fixed the issues caused by the 1.17 roll-out, so everything should be functioning properly with the refTools gadget now. The current plan is to deploy it sitewide on Monday (barring any other problems). Kaldari (talk) 19:26, 18 February 2011 (UTC)
This is deployed now, by the way. Kaldari (talk) 23:10, 23 February 2011 (UTC)