MediaWiki talk:Common.js/Archive Jul 2007

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia

Link to subpages from the toolbox in certain namespaces[edit]

/***** subPagesLink ********
* Adds a link to subpages of current page
*
*  Maintainers: [[:he:משתמש:ערן]], [[User:Dschwen]]
*
*  JSconfig items: bool JSconfig.subPagesLink
*                       (true=enabled (default), false=disabled)
****/
var JSconfig =
{
subPagesLink : true
}

var subPagesLink =
{ 
//
// Translations of the menu item
//
i18n :
{
  'de': 'Unterseiten',
  'en': 'Subpages',    // default
  'es': 'Subpáginas',
  'fr': 'Sous-pages',
  'he': 'דפי משנה',
  'it': 'Sottopagine',
  'ru': 'Подстраницы'
},

install: function()
{
  // honor user configuration
  if( !JSconfig.subPagesLink ) return;

  if ( document.getElementById("t-whatlinkshere") 
       &&  wgNamespaceNumber != -2   // Media: (upcoming)
       &&  wgNamespaceNumber != -1   // Special:
       && wgNamespaceNumber != 6     // Image:
       &&  wgNamespaceNumber != 14   // Category:
     )
  {
   var subpagesText = subPagesLink.i18n[wgUserLanguage] || subPagesLink.i18n['en'];
   var subpagesLink ='/wiki/Special:Prefixindex/' + wgPageName +'/';

   addPortletLink( 'p-tb', subpagesLink, subpagesText, 't-subpages' );
  }
}
}
addOnloadHook(subPagesLink.install);

I tried to ask for other people's opinion on WP:VPT but nobody responded. The code is definitely working as it's already been in the commons equivalent of this page for quite a while now. Yonatan talk 17:34, 27 May 2007 (UTC)[reply]

This is not very useful in article space, which doesn't have/support subpages. —Ruud 17:54, 27 May 2007 (UTC)[reply]
It can be turned off for that namespace as well. Yonatan talk 18:28, 27 May 2007 (UTC)[reply]
I also think its usefulness is quite limited if the link always shows up, instead of only when there actually are any subpages. —Ruud 18:33, 27 May 2007 (UTC)[reply]
It isn't really doable to add a query that checks whether there are any subpages for every page loaded. Its usefulness isn't limited at all, it's good for anyone wanting to see the subpages of a certain page but doesn't wanna go around looking for how to do it. Yonatan talk 06:39, 29 May 2007 (UTC)[reply]
It should be doable if it is coded into MediaWiki. With the current implementation you have to know beforehand that there are subpages and it adds even more clutter to the toolbox in the large majority of the cases where there are none, or you simply don't care. That makes me doubt whether this should be enabled by default. I think the Village Pump would be a better place to gauge support for this. —Ruud 18:29, 29 May 2007 (UTC)[reply]
This will have trouble on the secure server because of the hard-coded use of "/wiki". That part can be fixed by using wgArticlePath and a replace of "$1". There could also be issues if wgPageName contains special characters, which could be solved by using "?title=" + encodeURIComponent(wgPageName) instead of the path-based version of Special:Prefixindex.
The lack of response on WP:VPT could mean that there isn't any interest in adding this (and it wouldn't be the first time, as evidenced by my proposals page); I personally think this one makes more sense as a user script, since it isn't the sort of thing that the majority of readers (i.e. anons) care about, only people who are involved enough in the project that they probably wouldn't mind changing monobook.js. Mike Dillon 18:38, 27 May 2007 (UTC)[reply]
I agree subpages link is useful, but since I already have it, and the suggested code is a bit bloated (i18n and stuff), personally I'd vote for leaving it a personal script and simply adding a good how-to into Wikipedia:SubpagesAlex Smotrov 18:25, 29 May 2007 (UTC)[reply]

Could be useful here as well. —Ruud 22:03, 29 May 2007 (UTC)[reply]

I have added it now, I'm 99.99% sure it won't affect anything on the page. AzaToth 22:28, 29 May 2007 (UTC)[reply]
Hmm.. it breaks the wikilinks. —Ruud 22:37, 29 May 2007 (UTC)[reply]
Please discuss things here before implementing them, if you are 99.99% sure, and it is uploaded to 100,000 people then statistically you are messing up 10 people. Better that 10 or 20 people become 99.99% sure. (H) 22:48, 29 May 2007 (UTC)[reply]

Overriding automatic deletion summaries for attack pages[edit]

