This is an archive of past discussions. 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 15 | Archive 16 | Archive 17 | Archive 18 | Archive 19 | Archive 20 | → | Archive 23 |
proposal it so add
if(wgServer == 'https://secure.wikimedia.org')
importScript( 'MediaWiki:Common.js/secure.js')
This changes any http links to interwiki or diffs on a page to links for the secure server. The script is originally User:Anakin101/alwayssecurewikipedia.js. — TheDJ ( talk • contribs) 20:45, 17 January 2010 (UTC)
http:\/\/([^\/]+?)\.
should be http:\/\/([^a-z0-9\-]+?)\.
, change (page ? page : 'wiki/')
to (page || 'wiki/')
, \/?
is unnecessary since browser automatically add this in (I think), if (sub === undefined) continue;
seems to be in the wrong place. There one question, should this be supporting old links? Wikibooks use to be en.wikibook.com (no s), wikipedia.com/wiki/ redirects to the English Wikipedia, meta-wiki was meta.wikipedia.org. —
Dispenser
07:43, 18 January 2010 (UTC)\/?(.*)$
" with e.g. "(\/[^?#]*|)([#?].*|)$
" in the regexps and append the value of m[4]
to the fixed URL unconditionally. Also, there should be some way (e.g. setting window.disableSecureLinks=true
in their monobook/vector.js) for users to turn this script off if they don't want it.Done code deployed. — TheDJ ( talk • contribs) 20:44, 21 January 2010 (UTC)
Up in the "WikiMiniAtlas" discussion it was mentioned that "(All our other special scripts are only loaded when needed.)." I'm getting ready to implement a lot of JavaScript on my Wiki and I was just curious if this was simply a reference to doing a quick getElementById existence check in addOnloadHook for each script, or if there is some other system in place that I don't know about. I'm basically just trying to make sure that if I have 100 scripts, I don't have to do 100 checks on every page load to see if any of them apply to that page.
--
Cogniac (
talk)
18:11, 29 January 2010 (UTC)
Wikimedia commons has the following function in their MediaWiki:Common.js. This is useful for doing feature preview links like timed text preview. Any objections to adding the following?
/** &withJS= URL parameter *******
* Allow to try custom scripts from MediaWiki space
* without editing [[Special:Mypage/monobook.js]]
*/
var extraJS = getParamValue("withJS");
if ( extraJS && extraJS.match("^MediaWiki:[^&<>=%]*\.js$") ) {
importScript(extraJS);
}
mdale ( talk) 22:42, 4 February 2010 (UTC)
.match()
part check what that code means and that.match()
part does exactly what it should.While, I'm sure that whoever runs http://toolserver.org/~para/geoip.fcgi is perfectly trustworthy it seems like a very weak link in the chain. Whereas scripts from Wikipedia have high cache values, publicly viewable edit histories, and notify many people when they are modified; making it likely that malicious changes can be reverted without too much damage; a modification to this script could pass unnoticed for quite some time. Are there any mechanisms in place to prevent this being horribly abused? Conrad. Irwin ( on wikt) 22:55, 4 February 2010 (UTC)
The hasClass function...variable...thing uses some fairly advanced JavaScript that I'm just trying to figure out. I'm assuming that the reason it is set up as a variable and not just straight "function hasClass(className)" is part of the caching optimization. But I'm not getting how it basically amounts to "var hasClass = ()();" with stuff happening inside the first pair of parentheses. I have no idea what the deal is with the two pairs of parentheses or why it relies on an anonymous function inside an anonymous function to do the work, and I'm looking for a basic explanation, if anyone would be so kind.
--
Cogniac (
talk)
21:19, 12 February 2010 (UTC)
reCache
and returns another function which is assigned to the name hasClass. Due to JavaScript's scoping rules reCache
is now only accessible from hasClass
, but it's value still persists over multiple invocations of hasClass
.I'm trying to implement some custom edit buttons on my Wiki. They work, but only when placed in Common.js. I cannot get them to work when they are placed on Common.js/edit.js like they are here. I stuck an alert() call in my Common.js/edit.js to see if it was even being loaded, and it's not. Comparing my wikibits.js with Wikipedia's wikibits.js, and thus my importScript() with Wikipedia's, I notice the following differences:
Could these subtle differences somehow be causing my problem?
--
Cogniac (
talk)
20:43, 26 February 2010 (UTC)
I asked on Help whether Collapsing could be extended to cover certain rows and columns only. Then I realized I hadn’t anything to do for the rest of the day and wrote the code myself. It may need further testing (and perhaps optimizing), but the basic cases are covered alright. Collapsing columns is especially helpful for en.m.wikipedia.org. Is there any chance getting this into common.js? — Christoph Päper 11:33, 6 March 2010 (UTC)
On a related note to collapsible rows and columns above, it would be nice to have a class ‘rank’ on one heading cell in a ‘sortable’ table that would result in the cells below it – if they contain only whitespace, digits and punctuation – bearing a dynamically generated rank number which is updated on sorting (and perhaps restored on sorting based on that very column, otherwise ‘rank’ should imply ‘unsortable’). The workaround with two tables side by side (inside a third one) is really ugly and fails with rows of different height. — Christoph Päper 15:21, 2 March 2010 (UTC)
This is essentially the same function but includes the # hash to not include #anchors when you getURLParamValues
function getURLParamValue( paramName, url)
{
if (typeof (url) == 'undefined' || url === null) url = document.location.href;
var cmdRe=RegExp( '[&?]' + paramName + '=([^&#]*)' ); // Stop at hash
var m=cmdRe.exec(url);
if (m && m.length > 1) return decodeURIComponent(m1]);
return null;
}
mdale ( talk) 20:41, 3 March 2010 (UTC)
Please see Wikipedia:Village_pump_(proposals)#Collapse_template_transclusion_list_in_Edit_view. I'm not quite sure if the script is ready - I had some problems last time I used it and had to uninstall. But is this reasonable in principle? Rd232 talk 20:00, 8 April 2010 (UTC)
I know we once blocked a system that iframed wikipedia for it's own purposes. There is now this "ad service" http://www.magic-banner-bot.com/ which inserts images into wikipedia. It cannot be disabled, uses an iframe and insert ads into the wikipedia content, without explaining why. I think such is grounds for blocking that via Javascript. What do others think ? — TheDJ ( talk • contribs) 00:35, 11 April 2010 (UTC)
The adding following code to Mediawiki:Common.js should do the trick:
if (document.referrer.indexOf("magic-banner-bot.com") != -1) { location.href = "http://en.wikipedia.org/?title=User:Chris_G/Leech_detected&action=render"; }
The user will see this page with instructions on how to navigate to Wikipedia directly (someone might want to that page to be a bit nicer/user friendly first though). I've tested the script and it works in Firefox + Opera, but if a Windows user would please check it in IE (the older the version the better :) ) that would be good. Javascript isn't my forte so if someone could please double check that it won't break the site etc that would be great (maybe we should move it into it's own function? make it easier to add more sites as they pop up?) -- Chris 12:03, 12 April 2010 (UTC)
if( window != top ) { // this window is run inside a frame }
I'd definitely support breaking frames on a general basis, assuming we don't use frames legitimately ourselves, which I don't think we do. Thoughts? Happy‑ melon 12:42, 13 April 2010 (UTC)
wgBreakFrames
) been turned off. —
Dispenser
15:51, 13 April 2010 (UTC)
<AryehGregor> Happy-melon, it used to be always true. Non-configurably. <Happy-melon> until Dec 2006 <AryehGregor> A few years ago the config option was added, set to false by default in case anyone actually wanted it. <AryehGregor> It's never been true on Wikimedia since it's existed AFAIK.
The only reason why $wgBreakFrames is disabled is that no one ever asked for it to be turned on. There's a whitelist built into it, which has Google translate exempted by default, and other exemptions can be added. What toolserver tools would break? Happy‑ melon 16:15, 13 April 2010 (UTC)
Breaking a specific site that's causing a demonstrable issue is one thing. Breaking all use of frames just because is another. There may be a case here for intentionally breaking this magic-banner site, as there was for breaking modernista. But I don't see any compelling case for breaking frames in general, especially as there's a not-remote possibility of collateral damage and unintended consequences. -- MZMcBride ( talk) 18:30, 13 April 2010 (UTC)
I propose to load User:TheDJ/usagecollapse.js on edit pages and file description pages. The script allows you to collapse the sections "File usage", "Global file usage" and "Templates used" on those pages. By default the sections are shown and you can press the show/hide element in front of them to hide them. This action is then remembered with a cookie. The three sections all have their own cookie. — TheDJ ( talk • contribs) 14:35, 23 April 2010 (UTC)
.templatesUsed
into a scrollbox. However, my option on the File page still stands. —
Dispenser
15:33, 13 May 2010 (UTC)
I am looking for some help in resolving issues with the Hide/Show button for navigation boxes in the Yiddish WP, which uses an rtl orthography. I would expect the button to appear at the end of the line, that is on the left-hand side, but it appears at the beginning (on the right-hand side), for example here.
Another problem is with the appearance of the Hide/Show button in Beta (which uses the Vector skin). In this case the button attaches itself to the title of the box instead of appearing at one end of the title bar.
Any suggestions for clearing this up? -- Redaktor ( talk) 22:04, 3 May 2010 (UTC)
body.rtl .NavToggle { float:left; }
but I haven't tested that. As a matter of fact, we should probably setup some rtl CSS on the English Wikipedia as well.... I'm not really seeing the Vector issue... I note you guys use NavFrame instead of collapsible tables. It might have to do something with that, I don't think the NavFrame was tested a lot with Vector yet. —
TheDJ (
talk •
contribs)
22:46, 3 May 2010 (UTC)
body.rtl .NavToggle { float:left; }
has cleared up the problem in both skins. In addition another problem (wrong placing of coordinates in Vector) has gone away too. Thanks again!! --
Redaktor (
talk)
11:58, 4 May 2010 (UTC)Due to bugzilla:23570, we probably need to change
ButtonLink.setAttribute( "href", "javascript:collapseTable(" + tableIndex + ");" );
into
ButtonLink.setAttribute( "href", "#" );
ButtonLink.setAttribute( "onclick", "collapseTable(" + tableIndex + "); return false;");
We can probably also do it using addHandler i guess...
ButtonLink.setAttribute( "href", "#" );
addHandler( ButtonLink, "click", function() { collapseTable( tableIndex ); return false;} );
— TheDJ ( talk • contribs) 13:43, 7 June 2010 (UTC)
new Function()
since it would reference tableIndex
at the time of execution. Also, is there something better than herf="#"
for the fail through condition, I've always felt it was quite a hack. I've seen other sites using herf="javascript:// comment here"
and it would be nicer if the status bar could provide something a more informative. —
Dispenser
20:16, 7 June 2010 (UTC)
<a href="#">
a.setAttribute("href", "#");
function killEvt (evt) {
evt = evt || window.event || window.Event; // W3C, IE, Netscape
if (typeof (evt.preventDefault) != 'undefined') {
evt.preventDefault(); // Don't follow the link
evt.stopPropagation();
} else
evt.cancelBubble = true; // IE
return false; // Don't follow the link (IE)
}
// Use it like this:
ButtonLink.setAttribute( "href", "#" );
addHandler( ButtonLink, "click", function(evt) { collapseTable( tableIndex ); return killEvt( evt );} );
killEvent() is on its way. When it is deployed, we can fix this stuff. — TheDJ ( talk • contribs) 19:23, 14 June 2010 (UTC)
I've reverted this edit because it was causing a template to expand on RfPP in edit mode, and that was hiding the toolbox on the left side of the page with the different protection tags in it. I just checked RfPP, and after reverting that edit it was back to normal. SlimVirgin talk| contribs 04:23, 15 June 2010 (UTC)
The bigest part of edit.js is for the old toolbar and it is now useless for most users. It could be moved into a separate file. — AlexSm 20:56, 8 June 2010 (UTC)
Okay, more specifically, edit.js should contain
if (!window.wgWikiEditorEnabledModules || !wgWikiEditorEnabledModules.toolbar)
importScript('MediaWiki:Common.js/oldtoolbar.js')
and all the mwCustomEditButtons=...
statements (3.6Kb) should be moved into
MediaWiki:Common.js/oldtoolbar.js. —
AlexSm
17:50, 15 June 2010 (UTC)
I don't know what Cirt didn't comment here on the new code he introduced. But the new code is just the LinkFA() function duplicated for GAs. It would be more efficient if it was added as another branch in the LinkFA function. The consensus for this change was on
Wikipedia talk:WikiProject Good articles, but doesn't seem to have been advertised anywherewas listed on
WP:CENT from May 7-31. —
Dispenser
15:11, 31 May 2010 (UTC)
function LinkFGA()
{
if ( document.getElementById( "p-lang" ) ) {
var InterwikiLinks = document.getElementById( "p-lang" ).getElementsByTagName( "li" );
for ( var i = 0; i < InterwikiLinks.length; i++ ) {
if ( document.getElementById( InterwikiLinksi].className + "-fa" ) ) {
InterwikiLinksi].className += " FA"
InterwikiLinksi].title = "This is a featured article in another language.";
} else if ( document.getElementById( InterwikiLinksi].className + "-ga" ) ) {
InterwikiLinksi].className += " GA"
InterwikiLinksi].title = "This is a good article in another language.";
}
}
}
}
addOnloadHook( LinkFGA );
It looks like the new collapsible tables are not working properly with my
Wikipedia:Nominations Viewer script. (For instance, when used at
WP:FLC, you can't expand any of the collapsed tables there.) What my script does is it wraps all nominations, which sometimes includes collapsed tables, in <div>
, and so this seems to disable the addHandler()
for ButtonLink
. How can I get my script to work properly with these new collapsible tables?
Gary King (
talk)
02:24, 23 June 2010 (UTC)
<div>
so I can more easily manipulate each one, such as hiding each nomination by default. I'd be happy to hear about any better ways to achieve this, as I know that cloneNode isn't the best.
Gary King (
talk ·
scripts)
20:18, 15 July 2010 (UTC)
I asked in March whether we could introduce more sophisticated table collapsing. Since I never got an answer but also nothing happened I guess nobody except me wants to (not) collapse certain rows or columns only. Nevertheless, testing the script in practice for several months now, the feature I discovered to be the most useful is not hiding rows that have the class ‘sortbottom’ (which is a behavioral and not a semantic class name like it should have been). So if nothing else this should be implemented in common.js, luckily it’s probably the most robust part of the code. It also doesn’t require anything new to be done by authors.
Still I wonder, am I the only one who believes that many wide tables would benefit from hiding some select columns by default? Maybe the toggle button should have three states then (‘hidden’, ‘partial’, ‘complete’), which I haven’t implemented. The only problems my additions to the table collapsing script have are in combination with ‘colspan’, ‘rowspan’ and incomplete rows when collapsing columns. — Christoph Päper 06:32, 23 June 2010 (UTC)
Similar to the user-group specific CSS which is currently loaded for administrators and accountcreators (see /Archive 17#Accountcreator CSS) I would like to know if it would be possible to add some similar code to detect whether an editor is logged in or not. This would be very handy on Wikipedia:Article wizard where irrelevant options could be hidden, and there are other places where this could be useful too. — Martin ( MSGJ · talk) 09:51, 14 July 2010 (UTC)
uploadwizard_newusers()
. I agree appendCSS is a better approach than finding specific ids. —
AlexSm
20:21, 14 July 2010 (UTC)
appendCSS('.js-off, .user-ip {display:none}')
. This way users with JS off see a choice while normal users see only relevant steps. —
AlexSm
20:24, 15 July 2010 (UTC)
Poke. Any chance of someone writing some code for this? Thanks — Martin ( MSGJ · talk) 15:27, 24 July 2010 (UTC)
AlexSm has ushered his concerns about the current hack we have to force position of the topicons in monobook when central or sitenotices are running. These notices require that the topicons are moved, but unfortunately it is difficult to detect these notices reliably. The reason we have this hack is because otherwise we need to use the Vector method. In that method, we set bodyContent to relative and then adjust the positions of all positioned elements in the page. This is a major change to the way the monobook skin renders and might interfere with expectations of people and/or break their current settings for rendering topicon and other similar icons (on their userpages for instance), but also in many other locations.
So which way do we go, improving topicon rendering during notice periods (almost all year long these days), or supporting everyone who is still expecting the old monobook styling. — TheDJ ( talk • contribs) 12:09, 16 July 2010 (UTC)
if(navigator.userAgent.indexOf('MSIE 6') == -1)
appendCSS('#bodyContent { position:relative; } .topicon { top:-2em !important; } #coordinates { top:1px !important; right:0px !important; }');
MediaWiki:Common.js/secure.js needs another exemption for the domain noc.wikimedia.org. An example of a currently broken link is at [3].
Regards, HaeB ( talk) 00:58, 20 July 2010 (UTC)
Based on bugzilla:24516, and older discussion here and here, I have decided to force the IPA class upon all windows browsers, because apparently glyph fallback on Windows is simply such a hot mess. The class now forces some Windows specific fonts from MediaWiki:Common.css/WinFixes.css and is loaded with Javascript from Common.js. We have known about these problems for a long while, but have been hold back in are lack of testing abilities. I think we can afford to take a leap and see what works better. This or the old behavior. — TheDJ ( talk • contribs) 21:00, 23 July 2010 (UTC)
With the {{ Collapsible list}} template, the Show/Hide link is always blue, were as with the Navbox, the link is the same colour as the title text.
I'm thinking that a change in Common.js will be able to fix this:
NavFrame.childNodes[j].appendChild(NavToggle);
NavToggle.style.color = NavFrame.childNodes[j].style.color;
Could someone confirm that this would work and also possibly implement it? Thanks -- WOSlinker ( talk) 18:21, 4 August 2010 (UTC)
Maybe I'm missing something, but it seems that with the big redesign, edit.js does absolutely nothing. Whatsoever. Is there some mysterious way to customize the new toolbar in the same way edit.js allowed customization of the old toolbar?
--
Cogniac (
talk)
02:30, 19 September 2010 (UTC)
Wouldn't...
if (nstab.firstChild && wgUserLanguage=='en') { nstab.firstChild.nodeValue = 'Main Page' }
...do the same thing as...
if (nstab && wgUserLanguage=='en') { while (nstab.firstChild) nstab = nstab.firstChild nstab.nodeValue = 'Main Page' }
Kaldari ( talk) 20:24, 1 October 2010 (UTC)
Hi!!
I would like to propose that we make the header line of collapsible tables and divs clickable as it currently is on Wikibooks version ( example). Their script is at b:MediaWiki:Common.js/Navigation.js.
This way, we can use a CSS like cursor:pointer;
so that the mouse cursor changes when we put it over the header, and the content is expanded when we click on it (not only on the small button [show]).
What do you think? Helder ( talk) 13:45, 7 October 2010 (UTC)
What about moving the line
if (sub === 'www' || sub === 'mail') continue;
to above the line
//Here if (main === 'wikipedia') {
to avoid the regex matches? Helder ( talk) 19:46, 17 October 2010 (UTC)
I haven't gotten around to it yet, but NavFrame needs to be updated to use the same onclick method as navbox now uses. Current method breaks on IE6 in a preview of the edit window. This is a reminder that I or someone else should do that at some point. — TheDJ ( talk • contribs) 00:18, 13 October 2010 (UTC)
{{
editrequested|MediaWiki:Common.js/secure.js}}
Where it says "if (sub.match(/^
", please add "prototype"; see when I link to
http://prototype.wikimedia.org.
Hey
Mid (
contributions)
10:58, 3 November 2010 (UTC)
More specific:
-- Bachinchi ( talk) 18:43, 3 November 2010 (UTC)
A discussion at WP:VPL made me wonder about the feasibility of using a similar system for ENGVAR editnotices as we currently have for the BLP editnotice. The latter loads via MediaWiki:Common.js based on the mere existence of Category:Living people in an article; in principle we could do something similar with Category:British English articles etc. This would be better than the current system of eg {{ British-English-editnotice}}, as seen at Amnesty International, applied via the appropriate editnotice page ( Template:Editnotices/Page/Amnesty International), since this needs admin permission and as a result isn't too widely used. So my question is - is there any technical reason why this would be a problem? Rd232 talk 10:17, 17 November 2010 (UTC)
I would like to make nested collapsible tables in a wiki site. I've copied the relevant code in Common.js and Common.css from the Wikipedia site; this code is the same as at meta.wikimedia.org [5]. Now why does the following example work properly at Wikipedia, but not at meta.wikimedia.org or in my wiki? In the other sites the whole contents appear when I click the topmost "show" button, and I have to click on the inner button several times for it to fold. (I've asked the same question at meta, posting the same code, you can compare the result there [6].)
Click for interesting information | |||||
|
-- Rebollo fr ( talk) 19:44, 21 December 2010 (UTC)
var Rows = Table.getElementsByTagName( "tr" );
var Rows = Table.rows;
Sometimes we need to divide the header of a table in two lines, and use (col/row)spans for better organization of the content.
Would it be possible to improve the current script of sortable tables so that it could handle correctly cases like the following?
Wikicode{| class="wikitable sortable" |- ! rowspan=2 | Title 1 ! colspan=2 | Title 2 |- ! Title 2.1 ! Title 2.2 |- | B || C || A |- | A || B || C |- | C || A || B |} |
Rendering (try to click on sorting buttons)
|
As can be noticed, only the first button is added in the right place, and even this button doesn't works as expected. Here is what we should see when the table is...
Any thoughts on this? Helder 17:04, 1 January 2011 (UTC)
importScript('
User:Tcncv/sorttables.js');
to your monobook.js file (or appropriate xxx.js file for your chosen skin) to see the enhancements in action with the demo cases. Adding class="tsx_sortable"
to your own tables will enable the demo for them as well. I added the above table to the bottom of the demo page (
here) and it behaves just as you have requeested.As we still have not fixed the horrible way the "featured article star" looks in the inter-language links section, may I propose that we remove the star and replace it with a more subtle "mark the inter-language link in boldface"-effect instead? I think this would fit better with Vector's visually less distracting design. I would suggest doing exactly the same for the "good article plus-sign". A featured article on a small Wikipedia is less likely to be more in-depth than a good article on, for example, the German Wikipedia. So I do not think it really justifies using any "visual bandwidth" to make this distinction (a distinction which is likely to only be confusing to casual readers in the first place anyway). — Ruud 20:27, 1 January 2011 (UTC)
Why is there any sort of indication at all? Let's say that I go to the Dog article to read about dogs. Am I supposed to look at the interwiki links and think to myself, "oh, I should learn Catalan so I can read more about dogs"? — RockMFR 19:41, 2 January 2011 (UTC)
Moved this discussion to Wikipedia talk:Kvetch. -- MZMcBride ( talk) 22:00, 17 January 2011 (UTC)
Collapsible rows (in contrast to the existing collapsible tables) would be useful for taxoboxes like those in Fomes fomentarius (where an ugly hack with a table-inside-a-table is now used). I've implemented this feature in User:Ucucha/collapse.js, with an example here. Could this be added to common.js? Ucucha 23:25, 3 January 2011 (UTC)
{{ sudo}}
See Wikipedia:Village_pump_(proposals)#Proposal_-_Turn_on_RefTools_gadget_by_default. There is strong consensus supporting implementation; would someone please do so? -- N Y Kevin @286, i.e. 05:51, 31 January 2011 (UTC)
Help Please undo whatever has been done in the last few days that has prevented me from using the reftoolbar. See
User_talk:Mr.Z-man#RefTools. At least leave a gadget for the 1.0 version, that used to work for me a few days ago. Please do not overwrite existing gadgets in this way, let editors choose.
-
84user (
talk) 10:24, 17 February 2011 (UTC)(struck through as things appear back to normal again
84user (
talk)
14:25, 17 February 2011 (UTC))
This is an archive of past discussions. 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 15 | Archive 16 | Archive 17 | Archive 18 | Archive 19 | Archive 20 | → | Archive 23 |
proposal it so add
if(wgServer == 'https://secure.wikimedia.org')
importScript( 'MediaWiki:Common.js/secure.js')
This changes any http links to interwiki or diffs on a page to links for the secure server. The script is originally User:Anakin101/alwayssecurewikipedia.js. — TheDJ ( talk • contribs) 20:45, 17 January 2010 (UTC)
http:\/\/([^\/]+?)\.
should be http:\/\/([^a-z0-9\-]+?)\.
, change (page ? page : 'wiki/')
to (page || 'wiki/')
, \/?
is unnecessary since browser automatically add this in (I think), if (sub === undefined) continue;
seems to be in the wrong place. There one question, should this be supporting old links? Wikibooks use to be en.wikibook.com (no s), wikipedia.com/wiki/ redirects to the English Wikipedia, meta-wiki was meta.wikipedia.org. —
Dispenser
07:43, 18 January 2010 (UTC)\/?(.*)$
" with e.g. "(\/[^?#]*|)([#?].*|)$
" in the regexps and append the value of m[4]
to the fixed URL unconditionally. Also, there should be some way (e.g. setting window.disableSecureLinks=true
in their monobook/vector.js) for users to turn this script off if they don't want it.Done code deployed. — TheDJ ( talk • contribs) 20:44, 21 January 2010 (UTC)
Up in the "WikiMiniAtlas" discussion it was mentioned that "(All our other special scripts are only loaded when needed.)." I'm getting ready to implement a lot of JavaScript on my Wiki and I was just curious if this was simply a reference to doing a quick getElementById existence check in addOnloadHook for each script, or if there is some other system in place that I don't know about. I'm basically just trying to make sure that if I have 100 scripts, I don't have to do 100 checks on every page load to see if any of them apply to that page.
--
Cogniac (
talk)
18:11, 29 January 2010 (UTC)
Wikimedia commons has the following function in their MediaWiki:Common.js. This is useful for doing feature preview links like timed text preview. Any objections to adding the following?
/** &withJS= URL parameter *******
* Allow to try custom scripts from MediaWiki space
* without editing [[Special:Mypage/monobook.js]]
*/
var extraJS = getParamValue("withJS");
if ( extraJS && extraJS.match("^MediaWiki:[^&<>=%]*\.js$") ) {
importScript(extraJS);
}
mdale ( talk) 22:42, 4 February 2010 (UTC)
.match()
part check what that code means and that.match()
part does exactly what it should.While, I'm sure that whoever runs http://toolserver.org/~para/geoip.fcgi is perfectly trustworthy it seems like a very weak link in the chain. Whereas scripts from Wikipedia have high cache values, publicly viewable edit histories, and notify many people when they are modified; making it likely that malicious changes can be reverted without too much damage; a modification to this script could pass unnoticed for quite some time. Are there any mechanisms in place to prevent this being horribly abused? Conrad. Irwin ( on wikt) 22:55, 4 February 2010 (UTC)
The hasClass function...variable...thing uses some fairly advanced JavaScript that I'm just trying to figure out. I'm assuming that the reason it is set up as a variable and not just straight "function hasClass(className)" is part of the caching optimization. But I'm not getting how it basically amounts to "var hasClass = ()();" with stuff happening inside the first pair of parentheses. I have no idea what the deal is with the two pairs of parentheses or why it relies on an anonymous function inside an anonymous function to do the work, and I'm looking for a basic explanation, if anyone would be so kind.
--
Cogniac (
talk)
21:19, 12 February 2010 (UTC)
reCache
and returns another function which is assigned to the name hasClass. Due to JavaScript's scoping rules reCache
is now only accessible from hasClass
, but it's value still persists over multiple invocations of hasClass
.I'm trying to implement some custom edit buttons on my Wiki. They work, but only when placed in Common.js. I cannot get them to work when they are placed on Common.js/edit.js like they are here. I stuck an alert() call in my Common.js/edit.js to see if it was even being loaded, and it's not. Comparing my wikibits.js with Wikipedia's wikibits.js, and thus my importScript() with Wikipedia's, I notice the following differences:
Could these subtle differences somehow be causing my problem?
--
Cogniac (
talk)
20:43, 26 February 2010 (UTC)
I asked on Help whether Collapsing could be extended to cover certain rows and columns only. Then I realized I hadn’t anything to do for the rest of the day and wrote the code myself. It may need further testing (and perhaps optimizing), but the basic cases are covered alright. Collapsing columns is especially helpful for en.m.wikipedia.org. Is there any chance getting this into common.js? — Christoph Päper 11:33, 6 March 2010 (UTC)
On a related note to collapsible rows and columns above, it would be nice to have a class ‘rank’ on one heading cell in a ‘sortable’ table that would result in the cells below it – if they contain only whitespace, digits and punctuation – bearing a dynamically generated rank number which is updated on sorting (and perhaps restored on sorting based on that very column, otherwise ‘rank’ should imply ‘unsortable’). The workaround with two tables side by side (inside a third one) is really ugly and fails with rows of different height. — Christoph Päper 15:21, 2 March 2010 (UTC)
This is essentially the same function but includes the # hash to not include #anchors when you getURLParamValues
function getURLParamValue( paramName, url)
{
if (typeof (url) == 'undefined' || url === null) url = document.location.href;
var cmdRe=RegExp( '[&?]' + paramName + '=([^&#]*)' ); // Stop at hash
var m=cmdRe.exec(url);
if (m && m.length > 1) return decodeURIComponent(m1]);
return null;
}
mdale ( talk) 20:41, 3 March 2010 (UTC)
Please see Wikipedia:Village_pump_(proposals)#Collapse_template_transclusion_list_in_Edit_view. I'm not quite sure if the script is ready - I had some problems last time I used it and had to uninstall. But is this reasonable in principle? Rd232 talk 20:00, 8 April 2010 (UTC)
I know we once blocked a system that iframed wikipedia for it's own purposes. There is now this "ad service" http://www.magic-banner-bot.com/ which inserts images into wikipedia. It cannot be disabled, uses an iframe and insert ads into the wikipedia content, without explaining why. I think such is grounds for blocking that via Javascript. What do others think ? — TheDJ ( talk • contribs) 00:35, 11 April 2010 (UTC)
The adding following code to Mediawiki:Common.js should do the trick:
if (document.referrer.indexOf("magic-banner-bot.com") != -1) { location.href = "http://en.wikipedia.org/?title=User:Chris_G/Leech_detected&action=render"; }
The user will see this page with instructions on how to navigate to Wikipedia directly (someone might want to that page to be a bit nicer/user friendly first though). I've tested the script and it works in Firefox + Opera, but if a Windows user would please check it in IE (the older the version the better :) ) that would be good. Javascript isn't my forte so if someone could please double check that it won't break the site etc that would be great (maybe we should move it into it's own function? make it easier to add more sites as they pop up?) -- Chris 12:03, 12 April 2010 (UTC)
if( window != top ) { // this window is run inside a frame }
I'd definitely support breaking frames on a general basis, assuming we don't use frames legitimately ourselves, which I don't think we do. Thoughts? Happy‑ melon 12:42, 13 April 2010 (UTC)
wgBreakFrames
) been turned off. —
Dispenser
15:51, 13 April 2010 (UTC)
<AryehGregor> Happy-melon, it used to be always true. Non-configurably. <Happy-melon> until Dec 2006 <AryehGregor> A few years ago the config option was added, set to false by default in case anyone actually wanted it. <AryehGregor> It's never been true on Wikimedia since it's existed AFAIK.
The only reason why $wgBreakFrames is disabled is that no one ever asked for it to be turned on. There's a whitelist built into it, which has Google translate exempted by default, and other exemptions can be added. What toolserver tools would break? Happy‑ melon 16:15, 13 April 2010 (UTC)
Breaking a specific site that's causing a demonstrable issue is one thing. Breaking all use of frames just because is another. There may be a case here for intentionally breaking this magic-banner site, as there was for breaking modernista. But I don't see any compelling case for breaking frames in general, especially as there's a not-remote possibility of collateral damage and unintended consequences. -- MZMcBride ( talk) 18:30, 13 April 2010 (UTC)
I propose to load User:TheDJ/usagecollapse.js on edit pages and file description pages. The script allows you to collapse the sections "File usage", "Global file usage" and "Templates used" on those pages. By default the sections are shown and you can press the show/hide element in front of them to hide them. This action is then remembered with a cookie. The three sections all have their own cookie. — TheDJ ( talk • contribs) 14:35, 23 April 2010 (UTC)
.templatesUsed
into a scrollbox. However, my option on the File page still stands. —
Dispenser
15:33, 13 May 2010 (UTC)
I am looking for some help in resolving issues with the Hide/Show button for navigation boxes in the Yiddish WP, which uses an rtl orthography. I would expect the button to appear at the end of the line, that is on the left-hand side, but it appears at the beginning (on the right-hand side), for example here.
Another problem is with the appearance of the Hide/Show button in Beta (which uses the Vector skin). In this case the button attaches itself to the title of the box instead of appearing at one end of the title bar.
Any suggestions for clearing this up? -- Redaktor ( talk) 22:04, 3 May 2010 (UTC)
body.rtl .NavToggle { float:left; }
but I haven't tested that. As a matter of fact, we should probably setup some rtl CSS on the English Wikipedia as well.... I'm not really seeing the Vector issue... I note you guys use NavFrame instead of collapsible tables. It might have to do something with that, I don't think the NavFrame was tested a lot with Vector yet. —
TheDJ (
talk •
contribs)
22:46, 3 May 2010 (UTC)
body.rtl .NavToggle { float:left; }
has cleared up the problem in both skins. In addition another problem (wrong placing of coordinates in Vector) has gone away too. Thanks again!! --
Redaktor (
talk)
11:58, 4 May 2010 (UTC)Due to bugzilla:23570, we probably need to change
ButtonLink.setAttribute( "href", "javascript:collapseTable(" + tableIndex + ");" );
into
ButtonLink.setAttribute( "href", "#" );
ButtonLink.setAttribute( "onclick", "collapseTable(" + tableIndex + "); return false;");
We can probably also do it using addHandler i guess...
ButtonLink.setAttribute( "href", "#" );
addHandler( ButtonLink, "click", function() { collapseTable( tableIndex ); return false;} );
— TheDJ ( talk • contribs) 13:43, 7 June 2010 (UTC)
new Function()
since it would reference tableIndex
at the time of execution. Also, is there something better than herf="#"
for the fail through condition, I've always felt it was quite a hack. I've seen other sites using herf="javascript:// comment here"
and it would be nicer if the status bar could provide something a more informative. —
Dispenser
20:16, 7 June 2010 (UTC)
<a href="#">
a.setAttribute("href", "#");
function killEvt (evt) {
evt = evt || window.event || window.Event; // W3C, IE, Netscape
if (typeof (evt.preventDefault) != 'undefined') {
evt.preventDefault(); // Don't follow the link
evt.stopPropagation();
} else
evt.cancelBubble = true; // IE
return false; // Don't follow the link (IE)
}
// Use it like this:
ButtonLink.setAttribute( "href", "#" );
addHandler( ButtonLink, "click", function(evt) { collapseTable( tableIndex ); return killEvt( evt );} );
killEvent() is on its way. When it is deployed, we can fix this stuff. — TheDJ ( talk • contribs) 19:23, 14 June 2010 (UTC)
I've reverted this edit because it was causing a template to expand on RfPP in edit mode, and that was hiding the toolbox on the left side of the page with the different protection tags in it. I just checked RfPP, and after reverting that edit it was back to normal. SlimVirgin talk| contribs 04:23, 15 June 2010 (UTC)
The bigest part of edit.js is for the old toolbar and it is now useless for most users. It could be moved into a separate file. — AlexSm 20:56, 8 June 2010 (UTC)
Okay, more specifically, edit.js should contain
if (!window.wgWikiEditorEnabledModules || !wgWikiEditorEnabledModules.toolbar)
importScript('MediaWiki:Common.js/oldtoolbar.js')
and all the mwCustomEditButtons=...
statements (3.6Kb) should be moved into
MediaWiki:Common.js/oldtoolbar.js. —
AlexSm
17:50, 15 June 2010 (UTC)
I don't know what Cirt didn't comment here on the new code he introduced. But the new code is just the LinkFA() function duplicated for GAs. It would be more efficient if it was added as another branch in the LinkFA function. The consensus for this change was on
Wikipedia talk:WikiProject Good articles, but doesn't seem to have been advertised anywherewas listed on
WP:CENT from May 7-31. —
Dispenser
15:11, 31 May 2010 (UTC)
function LinkFGA()
{
if ( document.getElementById( "p-lang" ) ) {
var InterwikiLinks = document.getElementById( "p-lang" ).getElementsByTagName( "li" );
for ( var i = 0; i < InterwikiLinks.length; i++ ) {
if ( document.getElementById( InterwikiLinksi].className + "-fa" ) ) {
InterwikiLinksi].className += " FA"
InterwikiLinksi].title = "This is a featured article in another language.";
} else if ( document.getElementById( InterwikiLinksi].className + "-ga" ) ) {
InterwikiLinksi].className += " GA"
InterwikiLinksi].title = "This is a good article in another language.";
}
}
}
}
addOnloadHook( LinkFGA );
It looks like the new collapsible tables are not working properly with my
Wikipedia:Nominations Viewer script. (For instance, when used at
WP:FLC, you can't expand any of the collapsed tables there.) What my script does is it wraps all nominations, which sometimes includes collapsed tables, in <div>
, and so this seems to disable the addHandler()
for ButtonLink
. How can I get my script to work properly with these new collapsible tables?
Gary King (
talk)
02:24, 23 June 2010 (UTC)
<div>
so I can more easily manipulate each one, such as hiding each nomination by default. I'd be happy to hear about any better ways to achieve this, as I know that cloneNode isn't the best.
Gary King (
talk ·
scripts)
20:18, 15 July 2010 (UTC)
I asked in March whether we could introduce more sophisticated table collapsing. Since I never got an answer but also nothing happened I guess nobody except me wants to (not) collapse certain rows or columns only. Nevertheless, testing the script in practice for several months now, the feature I discovered to be the most useful is not hiding rows that have the class ‘sortbottom’ (which is a behavioral and not a semantic class name like it should have been). So if nothing else this should be implemented in common.js, luckily it’s probably the most robust part of the code. It also doesn’t require anything new to be done by authors.
Still I wonder, am I the only one who believes that many wide tables would benefit from hiding some select columns by default? Maybe the toggle button should have three states then (‘hidden’, ‘partial’, ‘complete’), which I haven’t implemented. The only problems my additions to the table collapsing script have are in combination with ‘colspan’, ‘rowspan’ and incomplete rows when collapsing columns. — Christoph Päper 06:32, 23 June 2010 (UTC)
Similar to the user-group specific CSS which is currently loaded for administrators and accountcreators (see /Archive 17#Accountcreator CSS) I would like to know if it would be possible to add some similar code to detect whether an editor is logged in or not. This would be very handy on Wikipedia:Article wizard where irrelevant options could be hidden, and there are other places where this could be useful too. — Martin ( MSGJ · talk) 09:51, 14 July 2010 (UTC)
uploadwizard_newusers()
. I agree appendCSS is a better approach than finding specific ids. —
AlexSm
20:21, 14 July 2010 (UTC)
appendCSS('.js-off, .user-ip {display:none}')
. This way users with JS off see a choice while normal users see only relevant steps. —
AlexSm
20:24, 15 July 2010 (UTC)
Poke. Any chance of someone writing some code for this? Thanks — Martin ( MSGJ · talk) 15:27, 24 July 2010 (UTC)
AlexSm has ushered his concerns about the current hack we have to force position of the topicons in monobook when central or sitenotices are running. These notices require that the topicons are moved, but unfortunately it is difficult to detect these notices reliably. The reason we have this hack is because otherwise we need to use the Vector method. In that method, we set bodyContent to relative and then adjust the positions of all positioned elements in the page. This is a major change to the way the monobook skin renders and might interfere with expectations of people and/or break their current settings for rendering topicon and other similar icons (on their userpages for instance), but also in many other locations.
So which way do we go, improving topicon rendering during notice periods (almost all year long these days), or supporting everyone who is still expecting the old monobook styling. — TheDJ ( talk • contribs) 12:09, 16 July 2010 (UTC)
if(navigator.userAgent.indexOf('MSIE 6') == -1)
appendCSS('#bodyContent { position:relative; } .topicon { top:-2em !important; } #coordinates { top:1px !important; right:0px !important; }');
MediaWiki:Common.js/secure.js needs another exemption for the domain noc.wikimedia.org. An example of a currently broken link is at [3].
Regards, HaeB ( talk) 00:58, 20 July 2010 (UTC)
Based on bugzilla:24516, and older discussion here and here, I have decided to force the IPA class upon all windows browsers, because apparently glyph fallback on Windows is simply such a hot mess. The class now forces some Windows specific fonts from MediaWiki:Common.css/WinFixes.css and is loaded with Javascript from Common.js. We have known about these problems for a long while, but have been hold back in are lack of testing abilities. I think we can afford to take a leap and see what works better. This or the old behavior. — TheDJ ( talk • contribs) 21:00, 23 July 2010 (UTC)
With the {{ Collapsible list}} template, the Show/Hide link is always blue, were as with the Navbox, the link is the same colour as the title text.
I'm thinking that a change in Common.js will be able to fix this:
NavFrame.childNodes[j].appendChild(NavToggle);
NavToggle.style.color = NavFrame.childNodes[j].style.color;
Could someone confirm that this would work and also possibly implement it? Thanks -- WOSlinker ( talk) 18:21, 4 August 2010 (UTC)
Maybe I'm missing something, but it seems that with the big redesign, edit.js does absolutely nothing. Whatsoever. Is there some mysterious way to customize the new toolbar in the same way edit.js allowed customization of the old toolbar?
--
Cogniac (
talk)
02:30, 19 September 2010 (UTC)
Wouldn't...
if (nstab.firstChild && wgUserLanguage=='en') { nstab.firstChild.nodeValue = 'Main Page' }
...do the same thing as...
if (nstab && wgUserLanguage=='en') { while (nstab.firstChild) nstab = nstab.firstChild nstab.nodeValue = 'Main Page' }
Kaldari ( talk) 20:24, 1 October 2010 (UTC)
Hi!!
I would like to propose that we make the header line of collapsible tables and divs clickable as it currently is on Wikibooks version ( example). Their script is at b:MediaWiki:Common.js/Navigation.js.
This way, we can use a CSS like cursor:pointer;
so that the mouse cursor changes when we put it over the header, and the content is expanded when we click on it (not only on the small button [show]).
What do you think? Helder ( talk) 13:45, 7 October 2010 (UTC)
What about moving the line
if (sub === 'www' || sub === 'mail') continue;
to above the line
//Here if (main === 'wikipedia') {
to avoid the regex matches? Helder ( talk) 19:46, 17 October 2010 (UTC)
I haven't gotten around to it yet, but NavFrame needs to be updated to use the same onclick method as navbox now uses. Current method breaks on IE6 in a preview of the edit window. This is a reminder that I or someone else should do that at some point. — TheDJ ( talk • contribs) 00:18, 13 October 2010 (UTC)
{{
editrequested|MediaWiki:Common.js/secure.js}}
Where it says "if (sub.match(/^
", please add "prototype"; see when I link to
http://prototype.wikimedia.org.
Hey
Mid (
contributions)
10:58, 3 November 2010 (UTC)
More specific:
-- Bachinchi ( talk) 18:43, 3 November 2010 (UTC)
A discussion at WP:VPL made me wonder about the feasibility of using a similar system for ENGVAR editnotices as we currently have for the BLP editnotice. The latter loads via MediaWiki:Common.js based on the mere existence of Category:Living people in an article; in principle we could do something similar with Category:British English articles etc. This would be better than the current system of eg {{ British-English-editnotice}}, as seen at Amnesty International, applied via the appropriate editnotice page ( Template:Editnotices/Page/Amnesty International), since this needs admin permission and as a result isn't too widely used. So my question is - is there any technical reason why this would be a problem? Rd232 talk 10:17, 17 November 2010 (UTC)
I would like to make nested collapsible tables in a wiki site. I've copied the relevant code in Common.js and Common.css from the Wikipedia site; this code is the same as at meta.wikimedia.org [5]. Now why does the following example work properly at Wikipedia, but not at meta.wikimedia.org or in my wiki? In the other sites the whole contents appear when I click the topmost "show" button, and I have to click on the inner button several times for it to fold. (I've asked the same question at meta, posting the same code, you can compare the result there [6].)
Click for interesting information | |||||
|
-- Rebollo fr ( talk) 19:44, 21 December 2010 (UTC)
var Rows = Table.getElementsByTagName( "tr" );
var Rows = Table.rows;
Sometimes we need to divide the header of a table in two lines, and use (col/row)spans for better organization of the content.
Would it be possible to improve the current script of sortable tables so that it could handle correctly cases like the following?
Wikicode{| class="wikitable sortable" |- ! rowspan=2 | Title 1 ! colspan=2 | Title 2 |- ! Title 2.1 ! Title 2.2 |- | B || C || A |- | A || B || C |- | C || A || B |} |
Rendering (try to click on sorting buttons)
|
As can be noticed, only the first button is added in the right place, and even this button doesn't works as expected. Here is what we should see when the table is...
...sorted by Title 1
|
...sorted by Title 2.1
|
...sorted by Title 2.2
|
Any thoughts on this? Helder 17:04, 1 January 2011 (UTC)
importScript('
User:Tcncv/sorttables.js');
to your monobook.js file (or appropriate xxx.js file for your chosen skin) to see the enhancements in action with the demo cases. Adding class="tsx_sortable"
to your own tables will enable the demo for them as well. I added the above table to the bottom of the demo page (
here) and it behaves just as you have requeested.As we still have not fixed the horrible way the "featured article star" looks in the inter-language links section, may I propose that we remove the star and replace it with a more subtle "mark the inter-language link in boldface"-effect instead? I think this would fit better with Vector's visually less distracting design. I would suggest doing exactly the same for the "good article plus-sign". A featured article on a small Wikipedia is less likely to be more in-depth than a good article on, for example, the German Wikipedia. So I do not think it really justifies using any "visual bandwidth" to make this distinction (a distinction which is likely to only be confusing to casual readers in the first place anyway). — Ruud 20:27, 1 January 2011 (UTC)
Why is there any sort of indication at all? Let's say that I go to the Dog article to read about dogs. Am I supposed to look at the interwiki links and think to myself, "oh, I should learn Catalan so I can read more about dogs"? — RockMFR 19:41, 2 January 2011 (UTC)
Moved this discussion to Wikipedia talk:Kvetch. -- MZMcBride ( talk) 22:00, 17 January 2011 (UTC)
Collapsible rows (in contrast to the existing collapsible tables) would be useful for taxoboxes like those in Fomes fomentarius (where an ugly hack with a table-inside-a-table is now used). I've implemented this feature in User:Ucucha/collapse.js, with an example here. Could this be added to common.js? Ucucha 23:25, 3 January 2011 (UTC)
{{ sudo}}
See Wikipedia:Village_pump_(proposals)#Proposal_-_Turn_on_RefTools_gadget_by_default. There is strong consensus supporting implementation; would someone please do so? -- N Y Kevin @286, i.e. 05:51, 31 January 2011 (UTC)
Help Please undo whatever has been done in the last few days that has prevented me from using the reftoolbar. See
User_talk:Mr.Z-man#RefTools. At least leave a gadget for the 1.0 version, that used to work for me a few days ago. Please do not overwrite existing gadgets in this way, let editors choose.
-
84user (
talk) 10:24, 17 February 2011 (UTC)(struck through as things appear back to normal again
84user (
talk)
14:25, 17 February 2011 (UTC))