MediaWiki talk:Common.js/Archive 1
![]() | This is an archive of past discussions about MediaWiki:Common.js. Do not edit the contents of this page. If you wish to start a new discussion or revive an old one, please do so on the current talk page. |
Archive 1 | Archive 2 | Archive 3 | → | Archive 5 |
What is the use of this message? Each tooltip had a message formerly. I tried to give a translation in the Spanish Wikipedia (es:MediaWiki:Monobook.js) but something is broken and now the tooltips are not shown there. Any help is appreciated. Thank you. ManuelGR 19:06, 14 Jun 2004 (UTC)
pref system/ access key update
- accesskeys and tooltips moved to js, needs to be customized/localized at MediaWiki:Monobook.js (copy everything below /* tooltips and access keys */ from [1]. Saves many calls to wfMsg, reduces page size, shows access key prefix depending on browser/os. Easy to customize in your own Monobook.js by changing the ta array.
- skinphptal underline and justification wired up to produce generated css- users have to adjust their prefs to get the default Monobook behaviour unfortunately
- MediaWiki:Monobook.css used for anons as well (-> underlined for them now)
- addcss call removed from header
- separate js var file included that holds things like the stylepath and the tooltip/accesskey array
- rtl css included from generated css
Translators: Many translated accesskey-XY and tooltip-XY messages need to be moved to the Monobook.js array, they are now deprecated. The remaining ones might follow soon.
I also changed the wording and key of the 'clear your cache' message as it's now also displayed above the prefs as well. A new string is qbsettingsnote.
To get the new files, a reload might be necessary (the usual reload in moz, ctrl-f5 in IE/Opera, cmd-r in safari). -- Gabriel Wicke 15:02, 9 Jun 2004 (UTC)
Tooltip for the "+" tab
Currently, the tooltip for the little "+" tab, which adds a section to a talk page, reads "Add a comment to this discussion". This is misleading for new users, however, since replying to somebody else's comment is also "adding a comment to the discussion", and this is not what the new section feature is intended for. The result is that new users who are not used to talk pages will add a heading just to say "yes", or somesuch. Here's an example.
Perhaps we could reword it to "Add a new section to this discussion page", or "Add a new heading to this discussion page", to highlight that a)individual comments don't usually have headings and b)the page is not necessarily one discussion. Thoughts, anyone? - IMSoP 14:56, 22 Sep 2004 (UTC)
- It is a good idea. Do changes made here ever get back into MediaWiki or do improvements only benefit the English Wikipedia? Angela. 05:14, Oct 4, 2004 (UTC)
Overloading of "d" shortcut
Currently, the "d" shortcut has two uses: (un)deleting pages and "show changes" on edit pages. I find this pretty confusing, so I turned off the first use in my personal Javascript. Perhaps this should be done site-wide, or one of them should be moved (e.g., "-" for delete)? -- Jitse Niesen (talk) 11:40, 20 August 2005 (UTC)
- I would love to have d moved to something else, like "-". I frequently use alt-d to access my address bar. — xaosflux Talk 23:12, 30 June 2006 (UTC)
How about putting the FA stars after the language names?
imo the current positioning makes the list look rather odd. Plugwash 00:34, 30 September 2005 (UTC)
At the Vietnamese Wikipedia, we instead set the list-style-image
property to be the star image, instead of the background-image
. It seems to look a bit better. – Minh Nguyễn (talk, contribs, blog) 05:17, 11 October 2005 (UTC)
Featured article icon on vi:
Crossposted from Template talk:Link FA and Wikipedia talk:Featured articles. See those pages for more discussion on this proposal.
All featured articles and future feature articles at the Vietnamese Wikipedia have been marked with the Sao chọn lọc template, which adds a little star icon in the "namespace icon area" (various namespaces at vi: display icons at the top-right corner of the page). This can be accomplished thusly:
Assuming that the Link FA code has already been added to MediaWiki:Monobook.js, the following code should be added to the script, just below the Link FA code:
/* Configuration for "star" logo at the top of Featured Articles */ function StarFA() { if (document.getElementById("FA")) { // Monobook.css will take over styling from here document.body.className += " FA"; // Iterate over all <h1> elements - this loop is optional for (var i = 0; a = document.getElementsByTagName("h1")[i]; i++) { // Apply a tooltip to the article title, which includes the little star if (a.className == "firstHeading") { a.title = "This article has gained featured status"; } } } } addLoadEvent(StarFA);
Then, add the following code to MediaWiki:Monobook.css:
/* Namespace icon area */ h1.firstHeading { background-position: bottom right; background-repeat: no-repeat; } /* Featured articles */ body.FA h1.firstHeading { background-image: url('/media/wikipedia/en/thumb/8/8c/Featured_article_star.png/16px-Featured_article_star.png'); }
Finally, create a template Template:Star FA that contains the following code:
<span id="FA" style="display: none" /> [[Category:Wikipedia featured articles|{{PAGENAME}}]]
And add transclude it into each page:
{{Star FA}}
This little logo isn't as intrusive as the meta-template that used to appear at the top of featured articles, but it still makes it easy to figure out if the article is of high quality, without having to load the Talk page.
If you are concerned about any potential impact on page loading time, just exclude or comment out the section marked "optional" in the JavaScript code above. If you enough people find this tip useful, I'll move it to a more widely read Talk page like Wikipedia talk:Featured articles.
You can see what this looks like in action at vi:Đệ nhị thế chiến.
– Minh Nguyễn (talk, contribs, blog) 04:53, 6 October 2005 (UTC)
A function to help users install tools
I've written the following function to allow users to easily install tools written by other users. The function includes the specified .js page and sets the specified global variables, using code from Wikipedia:Tools/Navigation_popups#Installation. So, do we want such a function? Zocky 00:12, 1 November 2005 (UTC)
- Usage
include_js (page_name,option1,value1,option2,value2, ...)
- Arguments
- page name:
- the name of the .js page to be included, without the "User:" prefix and the ".js" extension.
- option1, value1, ...
- Pairs of option names and their values to set
- Example
include_js ( 'Lupin/popupsdev', 'popupAdminLinks', true, 'popupStructure', 'menus', 'popupActionsMenu', true );
- Error messages
- The user is alerted if they provide inappropriate arguments.
- Caveats
- Variables are set before the included script is run. Developers of tools should take care to check whether variables have been set by the user and set defaults only where necessary; use something like optionvar==undef && optionvar=defaultvalue;
- Issues
- The name should maybe be changed to something like install_tool().
- Using globals for this doesn't sound like a good idea. Maybe options for all tools should be stored in an array, something like tools_options[].
- Source
function include_js(includedscript) { var i; if (include_js.arguments.length>0) { document.write('<script type="text/javascript" src="' + 'http://en.wikipedia.org/w/index.php?title=User:' + includedscript + '.js' + '&action=raw&ctype=text/javascript&dontcountme=s"></script>'); i=1; while (i < include_js.arguments.length) { if (typeof(include_js.arguments[i]) == "string" ) { i++; if (i < include_js.arguments.length) { window[include_js.arguments[i-1]] = include_js.arguments[i]; i++; } else { alert ("Variable "+ include_js.arguments[i-1] +" specified, but no value provided."); return; } } else { alert ("Bad name for variable"); return; } } } else { alert ("No script name provided."); } }
- Sorry, but this is hopelessly insecure. What's to stop me making a really useful tool, getting thousands of users to use it, and then replacing the tool script with an account hijacking script, stealing passwords and vandalising pages? The only way round this is some kind of secure accredited script inclusion system, but that would be quite a bit of work. Tom- 10:36, 1 November 2005 (UTC)
- The method of inclusion is already widely used by users. Puting it in a function doesn't make it any less secure than the current practice of users copying the chunk of code that does the same thing. There is nothing stopping you now from doing what you describe above and this function would not change that. OTOH, encouraging users to use a function like this would at least confine the scripts that get included to userspace.js pages, which are protected by default and are thus less prone to abuse.
- As for the other issue, about accredited scripts. We already list some tools on WP:TOOLS. I don't know if we have any formal process for quality assurance of tools included there. I would definitely support having such a system, especially if it provided a sane way for users to install tools. The technical side - a rudimentary API for installation and configuration - is quite straight-forward, but it would also require some kind of workflow guideline/policy for QA in order to work. Is there interest in such a project? How would we go about it? Zocky 11:27, 1 November 2005 (UTC)
- Hey, good idea... :P Lupin|talk|popups 03:18, 6 January 2006 (UTC)
- A very similar idea is already being discussed at Wikipedia talk:WikiProject User scripts#Towards a plugin system. One issue besides security is performance. Perhaps we can discuss the details further there? -- Jitse Niesen (talk) 13:13, 1 November 2005 (UTC)
- Security need not be an issue. We can change the function so that it (optionally) links to a specific revision for the paranoid; besides, as others have already said, this is simply a utility function to make things slightly easier to install. It adds nothing new to exploit. I'm not sure I see the advantage of setting variables by passing them to this function over setting them in the file itself, though; this functionality could be removed. For example,
function include_js(script, oldid) { document.write('<script type="text/javascript" src="' + 'http://en.wikipedia.org/w/index.php?title=' + includedscript + '.js' + (oldid ? '&oldid=' + oldid : ) + '&action=raw&ctype=text/javascript&dontcountme=s"></script>'); }
- This function would allow safe inclusion of scripts in non-userspace (such as those in WP:WPUS) with a specific revision id.
- I'd like to see a helper function of this type installed in a site-wide javascript file, not a skin-specific one like Monobook.js. Can we do that? Lupin|talk|popups 03:18, 6 January 2006 (UTC)
IE alpha transparency
If you add the following code to your personal monobook.js it fixes the internet explorer alpha transparency problem, why has not this been done before?
function correctPNG() // correctly handle PNG transparency in Win IE 5.5 & 6. { var arVersion = navigator.appVersion.split("MSIE") var version = parseFloat(arVersion[1]) if ((version >= 5.5) && (document.body.filters)) { for(var i=0; i<document.images.length; i++) { var img = document.images[i] var imgName = img.src.toUpperCase() if (imgName.substring(imgName.length-3, imgName.length) == "PNG") { var imgID = (img.id) ? "id='" + img.id + "' " : "" var imgClass = (img.className) ? "class='" + img.className + "' " : "" var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' " var imgStyle = "display:inline-block;" + img.style.cssText if (img.align == "left") imgStyle = "float:left;" + imgStyle if (img.align == "right") imgStyle = "float:right;" + imgStyle if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle var strNewHTML = "<span " + imgID + imgClass + imgTitle + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";" + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader" + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" img.outerHTML = strNewHTML i = i-1 } } } } window.attachEvent("onload", correctPNG);
To test it out use Internet Explorer and log in as Username: AchilleIEtest Password: IE
Cheers —This user has left wikipedia 15:48 2006-01-30
- Sounds like something that should be a normal part of one of the MSIE-specific style sheets. —Michael Z. 2006-01-30 18:14 Z
- Stylesheet? I'm confused... can you execute Javascript from a stylesheet? —This user has left wikipedia 19:09 2006-01-30
- The above works great for me on IE6. Why can't this be included in the main sheet? I've heard quite a few complaints about SVG backgrounds in IE, and having this by default would help a lot. Would it break non-MS browsers? Crotalus horridus (TALK • CONTRIBS) 06:16, 31 January 2006 (UTC)
- It shouldn't mess up non-IE browsers as the code above detects IE before doing anything (so non-MS browsers with an unmodified user-agent should ignore it). This is assuming the window.attachEvent code is universal of course. —Locke Cole • t • c 06:36, 31 January 2006 (UTC)
- If you wanted to modify the mediawiki, you could do this automatically. All that is happening here is that the image is wrapped in a span tag that includes 'filter:progid:DXImageTransform.Microsoft.AlphaImageLoader'. But this JS is an easy fix —This user has left wikipedia 07:29 2006-01-31
I guess I wasn't paying attention when I wrote "style sheet". I don't think everyone should be served up an extra 1.4 kB of code because Microsoft won't support PNG transparency. This belongs in the MSIE-specific javascript at /skins-1.5/common/IEFixes.js, but I have no idea where to edit that (maybe it's part of the MediaWiki software?). Also, many people do set their browser strings to MSIE so that they can use ignorant banking sites, etc. which don't want to support other browsers—will this script try to execute for these users? —Michael Z. 2006-01-31 16:04 Z
- Sadly, 70% or so of Internet users are running IE. I think that having 1.4 kB of code served to users of standards-compliant browsers is a lesser evil than 70% of our users seeing PNGs (and SVGs, too, due to the way these are converted) rendered with an ugly blue background instead of transparency. Maybe I can cut down on the code by removing comments, shortening variable names, etc. Crotalus horridus (TALK • CONTRIBS) 17:28, 31 January 2006 (UTC)
- I've only checked in firefox, but I'd expect the test for document.body.filters to exclude browsers which are just pretending to be IE. Lupin|talk|popups 16:52, 31 January 2006 (UTC)
- Shouldn't there be a test for the existence of window.attachEvent, before you call it? I thought this wasn't defined in Firefox. -- Jitse Niesen (talk) 17:48, 31 January 2006 (UTC)
- I don't mind this being put in here temporarily, to support MSIE users, but
- It should be purely an interim measure, with a reference to a relevant MediaWiki bug report requesting that this be added to IEFixes.js, which is served only to MSIE.
- Doesn't it belong in the main javascript rather than monobook, to work in all skins?
- —Michael Z. 2006-02-08 18:41 Z
- I don't mind this being put in here temporarily, to support MSIE users, but
I found that this fix causes a weird text display bug. Look at this page in Internet Explorer with the IE Alpha Transparency fix, scroll all the way to the bottom and you'll see the text is all screwed up. In addition, if you try editing the entire page, it doesn't work because the edit box becomes completely broken. I don't know what in the above javascript code could be causing this bug, but it's not good... –Tifego(t) 00:46, 20 March 2006 (UTC)
This fix, in our Windows 2003 host environment, caused the edit article toolbar to break. The buttons no longer applied syntax to highlighted code. Did not affect Firefox. The toolbar buttons worked when the code was commented-out. Cedarrapidsboy 16:37, 17 July 2007 (UTC)
Autofocus
I removed the autofocus script for blank pages, per talk at Wikipedia:Village pump (technical)#Focus. It was very annoying and inconsistent—I already know how to use my browser; it only interrupts my work if a web site tries to grab the mouse and click a field for me, and only on some pages at that. That edit field already has an accesskey assigned too, control-comma focuses it in my browser (Safari). —Michael Z. 2006-01-30 18:13 Z
- Autofocus is one of the worst usability choices one can make, I believe. I'm glad that we're not doing it. —Michiel Sikma, 12:29, 21 May 2006 (UTC)
Special characters menu, removed
Why does this javascript write HTML which adds another javascript, which in turn writes HTML to add a menu to the page? This seems inefficient and fragile; shouldn't the HTML just be added to the page template?
And it appears to be added to pages chosen by a common word in their title! So this is intended to be added to the article about the "Hypertext Editing System"? Sloppy.
Finally, what does this do? I can't see any menu for secial ("special"?) characters in either Safari of Firefox. If no one can explain the purpose of this script, I will remove it. —Michael Z. 2006-01-31 16:17 Z
/* add menu for selecting subsets of secial characters */ //if(document.title.indexOf("Editing ") == 0) { //document.write('<script type="text/javascript" src="' // + 'http://en.wikipedia.org/w/index.php?title=MediaWiki:Charset.js' // + '&action=raw&ctype=text/javascript&dontcountme=s"></script>'); //}
- The two slashes at the start of each line indicate C++ style comments, so this is not executed. The indirection is probably to save bandwidth: there is no need to transmit the script in Charset.js if it is not needed. And the condition in the if statement does not hold for the article Hypertext Editing System, only for articles whose title starts with "Editing". User:Brian0918 can probably fill you in on the details if you need to know more, as he has worked on it. But I agree that it can be removed, as it is dead weight at the moment anyway. -- Jitse Niesen (talk) 16:44, 31 January 2006 (UTC)
- By the way, this test for Editing is still a poor way to detect edit pages. For example, see [2]. Lupin|talk|popups 16:55, 31 January 2006 (UTC)
Bloat
I figure the entertainment that's been had by one or two authors in recent days on this page is the cause of th re-bloat to the editing tools box. Could someone please de-bloat that, quickly? It's really very unnecessary, and already met with resistance last time this was tried in the far more accessible edittools page. I'm on the point of reverting all the recent changes to achieve this.
Also, PLEASE STOP PLAYING WITH SUCH PAGES LIVE. Test it somewhere, in a local install or something. Mediawiki space IS NOT YOUR PLAYGROUND. -Splashtalk 13:41, 17 February 2006 (UTC)
- I looked at the history; the last edit was made on January 31, 2006. Are you sure you're on the right message? MediaWiki:Edittools might be where you meant to place this. —Locke Cole • t • c 13:43, 17 February 2006 (UTC)
- Actually no, I have no idea what's changing the edit tools. But there's been no recent edits here or at MediaWiki:Edittools. —Locke Cole • t • c 13:46, 17 February 2006 (UTC)
- Yes, I've been very confused by the strange appearances in the edittools box. I figured it must be this because it wasn't edittools, and I got month-lag looking at the history here. Apologies. -Splashtalk 13:59, 17 February 2006 (UTC)
- Actually no, I have no idea what's changing the edit tools. But there's been no recent edits here or at MediaWiki:Edittools. —Locke Cole • t • c 13:46, 17 February 2006 (UTC)
Broken templates - why?
This change broke a whole freakin’ lot of templates.( See Wikipedia:Village pump (technical) here and here for details.)
Why was this change made? Can that value please be changed back from 0 to 1? In fact, rather a lot of users would be happy to see it changed to 2 or even 3. -- WikidSmaht (talk) 04:59, 16 March 2006 (UTC)
- Okay, I changed it back to 1. In my opinion, changes to this page should always be discussed first. I'm considering adding a warning to that effect, like the message at the top of MediaWiki:Monobook.css. -- Jitse Niesen (talk) 06:18, 16 March 2006 (UTC)
- Thanks! Now maybe we should discuss changing it to 2 or 3... -- WikidSmaht (talk) 06:37, 16 March 2006 (UTC)
- I'd like to change it to 3. -- User:Docu
- In the meantime, it was changed to 3 (May 10). A change that was reverted 10 days later (May 20) as another template (Template:Hidden) depens on the setting as well. Maybe we can find a way to arrange both. Not sure if a template hidden should depend on a parameter with a number .. -- User:Docu
Main Page
The Main Page hack needs to be tightened. It currently triggers for both history mode and anything which starts with "Main Page" (like Main Page alternate (Classic 2006)). It should both check the full page title and avoid doing anything if there is an action= parameter. --cesarb 05:23, 20 March 2006 (UTC)
Update Monobook.js to reduce redundancy
Please see "Updates to CSS and JS pages to reduce redundancy". --Melancholie 00:45, 24 March 2006 (UTC)
Suggest removing tooltips
The tooltips serve little purpose and take up a couple KB of the file. I suggest removing them. — 0918BRIAN • 2006-03-30 13:03
- What a usability improvement! especially because all icons are really self-explaining...like this #R --Elian Talk 09:37, 25 April 2006 (UTC)
I was trying to make some changes to the above (see MediaWiki_talk:Cologneblue.js) to include features added here. How does it work? -- User:Docu —The preceding unsigned comment was added by Docu (talk • contribs) 11:03, 9 April 2006 (UTC).
- According to Wikipedia:Catalogue of CSS classes, only Monobook-derived skins have editable global javascript. Cologne Blue is not Monobook-derived. See also the discussion at MediaWiki talk:Edittools#Replacing charinsert with dynamic JavaScript, where this is mentioned. --cesarb 16:45, 9 April 2006 (UTC)
Main page
I know this is minor, but I think the main page tab should say "main page" and not "article", I've changed my JS so it says that, but want to ask around first before fooling with this one. I just don't think that the main page is really an "article". It links to many articles, and previews a few, but "main page" is not an article in itself.Voice-of-AllT|@|ESP 03:39, 13 April 2006 (UTC)
- It is in the article namespace.Geni 17:26, 13 April 2006 (UTC)
- Technically, it is in "article" namespace, since there is no "main page" namespace. Still, the URL just sais Wiki/ so nothing seems contradictory there. Also articles are named based on their title, there is no article called "main page"...it does not explain "main pages"...it is one, so it should be considered "Main Page" and not "article" I suppose.Voice-of-AllT|@|ESP 23:19, 13 April 2006 (UTC)
- I'm fine either way. I don't mind the way it is now, but I would also be fine with changing it.--Alhutch 17:27, 13 April 2006 (UTC)
- It's not a big deal, and just like Alhutch, I don't mind either way. Thanks! Flcelloguy (A note?) 19:21, 14 April 2006 (UTC)
Redirect edit button
I've changed how the redirect edit toolbar button gets added. The toolbar generation has been updated so the buttons show for current versions of Safari and Konqueror which support the necessary bits, and while I was in there I made it easier to add custom buttons in a slightly less hacky manner. (The extra button no longer will show in browsers which are detected as unable to run the toolbar.)
Note that the old code caused some weird incompatibility where the other buttons didn't function correctly in Safari or Firefox, I'm not totally sure why. --Brion 11:07, 17 April 2006 (UTC)
Move/rename
I think the name "move", while technically correct, is not the exact right choice to use. From what I get, the page history is moved to the other page, but it is basically renaming—and would be a simpler concept for new users to grasp, no? Would people be opposed to calling it "rename", or something along those lines? -Mysekurity [m!] 02:15, 18 April 2006 (UTC)
- Renaming is "moving" pretty much. However moving is slighty more general. Moving from place to place in one namespace is like renaming. "Userfying" or any other namespace to namespace change is more like a "move". Still, I don't care much either way.Voice-of-AllT|@|ESP 07:18, 28 April 2006 (UTC)
- I made a simple script that renames it to "rename" for all article namespace pages. I would support that.Voice-of-AllT|@|ESP 22:27, 11 May 2006 (UTC)
- Thanks for responding. Maybe take this to the Village Pump (things usually get lost there unless you have concrete ideas). -Mysekurity [m!] 00:48, 12 May 2006 (UTC)
- I think this can also be changed by editing the text at MediaWiki:Move. That's probably a cleaner solution than a script, but it does change it for everybody. -- Jitse Niesen (talk) 01:13, 12 May 2006 (UTC)
- I guess I just like tradition, but I prefer "move" better, and I'm not sure why. Perhaps it's the tone, or the monosyllabic appeal, but I like "move" better than "rename", though I don't mind either way. Thanks! Flcelloguy (A note?) 01:38, 12 May 2006 (UTC)
- The purpose of a script would be that non-article space pages would have different text for those accustomed to it (like how article space pages say Article, the Main Page says Main Page, MW pages say Message, and WP namespace pages say Project on their tabs). I know you guys are all apathetic, and I care only slightly, but I think it'd be a good step towards more usability. When one right-clicks (or alt-clicks for our Mac bretheren) on an icon within their operating system, it says "rename". It would only be right to have this apply to WP as well. -Mysekurity [m!] 01:49, 12 May 2006 (UTC)
- Certainly, IMO, rename seems more clear to newbies. I already use the script myself just to see what it is like.Voice-of-AllT|@|ESP 02:01, 12 May 2006 (UTC)
- I agree that "rename" is clearer. Mysekurity, do I understand you correctly that you want different texts depending on the namespace? If so, could you please explain? It seems rather confusing to me to use different descriptions for the same function. -- Jitse Niesen (talk) 02:10, 12 May 2006 (UTC)
- The script I made would make articles have a "rename" tab, where as project, help and portal pages (where moves are more serious (like AfD) and likely to result in double redirects and confusion and should not likely be moved by newbies anyway). Renaming articles is more likely a spelling/formality thing that for things like MediaWiki (where moving is really like file moving) and Images (when moving is supported).Voice-of-AllT|@|ESP 02:55, 12 May 2006 (UTC)
- You seem to have forgotten the end of the first sentence, but I assume that your script does not change the name of the tab for project, help and portal pages. That would be confusing, in my opinion. You make a good point for MediaWiki name space, but that's a very special case: how often are those pages moved? -- Jitse Niesen (talk) 06:44, 14 May 2006 (UTC)
- Rename is more clear and suggest that is is somewhat more minor that move. Project/portal pages are the true location of their topic, so renaming them is like moving them, and it creates a ton of double redirects, guarenteed. Articles are about a topic, but they are not the topic, there are usually 1 or a few correct possible titles. Articles are just articles, were as other namespaces either have serious technical effects to moving (MediaWiki, user JS, Images when they support it) or have a sense of location. WP:PP is at WP:PP, George Bush is not at Wikipedia's George Bush page. At any rate, new users shouldn't be moving projects anyway.Voice-of-AllT|@|ESP 06:54, 14 May 2006 (UTC)
- I personally disagree. To me, "move" is more clear, as that's how I visualise it: the article being sort of pushed to a new location, leaving a redirect trail. IMHO, "rename" sounds like the article sort of stays in the same place, which it doesn't. Also, I guess I like "move" for historical reasons. I'm not diehard opposed to the change, but I certainly prefer "move" for my own preferences as well as being clearer.
- Rename is more clear and suggest that is is somewhat more minor that move. Project/portal pages are the true location of their topic, so renaming them is like moving them, and it creates a ton of double redirects, guarenteed. Articles are about a topic, but they are not the topic, there are usually 1 or a few correct possible titles. Articles are just articles, were as other namespaces either have serious technical effects to moving (MediaWiki, user JS, Images when they support it) or have a sense of location. WP:PP is at WP:PP, George Bush is not at Wikipedia's George Bush page. At any rate, new users shouldn't be moving projects anyway.Voice-of-AllT|@|ESP 06:54, 14 May 2006 (UTC)
- I agree that "rename" is clearer. Mysekurity, do I understand you correctly that you want different texts depending on the namespace? If so, could you please explain? It seems rather confusing to me to use different descriptions for the same function. -- Jitse Niesen (talk) 02:10, 12 May 2006 (UTC)
- I think this can also be changed by editing the text at MediaWiki:Move. That's probably a cleaner solution than a script, but it does change it for everybody. -- Jitse Niesen (talk) 01:13, 12 May 2006 (UTC)
- Thanks for responding. Maybe take this to the Village Pump (things usually get lost there unless you have concrete ideas). -Mysekurity [m!] 00:48, 12 May 2006 (UTC)
- I made a simple script that renames it to "rename" for all article namespace pages. I would support that.Voice-of-AllT|@|ESP 22:27, 11 May 2006 (UTC)
- As a further note, I don't really understand the logic of not having the tab be the same for all pages. Isn't that even less newbie friendly than it is now? "Why do I have these two different tabs for different pages? They seem to do the same thing, but they must be different because the label is different, etc..." In addition, you'd have to have another MediaWiki page, one that said "rename page" for the articlespace, one that said "move page" for everything else. I don't really get why we'd want that. Snoutwood (talk) 07:21, 14 May 2006 (UTC)
- Oh, another note: If this goes through, don't forget to change the other skins to the new version as well. Snoutwood (talk) 07:22, 14 May 2006 (UTC)
- My small script also changes "history" to "revisions" for articles, since that makes it more clear.Voice-of-AllT|@|ESP 19:10, 13 May 2006 (UTC)
- Move sounds more approriate to me. I'd support implmentation of a Rename function, but would want to limit it's use to admins as the potential for vandalism would be high with it. Page moving may not be the most newbie friendly function, but it is also a function that can cause signifigant problems when done incorrectly, maybe it shouldn't be as friendly as the edit button. — xaosflux Talk 11:27, 14 May 2006 (UTC)
- Page moves really should be like 95% semi rather than 99% of users, that would avoid much page moving nonsense. If anything is to be less freindly, it would be page moves for project pages/portals/help ect...that would cause even more trouble than the usual article move.Voice-of-AllT|@|ESP 19:36, 14 May 2006 (UTC)
- The rename is fine by me. BrokenSegue 18:23, 14 May 2006 (UTC)
- I prefer "move", perhaps because I am used to it, but... Prodego talk 21:30, 14 May 2006 (UTC)
- I would keep "move" per Prodego, but I'd be in support of a rename function to be given to admins only which would be equivalent to a move w/o a redirect trail (or a move + deletion of the created redirects). I think this would be useful most espically in the case of userfication. --Charlie(@CIRL | talk) 23:56, 14 May 2006 (UTC)
- Perhaps...but I would see "move" as the one that one that created no redirects, "moving" a templatate would make inline refs to it break and become red, whereas renaming them would just make the redirect work so it still shows inline. "Renaming" an article will make redirects to its new name; moving it would break links IMO. Either way, this is even more complicated than my original idea, which is what I would like to stick to. "Rename" for naming things that talk about things and can only have certain correct names, "Move" for pages that are their topic and are the location of the topic, that we at Wikipedia can rename, and that moving is more even likely to cause double redirects (try moving WP:AFD).Voice-of-AllTalk 03:17, 20 May 2006 (UTC)
- shrugs* It seems to be simply a matter of intrepretation on how to define the terms at this point. Thinking abstractly about these actions, I think of "Rename" being an action where the article (file) has stayed in one place, just changed names, whereas "move" actually moves the article to a new location (therefore should create a pointer to the new location). Regards Charlie(@CIRL | talk) 04:41, 20 May 2006 (UTC)
- Perhaps...but I would see "move" as the one that one that created no redirects, "moving" a templatate would make inline refs to it break and become red, whereas renaming them would just make the redirect work so it still shows inline. "Renaming" an article will make redirects to its new name; moving it would break links IMO. Either way, this is even more complicated than my original idea, which is what I would like to stick to. "Rename" for naming things that talk about things and can only have certain correct names, "Move" for pages that are their topic and are the location of the topic, that we at Wikipedia can rename, and that moving is more even likely to cause double redirects (try moving WP:AFD).Voice-of-AllTalk 03:17, 20 May 2006 (UTC)
- I would keep "move" per Prodego, but I'd be in support of a rename function to be given to admins only which would be equivalent to a move w/o a redirect trail (or a move + deletion of the created redirects). I think this would be useful most espically in the case of userfication. --Charlie(@CIRL | talk) 23:56, 14 May 2006 (UTC)
- I prefer "move", perhaps because I am used to it, but... Prodego talk 21:30, 14 May 2006 (UTC)
I support renaming it "rename". "Move" implies relocating something in physical space, which is a decent UI metaphor for the process, but "rename" is direct, not metaphorical, and in my opinion provides for a more intuitive user interface. — Phil Welch (t) (c) 11:44, 15 May 2006 (UTC)
In this case short=better.Geni 12:04, 15 May 2006 (UTC)
Request: Edit L/R for diffs
I'm not sure how easy of a hack this would be, but I think it would be a really cool feature if when viewing diffs instead of having a single (slightly ambiguous) "edit this page", we could have an "edit left version" and "edit right version". I would find it very helpful espically when viewing diffs for fighting vandalism. Thoughts/Comments? Charlie(@CIRL | talk) 04:46, 20 May 2006 (UTC)
- And perhaps a revert to this version of the current (good for diffs where several editors vandalized)...I was thinking about this for a while...but just used popups....I'll get to work on the script (though it would be a personal thing), I will also make an edit button, (not just revert).Voice-of-AllTalk 04:50, 20 May 2006 (UTC)
- Awesome! You rock --Charlie(@CIRL | talk) 05:15, 20 May 2006 (UTC)
- I actually programmed this a while ago. The following fragment adds "edit" links to the left and right diffs, when inserted in your monobook.js :
function addOneEditLink(hd) { // first node is <strong><a href="..."> ... </a></strong> var node = hd.childNodes[0]; var href = node.childNodes[0].attributes.getNamedItem('href').value; // add a space and a link to the edit page var link = document.createElement('A'); link.href = href + '&action=edit'; link.appendChild(document.createTextNode('(edit)'), null); hd.insertBefore(link, node.nextSibling); hd.insertBefore(document.createTextNode(" "), node.nextSibling); } function addEditLinks() { if (window.location.href.indexOf('&diff=') != -1) { // in a diff page, so add edit links addOneEditLink(findthe("//TD[@class='diff-otitle']")); addOneEditLink(findthe("//TD[@class='diff-ntitle']")); } } addOnloadHook(addEditLinks);
- Is this similar to what you were looking for? -- Jitse Niesen (talk) 06:07, 20 May 2006 (UTC)
- I've finished a script that adds "edit this version" and "restore" to the older version (left side) for all admins. I would like to implement this in MediaWiki.Voice-of-AllTalk 18:07, 20 May 2006 (UTC)
- Is this similar to what you were looking for? -- Jitse Niesen (talk) 06:07, 20 May 2006 (UTC)
It would IMHO be preferable to implement this directly in MediaWiki rather than by JavaScript. I've submitted a patch for this at bugzilla:6125. —Ilmari Karonen (talk) 22:24, 28 May 2006 (UTC)
Proposal: striped table CSS class + JS
Hey all. I thought that people who watch this page may be interested in a proposal that I've posted on Wikipedia:Village pump (proposals) about striping wikitables. It involves changing CSS and JS. It's posted here: Village_pump_%28proposals%29#Proposal:_striped_table_CSS_class_.2B_JS. —Michiel Sikma, 05:21, 22 May 2006 (UTC)
Dynamic Navigation Bars - default setting
How can I set a dynamic navigation bar's default setting to "Show" rather than "Hide"? Thanks, Rfrisbietalk 07:57, 25 June 2006 (UTC)
- I'm working on some modifications to the NavBar code, and a way to do this can be supported if/when those changes are rolled in. Gimmetrow 13:13, 4 July 2006 (UTC)
User Logs in toolbox
I've shown the js to Xaosflux, who suggested I mention it here for possible inclusion:
Basically, the code adds "User logs" to any userpage or talkpage. I've used it for a while now and it looks stable.
/* Adds "User logs" to the toolbox. */ /* Coded by [[User:Bookofjude]], requested by [[User:Kylu]]. */ addOnloadHook(function () { if (document.getElementById('t-contributions')) { z=document.getElementById("content").childNodes; for (var n=0;n<z.length;n++) { if (z[n].className=="firstHeading") var username = z[n].textContent.replace(new RegExp('User(?:[ _]talk)?:([^/]*)', 'g'), '$1'); }; var toolbox = document.getElementById('p-tb').getElementsByTagName('ul')[0]; var link = document.createElement('a'); link.href = '/w/index.php?title=Special:Log&user='+username; link.appendChild(document.createTextNode('User logs')); var li = document.createElement('li'); li.appendChild(link); toolbox.appendChild(li); } });
(Other location: User:Kylu/userlog.js) ~Kylu (u|t) 04:31, 27 June 2006 (UTC)
- Strong Oppose - GeorgeMoney (talk) (Help Me Improve!) 18:18, 29 June 2006 (UTC)
- Why? Voting is evil, especially when there's no comments to indicate why you don't like it. Titoxd(?!?) 22:33, 30 June 2006 (UTC)
Why?. Because a) if we really wanted to do a user log thing, we should integrate it into mediawiki just like the "user contributions" link. b) this is really useful, yes (and I have a different version in my monobook), but some people might not like it; if we keep putting "useful" stuff in the global js file, then there will be so many scripts running, that it will be useless. c) I really don't get this "coded by bookofjude, requested by kylu" business; First of all, "requested by anyone" is not very important and it should be removed; also, i'm sure that not only bookofjude could have written that; for example, I could go ask any of the JS programmers here "can you make a script that adds a user log button to the toolbox" and they would be able to do it, and if I added "requested by GeorgeMoney" it would kinda seem like an easy way to get my name into the global js file; it would be like saying "1/342 of the code was written by bob", completely irrelevant. d) if people disable js in their browser, then they won't be able to use this; like I said before, we don't want the entire project running on JS. --GeorgeMoney (talk) (Help Me Improve!) 00:42, 1 July 2006 (UTC)
- Why? Voting is evil, especially when there's no comments to indicate why you don't like it. Titoxd(?!?) 22:33, 30 June 2006 (UTC)
- An easy way to get my name into the global js file? I rather assumed to trim down the size of the loaded scripts that unneeded comments were pruned anyway. Hadn't actually looked, but way to assume good faith. :) The main reason the comments are there is so that people understand:
- Bookofjude wrote it and this is where the skill came from, and
- I requested it, so while it's my responsibility, I don't quite understand it all (the regexes give me trouble, I'm sad to say.)
- It's convenient, but not strictly needed. If it doesn't fly with people in this discussion (it's not a vote), the code's still sitting here and people are free to copy-paste into their own monobook and use it.
- ~Kylu (u|t) 05:34, 2 July 2006 (UTC)
- Whatever; support. GeorgeMoney (talk) (Help Me Improve!) 06:01, 2 July 2006 (UTC)
- It's still not a vote, but thanks. c.c;; Hey, George, if you've got a similar script, maybe we could take a peek at it, hey? Drop a direct link so the lazy among us don't have to dig through your monobook. :) ~Kylu (u|t) 23:06, 2 July 2006 (UTC)
- The script was in my monobook until I installed lupin's antivandal tool, and that added 4 more links to the toolbox, so I had to remove it, and remove some links through CSS. GeorgeMoney (talk) 01:45, 4 July 2006 (UTC)
- Oppose - I'm changing back to oppose, because it adds an extra link to the toolbox, and the only "benefit" is that it saves 1 less click. All you have to do is press the "user contributions" link, and then press the "logs" link at the top. I really don't think we have to sacrifice an entire space, to save a click. Also, nobody added any id's to it, so people can't make it disappear through CSS even if they wanted to. GeorgeMoney (talk) 01:45, 4 July 2006 (UTC)
- Okay George, you don't like it. It probably won't get included, then. You're good at this CSS/JS stuff, so can you show some changes so those of us who do like it can make it better? I seem to recall you said something about you having your own version of it, but atm I can't check. (wikipedia'ing instead of working! :D ) Thanks! ~Kylu (u|t) 16:39, 4 July 2006 (UTC)
- My version is somewhere on the talk page of my monobook. GeorgeMoney (talk) 21:18, 4 July 2006 (UTC)
- Something like this would be extremely useful, and I already added it to my own monobook script file. The only thing is that a user's monobook doesn't load until after all the text and images have loaded, unlike the site-wide script, so it should be added there if possible. Titoxd(?!?) 22:33, 30 June 2006 (UTC)
- As an early reviewwer, I think this is a great idea, and have added it to my personal script for now. — xaosflux Talk 23:07, 30 June 2006 (UTC)
- When I tried adding this, I got double the User Tabs at the top. Gimmetrow 01:15, 1 July 2006 (UTC)
- Happened the first time I used it also, I've not quite figured that out, but on a hard refresh the problem went away and hasn't come back. Suggestions welcome. :) ~Kylu (u|t) 05:34, 2 July 2006 (UTC)
- I don't support this because it will cause all kinds of people's user scripts to mess up or have duplicates. What I would support is making custom JS more accessable to new users, like having a good centralized place for all major scripts, and what they do, kind of like the nagivation popups project page.Voice-of-All 03:18, 5 July 2006 (UTC)
- I still like the idea of having an inc(); function available globally, myself. I know the security concerns, but think people should be responsible for their own js security. Worst case scenario, they log out and post anonymously that their js is broken? ~Kylu (u|t) 18:00, 7 July 2006 (UTC)
Dynamic Navigation Bars
I wanted to do inline toggle switches but was unable with the current navbar code. The toggle text style.display really should be 'inline' rather than 'block' to allow for this. It would be nice to be able to specify alternate hide/show texts, and I was able to hack that though the title attribute. What's the better way? Also, the NavHead tags seem to need a nbsp, but the toggle text is placed after the nbsp, and this causes some odd alignments especially for left-justified text. (Using .insertBefore instead of .appendChild, would cause the same problem for right-justified text.) Suggestions? Is the experimantal (sic) navbar code still open to experiments? This is what I have so far. Since this uses the title attribute to do what I want, I don't think it breaks existing templates or anything that doesn't use titles, but of course this would need testing. Gimmetrow 01:15, 1 July 2006 (UTC)
[obsolete code removed by Gimmetrow]
- Playing with it now, I'll get back to you on it. ~Kylu (u|t) 05:51, 2 July 2006 (UTC)
- Cool. Just so it's clear, I want to be able to have a line that looks like:
- Group1 First : Last
- That expands to look like:
- Compress First : Some : Text : Last
- The idea of my code is to allow this to be implemented with something like below. Gimmetrow 10:33, 2 July 2006 (UTC)
- Cool. Just so it's clear, I want to be able to have a line that looks like:
<div class="NavFrame" title="Compress"><span class="NavHead" title="Group1"> </span> First:<div class="NavContent" title="inline" style="font-size:80%;">Some : Text :</div>Last</div>
Also, it would be nice to be able to specify some NavBars as shown, others as hidden. The current code hides all if there are more than one. This seems slightly odd, because a NavBox could be designed with one toggle intending text to be shown by default, but if it is used on a page with an unrelated NavBox it will be hidden by default. One way of doing this is to create another tag, <span class="NavShow"> </span>, that indicates the code to toggle this NavBox, but it would have to be ignored (or treated as a "hide") when there is only one NavBox on the page. Gimmetrow 13:25, 4 July 2006 (UTC)
- I'm afraid I had to disable it. I'm not sure why, but for some reason it seemed to slow down my browsing considerably. Perhaps it doesn't like some of my other scripting? I didn't leaktest it yet, but will check soon. ~Kylu (u|t) 16:20, 4 July 2006 (UTC)
- What do you mean by "it"? What can we do? I've tested the code given above mostly using a local version with different function names - if anything is slower this should be noticeable as it creates a different type of navbox. Didn't notice anything substantial on two different systems. I've made some changes that reduce the amount of string processing, which might help. If you want to try my local version, see User:Gimmetrow/dynabars.js Test samples at User:Gimmetrow/sand Gimmetrow 16:39, 4 July 2006 (UTC)
- Sorry I wasn't more clear: I meant "it" as in my local copy of the script I was playing with. Considering I'm loading around 1.2MB in scripting (yes, seriously) across three domains (last I checked) while wikibrowsing, I imagine it may well be more of this being the straw that broke the camel's back, rather than anything actually wrong with the scripting. I'll retest the script later, thanks! ~Kylu (u|t) 17:08, 4 July 2006 (UTC)
- No, it is probably the getAttribute calls, I just didn't think this would be that much worse than what the code already does. I will work on a different approach over the next few days. Gimmetrow 03:06, 5 July 2006 (UTC)
- Trying a different approach. Could you give User:Gimmetrow/dynabars.js a try and let me know if it still causes a major slowdown? Also, is there an easy way to identify popup windows so the dynabar code not try to process them? Gimmetrow 16:45, 7 July 2006 (UTC)
- No, it is probably the getAttribute calls, I just didn't think this would be that much worse than what the code already does. I will work on a different approach over the next few days. Gimmetrow 03:06, 5 July 2006 (UTC)
- Will do. As far as Popups goes, I know Lupin uses a custom css for popups... User:Lupin/navpop.css I think? There's also a "development" version of the css, though, and I don't recall where it is. I figure, check and see if his css tags are extant in the window, and if so, don't use the dynabars. I'm css-retarded, so will let you figure out what I'm trying to say. Oh, you might want to talk to him too. :D ~Kylu (u|t) 18:05, 7 July 2006 (UTC)
Another thing that would be great if we can 'expand/collapse' certain things with a + and - instead of show/hide. GeorgeMoney (talk) 18:45, 9 July 2006 (UTC)
For your own use, just put in your monobook.js
- NavigationBarShow = '[+]'; NavigationBarHide = '[-]';
Then every hide/show box will use these texts. As far as I know, with the current code there is no way to have these texts vary with different navboxes. This is another feature supported by my test code as shown above. However, using a specific text for hide/show in a navbox would prevent users from choosing different language texts. Although this is an English wikipedia, such a feature may not be desirable. Gimmetrow 18:44, 17 July 2006 (UTC)
- Just FYI, the new code seems to work fine. Figured I'd let you know. (Testing off-wikipedia, btw) ~Kylu (u|t) 23:24, 5 August 2006 (UTC)
Where can I find out more
Where can I learn more about my Monobook.js file, such as neat tools I can install and how to write my own? --Ideogram 06:28, 3 July 2006 (UTC)
- Check out WP:JS. ~Kylu (u|t) 07:02, 3 July 2006 (UTC)
- Oooh, cool. I have a lot of reading to do :-). --Ideogram 07:43, 3 July 2006 (UTC)
I'd like to add the support for a {{Link GA}} template, similar to {{Link FA}}. All this has already been implemented and tested on the French wiki. (fr:Modèle:Lien BA) I currently have a bot overthere that is adding the template, and I wanted to do the same here. An example of a GA link in interwikis can be found overthere : fr:Pi.
In fact you would need to alter LinkFA() into
function LinkFAorGA()
{
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( LinkFAorGA );
and add into Monobook.css
li.GA {
list-style-image: url("/media/wikipedia/fr/8/86/Icone_BA.png");
}
(You might need to find another link in en: to that very same image, thought)
Thanks,
NicDumZ ~ 17:46, 20 December 2007 (UTC)
- The template in question was deleted after discussion at Wikipedia:Templates for deletion/Log/2007 October 4#Template:Link GA, and I don't think MediaWiki_talk:Common.js is a good place for a new discussion whether we need this template at all ∴ AlexSm 18:14, 20 December 2007 (UTC)
- Yeah, I know, it was deleted because the function was not supported in the monobook and because it was adding wieird categories on the articles itself: "Category:Good Article in French", etc... It was stupid. Now that this is working on fr:, I'm asking this again.
- And... Where should I ask if not here ? NicDumZ ~ 18:23, 20 December 2007 (UTC)
- Make a proposal here. Cheers. --MZMcBride (talk) 01:00, 21 December 2007 (UTC)
- This idea has been rejected a few times already. I think the discussions should be somewhere in the archives of this talk page. —Ruud 09:31, 21 December 2007 (UTC)
Edit made without consensus
{{editprotected}}
Please undo this recent edit. This edit does not have consensus. The TeX markup was not intended to be displayed in the tooltips of images, and if we are going to make a change to display the markup in image tooltips, the change should be made for all browsers, not just Internet Explorer. —Remember the dot (talk) 21:26, 29 December 2007 (UTC)
- I restored Internet Explorer's default behaviour in this respect. The tooltips were showing before PngFix, and now they do again, as expected. Just because they are not supposed to show, does not mean we should not respect IE's default behaviour. IE shows alt tags as tooltips, and is not a matter that shoud be "fixed", even if it "breaks" HTML standards. — Edokter • Talk • 21:41, 29 December 2007 (UTC)
- If IE has quirky behavior and we can't fix it, that's one thing. But where IE has quirky behavior, and it's fixable (and it was fixed), that's another. Your change actually decreases performance on Internet Explorer for no other reason than to re-introduce one of Internet Explorer's quirks. If you think that we should make the TeX markup show up in tooltips, then that change needs to be made for all browsers, not just Internet Explorer. —Remember the dot (talk) 21:49, 29 December 2007 (UTC)
- Proposal
- Change
if (img.useMap)
toif (img.useMap || img.className == "tex")
Take outDone.outerSpan.title = img.title...
img.title is always empty anyway. Also, the img.classname lookup seems to have no speed impact at all (probably because it is cached). — Edokter • Talk • 17:06, 30 December 2007 (UTC)
- If you want to make the TeX markup show in the tooltips, make it appear there for users of all browsers, not just Internet Explorer. —Remember the dot (talk) 02:25, 31 December 2007 (UTC)
- You have a point about
outerSpan.title = img.title...
and I wouldn't mind if you removed this statement. —Remember the dot (talk) 02:26, 31 December 2007 (UTC)
- The script does not touch any other browser, so I can't make the tooltips appear in any other browser here; that requires a change in TeX or MediaWiki. But the change would restore IE default behaviour. — Edokter • Talk • 12:21, 31 December 2007 (UTC)
- Make another script that copies TeX alt attributes into TeX title attributes, and do not restrict that script to any one browser. —Remember the dot (talk) 19:29, 31 December 2007 (UTC)
- I'm not restricting anything; IE displays alt as tooltips, as it has always done (even Netscape did so). If you want other browsers to do the same, you're welcome to write s script that does so. — Edokter • Talk • 20:36, 1 January 2008 (UTC)
- Thank you for altering common.js appropriately. Here is code you can use for displaying the alt attribute in the tooltip:
/* Use alt attribute as the tooltip text, for example with TeX-generated images. The MediaWiki software never adds title attributes to images anyway, so there is no danger of overwriting an existing tooltip. */ function useAltForTooltips() { var documentImages = document.images for (var i = 0; i < documentImages.length; i++) { var img = documentImages[i] img.title = img.alt } } if (!window.useAltForTooltipsDisabled) { window.addOnloadHook(useAltForTooltips) }
- I don't have a strong opinion on whether we should use this code or not, so you can do what you like. Just try to keep the experience consistent across all browsers. —Remember the dot (talk) 22:06, 1 January 2008 (UTC)
- My intention was simply to restore IE's default behaviour, which I do not regard as a bug. If you want TeX-tooltips to display in other browsers as well, I suggest asking the community first (on WP:VPT) to see if non-IE users want the tooltips. In that case, a change should be made to TeX rather then add yet another script. I do intend to implement the other change listed above; that would at least speed up pages with TeX rendering. — Edokter • Talk • 22:46, 1 January 2008 (UTC)
- Sure, go ahead and make the other change. As long as the squid servers don't kill themselves again it should be fine. And feel free to ask the community about whether or not TeX markup should show up in tooltips. The major issue that I have is making it show up in the tooltips only for Internet Explorer, which results in inconsistency between browsers. —Remember the dot (talk) 23:19, 1 January 2008 (UTC)
- My point is just that it is an inconsistency that has always existed, and therefor not something that should be 'fixed'. People using IE expect certian behaviuour, users using ohter browser expect other behaviour. But I am dubbing over the squid issue... It does make me wonder why the standard monobook bullet doesn't kill the squids. — Edokter • Talk • 23:59, 1 January 2008 (UTC)
- IE has all sorts of inconsistencies that have always existed that cause all sorts of problems. Just because it's always been there doesn't mean that it's worth keeping there. The casual user knows nothing of all this, of course. They might actually wonder why Wikipedia shows tooltips on TeX images in IE7 but not in IE6, Firefox, Opera, Safari, etc. The answer is that there's not a good way to keep IE7 from displaying them, but there is in the other browsers. But, if we decide that having those tooltips there is a good thing, then we can make the change, and make it for all browsers. —Remember the dot (talk) 20:40, 2 January 2008 (UTC)
Hide "user page" link for anonymous users
{{editprotected}}
I proposed this at Wikipedia:Village pump (proposals)#Hide "user page" link for anonymous users and there were no serious objections, so I'd like to have this code added to the site-wide JavaScript. If this causes a revolt then just remove it. If people like it then we can ask the developers to provide a way to do this more elegantly through CSS.
/** Automatically hide "user page" link for anonymous users that do not have user pages * Created by Remember_the_dot */ function hideAnonUserPageLink() { var userPageLink = document.getElementById("ca-nstab-user") if (!window.hideAnonUserPageLinkDisabled && userPageLink.className == "new") { document.getElementById("ca-nstab-user").style.visibility = "hidden" } } if (wgPageName.search(/^(User_talk:(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))$/) == 0) { window.addOnloadHook(hideAnonUserPageLink) }
I can also make a gadget to disable this behavior if there is demand for it. —Remember the dot (talk) 01:48, 4 January 2008 (UTC)
- No please. Good suggestion, however, some of them have user pages. Also, this adds a few lines of code with no real net gain. Regards, Mercury 02:25, 4 January 2008 (UTC)
- It would only hide links to nonexistant user pages. —Remember the dot (talk) 03:00, 4 January 2008 (UTC)
- Not done. This code makes a change that is arguably deceptive; there's a standard that tabs exist, regardless of page existence, and adding this code would change that expected behavior. I also fear that it would lead to a lot of confusion among the community. In addition, there are legitimate reasons for wanting to post to an anonymous user's user page, and this code change would make it more difficult. It also adds more code to an already lengthy file, with little net gain, and very likely net losses. However, you're free of course to add it to your personal subpage. Also, it could be made into a gadget for users to choose to enable or not, however, the default should be off. Cheers. --MZMcBride (talk) 02:30, 4 January 2008 (UTC)
- What are the legitimate reasons for putting anything on an IP user page? IP user pages are never linked to, in fact if you type "User:78.86.150.44" into the search box and hit "Go", it will take you to the contributions page. —Remember the dot (talk) 03:00, 4 January 2008 (UTC)
- For one, it is common to place (shared) IP information and blocked sock templates on an IP's userpage, which would be hard to do if there is no tab. — Edokter • Talk • 12:15, 4 January 2008 (UTC)
- That information is almost always given on the IP's talk page where people will see it. —Remember the dot (talk) 18:00, 4 January 2008 (UTC)
- For one, it is common to place (shared) IP information and blocked sock templates on an IP's userpage, which would be hard to do if there is no tab. — Edokter • Talk • 12:15, 4 January 2008 (UTC)
- What are the legitimate reasons for putting anything on an IP user page? IP user pages are never linked to, in fact if you type "User:78.86.150.44" into the search box and hit "Go", it will take you to the contributions page. —Remember the dot (talk) 03:00, 4 January 2008 (UTC)
You can estimate how often IP user pages are used with about 200 searches like Special:Prefixindex/User:78.. It seems like not very often, most are redirects to talk pages. I agree that this kind of script is a hack and instead we need either a MediaWiki fix or a policy which would say "only use user_talk: for IPs" ∴ AlexSm 16:40, 4 January 2008 (UTC)
- The idea was that if people liked the change, we could get the MediaWiki software to allow us to do this through CSS, which would be a much more elegant solution. I would much prefer CSS to JavaScript. —Remember the dot (talk) 18:00, 4 January 2008 (UTC)
If we could do this through CSS, and the CSS only changed the link's color from red to gray instead of removing it entirely, would you support the change? —Remember the dot (talk) 18:57, 4 January 2008 (UTC)
I've filed bug 12509 about doing this more elegantly with CSS. —Remember the dot (talk) 02:11, 5 January 2008 (UTC)
addDismissButton in Opera
I don't think addDismissButton() should continue after it finds out that the cookie is set to hide the message. There is no point to create [dismiss] link after that. Besides, for some reason this link is still visible in Opera (9.25) while the whole message is hidden (probably Opera's fault, but still...). In other words, we need a return
immediately after watchlistMessage.style.display = "none"
∴ AlexSm 01:36, 7 January 2008 (UTC)
On subpages and tabs
Currently, when you're at a subpage, e.g., Template:Infobox Election/doc, the "discussion" tab links to the /doc talk page rather than the main talk page. I asked User:Splarka if there was a JavaScript way to fix this, and he wrote the code found below. It changes the tab to blue and links it to the main talk page if the tab is already non-existent. It's currently written to only work on /doc and /sandbox pages. Would there be any objections to implementing it site-wide? It would save a lot of unnecessary redirects. Improvements are, of course, welcome. Cheers. --MZMcBride (talk) 06:22, 7 January 2008 (UTC)
if(wgPageName.indexOf('/')!=-1 && (wgNamespaceNumber % 2)==0) addOnloadHook(redirSubpageTalk)
function redirSubpageTalk() {
var redir = [
/\/doc/i,
/\/sandbox/i
]
var talk = document.getElementById('ca-talk')
if(talk.className.indexOf('new')==-1) return;
var talka = talk.getElementsByTagName('a')[0];
for(var i=0;i<redir.length;i++) {
if(talka.href.search(redir[i])!=-1) {
talka.href = talka.href.replace(redir[i],'').replace(/action\=edit/i,'action=view');
talk.className = '';
}
}
}
- Wouldn't it be better to submit a bug report? (rather than link-munge) GracenotesT § 16:38, 7 January 2008 (UTC)
- On second note, I'm not sure this is a good idea, given that it violates the principle of least astonishment – users shouldn't have to check the status bar to see where a user interface link leads. it would make a good user script, however. GracenotesT § 18:21, 7 January 2008 (UTC)
- Yeah, I thought about that; however, the code stops if the /doc talk page actually exists, and I think it would be justifiable to do this if the result was easier accessibility. Currently, people are creating redirects, which simply seems kinda silly. --MZMcBride (talk) 21:31, 7 January 2008 (UTC)
- Why is it silly? Creating redirects is the way in which redirection is meant to be handled in MediaWiki wikis, not with kludgy javascript. Adding the above code would be very annoying; I'd have to disable javascript on Wikipedia and manually copy the rest of the scripts from various different places into a local file and use that, which would be a lot of fuss – Gurch 22:10, 7 January 2008 (UTC)
- It's silly because the pages are never going to be used for anything other than redirects to the target they should go to. And even if there is legitimate content, the script takes that into account and shuts down. Currently, most of the /doc talk subpages aren't redirects and the interface is just a little clunkier. Instead of being able to just click the tab and go to the page that they intended, users either have to create redirects or go back and then go to the talk page. Meh. I'll probably just enable it for myself; let them have red tabs. --MZMcBride (talk) 02:51, 8 January 2008 (UTC)
- That is proof only that the /doc subpage system was a stupid idea in the first place. There was nothing wrong with having the documentation on the discussion page – and avoiding all that silly meta-templating on the template page itself – but it just had to be changed, didn't it? – Gurch 18:34, 8 January 2008 (UTC)
- It's silly because the pages are never going to be used for anything other than redirects to the target they should go to. And even if there is legitimate content, the script takes that into account and shuts down. Currently, most of the /doc talk subpages aren't redirects and the interface is just a little clunkier. Instead of being able to just click the tab and go to the page that they intended, users either have to create redirects or go back and then go to the talk page. Meh. I'll probably just enable it for myself; let them have red tabs. --MZMcBride (talk) 02:51, 8 January 2008 (UTC)
- Why is it silly? Creating redirects is the way in which redirection is meant to be handled in MediaWiki wikis, not with kludgy javascript. Adding the above code would be very annoying; I'd have to disable javascript on Wikipedia and manually copy the rest of the scripts from various different places into a local file and use that, which would be a lot of fuss – Gurch 22:10, 7 January 2008 (UTC)
- Yeah, I thought about that; however, the code stops if the /doc talk page actually exists, and I think it would be justifiable to do this if the result was easier accessibility. Currently, people are creating redirects, which simply seems kinda silly. --MZMcBride (talk) 21:31, 7 January 2008 (UTC)
- On second note, I'm not sure this is a good idea, given that it violates the principle of least astonishment – users shouldn't have to check the status bar to see where a user interface link leads. it would make a good user script, however. GracenotesT § 18:21, 7 January 2008 (UTC)
- If people are competent enough to edit doc pages, why would they ever click the red link or think a redirect would be intuitive rather than misplaced? That's like making a redirect in articlespace to correspond with every talk archive. A trivial solution would be to add a link to the talk page to {{Documentation}}, if it's likely to be noticed. –Pomte 00:52, 9 January 2008 (UTC)
Problems with collapsible shells and older safari browsers
Hi - I've just realised that the reason so many navigation templates and WikiProject banners seem to have disappeared from Wikipedia in the last few months is that they haven't gone - I've just been unable to see them. With the combination of browser and platform I (and presumably other) WP editors use (Mac OS 10.2.8/ Safari 1.0.3) the shell renders all templates within it as thin, unexpandable lines. Is there any way to fix this so that I don't have to physically edit the article to see what templates are on it? There's some discussion of this already at Template_talk:WikiProjectBannerShell, which is where I first raised this issue, but the suggestion there is that this is the place to come. As an example of what I mean, here's how the top of Talk:Algeria looks to me:
User:Anomie suggests that: " If that is the case, I suspect the problem is on line 126 of the current version as I remember hearing that particularly old versions of Safari do not correctly support the table "rows" collection."
Any possible way of fixing the problem? Grutness...wha? 23:21, 18 January 2008 (UTC)
{{editprotected}}
- We've done some experimentation, and it seems I was correct as overriding the function in Grutness's monobook.js with a fixed version has fixed the problem. Please change line 126 from
var Rows = Table.rows;
tovar Rows = Table.getElementsByTagName( "tr" );
. Thanks. Anomie⚔ 13:33, 19 January 2008 (UTC)
- Has this been tested that it does not break other browsers? — Edokter • Talk • 14:35, 19 January 2008 (UTC)
- The other function implementing this feature,
createCollapseButtons
, usesgetElementsByTagName
to get the list of table rows, so if this would break anything then it is already broken. I suppose to be 100% safe you should use lower-case "tr" instead of "TR"; I have edited the request accordingly. Anomie⚔ 14:46, 19 January 2008 (UTC)
- The other function implementing this feature,
— Edokter • Talk • 15:02, 19 January 2008 (UTC)Done
- D'oh! I see you rightly reverted it as it caused unrelated problems. Anomie⚔ 15:12, 19 January 2008 (UTC)
I have had to revert this change, unfortunately. It broke functionality in nested tables in that they automatically expanded (and still showing the [show] link) when the main table is expanded. This needs more testing. — Edokter • Talk • 15:12, 19 January 2008 (UTC)
- Ok, I have another attempt at User:Anomie/Sandbox.js. The code there can be copied into a monobook.js for testing, I'm not going to be so hasty this time ;) So far, it seems to work for Grutness in the old Safari version and me in Firefox 2.0.0.11. Anomie⚔ 03:54, 20 January 2008 (UTC)
Problem with importStylesheet on Internet Explorer
{{edit protected}}
I mainly use Firefox, but I write some javascript that I want IE users to be able to use too. With Internet Explorer 7, I can't do appendChild on a STYLE element, nor can I set the innerHTML (both gives me errors). Thus, the importStylesheet() function here does not work with IE7 (though it does work fine with Firefox, Opera, and Safari). Instead, IE can use the document.createStyleSheet() function. -Pan Sola (talk) 09:31, 27 January 2008 (UTC)
- This is a known issue yes. Adding
if (document.createStyleSheet) document.createStyleSheet( theurl ); else { our current code }
should take care of it according to various websources.... --TheDJ (talk • contribs) 14:17, 27 January 2008 (UTC)- There are also other ways to fix this for IE, like using cssText property, or creating <link> element (instead of <style> with @import), but I agree that
document.createStyleSheet
seems to be the best option ∴ AlexSm 14:27, 27 January 2008 (UTC)
- There are also other ways to fix this for IE, like using cssText property, or creating <link> element (instead of <style> with @import), but I agree that
Is there a specific edit that needs to be done? If not, please do not use the editprotected template as a general call for help. — Edokter • Talk • 15:15, 27 January 2008 (UTC)
- Sorry I wasn't clear. I would like to advocate for the importStylesheet() function defined here to incorporate the IE check and calls document.createStyleSheet() from within, so that other javascripts needing to import stylesheets does not have to deal with the browser detection. Alternately, if for some reason importStyle() should not be modified to work on Internet Explorer, then I would advocate a note in the comments for the function here warning people that it will not work on Internet Explorer. -Pan Sola (talk) 21:23, 27 January 2008 (UTC)
Here is the diff that would do this. --TheDJ (talk • contribs) 22:10, 27 January 2008 (UTC)
- Hmm, the
{{edit protected}}
says it's for requesting immediate edit. Should I use it if I believe the edit should be made but without any urgency? -Pan Sola (talk) 20:37, 31 January 2008 (UTC)- It's a good question, perhaps the template should be able to be used to get admin attention about a request, even if a clear edit proposal is finish. →AzaToth 20:52, 31 January 2008 (UTC)
See also #import.2A.28.29_better.3F, but this createStylesheet() implementation is currently active in my private implementation of the import*() functions. --TheDJ (talk • contribs) 16:22, 21 February 2008 (UTC)
Big performance improvement
{{editprotected}}
It's been suggested before that we factor out all the IE fixes, but nobody actually took the time to do it. Were this done, we would see two improvements:
- Those not using IE (who consequently do not need the IE scripts) would not have to waste time downloading them
- Only one check would need to be made to see whether the browser is IE or not
So, I went through and came up with the code necessary to do it. The scripts will all continue to work as before, but users will see an improvement in page load time. Since this doesn't involve an appreciable change in behavior, we should be able to just go ahead and do it.
/* Import fixes specific to Internet Explorer 6.0 *****************************/ if (navigator.appVersion.substr(22, 1) == "6") { importScript("MediaWiki:Common IE6.js") } /** Internet Explorer bug fix ************************************************** * * Description: Fixes IE horizontal scrollbar bug * Maintainers: [[User:Tom-]]? */ if (document.compatMode == "CSS1Compat") { var oldWidth; var docEl = document.documentElement; function fixIEScroll() { if (!oldWidth || docEl.clientWidth > oldWidth) doFixIEScroll(); else setTimeout(doFixIEScroll, 1); oldWidth = docEl.clientWidth; } function doFixIEScroll() { docEl.style.overflowX = (docEl.scrollWidth - docEl.clientWidth < 4) ? "hidden" : ""; } document.attachEvent("onreadystatechange", fixIEScroll); attachEvent("onresize", fixIEScroll); } /** IE 6 Z-index bug workaround for anonnotice ************************** * * Description: This implements a work around for the Z-index bug found in Internet Explorer. * It correctly places the anon notice on the page, even under IE6. * See this Google search for more information about the bug: * http://www.google.com/search?hl=en&client=firefox-a&rls=org.mozilla%3Aen-US%3Aofficial&hs=q74&q=z-index+ie6+bug&btnG=Search * Created by: [[User:Gmaxwell]] */ addOnloadHook((function (){ if (wgUserName == null) { var messageEdu=new Array(); messageEdu[0]='<a href="/wiki/Wikipedia:Researching_with_Wikipedia" title="Wikipedia:Researching with Wikipedia">Learn more about using Wikipedia for research</a>'; messageEdu[1]='<a href="/wiki/Wikipedia:Ten_things_you_may_not_know_about_Wikipedia" title="Wikipedia:Ten things you may not know about Wikipedia">Ten things you may not know about Wikipedia</a>'; messageEdu[2]='<a href="/wiki/Wikipedia:Ten_things_you_may_not_know_about_images_on_Wikipedia" title="Wikipedia:Ten things you may not know about images on Wikipedia">Ten things you may not know about images on Wikipedia</a>'; messageEdu[3]='<a href="/wiki/Wikipedia:Citing_Wikipedia" title="Wikipedia:Citing Wikipedia">Learn more about citing Wikipedia</a>'; messageEdu[4]='Have questions? <a href="/wiki/Wikipedia:Questions" title="Wikipedia:Questions">Find out how to ask questions and get answers.</a>'; messageEdu[5]='<a href="/wiki/Wikipedia:Basic_navigation" title="Wikipedia:Basic navigation">Find out more about navigating Wikipedia and finding information</a>'; messageEdu[6]='<a href="/wiki/Wikipedia:Contributing_to_Wikipedia" title="Wikipedia:Contributing to Wikipedia">Interested in contributing to Wikipedia?</a>'; var whichMessageEdu = Math.floor(Math.random()*(messageEdu.length)); /** document.getElementById("contentSub").innerHTML +='<div style="position:absolute; z-index:100; right:100px; top:0px;" class="metadata" id="anontip"><div style="text-align:right; font-size:87%">• <i>' + messageEdu[whichMessageEdu] + '</i> •</div></div>'; */ } })); /** * Remove need for CSS hacks regarding MSIE and IPA. */ if (document.createStyleSheet) { document.createStyleSheet().addRule('.IPA', 'font-family: "Doulos SIL", "Charis SIL", Gentium, "DejaVu Sans", Code2000, "TITUS Cyberbit Basic", "Arial Unicode MS", "Lucida Sans Unicode", "Chrysanthi Unicode";');
/** * Correctly handle PNG transparency in Internet Explorer 6. * http://homepage.ntlworld.com/bobosola. Updated 18-Jan-2006. * * Adapted for Wikipedia by Remember_the_dot and Edokter. * * http://homepage.ntlworld.com/bobosola/pnginfo.htm states "This page contains more information for * the curious or those who wish to amend the script for special needs", which I take as permission to * modify or adapt this script freely. I release my changes into the public domain. */ function PngFix() { try { if (!document.body.filters) { window.PngFixDisabled = true } } catch (e) { window.PngFixDisabled = true } if (!window.PngFixDisabled) { var documentImages = document.images var documentCreateElement = document.createElement var funcEncodeURI = encodeURI for (var i = 0; i < documentImages.length;) { var img = documentImages[i] var imgSrc = img.src if (imgSrc.substr(imgSrc.length - 3).toLowerCase() == "png" && !img.onclick) { if (img.useMap) { img.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + encodeURI(imgSrc) + "')" img.src = "/media/wikipedia/commons/c/ce/Transparent.gif" i++ } else { var outerSpan = documentCreateElement("span") var innerSpan = documentCreateElement("span") var outerSpanStyle = outerSpan.style var innerSpanStyle = innerSpan.style var imgCurrentStyle = img.currentStyle outerSpan.id = img.id outerSpan.title = img.title outerSpan.className = img.className outerSpanStyle.backgroundImage = imgCurrentStyle.backgroundImage outerSpanStyle.borderWidth = imgCurrentStyle.borderWidth outerSpanStyle.borderStyle = imgCurrentStyle.borderStyle outerSpanStyle.borderColor = imgCurrentStyle.borderColor outerSpanStyle.display = "inline-block" outerSpanStyle.fontSize = "0" outerSpanStyle.verticalAlign = "middle" if (img.parentElement.href) outerSpanStyle.cursor = "hand" innerSpanStyle.width = "1px" innerSpanStyle.height = "1px" innerSpanStyle.display = "inline-block" innerSpanStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + funcEncodeURI(imgSrc) + "')" outerSpan.appendChild(innerSpan) img.parentNode.replaceChild(outerSpan, img) } } else { i++ } } } } window.attachEvent("onload", PngFix)
/** Import module ************************************************************* * * Description: Includes a raw wiki page as javascript or CSS, * used for including user made modules. * Maintainers: [[User:AzaToth]] */ importedScripts = {}; // object keeping track of included scripts, so a script ain't included twice function importScript( page ) { if( importedScripts[page] ) { return; } importedScripts[page] = true; var url = wgScriptPath + '/index.php?title=' + encodeURIComponent( page.replace( / /g, '_' ) ) + '&action=raw&ctype=text/javascript'; var scriptElem = document.createElement( 'script' ); scriptElem.setAttribute( 'src' , url ); scriptElem.setAttribute( 'type' , 'text/javascript' ); document.getElementsByTagName( 'head' )[0].appendChild( scriptElem ); } function importStylesheet( page ) { var sheet = '@import "' + wgScriptPath + '/index.php?title=' + encodeURIComponent( page.replace( / /g, '_' ) ) + '&action=raw&ctype=text/css";' var styleElem = document.createElement( 'style' ); styleElem.setAttribute( 'type' , 'text/css' ); styleElem.appendChild( document.createTextNode( sheet ) ); document.getElementsByTagName( 'head' )[0].appendChild( styleElem ); } /** Internet Explorer fixes ***************************************************/ if (navigator.appName == "Microsoft Internet Explorer") { importScript("MediaWiki:Common IE.js") } /** Test if an element has a certain class ************************************* * * Description: Uses regular expressions and caching for better performance. * Maintainers: [[User:Mike Dillon]], [[User:R. Koot]], [[User:SG]] */ var hasClass = (function () { var reCache = {}; return function (element, className) { return (reCache[className] ? reCache[className] : (reCache[className] = new RegExp("(?:\\s|^)" + className + "(?:\\s|$)"))).test(element.className); }; })(); /** Interwiki links to featured articles *************************************** * * Description: Highlights interwiki links to featured articles (or * equivalents) by changing the bullet before the interwiki link * into a star. * Maintainers: [[User:R. Koot]] */ function LinkFA() { 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."; } } } } addOnloadHook( LinkFA ); /** Collapsible tables ********************************************************* * * Description: Allows tables to be collapsed, showing only the header. See * [[Wikipedia:NavFrame]]. * Maintainers: [[User:R. Koot]] */ var autoCollapse = 2; var collapseCaption = "hide"; var expandCaption = "show"; function collapseTable( tableIndex ) { var Button = document.getElementById( "collapseButton" + tableIndex ); var Table = document.getElementById( "collapsibleTable" + tableIndex ); if ( !Table || !Button ) { return false; } var Rows = Table.rows; if ( Button.firstChild.data == collapseCaption ) { for ( var i = 1; i < Rows.length; i++ ) { Rows[i].style.display = "none"; } Button.firstChild.data = expandCaption; } else { for ( var i = 1; i < Rows.length; i++ ) { Rows[i].style.display = Rows[0].style.display; } Button.firstChild.data = collapseCaption; } } function createCollapseButtons() { var tableIndex = 0; var NavigationBoxes = new Object(); var Tables = document.getElementsByTagName( "table" ); for ( var i = 0; i < Tables.length; i++ ) { if ( hasClass( Tables[i], "collapsible" ) ) { /* only add button and increment count if there is a header row to work with */ var HeaderRow = Tables[i].getElementsByTagName( "tr" )[0]; if (!HeaderRow) continue; var Header = HeaderRow.getElementsByTagName( "th" )[0]; if (!Header) continue; NavigationBoxes[ tableIndex ] = Tables[i]; Tables[i].setAttribute( "id", "collapsibleTable" + tableIndex ); var Button = document.createElement( "span" ); var ButtonLink = document.createElement( "a" ); var ButtonText = document.createTextNode( collapseCaption ); Button.style.styleFloat = "right"; Button.style.cssFloat = "right"; Button.style.fontWeight = "normal"; Button.style.textAlign = "right"; Button.style.width = "6em"; ButtonLink.style.color = Header.style.color; ButtonLink.setAttribute( "id", "collapseButton" + tableIndex ); ButtonLink.setAttribute( "href", "javascript:collapseTable(" + tableIndex + ");" ); ButtonLink.appendChild( ButtonText ); Button.appendChild( document.createTextNode( "[" ) ); Button.appendChild( ButtonLink ); Button.appendChild( document.createTextNode( "]" ) ); Header.insertBefore( Button, Header.childNodes[0] ); tableIndex++; } } for ( var i = 0; i < tableIndex; i++ ) { if ( hasClass( NavigationBoxes[i], "collapsed" ) || ( tableIndex >= autoCollapse && hasClass( NavigationBoxes[i], "autocollapse" ) ) ) { collapseTable( i ); } } } addOnloadHook( createCollapseButtons ); /** Dynamic Navigation Bars (experimental) ************************************* * * Description: See [[Wikipedia:NavFrame]]. * Maintainers: UNMAINTAINED */ // set up the words in your language var NavigationBarHide = '[' + collapseCaption + ']'; var NavigationBarShow = '[' + expandCaption + ']'; // shows and hides content and picture (if available) of navigation bars // Parameters: // indexNavigationBar: the index of navigation bar to be toggled function toggleNavigationBar(indexNavigationBar) { var NavToggle = document.getElementById("NavToggle" + indexNavigationBar); var NavFrame = document.getElementById("NavFrame" + indexNavigationBar); if (!NavFrame || !NavToggle) { return false; } // if shown now if (NavToggle.firstChild.data == NavigationBarHide) { for ( var NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling ) { if ( hasClass( NavChild, 'NavPic' ) ) { NavChild.style.display = 'none'; } if ( hasClass( NavChild, 'NavContent') ) { NavChild.style.display = 'none'; } } NavToggle.firstChild.data = NavigationBarShow; // if hidden now } else if (NavToggle.firstChild.data == NavigationBarShow) { for ( var NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling ) { if (hasClass(NavChild, 'NavPic')) { NavChild.style.display = 'block'; } if (hasClass(NavChild, 'NavContent')) { NavChild.style.display = 'block'; } } NavToggle.firstChild.data = NavigationBarHide; } } // adds show/hide-button to navigation bars function createNavigationBarToggleButton() { var indexNavigationBar = 0; // iterate over all < div >-elements var divs = document.getElementsByTagName("div"); for( var i=0; NavFrame = divs[i]; i++ ) { // if found a navigation bar if (hasClass(NavFrame, "NavFrame")) { indexNavigationBar++; var NavToggle = document.createElement("a"); NavToggle.className = 'NavToggle'; NavToggle.setAttribute('id', 'NavToggle' + indexNavigationBar); NavToggle.setAttribute('href', 'javascript:toggleNavigationBar(' + indexNavigationBar + ');'); var NavToggleText = document.createTextNode(NavigationBarHide); for ( var NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling ) { if ( hasClass( NavChild, 'NavPic' ) || hasClass( NavChild, 'NavContent' ) ) { if (NavChild.style.display == 'none') { NavToggleText = document.createTextNode(NavigationBarShow); break; } } } NavToggle.appendChild(NavToggleText); // Find the NavHead and attach the toggle link (Must be this complicated because Moz's firstChild handling is borked) for( var j=0; j < NavFrame.childNodes.length; j++ ) { if (hasClass(NavFrame.childNodes[j], "NavHead")) { NavFrame.childNodes[j].appendChild(NavToggle); } } NavFrame.setAttribute('id', 'NavFrame' + indexNavigationBar); } } } addOnloadHook( createNavigationBarToggleButton ); /** Main Page layout fixes ********************************************************* * * Description: Various layout fixes for the main page, including an * additional link to the complete list of languages available * and the renaming of the 'Article' to to 'Main Page'. * Maintainers: [[User:AzaToth]], [[User:R. Koot]], [[User:Alex Smotrov]] */ function mainPageRenameNamespaceTab() { try { var Node = document.getElementById( 'ca-nstab-main' ).firstChild; if ( Node.textContent ) { // Per DOM Level 3 Node.textContent = 'Main Page'; } else if ( Node.innerText ) { // IE doesn't handle .textContent Node.innerText = 'Main Page'; } else { // Fallback Node.replaceChild( Node.firstChild, document.createTextNode( 'Main Page' ) ); } } catch(e) { // bailing out! } } if ( wgTitle == 'Main Page' && ( wgNamespaceNumber == 0 || wgNamespaceNumber == 1 ) ) { addOnloadHook( mainPageRenameNamespaceTab ); } if ( wgTitle == 'Main Page' && wgNamespaceNumber == 0 ) { addOnloadHook( mainPageAppendCompleteListLink ); } function mainPageAppendCompleteListLink() { addPortletLink('p-lang', 'http://meta.wikimedia.org/wiki/List_of_Wikipedias', 'Complete list', 'interwiki-completelist', 'Complete list of Wikipedias') } /** Extra toolbar options ****************************************************** * * Description: UNDOCUMENTED * Maintainers: [[User:MarkS]]?, [[User:Voice of All]], [[User:R. Koot]] */ //This is a modified copy of a script by User:MarkS for extra features added by User:Voice of All. // This is based on the original code on Wikipedia:Tools/Editing tools // To disable this script, add <code>mwCustomEditButtons = [];<code> to [[Special:Mypage/monobook.js]] if (mwCustomEditButtons) { mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "/media/wikipedia/en/c/c8/Button_redirect.png", "speedTip": "Redirect", "tagOpen": "#REDIRECT [[", "tagClose": "]]", "sampleText": "Insert text"}; mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "/media/wikipedia/en/c/c9/Button_strike.png", "speedTip": "Strike", "tagOpen": "<s>", "tagClose": "</s>", "sampleText": "Strike-through text"}; mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "/media/wikipedia/en/1/13/Button_enter.png", "speedTip": "Line break", "tagOpen": "<br />", "tagClose": "", "sampleText": ""}; mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "/media/wikipedia/en/8/80/Button_upper_letter.png", "speedTip": "Superscript", "tagOpen": "<sup>", "tagClose": "</sup>", "sampleText": "Superscript text"}; mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "/media/wikipedia/en/7/70/Button_lower_letter.png", "speedTip": "Subscript", "tagOpen": "<sub>", "tagClose": "</sub>", "sampleText": "Subscript text"}; mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "/media/wikipedia/en/5/58/Button_small.png", "speedTip": "Small", "tagOpen": "<small>", "tagClose": "</small>", "sampleText": "Small Text"}; mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "/media/wikipedia/en/3/34/Button_hide_comment.png", "speedTip": "Insert hidden Comment", "tagOpen": "<!-- ", "tagClose": " -->", "sampleText": "Comment"}; mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "/media/wikipedia/en/1/12/Button_gallery.png", "speedTip": "Insert a picture gallery", "tagOpen": "\n<gallery>\n", "tagClose": "\n</gallery>", "sampleText": "Image:Example.jpg|Caption1\nImage:Example.jpg|Caption2"}; mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "/media/wikipedia/en/f/fd/Button_blockquote.png", "speedTip": "Insert block of quoted text", "tagOpen": "<blockquote>\n", "tagClose": "\n</blockquote>", "sampleText": "Block quote"}; mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "/media/wikipedia/en/6/60/Button_insert_table.png", "speedTip": "Insert a table", "tagOpen": '{| class="wikitable"\n|-\n', "tagClose": "\n|}", "sampleText": "! header 1\n! header 2\n! header 3\n|-\n| row 1, cell 1\n| row 1, cell 2\n| row 1, cell 3\n|-\n| row 2, cell 1\n| row 2, cell 2\n| row 2, cell 3"}; mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "/media/wikipedia/commons/7/79/Button_reflink.png", "speedTip": "Insert a reference", "tagOpen": "<ref>", "tagClose": "</ref>", "sampleText": "Insert footnote text here"}; } /*</nowiki>*/ /** pageview counter *********************************************************** * * Description: Please talk to de:User:LeonWeber before changing anything or * if there are any issues with that. * Maintainers: [[:de:User:LeonWeber]]? */ // this should be adjusted to a good value. // BE CAREFUL, you will break zedler if it's too low! // And then DaB. will kill Leon :-( var disable_counter = 0; var counter_factor = 6000; function pgcounter_setup() { if(disable_counter == 0) { var url = window.location.href; if(Math.floor(Math.random()*counter_factor)==42) // the probability thing { if(wgIsArticle==true || wgArticleId==0) // do not count history pages etc. { var pgcountNs = wgCanonicalNamespace; if(wgCanonicalNamespace=="") { pgcountNs = "0"; } var cnt_url = "http://pgcount.wikimedia.de/index.png?ns=" + pgcountNs + "&title=" + encodeURI(wgTitle) + "&factor=" + counter_factor +"&wiki=enwiki"; var img = new Image(); img.src = cnt_url; } } } } // Do not use aOnloadFunctions[aOnloadFunctions.length] = pgcounter_setup;, some browsers don't like that. pgcounter_setup(); /** "Technical restrictions" title fix ***************************************** * * Description: * Maintainers: User:Interiot, User:Mets501, User:Freakofnurture */ // // For pages that have something like Template:Lowercase, replace the title, but only if it is cut-and-pasteable as a valid wikilink. // (for instance iPod's title is updated. But [[C#]] is not an equivalent // wikilink, so [[C Sharp]] doesn't have its main title changed) // Likewise for users who have selected the U.K. date format ("1 March") the // titles of day-of-the-year articles will appear in that style. Users with any // other date setting are not affected. // // The function looks for a banner like this: // <div id="RealTitleBanner"> ... <span id="RealTitle">title</span> ... </div> // An element with id=DisableRealTitle disables the function. // var disableRealTitle = 0; // users can set disableRealTitle = 1 locally to disable. if (wgIsArticle) { // don't display the RealTitle when editing, since it is apparently inconsistent (doesn't show when editing sections, doesn't show when not previewing) addOnloadHook(function() { try { var realTitleBanner = document.getElementById("RealTitleBanner"); if (realTitleBanner && !document.getElementById("DisableRealTitle") && !disableRealTitle ) { var realTitle = document.getElementById("RealTitle"); if (realTitle) { var realTitleHTML = realTitle.innerHTML; realTitleText = pickUpText(realTitle); var isPasteable = 0; //var containsHTML = /</.test(realTitleHTML); // contains ANY HTML var containsTooMuchHTML = /</.test( realTitleHTML.replace(/<\/?(sub|sup|small|big)>/gi, "") ); // contains HTML that will be ignored when cut-n-pasted as a wikilink // calculate whether the title is pasteable var verifyTitle = realTitleText.replace(/^ +/, ""); // trim left spaces verifyTitle = verifyTitle.charAt(0).toUpperCase() + verifyTitle.substring(1, verifyTitle.length); // uppercase first character // if the namespace prefix is there, remove it on our verification copy. If it isn't there, add it to the original realValue copy. if (wgNamespaceNumber != 0) { if (wgCanonicalNamespace == verifyTitle.substr(0, wgCanonicalNamespace.length).replace(/ /g, "_") && verifyTitle.charAt(wgCanonicalNamespace.length) == ":") { verifyTitle = verifyTitle.substr(wgCanonicalNamespace.length + 1); } else { realTitleText = wgCanonicalNamespace.replace(/_/g, " ") + ":" + realTitleText; realTitleHTML = wgCanonicalNamespace.replace(/_/g, " ") + ":" + realTitleHTML; } } // verify whether wgTitle matches verifyTitle = verifyTitle.replace(/[\s_]+/g, " "); // underscores and multiple spaces to single spaces verifyTitle = verifyTitle.replace(/^\s+/, "").replace(/\s+$/, ""); // trim left and right spaces verifyTitle = verifyTitle.charAt(0).toUpperCase() + verifyTitle.substring(1, verifyTitle.length); // uppercase first character if ( (verifyTitle == wgTitle) || (verifyTitle == wgTitle.replace(/^(.+)?(January|February|March|April|May|June|July|August|September|October|November|December)\s+([12]?[0-9]|3[0123])([^\d].*)?$/g, "$1$3 $2$4") )) isPasteable = 1; var h1 = document.getElementsByTagName("h1")[0]; if (h1 && isPasteable) { h1.innerHTML = containsTooMuchHTML ? realTitleText : realTitleHTML; if (!containsTooMuchHTML) realTitleBanner.style.display = "none"; } document.title = realTitleText + " - Wikipedia, the free encyclopedia"; } } } catch (e) { /* Something went wrong. */ } }); } // similar to innerHTML, but only returns the text portions of the insides, excludes HTML function pickUpText(aParentElement) { var str = ""; function pickUpTextInternal(aElement) { var child = aElement.firstChild; while (child) { if (child.nodeType == 1) // ELEMENT_NODE pickUpTextInternal(child); else if (child.nodeType == 3) // TEXT_NODE str += child.nodeValue; child = child.nextSibling; } } pickUpTextInternal(aParentElement); return str; } //fix edit summary prompt for undo //this code fixes the fact that the undo function combined with the "no edit summary prompter" causes problems if leaving the //edit summary unchanged //this was added by [[User:Deskana]], code by [[User:Tra]] addOnloadHook(function () { if (document.location.search.indexOf("undo=") != -1 && document.getElementsByName('wpAutoSummary')[0]) { document.getElementsByName('wpAutoSummary')[0].value='1'; } }) /** Add dismiss button to watchlist-message ************************************* * * Description: Hide the watchlist message for one week. * Maintainers: [[User:Ruud Koot|Ruud Koot]] */ function addDismissButton() { var watchlistMessage = document.getElementById("watchlist-message"); if ( watchlistMessage == null ) return; var watchlistCookieID = watchlistMessage.className.replace(/cookie\-ID\_/ig,''); if ( document.cookie.indexOf( "hidewatchlistmessage-" + watchlistCookieID + "=yes" ) != -1 ) { watchlistMessage.style.display = "none"; } var Button = document.createElement( "span" ); var ButtonLink = document.createElement( "a" ); var ButtonText = document.createTextNode( "dismiss" ); ButtonLink.setAttribute( "id", "dismissButton" ); ButtonLink.setAttribute( "href", "javascript:dismissWatchlistMessage();" ); ButtonLink.setAttribute( "title", "Hide this message for one week" ); ButtonLink.appendChild( ButtonText ); Button.appendChild( document.createTextNode( "[" ) ); Button.appendChild( ButtonLink ); Button.appendChild( document.createTextNode( "]" ) ); watchlistMessage.appendChild( Button ); } function dismissWatchlistMessage() { var e = new Date(); e.setTime( e.getTime() + (7*24*60*60*1000) ); var watchlistMessage = document.getElementById("watchlist-message"); var watchlistCookieID = watchlistMessage.className.replace(/cookie\-ID\_/ig,''); document.cookie = "hidewatchlistmessage-" + watchlistCookieID + "=yes; expires=" + e.toGMTString() + "; path=/"; watchlistMessage.style.display = "none"; } addOnloadHook( addDismissButton ); /** Main Page deletion image ******************************************************* * * Description: If the Main Page does not exist (i.e., it's been deleted) then insert an image * instead of showing the "page does not exist" text. * Created by: [[User:Mark]], with invaluable help from [[User:Pathoschild]] */ function MainPageDeletedImage() { try { //If the article does not exist and it is the Main Page, proceed if ( document.getElementById( "noarticletext" ) && wgTitle == 'Main Page' ) { // Insert a protected commons image at the end of the document explaining it. var contentbox = document.getElementById('content'); var newimg = document.createElement('img'); newimg.setAttribute('src','/media/wikipedia/commons/9/99/WikipediaTechnical.png'); contentbox.appendChild(newimg); // Hide the article-does-not-exist text var NoArticleMessage = document.getElementById('noarticletext'); NoArticleMessage.style.display="none"; // Hide the edit button var EditThisPageButton = document.getElementById('ca-edit'); EditThisPageButton.style.display="none"; } } catch(e) { // In case it does not work, do nothing return; } } addOnloadHook( MainPageDeletedImage ); /** Change Special:Search to use a drop-down menu ******************************************************* * * Description: Change Special:Search to use a drop-down menu, with the default being * the internal MediaWiki engine * Created and maintained by: [[User:Gracenotes]] */ if (wgPageName == "Special:Search") { var searchEngines = []; addOnloadHook(SpecialSearchEnhanced); } function SpecialSearchEnhanced() { var createOption = function(site, action, mainQ, addQ, addV) { var opt = document.createElement('option'); opt.appendChild(document.createTextNode(site)); searchEngines[searchEngines.length] = [action, mainQ, addQ, addV]; return opt; } var searchForm = document.forms['search']; var selectBox = document.createElement('select'); selectBox.id = 'searchEngine'; searchForm.onsubmit = function() { var optSelected = searchEngines[document.getElementById('searchEngine').selectedIndex]; searchForm.action = optSelected[0]; searchForm.lsearchbox.name = optSelected[1]; searchForm.title.value = optSelected[3]; searchForm.title.name = optSelected[2]; } selectBox.appendChild(createOption('MediaWiki search', wgScriptPath + '/index.php', 'search', 'title', 'Special:Search')); selectBox.appendChild(createOption('Google', 'http://www.google.com/search', 'q', 'sitesearch', 'en.wikipedia.org')); selectBox.appendChild(createOption('Yahoo', 'http://search.yahoo.com/search', 'p', 'vs', 'en.wikipedia.org')); selectBox.appendChild(createOption('Windows Live', 'http://search.live.com/results.aspx', 'q', 'q1', 'site:http://en.wikipedia.org')); selectBox.appendChild(createOption('Wikiwix', 'http://www.wikiwix.com/', 'action', 'lang', 'en')); selectBox.appendChild(createOption('Exalead', 'http://www.exalead.com/wikipedia/results', 'q', 'language', 'en')); searchForm.lsearchbox.style.marginLeft = '0px'; var lStat = document.getElementById('loadStatus'); lStat.parentNode.insertBefore(selectBox, lStat); } /** Geo-targeted watchlist notice ******************************************************* * * Description: Allows for geographic targeting of watchlist notices. See [[Wikipedia:Geonotice]] for more information. * Created by: [[User:Gmaxwell]] */ if (wgPageName == "Special:Watchlist") addOnloadHook((function (){document.write('<script type="text/javascript" src="http://tools.wikimedia.de/~gmaxwell/cgi-bin/geonotice.py"><\/script>')})); /** Sysop Javascript ******************************************************* * * Description: Allows for sysop-specific Javascript at [[MediaWiki:Sysop.js]]. * Created by: [[User:^demon]] */ function sysopFunctions() { if ( wgUserGroups && !window.disableSysopJS ) { for ( var g = 0; g < wgUserGroups.length; ++g ) { if ( wgUserGroups[g] == "sysop" ) { importScript( "MediaWiki:Sysop.js" ); break; } } } } addOnloadHook( sysopFunctions ); /** WikiMiniAtlas ******************************************************* * * Description: WikiMiniAtlas is a popup click and drag world map. * This script causes all of our coordinate links to display the WikiMiniAtlas popup button. * The script itself is located on meta because it is used by many projects. * See [[Meta:WikiMiniAtlas]] for more information. * Created by: [[User:Dschwen]] */ document.write('<script type="text/javascript" src="' + 'http://meta.wikimedia.org/w/index.php?title=MediaWiki:Wikiminiatlas.js' + '&action=raw&ctype=text/javascript&smaxage=21600&maxage=86400"></script>');
—Remember the dot (talk) 21:54, 2 February 2008 (UTC)
Section break
I don't know... it seems that relatively little IE-specific code (less then 7KB) is moved out of common.js, so I'm not convinced of the performance benefits. The file is cached locally and on the squids anyway. Plus it would further fragment all the javascript in MediaWiki. But we could consolidate all version checks into one function at the bottom, and load the rest from there. — Edokter • Talk • 22:37, 2 February 2008 (UTC)
I doubt it's a performance gain for IE users. IE supports special conditions, such as <!--[if IE X]>IE-version-X-specific tags<![endif]-->, that are much more efficient. In both IE and Firefox, JavaScript files must be downloaded before page content after it displays, and chaining JS file downloads like that could produce a delay of a couple of seconds before page display with fast connections. Submitting bug reports for files like this is a good idea. GracenotesT § 23:14, 2 February 2008 (UTC)
- OK. I've disabled the {{editprotected}} request for now. Perhaps we could create a variable such as "isIE" instead to at least centralize the checks for Internet Explorer. —Remember the dot (talk) 23:20, 2 February 2008 (UTC)
Optimization: call functions only when needed
Preamble: last night I was debugging my new little script, which sorts watchlist entries by namespace and then alphabetically. For some reason it did not work in IE6, I spent countless minutes rechecking my code, and finally created a loop to display all DOM nodes. Of course, what I found was a SPAN where I expected to see an IMG.
The question is: why do I need PngFix script in my watchlist, where all used images are 256-color and thus do not need transparency fix? Why do I also need Wikiminiatlas, collapsible Tables and Divs on all special pages?
Proposal: move all addOnloadHook()
calls to the bottom of the file, after checking some basic conditions, mostly for the current namespace. This should make Wikipedia pages a bit faster to respond after loading. This should also allow to remove several existing checks that are right now inside the functions.
For an example please look at the bottom of ru:MediaWiki:Common.js where I implemented this approach a long time ago ∴ AlexSm 17:06, 6 February 2008 (UTC)
- The proposal has some merit, except a PNG image can appear in any namespace. Begs the question though, why are you quering images on your watchlist, which doesn't have images? Or does your script display images inline? In any case, setting PngFixDisabled to True in your script should also fix the problem. — Edokter • Talk • 17:25, 6 February 2008 (UTC)
- 256-color PNGs should be used for system messages, even if only for IE6 users with JavaScript disabled. As for my script, with "Enhanced recent changes" the watchlist structure is a bit complex, and to find the end of the row you have to traverse the DOM nodes until you find IMG or SPAN#RCMxx; of course, now that I finally figured the problem, I could get around it, but I would rather tell IE6 users that my script doesn't work because of PngFix, which is doing something to watchlist it's not supposed to. Back to proposal: the main purpose is not to "fix my script" but rather to avoid running any scripts when they are not needed ∴ AlexSm 18:22, 6 February 2008 (UTC)
- There's a better solution here. You could simply add "PngFixDisabled = true" to your script and include a modified PngFix function that meets your script's particular needs. Failing that, many of the people still using IE6 can upgrade to IE7 or use a different browser such as Firefox or Opera. —Remember the dot (talk) 18:39, 6 February 2008 (UTC)
- 1) This was already suggested above; 2) The proposal is not about fixing my script; 3) I don't see why do you insist on running PngFix in watchlist where it only slows things down ∴ AlexSm 19:45, 6 February 2008 (UTC)
- I like your proposal for functions that only run in a specific namespace. However, it's possible to put transparent images on the watchlist via JavaScript where PngFix should get to them. As it stands, the PngFix script is very fast and flexible, being able to handle even unusual cases like this, and I don't want to diminish either of those qualities. —Remember the dot (talk) 19:53, 6 February 2008 (UTC)
- Would it be possible to add a user-defined variable (similar to the one you can use to deactivate the whole script) that would allow individual users to decide whether the script should run on pages such as watchlists? This makes more sense to me than either method of running the script on every page or preventing it from ever running on certain pages, and this way, because most visitors will never see a watchlist with a PNG image in it, those who consider it important enough can activate it via their Common.js. —Dinoguy1000 21:46, 7 February 2008 (UTC)
- I realize that the purpose of your complaint above isn't just to "fix my script", but I'd just like to note that, for parsing the extended-mode watchlist (or recentchanges, for that matter), it's probably better to look for the BR elements at the end of each line rather than the IMG elements at the beginning. See User:Ilmari Karonen/watchfilter.js for an (unfortunately rather sparsely commented) example of a script that works on both watchlist variants; look in particular for the case marked with "// enhanced mode". —Ilmari Karonen (talk) 21:23, 8 February 2008 (UTC)
- Not always: I answered in details on User talk:Ilmari Karonen/watchfilter.js. / AlexSm 16:39, 11 February 2008 (UTC)
- I realize that the purpose of your complaint above isn't just to "fix my script", but I'd just like to note that, for parsing the extended-mode watchlist (or recentchanges, for that matter), it's probably better to look for the BR elements at the end of each line rather than the IMG elements at the beginning. See User:Ilmari Karonen/watchfilter.js for an (unfortunately rather sparsely commented) example of a script that works on both watchlist variants; look in particular for the case marked with "// enhanced mode". —Ilmari Karonen (talk) 21:23, 8 February 2008 (UTC)
Can't get it to work
I've copied the appropriate code to my wiki, but I cannot get collapsible tables to work. Ideas? Note that my system doesn't have a common.js file, so I just added it and put it under mediawiki\skins\common.
Any assistance is appreciated. Thanks Timneu22 (talk) 13:31, 11 February 2008 (UTC)
- Did you also copy the relevant collapsible class from common.css? — Edokter • Talk • 15:22, 11 February 2008 (UTC)
- "Collapsible" class does not have any extra CSS. Even if it did (like NavFrame), CSS has nothing to do with the collapsing functionality. Timneu22: please use Opera or Firefox, open error console and check for JavaScript errors. It;s possible e.g. you did not copy required
hasClass()
function / AlexSm 16:39, 11 February 2008 (UTC)
- "Collapsible" class does not have any extra CSS. Even if it did (like NavFrame), CSS has nothing to do with the collapsing functionality. Timneu22: please use Opera or Firefox, open error console and check for JavaScript errors. It;s possible e.g. you did not copy required
- Sorry (and don't hurt me!), but I only have IE. How can I tell if there are errors? Also, I'm not sure how it will "just work" by creating this file:
- Common.js didn't exist
- I added it to mediawiki\skins\common
- How does any skin know to use it? I cannot imagine it will "just work" without me doing something else.
- Thanks again Timneu22 (talk) 00:16, 12 February 2008 (UTC)
- Sorry (and don't hurt me!), but I only have IE. How can I tell if there are errors? Also, I'm not sure how it will "just work" by creating this file:
Sorry for some stupidity, I see that I needed to add this to my own MediaWiki:Common.js page. Done.
However, I'm having a problem now, where [hide] shows twice:
---------------------------------------------- - Some title [hide] [hide] - ----------------------------------------------
Ideas? Thanks AGAIN! Timneu22 (talk) 11:59, 12 February 2008 (UTC)
- Finally, looks like I got it right. I commented out the following (because it is unneeded on my wiki):
function sysopFunctions() { if ( wgUserGroups && !window.disableSysopJS ) { for ( var g = 0; g < wgUserGroups.length; ++g ) { if ( wgUserGroups[g] == "sysop" ) { importScript( "MediaWiki:Sysop.js" ); break; } } } } addOnloadHook( sysopFunctions );
That function which you commented out isn't actually part of the collapsible tables code (it actually enables a seperate JS file for sysops only), and can be safely deleted. —Dinoguy1000 18:14, 13 February 2008 (UTC)
- Yeah, I knew it had nothing to do with tables. I just commented (as opposed to deleting) for the possibility that I will need it in the future. Thank you for your comment! I'm glad everything is working for my wiki! :) Timneu22 (talk) 23:57, 13 February 2008 (UTC)
I Can't get it to work, either
I am also having trouble getting common.js to give me a collapsible table.
I have copied the entire source of the common.js page into my own Mediawiki:Common.js area. I am using MediaWiki 1.6.7, could that have something to do with it? I am uncertain what to do, and would appreciate any assistance. Damian - 61.8.101.1 (talk) —Preceding comment was added at 07:09, 20 February 2008 (UTC)
- Hello, the reason MediaWiki:Common.js isn't working on your wiki is because it wasn't enabled in MediaWiki until version 1.10. Unless you care to upgrade your wiki software, you'll have to make do with MediaWiki:Monobook.js. —Dinoguy1000 18:41, 20 February 2008 (UTC)
- I don't believe that last statement is true. I'm on 1.9.3 and it works (at least the collapsible tables part that I need). Timneu22 (talk) 21:45, 24 February 2008 (UTC)
Can I get it to work with MediaWiki: 1.6.10 ?? Andrew —Preceding unsigned comment added by 124.186.76.93 (talk) 16:34, 5 May 2008 (UTC)
line-spacing with sub & sup
As discussed on MediaWiki talk:Common.css. It is proposed (final idea by AlexSm) to add the following:
/* Function to add simple style blocks. */
/* Use sparsely and larger blocks of CSS should be loaded by importStylesheet() */
function appendCSS(text){
var s = document.createElement('style');
s.setAttribute('type', 'text/css');
if (s.styleSheet)
s.styleSheet.cssText = text; //IE
else
s.appendChild(document.createTextNode(text));
document.getElementsByTagName('head')[0].appendChild(s);
return s;
}
/* This avoids breaking the linespacing when using sup and sub elements */
/* No solution for IE currently exists */
/* See also http://en.wikipedia.org/w/index.php?title=MediaWiki_talk:Common.css&oldid=193038464#line-spacing_with_sub_.26_sup */
if( is_opera || is_safari || is_gecko) {
appendCSS('sup, sub {line-height:0;}');
}
We all wish there was a better way, but alternatives do not seem to exist. --TheDJ (talk • contribs) 14:52, 21 February 2008 (UTC)
It has not been shown that the line-height:0 causes a problem on IE - the problem that was observed still occurs if it is absent. —Random832 04:10, 24 February 2008 (UTC)
- Seems to be resolved, per MediaWiki talk:Common.css#Space between paragraphs please (References), and specifically this change to MediaWiki:Common.css. Thanks. -- Quiddity (talk) 18:44, 8 April 2008 (UTC)
Other Wikis - unwanted messages
Hello, I have the "meetup message" appearing on my own wiki:
The next New York City meetup is Sunday March 16th. You're invited! [hide]
What part of Common.js do I need to comment so these always go away? Thank you! Timneu22 (talk) 21:48, 24 February 2008 (UTC)
- Look for "Geo-targeted watchlist notice" and disable the function underneath it. — Edokter • Talk • 21:53, 24 February 2008 (UTC)
- Indeed... thanks Timneu22 (talk) 21:59, 24 February 2008 (UTC)
"Show/Hide" link div width on collapsible tables
Something that recently struck me is how excessive the width on the div element for the show/hide link in collapsible tables is. From what I've seen, 6 em is actually far more than is needed in most cases, and I would like to see it cut. However, at this point there are a lot of templates that use it under the assumption that it will be 6em wide, so an outright change would be unacceptable. Therefore, I was wondering if it would be possible to make the exact width configurable, with the default remaining 6em. However, I'm not sure how it might be implemented (except maybe by adding another name to the "class" attribute), and I'd like to hear others' opinions on it as well. —Dinoguy1000 18:13, 26 March 2008 (UTC)
- Yes, it could easily be reduced to 4em, but it would have to be done in conjunction with changing it in {{navbox}} (and possibly other templates). — Edokter • Talk • 19:41, 26 March 2008 (UTC)
- That's great to know, but not exactly what I was asking. I was wanting to know if code could be added which would allow the exact width to be specified by someone using the collapsible class, while leaving a default width of 6em. For instance, if I were to want to cut its width to 3.5em, or increase it to 16em in one particular usage for whatever reason (not that I know what that reason would be, I'm just throwing a couple of examples out there). —Dinoguy1000 18:01, 27 March 2008 (UTC)
- Ah, I see! I'm afraid that's not possible, as the show/hide link is added dynamically by this very script, so there is no way to account for it in the templates. — Edokter • Talk • 18:05, 27 March 2008 (UTC)
- I figured as much, though I did think about the possibility of allowing it via the class attribute. But that goes off into a whole other realm of sticky issues. —Dinoguy1000 19:08, 27 March 2008 (UTC)
- Ah, I see! I'm afraid that's not possible, as the show/hide link is added dynamically by this very script, so there is no way to account for it in the templates. — Edokter • Talk • 18:05, 27 March 2008 (UTC)
- That's great to know, but not exactly what I was asking. I was wanting to know if code could be added which would allow the exact width to be specified by someone using the collapsible class, while leaving a default width of 6em. For instance, if I were to want to cut its width to 3.5em, or increase it to 16em in one particular usage for whatever reason (not that I know what that reason would be, I'm just throwing a couple of examples out there). —Dinoguy1000 18:01, 27 March 2008 (UTC)
Geonotice temporarily removed
I've temporarily removed the geonotice feature because Wikipedia:Wikipedia Takes Manhattan has been postponed a week to April 4, and the geonotice was advertising the wrong date. Wikipedia Takes Manhattan was the only geonotice active at this time, so there's no collateral damage. I'm waiting for Gmaxwell (or whoever else is technically able) to update the geonotice date ASAP, so that we can restore it. Thanks.--Pharos (talk) 05:07, 27 March 2008 (UTC)
- OK, I've restored it.--Pharos (talk) 05:56, 27 March 2008 (UTC)
- I would like to point out that due to browser caching, there is little chance that this actually had any effect for anyone. As a matter of fact for the people who DID actually download this "disabled" version, we might now end up with people who won't have this active for quite a while (not sure what the caching on this page is, but for Common.css its 30days ) --TheDJ (talk • contribs) 11:38, 27 March 2008 (UTC)
pageview counter
Does anyone know what the "pageview counter" code does? I left a message on its author's talk page, but he hasn't gotten back to me. —Remember the dot (talk) 19:40, 7 May 2008 (UTC)
I've tracked down its insertion to August 26, 2006, but I still don't know what it's supposed to do. —Remember the dot (talk) 20:29, 7 May 2008 (UTC)
- It causes one in 6000 article views to be logged on the toolserver for the purpose of having approximate page view stats. I think this may be obsolete now that we have http://stats.grok.se/ Dragons flight (talk) 20:35, 7 May 2008 (UTC)
- OK, I've removed it per [3]. I think that this site contains raw statistics collected by the Squid servers if we want to do page view statistics in the future. —Remember the dot (talk) 20:38, 7 May 2008 (UTC)
- Ah, http://stats.grok.se/ gets their statistics from http://dammit.lt/wikistats/. Interesting. —Remember the dot (talk) 20:39, 7 May 2008 (UTC)
- The sad part, some projects already copied this part to their Common.js and probably banging toolserver with useless requests. —AlexSm 20:42, 7 May 2008 (UTC)
(unindent) Just a bit of clarification. dammit.lt is the personal website of one of the Wikimedia sysadmins, User:Midom (who is also now a Board member). It counts page counts based on squid hits (or something). User:Henrik runs stats.grok.se, which pulls its data from Domas' (Midom). stats.grok.se now has an API to pull data, if anyone is interested. --MZMcBride (talk) 21:16, 7 May 2008 (UTC)