MediaWiki talk:Common.js/Archive 8
Global JS/CSS "safe" now
{{editprotected}} Looks like developers did the same thing for global JS/CSS files as they already did before for personal js/css files: now the whole page is shown inside <pre class="mw-code mw-js"> tag, which means nothing is going to work inside and we can remove all templates (e.g. {{Interwiki-all}} in MediaWiki:Monobook.css and MediaWiki:Common.css), [[User:]] links, headings, <pre> tags and so on. However, there is still one little reason to keep <source> tag: you can trasclude the file on another page and then still enjoy it with syntax highlighting ∴ Alex Smotrov 22:29, 27 June 2007 (UTC)
- For highlighting add both </pre> before <source ...> and <pre> after </source> tags.--AlefZet 21:57, 28 June 2007 (UTC)
- Well, that was my first idea as well, but it doesn't work since Mediawiki simply replaces all < into <. Note that this doesn't happen immediately after saving (I have no idea why), so if markup on js/css pages seems to work for you, just wait a little and it won't ;) ∴ Alex Smotrov 22:13, 28 June 2007 (UTC)
Now it <pre> with syntax highlighting, which is nice. Still, no markup works inside, so it's better to remove it ∴ Alex Smotrov 16:15, 29 June 2007 (UTC)
Fixed →AzaToth 17:07, 29 June 2007 (UTC)
If you still want to see it with all the bells and whistles (parsed wikicode), try a diff, like: &oldid=141424535&diff=. --Splarka (rant) 07:05, 30 June 2007 (UTC)
- There is ongoing discussion about this on bugzilla (bugs 10196, 10314, 10410, 10422), so don't be surprised if it changes again soon. --ais523 15:39, 2 July 2007 (UTC)
Make "Upload file" more like on commons
{{editprotected}} There are a few things that I would like to propose for en: when uploading files. Most of these are not original ideas. I could provide a link to where they were first proposed but I don't think it's that important. I think they can be done with js of some kind.
- Remove the "Upload file" link in the "toolbox" and move the "File upload wizard" into the "toolbox". I believe this has been done on zh: and can probably be done here with js.
- Have the {{information}} preloaded into the editbox, again, much like at commons, and much of the info filled out. It has been suggested rather to have a link that will fill it in if needed, but personally I don't like the later idea. Having it automatically in the editbox will give people a better idea of what info is needed. I have located how it was done on commons, it is a simple js here.
- A small thing is to have the editbox 50% larger, or more.
This same message went trough the Village Pump (Make "Upload file" more like on Commons) without anyone noticing. So I thought I'd add it here. --Steinninn 16:03, 4 July 2007 (UTC)
- These sound like good ideas, get consensus for them then re-enable the template. Thanks, GDonato (talk) 12:53, 6 July 2007 (UTC)
- I already posted it at the village pump, what more do you need? --Steinninn 13:55, 6 July 2007 (UTC)
- Unfortunately, I am unwilling to make such changes without agreement of the community. The only thing I would say is trying re-listing, possibly at WP:VPT too. GDonato (talk) 18:32, 6 July 2007 (UTC)
- I already posted it at the village pump, what more do you need? --Steinninn 13:55, 6 July 2007 (UTC)
- These sound like good ideas, get consensus for them then re-enable the template. Thanks, GDonato (talk) 12:53, 6 July 2007 (UTC)
Search images
I have just reverted Martinp23's addition of the search engine images. Adding images like these violates our fair use policy and may be interpreted as ads. Sean William 22:46, 19 May 2007 (UTC)
- Agreed. (H) 22:50, 19 May 2007 (UTC)
- Likewise. I factored the images out, but apparantely I'm not allowed to do that, so putting this reversion up for discussion - to be clear, the ideal way to give the external searches would be server-side, in the mediawiki text, but as no params are available in the relevant text, something client side is required. This has been requested in various places, including WP:AN (which, incidentally, is where I decided to add the images code, from fr.wiki, as a favour - still somewhat sick at the hostility of some to an easily reversible mistake...). The removal of the code which I changes is reverted here. Martinp23 00:21, 20 May 2007 (UTC)
- Unfortunately any code pasted here is not easily reverted as it can stayed cached in visitors' browser cache for weeks. Any mistakes in the code can cause anything from annoying popups to appear to all pages on Wikipedia showing up blank during that time. From the simple cut 'n paste job you did I assumed you are not familiar with Javascript yourself, while adding executable code to one of the most visited websites is something that should not be doen without a little care. There are usually enough people hanging around on this page who van evaluate (and perhaps improve the code) on it's correctness, performance impact, maintainability etc. This was not meant as a hostile action, but as necessary caution. A reaction you can sometimes expect when being bold. —Ruud 13:27, 20 May 2007 (UTC)
- I understand your reasons, but should note that this wasn't a "simple cut-and-paste job" - in fact I did test my extensive changes to the code in my personal monobook.js before adding it here - the code below (as I added) is somewhat different from the code on fr.wiki, but I of course do invite people to look over (and inevitably improve) it. Martinp23 14:37, 20 May 2007 (UTC)
- Okay, better safe than sorry was my motto here. No hurt feelings I hope. —Ruud 18:59, 20 May 2007 (UTC)
- Not at all! Thank you for your diligence in taking that care. Feel free to re-enter the js when/if you feel it has been suitably reviewed. Martinp23 19:25, 20 May 2007 (UTC)
- Okay, better safe than sorry was my motto here. No hurt feelings I hope. —Ruud 18:59, 20 May 2007 (UTC)
- I understand your reasons, but should note that this wasn't a "simple cut-and-paste job" - in fact I did test my extensive changes to the code in my personal monobook.js before adding it here - the code below (as I added) is somewhat different from the code on fr.wiki, but I of course do invite people to look over (and inevitably improve) it. Martinp23 14:37, 20 May 2007 (UTC)
- Unfortunately any code pasted here is not easily reverted as it can stayed cached in visitors' browser cache for weeks. Any mistakes in the code can cause anything from annoying popups to appear to all pages on Wikipedia showing up blank during that time. From the simple cut 'n paste job you did I assumed you are not familiar with Javascript yourself, while adding executable code to one of the most visited websites is something that should not be doen without a little care. There are usually enough people hanging around on this page who van evaluate (and perhaps improve the code) on it's correctness, performance impact, maintainability etc. This was not meant as a hostile action, but as necessary caution. A reaction you can sometimes expect when being bold. —Ruud 13:27, 20 May 2007 (UTC)
- Likewise. I factored the images out, but apparantely I'm not allowed to do that, so putting this reversion up for discussion - to be clear, the ideal way to give the external searches would be server-side, in the mediawiki text, but as no params are available in the relevant text, something client side is required. This has been requested in various places, including WP:AN (which, incidentally, is where I decided to add the images code, from fr.wiki, as a favour - still somewhat sick at the hostility of some to an easily reversible mistake...). The removal of the code which I changes is reverted here. Martinp23 00:21, 20 May 2007 (UTC)
- I support the image free version. Good idea. (H) 19:28, 20 May 2007 (UTC)
- See my note below. I'm not a fan, but at least I can do
onloadFuncts.splice(onloadFuncts.indexOf(SpecialSearchEnhanced3), 1)
. GracenotesT § 19:41, 20 May 2007 (UTC)
/** Search page improvements ****************************************************** * Amélioration de la page de recherche v3 * Auteur : Marc Mongenet * Sous licence GFDL & GPL<nowiki> * Improvement to search page * Authour: Marc Mongenet (from fr.wiki) * Licensed GFDL and GPL * Modified for en-wiki by Martinp23 */ function SpecialSearchEnhanced3() { function SearchForm(search_action_url, engine_url, engine_name, search_field_name, search_field_value, site_field_name, site_field_value) { var span = document.createElement("div"); span.style.marginRight = "1em"; span.style.width="100%"; span.style.whiteSpace = "nowrap"; var form = document.createElement("form"); form.method = "get"; form.action = search_action_url; form.style.display = "inline"; span.appendChild(form); var input = document.createElement("input"); input.type = "hidden"; input.name = search_field_name; form.appendChild(input); var site = document.createElement("input"); site.type = "hidden"; site.name = site_field_name; site.value = site_field_value; form.appendChild(site); form.onsubmit = function() { input.value = document.getElementById("lsearchbox").value; } var submit = document.createElement("input"); submit.type = "submit"; submit.style.margin = "3px"; submit.value = "Use " + engine_name + " search"; form.appendChild(submit); return span; } if (typeof SpecialSearchEnhanced3Disabled != 'undefined') return; if (wgPageName != "Special:Search") return; var mainNode = document.getElementsByTagName("form"); if (!mainNode) return; mainNode = mainNode[0]; mainNode.appendChild(document.createElement("center")); mainNode = mainNode.lastChild; var searchValue = document.getElementById("lsearchbox").value; var engine; engine = SearchForm("http://www.google.com/search", "http://www.google.com/", "Google", "q", searchValue, "as_sitesearch", "en.wikipedia.org"); mainNode.appendChild(engine); engine = SearchForm("http://www.wikiwix.com/", "http://www.wikiwix.com/", "Wikiwix", "action", searchValue, "lang", "en"); mainNode.appendChild(engine); engine = SearchForm("http://search.live.com/results.aspx", "http://search.live.com/", "Windows Live", "q", searchValue, "q1", "site:http://en.wikipedia.org"); mainNode.appendChild(engine); engine = SearchForm("http://en.search.yahoo.com/search", "http://en.search.yahoo.com/", "Yahoo!", "p", searchValue, "vs", "en.wikipedia.org"); mainNode.appendChild(engine); } addOnloadHook(SpecialSearchEnhanced3); /* End of search page */
Drop-down approach
{{editprotected}}
Hm... could we possibly keep the buttons down to a minumum? Mere links would be good, I think. I mean... I dislike them: too large, and too many of them. GracenotesT § 19:23, 20 May 2007 (UTC)
- I agree, a drop-down list should be used to let the user select which search engine he wants to use (defaulting to MediaWiki's internal search engine). —Ruud 19:49, 20 May 2007 (UTC)
- What I think would look nice would be to have them as links instead of buttons, and to have them side-by-side instead of one-under-the-other, to save screen space. Tra (Talk) 20:40, 20 May 2007 (UTC)
- I personally like Ruud's solution: all it requires is creating a menu, and then changing the action of the form when the selection is changed. And only one form is required. GracenotesT § 20:57, 20 May 2007 (UTC)
This code might work, if anyone's in favor of it, and if it works on all browsers:
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', '/w/index.php', 'search', 'title', 'Special:Search')); selectBox.appendChild(createOption('Google', 'http://www.google.com/search', 'q', 'as_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')); searchForm.lsearchbox.style.marginLeft = '0px'; var lStat = document.getElementById('loadStatus'); lStat.parentNode.insertBefore(selectBox, lStat); }
The only problem is that "fulltext=search" is submitted as part of the query, since that's the name/value of the submit button. GracenotesT § 02:32, 23 May 2007 (UTC)
- Could we add Wikiwix to that? It has been requested on AN and not objected to there, and the development team for that have (AFAIK) gone to great lengths to ensure a quick and very accurate search, optimised to Wiki*edia projects. Martinp23 09:48, 23 May 2007 (UTC)
- Done. Feel free to change the order. GracenotesT § 17:10, 23 May 2007 (UTC)
- I've requested the changes; does anyone object for any reason? GracenotesT § 21:26, 23 May 2007 (UTC)
Done. Cheers. --MZMcBride 23:34, 24 May 2007 (UTC)
The code for Mediawiki search fails when using the secure server. It brings up secure.wikimedia.org/w/index.php which leads to a "Wiki does not exist" message. Can someone make the script check for secure.wikimedia.org and change the Mediawiki search URL accordingly? Resurgent insurgent 01:25, 26 May 2007 (UTC)
- The code that says
'/w/index.php'
should be changed towgScriptPath + '/index.php'
. Mike Dillon 01:40, 26 May 2007 (UTC)Done. Purge and all that.... Cheers. --MZMcBride 02:06, 26 May 2007 (UTC)
{{editprotected}}
Is it all right if someone changes "as_sitesearch" to "sitesearch" for the Google drop-down item in this script, which produces this search rather than this one? The former is a bit cleaner, and less confusing for people who are less familiar with Google. Thank you, GracenotesT § 00:40, 9 June 2007 (UTC)
Done. Cheers. --MZMcBride 01:11, 9 June 2007 (UTC)
CJK character problems with Yahoo!
There's some problems when searching some terms including the CJK characters when searching using the Yahoo! option. And I've found out that a field name and a value is required in addition of the existing search term that using the Yahoo! sarch engine. i.e. the [ei=utf-8] is required when a Yahoo! search engine is selected. Any idea how to solve this issue? Shinjiman ⇔ ♨ 13:46, 9 July 2007 (UTC)
- It would require a bit of tweaking to the script since it assumes that there is only one additional parameter besides the free text field used for the search term. For Yahoo!, this is currently being used for
vs=en.wikipedia.org
. The code would have to be changed to add a hidden element to the form for theei
parameter on submit, which would significantly alter the structure of the code. Mike Dillon 02:24, 10 July 2007 (UTC)
small replace() bug
{{editprotected}}
The definitions of importScript
and importStylesheet
call page.replace( ' ', '_' )
, but this will only replace the first space in page
, without touching the rest.
This is not a big deal, because Wikipedia generates a 301 Moved Permanently for the spaced URL, but the code should probably be corrected to page.replace(/_/g, ' ')
, for neatness and efficiency. --Piet Delport 01:42, 5 July 2007 (UTC)
- That is, switch that around,
page.replace(/ /g, '_')
(orpage.replace(/\s/g, '_')
). GracenotesT § 04:13, 5 July 2007 (UTC)Done (after testing the relevant expressions). (There are certainly a lot of ways to express the intended concept; I went for / /g in the actual change, but when writing my own code I often use /\ /g (which is correct in both JavaScript and Perl, even when using Perl's /x modifier) or even split(" ").join("_") (which has the advantages of accepting non-literal strings). --ais523 17:22, 6 July 2007 (UTC)
- Right, my copy&paste mistake. --Piet Delport 10:14, 11 July 2007 (UTC)