MediaWiki talk:Common.js

Missing object
We have a problem here, an object can't be found by IE 6's script debugger. Can we get this sorted out?

function dotabs {   //first tab var a = document.getElementById("ca-nstab-main"); --> var s = a.innerHTML;

Looks like a is not defined for some reason. - Ta bu shi da yu 05:59, 29 March 2006 (UTC)


 * I don't get that problem; I assume it's been fixed since then. If not, you'll probably get more responses if you add a note on the community discussion page linking to your question here. — {admin} Pathoschild 01:38, 23 January 2007 (UTC)

Directory
Where can I find COMMON.JS? what is the path directory? I can't find it... thanks Alain, 22, January 2007


 * Hello Alain. Common.js is dynamically generated from MediaWiki:Common.js, and isn't saved in the files. You can see it for yourself by visiting en.wikisource.org/w/index.php?title=-&action=raw&smaxage=0&gen=js. It's called in the XHTML code on this line:   . — {admin} Pathoschild 01:38, 23 January 2007 (UTC)

dotabs error
The innerHTML hack in dotabs messes up pages with non-english interface really bad. Please use proper DOM manipulation instead. --Tgr 17:13, 12 April 2007 (UTC)


 * I'll recode it soon. — {admin} Pathoschild 05:33:54, 13 April 2007 (UTC)

wgArticlePath
I just [ tried] to fix some bugs on the secure wiki (logging on to which is now encouraged) by replacing links beginning with  with code similar to   (along with changing png images to their svg counterparts) and failed somehow (images don't show any more at all). Can somehow with better knowledge of the workings of our site JavaScript look into this? Thank you.--GrafZahl (talk) 11:13, 27 July 2007 (UTC)

Script error
I can't pinpoint the exact cause, but most pages on Wikisource produce this error in IE6:

Line: 322 Char: 3 Error: Object doesn't support this property or method.

Edokter 19:19, 17 October 2007 (UTC)

A better DisplayFooter function
I think I found a way to get this function to work in IE too. Here's how:

Works in IE, Firefox, Opera and Safari (tested in ru.wikisource). — Lozman (talk) 19:42, 8 September 2008 (UTC)


 * Thank you. I don't have IE and I didn't even know it doesn't work with it. Can some admin with IE try out the new code here on this Wikisource? Thanks!--GrafZahl (talk) 08:02, 10 September 2008 (UTC)

MediaWiki:Common.js
where do i find MediaWiki:Common.js on my mediawiki. for example local setting or do i have to start a page called MediaWiki:Common.js but where? Thanks --86.136.108.50 15:15, 18 February 2009 (UTC)


 * You need to create a page called "MediaWiki:Common.js"; go to that page name, and click edit. mw:Manual:Interface/JavaScript has a little bit more information, and that is the website where you should seek further technical support. John Vandenberg (chat) 22:54, 18 February 2009 (UTC)

Tabber
What is the tabber code actually being used for on WikiSource? There has been talk of some day implementing an easy way to create additional tabs in MediaWiki, but it would be good to know the various use cases before anything gets developed. Kaldari (talk) 05:02, 4 September 2010 (UTC)
 * Primarily Template:Welcome, hence widely used. Not sure of other use. — billinghurst  sDrewth  07:50, 4 September 2010 (UTC)
 * So we're loading 20K of Javascript on every page load just so Template:Welcome doesn't have to use any CSS? Seems like overkill to me. Kaldari (talk) 06:08, 5 September 2010 (UTC)


 * Removed. cygnis insignis 13:25, 15 October 2010 (UTC)
 * Cool. Thanks for taking care of that. Kaldari (talk) 00:30, 16 October 2010 (UTC)

Implemented commons script for secure servers
There has been navigation issues for those logged in via the secure login facility with relation to some links, especially crosswiki and interwiki links. Pathoschild amended those issues that came with the extension DoubleWiki yesterday, and today I have added the fix from Commons that rewrites the links. If there problems then we should revert my change to import that script. — billinghurst  sDrewth  00:23, 11 January 2011 (UTC)
 * I'm having problems with false-positive result for https WS, resulting in broken links of the format en.wikisource.org/wikisource/en/wiki/blah everywhere. Happens on both chrome and IE. Prosody (talk) 00:47, 11 January 2011 (UTC)
 * That was probably badly worded. I'm not using secure.wikimedia.org, but getting links as if I am. Prosody (talk) 00:49, 11 January 2011 (UTC)
 * Per commons:MediaWiki:Common.js, I think you just need to enclose the importScriptURI in 'if( wgServer == 'https://secure.wikimedia.org' )' Prosody (talk) 01:03, 11 January 2011 (UTC)


 * Don't know if its related or just me but attempting to patrol edits from the (prev) link(s) on the Recent Changes page brings up 404-server-type errors. The provided alternative link does eventually take you to where you wanted to go apparently. -- George Orwell III (talk) 01:36, 11 January 2011 (UTC)
 * This just stopped - back to as before -- George Orwell III (talk) 01:53, 11 January 2011 (UTC)
 * Been better gIFt wrapped this time, and using enWP as per John's preference. Apologies. — billinghurst  sDrewth  02:20, 11 January 2011 (UTC)

Adding withJS support & temporal media fragments
I added withJS support to match commons and en.wikipeida this is helpful for people to try out gadgets. Per bug 26663 and Theornamentalist and I wanted to try supporting temporal media fragments for wikisource articles about video assets. You can see the work in progress here. If desirable we can more broadly enable the feature. Mdale (talk) 19:03, 14 January 2011 (UTC)

Commented out usejs
After a quick chat with the author of usejs, it was indicated that we believe that the script is archaic, unused and no longer supported, hence there is no longer a need for it to be included in the file. I have commented out the file, and see if this is an issue for users. — billinghurst  sDrewth  06:47, 11 April 2011 (UTC)

protocol relative url
Following the implementation of relative urls (see announcement at https://blog.wikimedia.org/2011/10/03/native-https-support-enabled-for-all-wikimedia-foundation-wikis/) I have modified the urls to be relative, which should allow a smooth transition. If not, then please revert and get back to me and I will seek an expert's opinion. — billinghurst  sDrewth  12:57, 4 October 2011 (UTC)
 * Could you get that last one at the bottom? Prosody (talk) 06:52, 15 October 2011 (UTC)
 * ✅ - hope that is correct; please let me know if it is not. -- George Orwell III (talk) 07:19, 15 October 2011 (UTC)
 * For the record, the oldws link was broken before this edit. I think it broke during the 1.18 upgrade. Prosody (talk) 07:33, 15 October 2011 (UTC)
 * ???? If it was/is not working, is there any reason to keep the line at all? -- George Orwell III (talk) 08:00, 15 October 2011 (UTC)
 * Good point. I was banking on the script being fixed soonish, but that may not be the case. As is, even if we remove that include we still have a bunch of broken interlanguage links to Arab wikisource everywhere, and it wouldn't be worthwhile to go about removing them unless we decided that we were just going to give up on on old ws links through that js for good. Prosody (talk) 01:14, 17 October 2011 (UTC)
 * Nevermind, it works. I was under the impression that Chrome only reported insecure js but it apparently refuses to run it also. Prosody (talk) 01:20, 17 October 2011 (UTC)

Reverted previous edit
Not sure what was happening why, however, I was getting a title, and no displayed text. Text was there (show sourced), but not displaying. A little problematic with refresh cache to know exactly it occurred. — billinghurst  sDrewth  06:43, 3 November 2013 (UTC)

Give search results even when page doesn't exist
Hello, I propose to enable the tool created by Magnus Manske (creator of MediaWiki) to provide results from other languages and Commons (via Wikidata) when a page doesn't exist here: links are added to Special:Search and noarticletext. This helps to encourage translation and to make readers use your wiki more, because they can be sure to find something even if it's not local (rather than searching directly on the biggest wiki). The Italian and Polish Wikipedias, among others already enabled it by default. Examples:. More information: Magnus blog. How to: just add the following line at the end of Common.js. // Results from Wikidata // if ( mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Search' || ( mw.config.get( 'wgArticleId' ) === 0 && mw.config.get( 'wgCanonicalSpecialPageName' ) === false ) ) { importScriptURI("//en.wikipedia.org/w/index.php?title=MediaWiki:Wdsearch.js&action=raw&ctype=text/javascript"); } --Nemo (comments, translations and last instructions)

Proposed layouts, there is a gadget for this
There is an existing gadget that can be turned on and off for testing proposed layouts "Sandbox for new layouts". This saves having to edit common.js, and having it listed on the layout rotations, and the issues of caches, etc. — billinghurst  sDrewth  05:56, 10 January 2014 (UTC)


 * Yeah but not everybody will see the proposed layout that way, so what is the point? Its passed the testing phase as far as I'm concerned - all I want to get to now is any possible objections/browser issues. I didn't even announce it yet basically for the same reason you're looking to lock in a specific Layout (it no workie). Eliyak would be the person to tap btw. -- George Orwell III (talk) 04:58, 10 January 2014 (UTC)


 * If it is in the rotation, then is it still proposed? If it is in call it 4, and tell people. Or if want people to test we can get them to gadget on. We are doing more and more live and in full view presentation of tests, and that is a change in which I am not fully supporting. We used to test and comment out of full view, and get comment prior to implementation, and that doesn't seem to be the approach now taken. — billinghurst  sDrewth  05:56, 10 January 2014 (UTC)

Updates
Hi George Orwell III!

Could you make these updates to the site JS? This will reduce the number of warnings like Use of "addOnloadHook" is deprecated. Use jQuery instead in the console. Helder.wiki 14:48, 13 March 2014 (UTC)


 * ✅ - Helder.wiki. Keep them coming! I'm [eventually] here everyday :) George Orwell III (talk) 18:27, 13 March 2014 (UTC)
 * George Orwell III, thanks! BTW: it seems you changed the code manually based in the diff I linked above, but I usually provide a full copy of the new code in the sandbox, so you can just copy it from there to replace the current one. Helder.wiki 18:39, 13 March 2014 (UTC)
 * Lesson learned Helder.wiki. I couldn't manage 4 simple changes without screwin' one up. will do from now on. -- George Orwell III (talk) 18:54, 13 March 2014 (UTC)
 * No problem. I also make this some times... Some of the errors are easy to catch by pasting the code on http://www.jshint.com/ to validate it before saving (and possibly setting a few options in the "configure" menu, to avoid warnings about thinks we don't care for now - or if there are many, just count the number of errors before and after a change to at least do not increase it [[Image:Tongue.png]]). Helder.wiki 18:57, 13 March 2014 (UTC)

Gadgetizing PageNumbers.js
In my ongoing quest to convert MediaWiki:PageNumbers.js into a Gadget—so that it can be turned off in order to test updates, alternatives, modifications, layouts, etc.—I have, I think, come up with a reasonable temporary way to disable it when needed.


 * diff

The idea is to have the code that loads PageNumbers.js and the code for the fixup functions conditional on a test for the presence of a particular HTML  attribute that is highly unlikely to occur by accident. This is of course ugly and hacky, but should have no major drawbacks as a temporary solution. Once a Gadgetized version of the script is available that can be enabled and disabled in user preferences in the normal way (or if the attempt is abandoned), this hack can be removed along with the existing PageNumbers.js-related code in Common.js.

(or someone else with global-interface-admin rights) I can't actually test this, but the code is very simple so it should be low risk; and it's easy to roll back if needed. Can you apply the above linked diff to MediaWiki:Common.js? --Xover (talk) 11:32, 16 September 2019 (UTC)
 * but you can turn off already (well, hide) the page numbers in the sidebar at this time ... "page links displayed". Are you wanting to obliterate them completely? — billinghurst  sDrewth  12:28, 17 October 2019 (UTC)
 * I want to disable the code completely, because it modifies the DOM (on all pages in all namespaces) and makes it impossible to experiment with an alternate version of the PageNumbers.js script. And since the current version is buggy and limited in ways that cannot easily be fixed by just reading the code and requesting a simple edit (like the above), there is a need to be able to have a private copy in my userspace for debugging and experimentation, from which I can generate a diff that can be applied to the global version. Or put another way, I need to be able to have my own copy that I can modify without the global version interfering.The above requested edit is the first step: it makes the Pagenumbers-related code disable itself on pages with a very specific HTML tag, so that I can create a test page where the global version is not active at all. The next step will be to make a copy of PageNumbers.js that I can modify until it can function as a Gadget that can be turned on and off at will in user preferences. At which point we can remove all the special code in Common.js (both my extra IF statements, and the original code that those if statements wrap). And at that point, anybody that wants to fix bugs or add new functionality to the script have an easy way to experiment without affecting anybody else until they have something worthwhile to propose as a modification to the global Gadget.Once we're at that point I intend to work on fixing the bugs that prevent us from working around browser bugs tickled by proofreadpage (empty inline elements), and possibly clean up the dynamic layouts system such that it becomes feasible for someone other than GOIII to add or modify layouts (they'd typically be a .css file in Mediawiki:-space, or possibly even a personal stylesheet in User:-space). I don't have specific plans beyond that, but I know we occasionally run into issues with slightly odd page numbering schemes that may become more readily addressable at that point. --Xover (talk) 12:49, 17 October 2019 (UTC)


 * Done, in the way you suggest. If it turns out that's not flexible enough, we could add something like the MW Options API to allow to toggle easily without editing a page, but we'll see if that's needed. Inductiveload— talk/contribs  09:38, 25 August 2020 (UTC)