In response to the suggestions made on WP:AN#Deletion summaries for attack pages, I wrote User:Ilmari Karonen/cleandelsummary.js. What it does is check if the MediaWiki-prefilled deletion summary contains a template such as {{db-attack}} and, if so, replaces the summary with one that doesn't contain any of the content being deleted. Assuming this does not cause any unexpected problems, would anyone oppose including such code here? —Ilmari Karonen (talk) 21:50, 6 June 2007 (UTC)[reply]

See two threads up. —Ruud 22:38, 6 June 2007 (UTC)[reply]
Assuming you mean #Administrator.js, if we do set up such a system this should obviously be placed there. In the mean time, the code is only nine lines (which isn't that much more than what the code to pull in an extra .js page would take anyway), and does absolutely nothing except on pages having action=delete. —Ilmari Karonen (talk) 23:55, 6 June 2007 (UTC)[reply]

Exalead search engine[edit]

I added Exalead's search engine. The idea has been floated at Village Pump and was not opposed. My experience is that users complaining about our search engine on OTRS are pleased with Exalead's solution. David.Monniaux 11:43, 8 June 2007 (UTC) [reply]

Navigation and general appearance[edit]

It might enhance the convenience of the page if the following was done for each script:

  1. Preface each one with //<span id="Script name"></span><source lang="JavaScript">. "Script name" is a simple description of the script.
  2. Added * Shortcut: [[MediaWiki:Common.js#Script name]] to each code description
  3. Ended each one with </source>

It should be mentioned, this does increase the byte count of the page a bit without enhancing the scripts' functionalities. This will make the page more navigable and allow the space between <source/> tags to make scripts more visibly separate. How does this idea sound? GracenotesT § 01:07, 15 June 2007 (UTC)[reply]

Sounds fine to me. If there are no objections, I'll go ahead an implement. AmiDaniel (talk) 02:19, 15 June 2007 (UTC)[reply]
This might be a good idea. But I wish somebody would also clean the code a little bit, removing unnecessary *************** lines, meaningless comments, etc. And there are so many places where the code could be shortened, making it easier to read at the same time ∴ Alex Smotrov 14:49, 15 June 2007 (UTC)[reply]

Help with a section please[edit]

Hello, I would like to include this section to a Common.js on another wiki, but somehow it does not work, is there any other thing I have to change, many thanks in advance, --birdy (:> )=| 23:47, 18 June 2007 (UTC)[reply]

 function mainPageAppendCompleteListLink() {
     try {
         var node = document.getElementById( "p-lang" )
                            .getElementsByTagName('div')[0]
                            .getElementsByTagName('ul')[0];
 
         var aNode = document.createElement( 'a' );
         var liNode = document.createElement( 'li' );
 
         aNode.appendChild( document.createTextNode( 'Complete list' ) );
         aNode.setAttribute( 'href' , 'http://meta.wikimedia.org/wiki/List_of_Wikipedias' );
         liNode.appendChild( aNode );
         liNode.className = 'interwiki-completelist';
         node.appendChild( liNode );
      } catch(e) {
        // lets just ignore what's happened
        return;
     }
 }
 
 if ( wgTitle == 'Main Page' && ( wgNamespaceNumber == 0 || wgNamespaceNumber == 1 ) ) {
        addOnloadHook( mainPageRenameNamespaceTab );
 }
 
 if ( wgTitle == 'Main Page' && wgNamespaceNumber == 0 ) {
        addOnloadHook( mainPageAppendCompleteListLink );
 }
If you're just taking this part, mainPageRenameNamespaceTab is going to be undefined. Title of you "Main Page" is probably different. If that doesn't help, give us a link to your code.
By the way, note to our admins: mainPageAppendCompleteListLink() should've used addPortletLink() ∴ Alex Smotrov 04:22, 19 June 2007 (UTC)[reply]
Well, they couldn't have used it at the time. That function was added to Common.js December 29th, 2006 (being a rewrite of some of the previous code, much of which was moved to per-page css), but the AddPortletLink() function was only added to wikibits.js January 13th, 2007 (before which, there were several other user-written and soemwhat random functions, like AddLILink() and AddLink()). You might suggest to User:Ruud_Koot that they rewrite it with AddPortletLink() though. --Splarka (rant) 07:28, 19 June 2007 (UTC)[reply]
Well, couldn't we interpret my note as "… since addPortletLink() was available" ;) Anyway, I put the suggestion below in a separate section ∴ Alex Smotrov 13:53, 19 June 2007 (UTC)[reply]
Thank You, here is the link http://de.wiktionary.org/wiki/MediaWiki:Common.js (the code is at the bottom), many thanks in advance, --birdy (:> )=| 11:32, 19 June 2007 (UTC)[reply]
Spacebirdy: you go to the main page of your project (de.wiktionary.org) and then view HTML source of that page. Somewhere at the top there is an inline script with a lot of useful variables. Then you can see that in your project you need the condition below ∴ Alex Smotrov 13:53, 19 June 2007 (UTC)[reply]
if (wgTitle == 'Hauptseite' && wgNamespaceNumber == 4)
   addOnloadHook(mainPageAppendCompleteListLink);
Hi Alex Smotrov, thank You very much for this, and for the hint with the variables, it works now, but for some reason it kills the link to the mainpage itself while one is on the mainpage :( I don't understand why, --birdy (:> )=| 15:05, 19 June 2007 (UTC)[reply]

How to install[edit]

This may be obvious to some, but others seem to find it difficult to know what this article is all about. Perhaps it would be handy to place a comment near the top of these messages spelling out that one should view it's source and past the contents into the MediaWiki:Common.js article/message at your mediawiki site. I can tell you that I felt a little dumb having spent a few days figuring out something this obvious which a simple comment might have told me. --D0li0 22:11, 21 June 2007 (UTC)[reply]

Likewise I feel dumb for not understanding anything you just said. —freak(talk) 22:14, 21 June 2007 (UTC)[reply]
This JavaScript code is not meant for installing on other sites. It is purpose-specific to English Wikipedia. What made you think that this is something you should install on another MediaWiki site? If there is something on the site leading people to think this code is ready-made for installation on other sites, it needs to be fixed. Mike Dillon 21:56, 23 June 2007 (UTC)[reply]

Request: mainPageAppendCompleteListLink() rewrite[edit]

I suggest rewriting this function as

function mainPageAppendCompleteListLink() {
 addPortletLink('p-lang', 'http://meta.wikimedia.org/wiki/List_of_Wikipedias', 
  'Complete list', 'interwiki-completelist', 'Complete list of Wikipedias');
 var lnk = document.getElementById('interwiki-completelist');
 if (lnk) lnk.style.fontWeight = 'bold';
}

and then also removing the code below from MediaWiki:Common.cssAlex Smotrov 13:53, 19 June 2007 (UTC)[reply]

/* Main page fixes */
.interwiki-completelist {
    font-weight: bold;
}
I agree with using addPortletLink but don't see why not to use CSS for the styling? —Ruud 19:33, 24 June 2007 (UTC)[reply]


The way I see it, global CSS should be used:
  • for common Mediawiki elements, which are present on almost any page, e.g. portlets, #bodyContent, etc.
  • for things that cannot be done using inline styles, e.g. child selectors, :hover, etc.
  • (maybe) for some templates that are used on a lot of pages
One element that appears on only one page imho doesn't deserve to be mentioned in global CSS file ∴ Alex Smotrov 20:23, 24 June 2007 (UTC)[reply]
I'd agree if this was something in the content-area (which could easily lead to an almost infinite number of CSS stylings) but I consider this link part of the MediaWiki-interface (which are quite finite in their number). Using CSS might have a (likely negligible) performance benefit, under the assumption the CSS class can be assigned to the element before it is added to the document tree. —Ruud 20:29, 24 June 2007 (UTC)[reply]
Well, if the code was moved into say MainPage.js… but since it's still here — okay, let it be CSS, since CSS there takes less space than Javascript here. P.S. Don't forget that 'interwiki-completelist' is going to be id now, not classAlex Smotrov 22:29, 27 June 2007 (UTC)[reply]

CSD Script[edit]

I've been hosting for some time now a CSD user script which adds a drop down list of CSD criteria next to the wpReason box on the deletion page (ie: admins only). Would there be any opposition to adding this to Common.js so all admins have access to it by default? Of course I'd like us to do some more testing so it doesn't break people, but so far it works in IE6/7, Firefox and Safari with no issues. The project page is here, if you wish to look for more information, including the code. In addition, we'd need to finalize the wording of the deletion rationales, since this would be used on such a large scale. Thanks, ^demon[omg plz] 14:25, 29 June 2007 (UTC)[reply]

I support this. – Steel 15:20, 29 June 2007 (UTC)[reply]
I don't mind but ONLY if inside Administrator.js (proposal above), the main file is big enough already ∴ Alex Smotrov 16:15, 29 June 2007 (UTC)[reply]