MediaWiki talk:Common.js/Archive 14
{{Link GA}}I'd like to add the support for a Link GA template, similar to Link FA. All this has already been implemented and tested on the French wiki. (fr:Modèle:Lien BA) I currently have a bot overthere that is adding the template, and I wanted to do the same here. An example of a GA link in interwikis can be found overthere : fr:Pi. In fact you would need to alter LinkFA() into function LinkFAorGA()
{
if ( document.getElementById( "p-lang" ) ) {
var InterwikiLinks = document.getElementById( "p-lang" ).getElementsByTagName( "li" );
for ( var i = 0; i < InterwikiLinks.length; i++ ) {
if ( document.getElementById( InterwikiLinks[i].className + "-fa" ) ) {
InterwikiLinks[i].className += " FA"
InterwikiLinks[i].title = "This is a featured article in another language.";
}
else if ( document.getElementById( InterwikiLinks[i].className + "-ga" ) ) {
InterwikiLinks[i].className += " GA"
InterwikiLinks[i].title = "This is a good article in another language.";
}
}
}
}
addOnloadHook( LinkFAorGA );
and add into Monobook.css li.GA {
list-style-image: url("http://upload.wikimedia.org/wikipedia/fr/8/86/Icone_BA.png");
}
(You might need to find another link in en: to that very same image, thought) Thanks, NicDumZ ~ 17:46, 20 December 2007 (UTC)
Edit made without consensus
Please undo this recent edit. This edit does not have consensus. The TeX markup was not intended to be displayed in the tooltips of images, and if we are going to make a change to display the markup in image tooltips, the change should be made for all browsers, not just Internet Explorer. —Remember the dot (talk) 21:26, 29 December 2007 (UTC)
/* Use alt attribute as the tooltip text, for example with TeX-generated images. The MediaWiki software never adds title attributes to images anyway, so there is no danger of overwriting an existing tooltip. */ function useAltForTooltips() { var documentImages = document.images for (var i = 0; i < documentImages.length; i++) { var img = documentImages[i] img.title = img.alt } } if (!window.useAltForTooltipsDisabled) { window.addOnloadHook(useAltForTooltips) }
class,IPAThe {{IPA}} template which is based on class.IPA forces Firefox to display the IPA correctly, but adding to a table class="IPA" or class="IPA wikitable", which are based on the same class, does not. Instead, it displays with Arial Unicode, which is defective in its IPA range. How do we fix this? kwami (talk) 07:06, 3 January 2008 (UTC)
Hide "user page" link for anonymous users
I proposed this at Wikipedia:Village pump (proposals)#Hide "user page" link for anonymous users and there were no serious objections, so I'd like to have this code added to the site-wide JavaScript. If this causes a revolt then just remove it. If people like it then we can ask the developers to provide a way to do this more elegantly through CSS. /** Automatically hide "user page" link for anonymous users that do not have user pages * Created by Remember_the_dot */ function hideAnonUserPageLink() { var userPageLink = document.getElementById("ca-nstab-user") if (!window.hideAnonUserPageLinkDisabled && userPageLink.className == "new") { document.getElementById("ca-nstab-user").style.visibility = "hidden" } } if (wgPageName.search(/^(User_talk:(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))$/) == 0) { window.addOnloadHook(hideAnonUserPageLink) } I can also make a gadget to disable this behavior if there is demand for it. —Remember the dot (talk) 01:48, 4 January 2008 (UTC)
You can estimate how often IP user pages are used with about 200 searches like Special:Prefixindex/User:78.. It seems like not very often, most are redirects to talk pages. I agree that this kind of script is a hack and instead we need either a MediaWiki fix or a policy which would say "only use user_talk: for IPs" ∴ AlexSm 16:40, 4 January 2008 (UTC)
If we could do this through CSS, and the CSS only changed the link's color from red to gray instead of removing it entirely, would you support the change? —Remember the dot (talk) 18:57, 4 January 2008 (UTC) I've filed bug 12509 about doing this more elegantly with CSS. —Remember the dot (talk) 02:11, 5 January 2008 (UTC) addDismissButton in OperaI don't think addDismissButton() should continue after it finds out that the cookie is set to hide the message. There is no point to create [dismiss] link after that. Besides, for some reason this link is still visible in Opera (9.25) while the whole message is hidden (probably Opera's fault, but still...). In other words, we need a On subpages and tabsCurrently, when you're at a subpage, e.g., Template:Infobox Election/doc, the "discussion" tab links to the /doc talk page rather than the main talk page. I asked User:Splarka if there was a JavaScript way to fix this, and he wrote the code found below. It changes the tab to blue and links it to the main talk page if the tab is already non-existent. It's currently written to only work on /doc and /sandbox pages. Would there be any objections to implementing it site-wide? It would save a lot of unnecessary redirects. Improvements are, of course, welcome. Cheers. --MZMcBride (talk) 06:22, 7 January 2008 (UTC) if(wgPageName.indexOf('/')!=-1 && (wgNamespaceNumber % 2)==0) addOnloadHook(redirSubpageTalk)
function redirSubpageTalk() {
var redir = [
/\/doc/i,
/\/sandbox/i
]
var talk = document.getElementById('ca-talk')
if(talk.className.indexOf('new')==-1) return;
var talka = talk.getElementsByTagName('a')[0];
for(var i=0;i<redir.length;i++) {
if(talka.href.search(redir[i])!=-1) {
talka.href = talka.href.replace(redir[i],'').replace(/action\=edit/i,'action=view');
talk.className = '';
}
}
}
Problems with collapsible shells and older safari browsersHi - I've just realised that the reason so many navigation templates and WikiProject banners seem to have disappeared from Wikipedia in the last few months is that they haven't gone - I've just been unable to see them. With the combination of browser and platform I (and presumably other) WP editors use (Mac OS 10.2.8/ Safari 1.0.3) the shell renders all templates within it as thin, unexpandable lines. Is there any way to fix this so that I don't have to physically edit the article to see what templates are on it? There's some discussion of this already at Template_talk:WikiProjectBannerShell, which is where I first raised this issue, but the suggestion there is that this is the place to come. As an example of what I mean, here's how the top of Talk:Algeria looks to me: User:Anomie suggests that: " If that is the case, I suspect the problem is on line 126 of the current version as I remember hearing that particularly old versions of Safari do not correctly support the table "rows" collection." Any possible way of fixing the problem? Grutness...wha? 23:21, 18 January 2008 (UTC)
I have had to revert this change, unfortunately. It broke functionality in nested tables in that they automatically expanded (and still showing the [show] link) when the main table is expanded. This needs more testing. — Edokter • Talk • 15:12, 19 January 2008 (UTC)
smaxage=0Due to persistent caching of user/site scripts and stylesheets, what do you think of temporarily modifying the following two lines from importScript and importStylesheet? + '&action=raw&ctype=text/javascript';
+ '&action=raw&ctype=text/css";'
to include &smaxage=0 so as to reduce the server-side cache to as low a number as possible? Eg: + '&action=raw&smaxage=0&ctype=text/javascript';
+ '&action=raw&smaxage=0&ctype=text/css";'
Notes:
Please reach consensus before implementing (if at all?). An implement/revert/implement/revert battle over this, coupled with the caching bugs, would be worse than no action taken at all. --Splarka (rant) 05:27, 21 January 2008 (UTC)
import*() better?A secondary request is to have these functions able to import scripts/styles from elsewhere, for example:
This would only take a quick if() block around the URL generator, eg for importScript something like... (the css version would be similar): if(page.indexOf('http://') == 0 || page.indexOf('https://') == 0 || page.indexOf('file://') == 0) {
var url = page;
} else {
var url = wgScript + '?title=' + encodeURIComponent( page.replace( / /g, '_' ) )
+ '&action=raw&ctype=text/javascript';
}
Note: You may be tempted to ask for an tertiary interwiki feature, eg to [[m:User:Foo/bar.js]] but this would be... very hard to implement, as well as support, while the above modification would be relatively easy if done properly. Thoughts? --Splarka (rant) 05:27, 21 January 2008 (UTC)
I have made versions of import* that do this for myself so that I can test them: See my diff. I agree that there is a risk for increased usage of external scripts, but I'm not sure wether that is a real problem. It is already happening with some of our most profound scripts (Lupin's tools, mini atlas, and CH2 all use commons and local servers for scripts). I don't really see the added danger, but; we could check for something like Problem with importStylesheet on Internet Explorer
I mainly use Firefox, but I write some javascript that I want IE users to be able to use too. With Internet Explorer 7, I can't do appendChild on a STYLE element, nor can I set the innerHTML (both gives me errors). Thus, the importStylesheet() function here does not work with IE7 (though it does work fine with Firefox, Opera, and Safari). Instead, IE can use the document.createStyleSheet() function. -Pan Sola (talk) 09:31, 27 January 2008 (UTC)
Is there a specific edit that needs to be done? If not, please do not use the editprotected template as a general call for help. — Edokter • Talk • 15:15, 27 January 2008 (UTC)
Here is the diff that would do this. --TheDJ (talk • contribs) 22:10, 27 January 2008 (UTC)
See also #import.2A.28.29_better.3F, but this createStylesheet() implementation is currently active in my private implementation of the import*() functions. --TheDJ (talk • contribs) 16:22, 21 February 2008 (UTC) Big performance improvement{{editprotected}} It's been suggested before that we factor out all the IE fixes, but nobody actually took the time to do it. Were this done, we would see two improvements:
So, I went through and came up with the code necessary to do it. The scripts will all continue to work as before, but users will see an improvement in page load time. Since this doesn't involve an appreciable change in behavior, we should be able to just go ahead and do it. Please create MediaWiki:Common IE.js with: /* Import fixes specific to Internet Explorer 6.0 *****************************/ if (navigator.appVersion.substr(22, 1) == "6") { importScript("MediaWiki:Common IE6.js") } /** Internet Explorer bug fix ************************************************** * * Description: Fixes IE horizontal scrollbar bug * Maintainers: [[User:Tom-]]? */ if (document.compatMode == "CSS1Compat") { var oldWidth; var docEl = document.documentElement; function fixIEScroll() { if (!oldWidth || docEl.clientWidth > oldWidth) doFixIEScroll(); else setTimeout(doFixIEScroll, 1); oldWidth = docEl.clientWidth; } function doFixIEScroll() { docEl.style.overflowX = (docEl.scrollWidth - docEl.clientWidth < 4) ? "hidden" : ""; } document.attachEvent("onreadystatechange", fixIEScroll); attachEvent("onresize", fixIEScroll); } /** IE 6 Z-index bug workaround for anonnotice ************************** * * Description: This implements a work around for the Z-index bug found in Internet Explorer. * It correctly places the anon notice on the page, even under IE6. * See this Google search for more information about the bug: * http://www.google.com/search?hl=en&client=firefox-a&rls=org.mozilla%3Aen-US%3Aofficial&hs=q74&q=z-index+ie6+bug&btnG=Search * Created by: [[User:Gmaxwell]] */ addOnloadHook((function (){ if (wgUserName == null) { var messageEdu=new Array(); messageEdu[0]='<a href="http://en.wikipedia.org/wiki/Wikipedia:Researching_with_Wikipedia" title="Wikipedia:Researching with Wikipedia">Learn more about using Wikipedia for research</a>'; messageEdu[1]='<a href="http://en.wikipedia.org/wiki/Wikipedia:Ten_things_you_may_not_know_about_Wikipedia" title="Wikipedia:Ten things you may not know about Wikipedia">Ten things you may not know about Wikipedia</a>'; messageEdu[2]='<a href="http://en.wikipedia.org/wiki/Wikipedia:Ten_things_you_may_not_know_about_images_on_Wikipedia" title="Wikipedia:Ten things you may not know about images on Wikipedia">Ten things you may not know about images on Wikipedia</a>'; messageEdu[3]='<a href="http://en.wikipedia.org/wiki/Wikipedia:Citing_Wikipedia" title="Wikipedia:Citing Wikipedia">Learn more about citing Wikipedia</a>'; messageEdu[4]='Have questions? <a href="http://en.wikipedia.org/wiki/Wikipedia:Questions" title="Wikipedia:Questions">Find out how to ask questions and get answers.</a>'; messageEdu[5]='<a href="http://en.wikipedia.org/wiki/Wikipedia:Basic_navigation" title="Wikipedia:Basic navigation">Find out more about navigating Wikipedia and finding information</a>'; messageEdu[6]='<a href="http://en.wikipedia.org/wiki/Wikipedia:Contributing_to_Wikipedia" title="Wikipedia:Contributing to Wikipedia">Interested in contributing to Wikipedia?</a>'; var whichMessageEdu = Math.floor(Math.random()*(messageEdu.length)); /** document.getElementById("contentSub").innerHTML +='<div style="position:absolute; z-index:100; right:100px; top:0px;" class="metadata" id="anontip"><div style="text-align:right; font-size:87%">• <i>' + messageEdu[whichMessageEdu] + '</i> •</div></div>'; */ } })); /** * Remove need for CSS hacks regarding MSIE and IPA. */ if (document.createStyleSheet) { document.createStyleSheet().addRule('.IPA', 'font-family: "Doulos SIL", "Charis SIL", Gentium, "DejaVu Sans", Code2000, "TITUS Cyberbit Basic", "Arial Unicode MS", "Lucida Sans Unicode", "Chrysanthi Unicode";'); Please create MediaWiki:Common IE6.js with: /** * Correctly handle PNG transparency in Internet Explorer 6. * http://homepage.ntlworld.com/bobosola. Updated 18-Jan-2006. * * Adapted for Wikipedia by Remember_the_dot and Edokter. * * http://homepage.ntlworld.com/bobosola/pnginfo.htm states "This page contains more information for * the curious or those who wish to amend the script for special needs", which I take as permission to * modify or adapt this script freely. I release my changes into the public domain. */ function PngFix() { try { if (!document.body.filters) { window.PngFixDisabled = true } } catch (e) { window.PngFixDisabled = true } if (!window.PngFixDisabled) { var documentImages = document.images var documentCreateElement = document.createElement var funcEncodeURI = encodeURI for (var i = 0; i < documentImages.length;) { var img = documentImages[i] var imgSrc = img.src if (imgSrc.substr(imgSrc.length - 3).toLowerCase() == "png" && !img.onclick) { if (img.useMap) { img.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + encodeURI(imgSrc) + "')" img.src = "http://upload.wikimedia.org/wikipedia/commons/c/ce/Transparent.gif" i++ } else { var outerSpan = documentCreateElement("span") var innerSpan = documentCreateElement("span") var outerSpanStyle = outerSpan.style var innerSpanStyle = innerSpan.style var imgCurrentStyle = img.currentStyle outerSpan.id = img.id outerSpan.title = img.title outerSpan.className = img.className outerSpanStyle.backgroundImage = imgCurrentStyle.backgroundImage outerSpanStyle.borderWidth = imgCurrentStyle.borderWidth outerSpanStyle.borderStyle = imgCurrentStyle.borderStyle outerSpanStyle.borderColor = imgCurrentStyle.borderColor outerSpanStyle.display = "inline-block" outerSpanStyle.fontSize = "0" outerSpanStyle.verticalAlign = "middle" if (img.parentElement.href) outerSpanStyle.cursor = "hand" innerSpanStyle.width = "1px" innerSpanStyle.height = "1px" innerSpanStyle.display = "inline-block" innerSpanStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + funcEncodeURI(imgSrc) + "')" outerSpan.appendChild(innerSpan) img.parentNode.replaceChild(outerSpan, img) } } else { i++ } } } } window.attachEvent("onload", PngFix) And finally, change MediaWiki:Common.js to: /** Import module ************************************************************* * * Description: Includes a raw wiki page as javascript or CSS, * used for including user made modules. * Maintainers: [[User:AzaToth]] */ importedScripts = {}; // object keeping track of included scripts, so a script ain't included twice function importScript( page ) { if( importedScripts[page] ) { return; } importedScripts[page] = true; var url = wgScriptPath + '/index.php?title=' + encodeURIComponent( page.replace( / /g, '_' ) ) + '&action=raw&ctype=text/javascript'; var scriptElem = document.createElement( 'script' ); scriptElem.setAttribute( 'src' , url ); scriptElem.setAttribute( 'type' , 'text/javascript' ); document.getElementsByTagName( 'head' )[0].appendChild( scriptElem ); } function importStylesheet( page ) { var sheet = '@import "' + wgScriptPath + '/index.php?title=' + encodeURIComponent( page.replace( / /g, '_' ) ) + '&action=raw&ctype=text/css";' var styleElem = document.createElement( 'style' ); styleElem.setAttribute( 'type' , 'text/css' ); styleElem.appendChild( document.createTextNode( sheet ) ); document.getElementsByTagName( 'head' )[0].appendChild( styleElem ); } /** Internet Explorer fixes ***************************************************/ if (navigator.appName == "Microsoft Internet Explorer") { importScript("MediaWiki:Common IE.js") } /** Test if an element has a certain class ************************************* * * Description: Uses regular expressions and caching for better performance. * Maintainers: [[User:Mike Dillon]], [[User:R. Koot]], [[User:SG]] */ var hasClass = (function () { var reCache = {}; return function (element, className) { return (reCache[className] ? reCache[className] : (reCache[className] = new RegExp("(?:\\s|^)" + className + "(?:\\s|$)"))).test(element.className); }; })(); /** Interwiki links to featured articles *************************************** * * Description: Highlights interwiki links to featured articles (or * equivalents) by changing the bullet before the interwiki link * into a star. * Maintainers: [[User:R. Koot]] */ function LinkFA() { if ( document.getElementById( "p-lang" ) ) { var InterwikiLinks = document.getElementById( "p-lang" ).getElementsByTagName( "li" ); for ( var i = 0; i < InterwikiLinks.length; i++ ) { if ( document.getElementById( InterwikiLinks[i].className + "-fa" ) ) { InterwikiLinks[i].className += " FA" InterwikiLinks[i].title = "This is a featured article in another language."; } } } } addOnloadHook( LinkFA ); /** Collapsible tables ********************************************************* * * Description: Allows tables to be collapsed, showing only the header. See * [[Wikipedia:NavFrame collapsed]]. * Maintainers: [[User:R. Koot]] */ var autoCollapse = 2; var collapseCaption = "hide"; var expandCaption = "show"; function collapseTable( tableIndex ) { var Button = document.getElementById( "collapseButton" + tableIndex ); var Table = document.getElementById( "collapsibleTable" + tableIndex ); if ( !Table || !Button ) { return false; } var Rows = Table.rows; if ( Button.firstChild.data == collapseCaption ) { for ( var i = 1; i < Rows.length; i++ ) { Rows[i].style.display = "none"; } Button.firstChild.data = expandCaption; } else { for ( var i = 1; i < Rows.length; i++ ) { Rows[i].style.display = Rows[0].style.display; } Button.firstChild.data = collapseCaption; } } function createCollapseButtons() { var tableIndex = 0; var NavigationBoxes = new Object(); var Tables = document.getElementsByTagName( "table" ); for ( var i = 0; i < Tables.length; i++ ) { if ( hasClass( Tables[i], "collapsible" ) ) { /* only add button and increment count if there is a header row to work with */ var HeaderRow = Tables[i].getElementsByTagName( "tr" )[0]; if (!HeaderRow) continue; var Header = HeaderRow.getElementsByTagName( "th" )[0]; if (!Header) continue; NavigationBoxes[ tableIndex ] = Tables[i]; Tables[i].setAttribute( "id", "collapsibleTable" + tableIndex ); var Button = document.createElement( "span" ); var ButtonLink = document.createElement( "a" ); var ButtonText = document.createTextNode( collapseCaption ); Button.style.styleFloat = "right"; Button.style.cssFloat = "right"; Button.style.fontWeight = "normal"; Button.style.textAlign = "right"; Button.style.width = "6em"; ButtonLink.style.color = Header.style.color; ButtonLink.setAttribute( "id", "collapseButton" + tableIndex ); ButtonLink.setAttribute( "href", "javascript:collapseTable(" + tableIndex + ");" ); ButtonLink.appendChild( ButtonText ); Button.appendChild( document.createTextNode( "[" ) ); Button.appendChild( ButtonLink ); Button.appendChild( document.createTextNode( "]" ) ); Header.insertBefore( Button, Header.childNodes[0] ); tableIndex++; } } for ( var i = 0; i < tableIndex; i++ ) { if ( hasClass( NavigationBoxes[i], "collapsed" ) || ( tableIndex >= autoCollapse && hasClass( NavigationBoxes[i], "autocollapse" ) ) ) { collapseTable( i ); } } } addOnloadHook( createCollapseButtons ); /** Dynamic Navigation Bars (experimental) ************************************* * * Description: See [[Wikipedia:NavFrame]]. * Maintainers: UNMAINTAINED */ // set up the words in your language var NavigationBarHide = '[' + collapseCaption + ']'; var NavigationBarShow = '[' + expandCaption + ']'; // shows and hides content and picture (if available) of navigation bars // Parameters: // indexNavigationBar: the index of navigation bar to be toggled function toggleNavigationBar(indexNavigationBar) { var NavToggle = document.getElementById("NavToggle" + indexNavigationBar); var NavFrame = document.getElementById("NavFrame" + indexNavigationBar); if (!NavFrame || !NavToggle) { return false; } // if shown now if (NavToggle.firstChild.data == NavigationBarHide) { for ( var NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling ) { if ( hasClass( NavChild, 'NavPic' ) ) { NavChild.style.display = 'none'; } if ( hasClass( NavChild, 'NavContent') ) { NavChild.style.display = 'none'; } } NavToggle.firstChild.data = NavigationBarShow; // if hidden now } else if (NavToggle.firstChild.data == NavigationBarShow) { for ( var NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling ) { if (hasClass(NavChild, 'NavPic')) { NavChild.style.display = 'block'; } if (hasClass(NavChild, 'NavContent')) { NavChild.style.display = 'block'; } } NavToggle.firstChild.data = NavigationBarHide; } } // adds show/hide-button to navigation bars function createNavigationBarToggleButton() { var indexNavigationBar = 0; // iterate over all < div >-elements var divs = document.getElementsByTagName("div"); for( var i=0; NavFrame = divs[i]; i++ ) { // if found a navigation bar if (hasClass(NavFrame, "NavFrame")) { indexNavigationBar++; var NavToggle = document.createElement("a"); NavToggle.className = 'NavToggle'; NavToggle.setAttribute('id', 'NavToggle' + indexNavigationBar); NavToggle.setAttribute('href', 'javascript:toggleNavigationBar(' + indexNavigationBar + ');'); var NavToggleText = document.createTextNode(NavigationBarHide); for ( var NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling ) { if ( hasClass( NavChild, 'NavPic' ) || hasClass( NavChild, 'NavContent' ) ) { if (NavChild.style.display == 'none') { NavToggleText = document.createTextNode(NavigationBarShow); break; } } } NavToggle.appendChild(NavToggleText); // Find the NavHead and attach the toggle link (Must be this complicated because Moz's firstChild handling is borked) for( var j=0; j < NavFrame.childNodes.length; j++ ) { if (hasClass(NavFrame.childNodes[j], "NavHead")) { NavFrame.childNodes[j].appendChild(NavToggle); } } NavFrame.setAttribute('id', 'NavFrame' + indexNavigationBar); } } } addOnloadHook( createNavigationBarToggleButton ); /** Main Page layout fixes ********************************************************* * * Description: Various layout fixes for the main page, including an * additional link to the complete list of languages available * and the renaming of the 'Article' to to 'Main Page'. * Maintainers: [[User:AzaToth]], [[User:R. Koot]], [[User:Alex Smotrov]] */ function mainPageRenameNamespaceTab() { try { var Node = document.getElementById( 'ca-nstab-main' ).firstChild; if ( Node.textContent ) { // Per DOM Level 3 Node.textContent = 'Main Page'; } else if ( Node.innerText ) { // IE doesn't handle .textContent Node.innerText = 'Main Page'; } else { // Fallback Node.replaceChild( Node.firstChild, document.createTextNode( 'Main Page' ) ); } } catch(e) { // bailing out! } } if ( wgTitle == 'Main Page' && ( wgNamespaceNumber == 0 || wgNamespaceNumber == 1 ) ) { addOnloadHook( mainPageRenameNamespaceTab ); } if ( wgTitle == 'Main Page' && wgNamespaceNumber == 0 ) { addOnloadHook( mainPageAppendCompleteListLink ); } function mainPageAppendCompleteListLink() { addPortletLink('p-lang', 'http://meta.wikimedia.org/wiki/List_of_Wikipedias', 'Complete list', 'interwiki-completelist', 'Complete list of Wikipedias') } /** Extra toolbar options ****************************************************** * * Description: UNDOCUMENTED * Maintainers: [[User:MarkS]]?, [[User:Voice of All]], [[User:R. Koot]] */ //This is a modified copy of a script by User:MarkS for extra features added by User:Voice of All. // This is based on the original code on Wikipedia:Tools/Editing tools // To disable this script, add <code>mwCustomEditButtons = [];<code> to [[Special:Mypage/monobook.js]] if (mwCustomEditButtons) { mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://upload.wikimedia.org/wikipedia/en/c/c8/Button_redirect.png", "speedTip": "Redirect", "tagOpen": "#REDIRECT [[", "tagClose": "]]", "sampleText": "Insert text"}; mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://upload.wikimedia.org/wikipedia/en/c/c9/Button_strike.png", "speedTip": "Strike", "tagOpen": "<s>", "tagClose": "</s>", "sampleText": "Strike-through text"}; mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://upload.wikimedia.org/wikipedia/en/1/13/Button_enter.png", "speedTip": "Line break", "tagOpen": "<br />", "tagClose": "", "sampleText": ""}; mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://upload.wikimedia.org/wikipedia/en/8/80/Button_upper_letter.png", "speedTip": "Superscript", "tagOpen": "<sup>", "tagClose": "</sup>", "sampleText": "Superscript text"}; mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://upload.wikimedia.org/wikipedia/en/7/70/Button_lower_letter.png", "speedTip": "Subscript", "tagOpen": "<sub>", "tagClose": "</sub>", "sampleText": "Subscript text"}; mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://upload.wikimedia.org/wikipedia/en/5/58/Button_small.png", "speedTip": "Small", "tagOpen": "<small>", "tagClose": "</small>", "sampleText": "Small Text"}; mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://upload.wikimedia.org/wikipedia/en/3/34/Button_hide_comment.png", "speedTip": "Insert hidden Comment", "tagOpen": "<!-- ", "tagClose": " -->", "sampleText": "Comment"}; mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://upload.wikimedia.org/wikipedia/en/1/12/Button_gallery.png", "speedTip": "Insert a picture gallery", "tagOpen": "\n<gallery>\n", "tagClose": "\n</gallery>", "sampleText": "Image:Example.jpg|Caption1\nImage:Example.jpg|Caption2"}; mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://upload.wikimedia.org/wikipedia/en/f/fd/Button_blockquote.png", "speedTip": "Insert block of quoted text", "tagOpen": "<blockquote>\n", "tagClose": "\n</blockquote>", "sampleText": "Block quote"}; mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://upload.wikimedia.org/wikipedia/en/6/60/Button_insert_table.png", "speedTip": "Insert a table", "tagOpen": '{| class="wikitable"\n|-\n', "tagClose": "\n|}", "sampleText": "! header 1\n! header 2\n! header 3\n|-\n| row 1, cell 1\n| row 1, cell 2\n| row 1, cell 3\n|-\n| row 2, cell 1\n| row 2, cell 2\n| row 2, cell 3"}; mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://upload.wikimedia.org/wikipedia/commons/7/79/Button_reflink.png", "speedTip": "Insert a reference", "tagOpen": "<ref>", "tagClose": "</ref>", "sampleText": "Insert footnote text here"}; } /*</nowiki>*/ /** pageview counter *********************************************************** * * Description: Please talk to de:User:LeonWeber before changing anything or * if there are any issues with that. * Maintainers: [[:de:User:LeonWeber]]? */ // this should be adjusted to a good value. // BE CAREFUL, you will break zedler if it's too low! // And then DaB. will kill Leon :-( var disable_counter = 0; var counter_factor = 6000; function pgcounter_setup() { if(disable_counter == 0) { var url = window.location.href; if(Math.floor(Math.random()*counter_factor)==42) // the probability thing { if(wgIsArticle==true || wgArticleId==0) // do not count history pages etc. { var pgcountNs = wgCanonicalNamespace; if(wgCanonicalNamespace=="") { pgcountNs = "0"; } var cnt_url = "http://pgcount.wikimedia.de/index.png?ns=" + pgcountNs + "&title=" + encodeURI(wgTitle) + "&factor=" + counter_factor +"&wiki=enwiki"; var img = new Image(); img.src = cnt_url; } } } } // Do not use aOnloadFunctions[aOnloadFunctions.length] = pgcounter_setup;, some browsers don't like that. pgcounter_setup(); /** "Technical restrictions" title fix ***************************************** * * Description: * Maintainers: User:Interiot, User:Mets501, User:Freakofnurture */ // // For pages that have something like Template:Lowercase, replace the title, but only if it is cut-and-pasteable as a valid wikilink. // (for instance iPod's title is updated. But [[C#]] is not an equivalent // wikilink, so [[C Sharp]] doesn't have its main title changed) // Likewise for users who have selected the U.K. date format ("1 March") the // titles of day-of-the-year articles will appear in that style. Users with any // other date setting are not affected. // // The function looks for a banner like this: // <div id="RealTitleBanner"> ... <span id="RealTitle">title</span> ... </div> // An element with id=DisableRealTitle disables the function. // var disableRealTitle = 0; // users can set disableRealTitle = 1 locally to disable. if (wgIsArticle) { // don't display the RealTitle when editing, since it is apparently inconsistent (doesn't show when editing sections, doesn't show when not previewing) addOnloadHook(function() { try { var realTitleBanner = document.getElementById("RealTitleBanner"); if (realTitleBanner && !document.getElementById("DisableRealTitle") && !disableRealTitle ) { var realTitle = document.getElementById("RealTitle"); if (realTitle) { var realTitleHTML = realTitle.innerHTML; realTitleText = pickUpText(realTitle); var isPasteable = 0; //var containsHTML = /</.test(realTitleHTML); // contains ANY HTML var containsTooMuchHTML = /</.test( realTitleHTML.replace(/<\/?(sub|sup|small|big)>/gi, "") ); // contains HTML that will be ignored when cut-n-pasted as a wikilink // calculate whether the title is pasteable var verifyTitle = realTitleText.replace(/^ +/, ""); // trim left spaces verifyTitle = verifyTitle.charAt(0).toUpperCase() + verifyTitle.substring(1, verifyTitle.length); // uppercase first character // if the namespace prefix is there, remove it on our verification copy. If it isn't there, add it to the original realValue copy. if (wgNamespaceNumber != 0) { if (wgCanonicalNamespace == verifyTitle.substr(0, wgCanonicalNamespace.length).replace(/ /g, "_") && verifyTitle.charAt(wgCanonicalNamespace.length) == ":") { verifyTitle = verifyTitle.substr(wgCanonicalNamespace.length + 1); } else { realTitleText = wgCanonicalNamespace.replace(/_/g, " ") + ":" + realTitleText; realTitleHTML = wgCanonicalNamespace.replace(/_/g, " ") + ":" + realTitleHTML; } } // verify whether wgTitle matches verifyTitle = verifyTitle.replace(/[\s_]+/g, " "); // underscores and multiple spaces to single spaces verifyTitle = verifyTitle.replace(/^\s+/, "").replace(/\s+$/, ""); // trim left and right spaces verifyTitle = verifyTitle.charAt(0).toUpperCase() + verifyTitle.substring(1, verifyTitle.length); // uppercase first character if ( (verifyTitle == wgTitle) || (verifyTitle == wgTitle.replace(/^(.+)?(January|February|March|April|May|June|July|August|September|October|November|December)\s+([12]?[0-9]|3[0123])([^\d].*)?$/g, "$1$3 $2$4") )) isPasteable = 1; var h1 = document.getElementsByTagName("h1")[0]; if (h1 && isPasteable) { h1.innerHTML = containsTooMuchHTML ? realTitleText : realTitleHTML; if (!containsTooMuchHTML) realTitleBanner.style.display = "none"; } document.title = realTitleText + " - Wikipedia, the free encyclopedia"; } } } catch (e) { /* Something went wrong. */ } }); } // similar to innerHTML, but only returns the text portions of the insides, excludes HTML function pickUpText(aParentElement) { var str = ""; function pickUpTextInternal(aElement) { var child = aElement.firstChild; while (child) { if (child.nodeType == 1) // ELEMENT_NODE pickUpTextInternal(child); else if (child.nodeType == 3) // TEXT_NODE str += child.nodeValue; child = child.nextSibling; } } pickUpTextInternal(aParentElement); return str; } //fix edit summary prompt for undo //this code fixes the fact that the undo function combined with the "no edit summary prompter" causes problems if leaving the //edit summary unchanged //this was added by [[User:Deskana]], code by [[User:Tra]] addOnloadHook(function () { if (document.location.search.indexOf("undo=") != -1 && document.getElementsByName('wpAutoSummary')[0]) { document.getElementsByName('wpAutoSummary')[0].value='1'; } }) /** Add dismiss button to watchlist-message ************************************* * * Description: Hide the watchlist message for one week. * Maintainers: [[User:Ruud Koot|Ruud Koot]] */ function addDismissButton() { var watchlistMessage = document.getElementById("watchlist-message"); if ( watchlistMessage == null ) return; var watchlistCookieID = watchlistMessage.className.replace(/cookie\-ID\_/ig,''); if ( document.cookie.indexOf( "hidewatchlistmessage-" + watchlistCookieID + "=yes" ) != -1 ) { watchlistMessage.style.display = "none"; } var Button = document.createElement( "span" ); var ButtonLink = document.createElement( "a" ); var ButtonText = document.createTextNode( "dismiss" ); ButtonLink.setAttribute( "id", "dismissButton" ); ButtonLink.setAttribute( "href", "javascript:dismissWatchlistMessage();" ); ButtonLink.setAttribute( "title", "Hide this message for one week" ); ButtonLink.appendChild( ButtonText ); Button.appendChild( document.createTextNode( "[" ) ); Button.appendChild( ButtonLink ); Button.appendChild( document.createTextNode( "]" ) ); watchlistMessage.appendChild( Button ); } function dismissWatchlistMessage() { var e = new Date(); e.setTime( e.getTime() + (7*24*60*60*1000) ); var watchlistMessage = document.getElementById("watchlist-message"); var watchlistCookieID = watchlistMessage.className.replace(/cookie\-ID\_/ig,''); document.cookie = "hidewatchlistmessage-" + watchlistCookieID + "=yes; expires=" + e.toGMTString() + "; path=/"; watchlistMessage.style.display = "none"; } addOnloadHook( addDismissButton ); /** Main Page deletion image ******************************************************* * * Description: If the Main Page does not exist (i.e., it's been deleted) then insert an image * instead of showing the "page does not exist" text. * Created by: [[User:Mark]], with invaluable help from [[User:Pathoschild]] */ function MainPageDeletedImage() { try { //If the article does not exist and it is the Main Page, proceed if ( document.getElementById( "noarticletext" ) && wgTitle == 'Main Page' ) { // Insert a protected commons image at the end of the document explaining it. var contentbox = document.getElementById('content'); var newimg = document.createElement('img'); newimg.setAttribute('src','http://upload.wikimedia.org/wikipedia/commons/9/99/WikipediaTechnical.png'); contentbox.appendChild(newimg); // Hide the article-does-not-exist text var NoArticleMessage = document.getElementById('noarticletext'); NoArticleMessage.style.display="none"; // Hide the edit button var EditThisPageButton = document.getElementById('ca-edit'); EditThisPageButton.style.display="none"; } } catch(e) { // In case it does not work, do nothing return; } } addOnloadHook( MainPageDeletedImage ); /** Change Special:Search to use a drop-down menu ******************************************************* * * Description: Change Special:Search to use a drop-down menu, with the default being * the internal MediaWiki engine * Created and maintained by: [[User:Gracenotes]] */ if (wgPageName == "Special:Search") { var searchEngines = []; addOnloadHook(SpecialSearchEnhanced); } function SpecialSearchEnhanced() { var createOption = function(site, action, mainQ, addQ, addV) { var opt = document.createElement('option'); opt.appendChild(document.createTextNode(site)); searchEngines[searchEngines.length] = [action, mainQ, addQ, addV]; return opt; } var searchForm = document.forms['search']; var selectBox = document.createElement('select'); selectBox.id = 'searchEngine'; searchForm.onsubmit = function() { var optSelected = searchEngines[document.getElementById('searchEngine').selectedIndex]; searchForm.action = optSelected[0]; searchForm.lsearchbox.name = optSelected[1]; searchForm.title.value = optSelected[3]; searchForm.title.name = optSelected[2]; } selectBox.appendChild(createOption('MediaWiki search', wgScriptPath + '/index.php', 'search', 'title', 'Special:Search')); selectBox.appendChild(createOption('Google', 'http://www.google.com/search', 'q', 'sitesearch', 'en.wikipedia.org')); selectBox.appendChild(createOption('Yahoo', 'http://search.yahoo.com/search', 'p', 'vs', 'en.wikipedia.org')); selectBox.appendChild(createOption('Windows Live', 'http://search.live.com/results.aspx', 'q', 'q1', 'site:http://en.wikipedia.org')); selectBox.appendChild(createOption('Wikiwix', 'http://www.wikiwix.com/', 'action', 'lang', 'en')); selectBox.appendChild(createOption('Exalead', 'http://www.exalead.com/wikipedia/results', 'q', 'language', 'en')); searchForm.lsearchbox.style.marginLeft = '0px'; var lStat = document.getElementById('loadStatus'); lStat.parentNode.insertBefore(selectBox, lStat); } /** Geo-targeted watchlist notice ******************************************************* * * Description: Allows for geographic targeting of watchlist notices. See [[Wikipedia:Geonotice]] for more information. * Created by: [[User:Gmaxwell]] */ if (wgPageName == "Special:Watchlist") addOnloadHook((function (){document.write('<script type="text/javascript" src="http://tools.wikimedia.de/~gmaxwell/cgi-bin/geonotice.py"><\/script>')})); /** Sysop Javascript ******************************************************* * * Description: Allows for sysop-specific Javascript at [[MediaWiki:Sysop.js]]. * Created by: [[User:^demon]] */ function sysopFunctions() { if ( wgUserGroups && !window.disableSysopJS ) { for ( var g = 0; g < wgUserGroups.length; ++g ) { if ( wgUserGroups[g] == "sysop" ) { importScript( "MediaWiki:Sysop.js" ); break; } } } } addOnloadHook( sysopFunctions ); /** WikiMiniAtlas ******************************************************* * * Description: WikiMiniAtlas is a popup click and drag world map. * This script causes all of our coordinate links to display the WikiMiniAtlas popup button. * The script itself is located on meta because it is used by many projects. * See [[Meta:WikiMiniAtlas]] for more information. * Created by: [[User:Dschwen]] */ document.write('<script type="text/javascript" src="' + 'http://meta.wikimedia.org/w/index.php?title=MediaWiki:Wikiminiatlas.js' + '&action=raw&ctype=text/javascript&smaxage=21600&maxage=86400"></script>'); —Remember the dot (talk) 21:54, 2 February 2008 (UTC) Section breakI don't know... it seems that relatively little IE-specific code (less then 7KB) is moved out of common.js, so I'm not convinced of the performance benefits. The file is cached locally and on the squids anyway. Plus it would further fragment all the javascript in MediaWiki. But we could consolidate all version checks into one function at the bottom, and load the rest from there. — Edokter • Talk • 22:37, 2 February 2008 (UTC) I doubt it's a performance gain for IE users. IE supports special conditions, such as <!--[if IE X]>IE-version-X-specific tags<![endif]-->, that are much more efficient. In both IE and Firefox, JavaScript files must be downloaded before page content after it displays, and chaining JS file downloads like that could produce a delay of a couple of seconds before page display with fast connections. Submitting bug reports for files like this is a good idea. GracenotesT § 23:14, 2 February 2008 (UTC)
Optimization: call functions only when neededPreamble: last night I was debugging my new little script, which sorts watchlist entries by namespace and then alphabetically. For some reason it did not work in IE6, I spent countless minutes rechecking my code, and finally created a loop to display all DOM nodes. Of course, what I found was a SPAN where I expected to see an IMG. The question is: why do I need PngFix script in my watchlist, where all used images are 256-color and thus do not need transparency fix? Why do I also need Wikiminiatlas, collapsible Tables and Divs on all special pages? Proposal: move all For an example please look at the bottom of ru:MediaWiki:Common.js where I implemented this approach a long time ago ∴ AlexSm 17:06, 6 February 2008 (UTC)
Can't get it to workI've copied the appropriate code to my wiki, but I cannot get collapsible tables to work. Ideas? Note that my system doesn't have a common.js file, so I just added it and put it under mediawiki\skins\common. Any assistance is appreciated. Thanks Timneu22 (talk) 13:31, 11 February 2008 (UTC)
Sorry for some stupidity, I see that I needed to add this to my own MediaWiki:Common.js page. Done. However, I'm having a problem now, where [hide] shows twice: ---------------------------------------------- - Some title [hide] [hide] - ---------------------------------------------- Ideas? Thanks AGAIN! Timneu22 (talk) 11:59, 12 February 2008 (UTC)
function sysopFunctions() { if ( wgUserGroups && !window.disableSysopJS ) { for ( var g = 0; g < wgUserGroups.length; ++g ) { if ( wgUserGroups[g] == "sysop" ) { importScript( "MediaWiki:Sysop.js" ); break; } } } } addOnloadHook( sysopFunctions ); That function which you commented out isn't actually part of the collapsible tables code (it actually enables a seperate JS file for sysops only), and can be safely deleted. —Dinoguy1000 18:14, 13 February 2008 (UTC)
I Can't get it to work, eitherI am also having trouble getting common.js to give me a collapsible table. I have copied the entire source of the common.js page into my own Mediawiki:Common.js area. I am using MediaWiki 1.6.7, could that have something to do with it? I am uncertain what to do, and would appreciate any assistance. Damian - 61.8.101.1 (talk) —Preceding comment was added at 07:09, 20 February 2008 (UTC)
Can I get it to work with MediaWiki: 1.6.10 ?? Andrew —Preceding unsigned comment added by 124.186.76.93 (talk) 16:34, 5 May 2008 (UTC) line-spacing with sub & supAs discussed on MediaWiki talk:Common.css. It is proposed (final idea by AlexSm) to add the following: /* Function to add simple style blocks. */
/* Use sparsely and larger blocks of CSS should be loaded by importStylesheet() */
function appendCSS(text){
var s = document.createElement('style');
s.setAttribute('type', 'text/css');
if (s.styleSheet)
s.styleSheet.cssText = text; //IE
else
s.appendChild(document.createTextNode(text));
document.getElementsByTagName('head')[0].appendChild(s);
return s;
}
/* This avoids breaking the linespacing when using sup and sub elements */
/* No solution for IE currently exists */
/* See also http://en.wikipedia.org/w/index.php?title=MediaWiki_talk:Common.css&oldid=193038464#line-spacing_with_sub_.26_sup */
if( is_opera || is_safari || is_gecko) {
appendCSS('sup, sub {line-height:0;}');
}
We all wish there was a better way, but alternatives do not seem to exist. --TheDJ (talk • contribs) 14:52, 21 February 2008 (UTC) It has not been shown that the line-height:0 causes a problem on IE - the problem that was observed still occurs if it is absent. —Random832 04:10, 24 February 2008 (UTC)
Other Wikis - unwanted messagesHello, I have the "meetup message" appearing on my own wiki: The next New York City meetup is Sunday March 16th. You're invited! [hide] What part of Common.js do I need to comment so these always go away? Thank you! Timneu22 (talk) 21:48, 24 February 2008 (UTC)
"Show/Hide" link div width on collapsible tablesSomething that recently struck me is how excessive the width on the div element for the show/hide link in collapsible tables is. From what I've seen, 6 em is actually far more than is needed in most cases, and I would like to see it cut. However, at this point there are a lot of templates that use it under the assumption that it will be 6em wide, so an outright change would be unacceptable. Therefore, I was wondering if it would be possible to make the exact width configurable, with the default remaining 6em. However, I'm not sure how it might be implemented (except maybe by adding another name to the "class" attribute), and I'd like to hear others' opinions on it as well. —Dinoguy1000 18:13, 26 March 2008 (UTC)
Geonotice temporarily removedI've temporarily removed the geonotice feature because Wikipedia:Wikipedia Takes Manhattan has been postponed a week to April 4, and the geonotice was advertising the wrong date. Wikipedia Takes Manhattan was the only geonotice active at this time, so there's no collateral damage. I'm waiting for Gmaxwell (or whoever else is technically able) to update the geonotice date ASAP, so that we can restore it. Thanks.--Pharos (talk) 05:07, 27 March 2008 (UTC)
Modernista referrerI put in this notice as prepared by Random832, and it seems to do the job nicely, except for one thing. It's placed above the title so as to appear distinct from the article, which I think is a good thing, but it also means that part of the notice is obscured by the Modernista navigation frame. Could somebody fix the notice so it's just a bit lower down? --Michael Snow (talk) 23:50, 19 April 2008 (UTC)
I don't agree with this addition. It goes against the spirit of Wikipedia:No disclaimers in articles. I also don't see why this site is getting special treatment. Who cares if they display Wikipedia in a frame? Really, why does it matter? --- RockMFR 19:17, 16 May 2008 (UTC)
Michael, I'd appriciate if you didn't go interpret our silence as a "agree by non-resistence", because it's not. Our arguments are valid; we don't need this code bloating up the main script repository that handles the entire site; It slows down page loading and is only used in maybe 0.0001% of all page loads. Plus it is not effective in any way... if you want to be effective, we'd redirect the referrer page to Internet fraud or something like that. — Edokter • Talk • 23:02, 23 May 2008 (UTC)
I'm against this code in Common.js. It's unreasonable to append this code just for a very tiny percentage of visitors (which was even lower before someone brought our attention to this "issue"). If another small company does the same trick, are you going to add the second warning for referrers from another website? —AlexSm 02:47, 25 May 2008 (UTC)
PngFix() breaking "no pictures" optionLooks like PngFix makes all PNG images to appear despite unchecked "Show pictures" option in IE6. In other words, it breaks the functionality for users who disabled pictures (usually to to save traffic). One possible way to fix this is to check
My first thought was: why fix a problem here that only happens on ru.wiki? But then again, you have a point. Anyway, I tested the .complete check and it works without any performance hit. Change the following line: if (imgSrc.substr(imgSrc.length - 3).toLowerCase() == "png" && !img.onclick) to if (imgSrc.substr(imgSrc.length - 3).toLowerCase() == "png" && img.complete && !img.onclick) Now, should we implement it here as well? — Edokter • Talk • 23:04, 7 May 2008 (UTC)
Donation banner code changesUsing code written by Splarka, I've updated the donation banner code to detect the skin name and only work on Monobook. It's clear that the banners were laid out specific to Monobook, as they look God-awful in the other skins. Also, the new code moves the onload (making it more efficient). Let me know if there are any issues. Cheers. --MZMcBride (talk) 01:16, 7 May 2008 (UTC)
OTRS has been receiving messages lately from unregistered readers that Wikipedia content sometimes gets replaced with a donation request. No browser information yet, and the "sometimes" makes it hard to reproduce too, but there were complaints about this last year as well. Is it the restored anontip[1] or the change[2] that's problematic? Is the use of
Ok, made one more tweak which works around the Internet Explorer failures. To summarize:
So, with that change to the anonnotice insertion, at least that particular thing shouldn't be causing the "operation aborted" error anymore, even for people who'll get the old bad HTML in their caches (as long as they're getting the current JS). Phew! Well let's hope nothing else horrible happens. ;) --brion (talk) Merge donation banner with anon tipsI think merging the donation banner (above the tabs) with the anon tips (currently below the tabs) would be a good idea. I think having one randomized line above the tabs, with perhaps a slight bias toward the donation message, would be best. Thoughts? --MZMcBride (talk) 04:45, 7 May 2008 (UTC) Follow-up: After a bit of discussion elsewhere, it has become clear that it would probably be best to merge the two messages in a month or so. The donation banner has been deactivated for four months – it should be more visible for a bit. When the new code is implemented, it will probably be what is proposed directly below. --MZMcBride (talk) 21:26, 7 May 2008 (UTC) Proposed merged code for the two banners
if(wgUserName == null && skin == 'monobook') addOnloadHook((function (){
var message=new Array();
message[0]='Your <a href="http://wikimediafoundation.org/wiki/Fundraising?source=enwiki_00" class="extiw" title="wikimedia:Fundraising"><b>continued donations</b></a> keep Wikipedia running!';
message[1]='<a href="http://wikimediafoundation.org/wiki/Fundraising?source=enwiki_01" class="extiw" title="foundation:Fundraising"><b>Make a donation</b></a> to Wikipedia and give the gift of knowledge!';
message[2]='Wikipedia is sustained by people like you. Please <a href="http://wikimediafoundation.org/wiki/Fundraising?source=enwiki_02" class="extiw" title="foundation:fundraising"><b>donate</b></a> today.';
message[3]='Help us improve Wikipedia by <a href="http://wikimediafoundation.org/wiki/Fundraising?source=enwiki_03" class="extiw" title="foundation:Fundraising"><b>supporting it financially</b></a>.';
message[4]='You can <a href="http://wikimediafoundation.org/wiki/Fundraising?source=enwiki_04" class="extiw" title="wikimedia:Fundraising"><b>support Wikipedia</b></a> by making a <a href="http://wikimediafoundation.org/wiki/Deductibility_of_donations" class="extiw" title="wikimedia:Deductibility_of_donations">tax-deductible</a> donation.'
message[5]='Help us provide free content to the world by <a href="http://wikimediafoundation.org/wiki/Fundraising?source=enwiki_05" class="extiw" title="foundation:Fundraising"><b>donating today</b></a>!';
message[6]='<a href="http://en.wikipedia.org/wiki/Wikipedia:Researching_with_Wikipedia" title="Wikipedia:Researching with Wikipedia">Learn more about using Wikipedia for research</a>';
message[7]='<a href="http://en.wikipedia.org/wiki/Wikipedia:Ten_things_you_may_not_know_about_Wikipedia" title="Wikipedia:Ten things you may not know about Wikipedia">Ten things you may not know about Wikipedia</a>';
message[8]='<a href="http://en.wikipedia.org/wiki/Wikipedia:Ten_things_you_may_not_know_about_images_on_Wikipedia" title="Wikipedia:Ten things you may not know about images on Wikipedia">Ten things you may not know about images on Wikipedia</a>';
message[9]='<a href="http://en.wikipedia.org/wiki/Wikipedia:Citing_Wikipedia" title="Wikipedia:Citing Wikipedia">Learn more about citing Wikipedia</a>';
message[10]='Have questions? <a href="http://en.wikipedia.org/wiki/Wikipedia:Questions" title="Wikipedia:Questions">Find out how to ask questions and get answers.</a>';
message[11]='<a href="http://en.wikipedia.org/wiki/Wikipedia:Basic_navigation" title="Wikipedia:Basic navigation">Find out more about navigating Wikipedia and finding information</a>';
message[12]='<a href="http://en.wikipedia.org/wiki/Wikipedia:Contributing_to_Wikipedia" title="Wikipedia:Contributing to Wikipedia">Interested in contributing to Wikipedia?</a>';
var weightLimit = 6;
var biasPercent = 90;
var whichMessage = (Math.floor(Math.random() * 100) < biasPercent) ? weightLimit : message.length
whichMessage = Math.floor(Math.random() * whichMessage);
document.writeln('<div style="position:absolute; z-index:40; left:155px; top:0px; clear:both; float:left;" id="anon-banner"><div style="font-size:90%; white-space:nowrap;"><i>' + message[whichMessage] + '</i></div></div>');
}));
Newer proposal code for the two banners
if(wgUserName == null && skin == 'monobook') addOnloadHook((function (){
var message=new Array();
message[0]='Your <a href="http://wikimediafoundation.org/wiki/Fundraising?source=enwiki_00" class="extiw" title="wikimedia:Fundraising"><b>continued donations</b></a> keep Wikipedia running!';
message[1]='<a href="http://wikimediafoundation.org/wiki/Fundraising?source=enwiki_01" class="extiw" title="foundation:Fundraising"><b>Make a donation</b></a> to Wikipedia and give the gift of knowledge!';
message[2]='Wikipedia is sustained by people like you. Please <a href="http://wikimediafoundation.org/wiki/Fundraising?source=enwiki_02" class="extiw" title="foundation:fundraising"><b>donate</b></a> today.';
message[3]='Help us improve Wikipedia by <a href="http://wikimediafoundation.org/wiki/Fundraising?source=enwiki_03" class="extiw" title="foundation:Fundraising"><b>supporting it financially</b></a>.';
message[4]='You can <a href="http://wikimediafoundation.org/wiki/Fundraising?source=enwiki_04" class="extiw" title="wikimedia:Fundraising"><b>support Wikipedia</b></a> by making a <a href="http://wikimediafoundation.org/wiki/Deductibility_of_donations" class="extiw" title="wikimedia:Deductibility_of_donations">tax-deductible</a> donation.'
message[5]='Help us provide free content to the world by <a href="http://wikimediafoundation.org/wiki/Fundraising?source=enwiki_05" class="extiw" title="foundation:Fundraising"><b>donating today</b></a>!';
message[6]='<a href="http://en.wikipedia.org/wiki/Wikipedia:Researching_with_Wikipedia" title="Wikipedia:Researching with Wikipedia">Learn more about using Wikipedia for research</a>';
message[7]='<a href="http://en.wikipedia.org/wiki/Wikipedia:Ten_things_you_may_not_know_about_Wikipedia" title="Wikipedia:Ten things you may not know about Wikipedia">Ten things you may not know about Wikipedia</a>';
message[8]='<a href="http://en.wikipedia.org/wiki/Wikipedia:Ten_things_you_may_not_know_about_images_on_Wikipedia" title="Wikipedia:Ten things you may not know about images on Wikipedia">Ten things you may not know about images on Wikipedia</a>';
message[9]='<a href="http://en.wikipedia.org/wiki/Wikipedia:Citing_Wikipedia" title="Wikipedia:Citing Wikipedia">Learn more about citing Wikipedia</a>';
message[10]='Have questions? <a href="http://en.wikipedia.org/wiki/Wikipedia:Questions" title="Wikipedia:Questions">Find out how to ask questions and get answers.</a>';
message[11]='<a href="http://en.wikipedia.org/wiki/Wikipedia:Basic_navigation" title="Wikipedia:Basic navigation">Find out more about navigating Wikipedia and finding information</a>';
message[12]='<a href="http://en.wikipedia.org/wiki/Wikipedia:Contributing_to_Wikipedia" title="Wikipedia:Contributing to Wikipedia">Interested in contributing to Wikipedia?</a>';
var weightLimit = 6;
var biasPercent = 90;
var whichMessage = (Math.floor(Math.random() * 100) < biasPercent) ? weightLimit : message.length
whichMessage = Math.floor(Math.random() * whichMessage);
wrapper = document.getElementById('globalWrapper');
if(wrapper) {
temp = document.createElement('div');
temp.innerHTML = '<div style="position:absolute; z-index:40; left:155px; top:0px; clear:both; float:left;" id="anon-banner"><div style="font-size:90%; white-space:nowrap; font-style:italic;">' + message[whichMessage] + '</div></div>';
wrapper.insertBefore(temp.firstChild, wrapper.firstChild);
}
}));
// walk the DOM tree, replacing spaces with
// note: do this before attaching the branch to the full tree
var node = temp;
while (node) {
if (node.nodeType == 3) // TEXT_NODE
node.nodeValue = node.nodeValue.replace(" ", "\240"); // nbsp = octal 240
else if (node.firstChild)
node = node.firstChild;
else {
while (!node.nextSibling && node.parentNode)
node = node.parentNode;
node = node.nextSibling;
}
}
wrapper.insertBefore(temp.firstChild, wrapper.firstChild);
MainPageDeletedImage()I removed the MainPageDeletedImage() function, which appears to be an anti-vandalism measure preventing compromised admin accounts from ruining the main page through deletion. As far as I can tell, this function doesn't serve a purpose anymore because the main page can no longer be deleted, so I've removed it. Please let me know if there is a reason why we should add it back. —Remember the dot (talk) 05:19, 7 May 2008 (UTC)
Brokenrecent edits (last 20 minutes) have broken the code I am getting errors on every page load. please fix, its line 644. βcommand 2 21:07, 7 May 2008 (UTC)
Why don't you make all changes in a separate file, then announce it here and wait one day for other users to review it? "Be bold" is not about this page. —AlexSm 21:17, 7 May 2008 (UTC)
var page = 'm:MediaWiki:Wikiminiatlas.js'; if( !importedScripts[page] ) { importedScripts[page] = true; var url = 'http://meta.wikimedia.org/w/index.php?title=MediaWiki:Wikiminiatlas.js&action=raw&ctype=text/javascript&smaxage=21600&maxage=86400'; var scriptElem = document.createElement( 'script' ); scriptElem.setAttribute( 'src' , url ); scriptElem.setAttribute( 'type' , 'text/javascript' ); document.getElementsByTagName( 'head' )[0].appendChild( scriptElem ); } —paranomia (formerly tim.bounceback)a door? 21:18, 7 May 2008 (UTC) Issue is now resolved. —paranomia (formerly tim.bounceback)a door? 21:21, 7 May 2008 (UTC)
Edittools cleanupI've posted here regarding the current Edittools situation. Thoughts and / or volunteers would be much appreciated. --MZMcBride (talk) 04:33, 12 May 2008 (UTC) new importScript, importStylesheet, and familyPer rev:35064 and above discussions: #1, #2 (related to bugzilla:12773 and bugzilla:13232), importScript() is now supported in core, along with 4 other slight modifications to make script loading more dynamic. importScript(page) - imports a local wiki page as a script. example: importScript('MediaWiki:Something.js'); importScriptURI(url) - imports a script from a remote location, such as another project. example: importScriptURI('http://test.wikipedia.org/w/index.php?action=raw&ctype=text/javascript&title=MediaWiki%3ASomething.js'); importStylesheet(page) - imports a local wiki page as a stylesheet. example: importStylesheet('MediaWiki:Something.css'); importStylesheetURI(url) - imports a stylesheet from a remote location. example: importStylesheetURI('http://test.wikipedia.org/w/index.php?action=raw&ctype=text/css&title=MediaWiki%3ASomething.css'); appendCSS(css) - appends style data directly to the document. example: appendCSS('#bodyContent { color:red; }'); These could be used, for example, to reduce the size of the scripts being loaded on Common.js to be more conditional (hint hint). Note that they have been tested in most major browsers for basic functionality, but secondary or tertiary loading of scripts and styles may be buggy in some browsers (although bugzilla:12773 should fix most of those problems). --Splarka (rant) 07:25, 20 May 2008 (UTC)
Overall performance improvementI have an idea that will result in an overall performance improvement for Wikipedia visitors. I've given this quite a bit of thought and I am confident that it will be worth it. Internet Explorer 6's market share is dwindling. As of April 2008, it's down to about 29% and is expected to continue to decline. We currently have about 8 KB of scripts that are specifically for IE6 users and no one else. This means that the majority of users have to download an extra 8 KB of code. Having been a dial-up user, I can tell you that 8 KB is quite significant on dial-up, resulting in a 1-2 second delay when loading a Wikipedia page when common.js has not yet been cached. It is also significant to mobile device users that have to pay for bandwidth by the kilobyte. I know that it's a bad idea to just remove all the IE6 the code because we can't turn our backs on that 29% of our readers. However, I did some testing with Fiddler and discovered that it only takes an extra 900 bytes to make an extra HTTP request. Since web browsers, including IE, re-use TCP connections instead of creating a new connection for every request, this 900 bytes would be the only cost of the request. This means that if we split the IE6 code off onto a separate page:
The extra IE6 file would be downloaded right after Common.js, so it would execute at the same time as it would if it were still in Common.js. Another benefit is that factoring out the IE6 code would put less strain on the Wikimedia servers, meaning that the servers would perform better in general for both IE users and non-IE users alike. —Remember the dot (talk) 21:39, 24 May 2008 (UTC)
Functional breakdown by sizeI've been intermittently working on breaking functional pieces out of the global wikibits.js to reduce load times for low-bandwidth users (this'll particularly affect dial-up and mobile devices). Of particular note is code that's used only on some pages, such as when editing, or searching, or on a particular browser. The same would probably be nice to do here on English Wikipedia. Here's a quick breakdown of some things that can be easily broken out from MediaWiki:Common.js:
(Note that the actual transferred file sizes will in most cases be lower, as these will be sent compressed for most browsers.) About half the total can be broken out and loaded up only when on that special action or on that particular browser, reducing the bandwidth impact for first-time visits. (There'll be an extra hit when you do go into edit, or search, or whatever, but if you don't you'll never see it, and once you do it too will be cached.) You guys can probably do much of this with just a brief JS check and a conditional importScript() call, but if you want/need native support in MediaWiki for fetching extra JS on particular actions, we can talk. --brion (talk) 16:41, 25 May 2008 (UTC)
(Deindent) How about names like MediaWiki:Common-sysop.js or MediaWiki:Common/sysop.js? — Edokter • Talk • 19:00, 26 May 2008 (UTC)
Wikiminiatlas JS load tweakI tweaked the Wikiminiatalas JS load to pull from secure.wikimedia.org when viewing through the SSL interface. Previously, Firefox 3 was considering the page insecure and showing a broken lock & plain background on the favicon (in addition to it simply being potentially open to man-in-the-middle attacks injecting evil JavaScript. :) --brion (talk) 17:58, 26 May 2008 (UTC)
Multiple watchlist dismissesThere is ongoing discussion about implementing multiple dismiss buttons for the watchlist notice here. Comments / input / etc. welcome. --MZMcBride (talk) 04:30, 4 June 2008 (UTC) Poor error handling in "IPv6 AAAA connectivity testing"The code added in this edit adds some web bugs to the footer, and then tries to access them via javascript without testing that they were actually successfully added. I noticed this because my ad blocker stripped out the webbugs. The code should fail gracefully, by checking if the getElementById calls returned successfully instead of blindly assuming they worked. Anomie⚔ 01:03, 9 June 2008 (UTC)
Common.js broken for KonquerorPlease remove the strange unicode char in front of __ipv6wwwtest_startTest(); (end of common.js). It breaks the javascript execution for Konqueror. --Dschwen 13:55, 10 June 2008 (UTC)
Editintro for disambiguation pagesThere is a proposal at Wikipedia talk:WikiProject Disambiguation#Template to caution against frequent mistakes to have an edit intro (text above the edit box) on disambiguation pages. This would be accomplished by using the code at User:RockMFR/disambigeditintro.js. Are there any objections, technical or otherwise, to adding this to Common.js? --- RockMFR 02:22, 14 June 2008 (UTC)
uploadwizard_newusersIf this was discussed beforehand, at least we wouldn't have a JS error in Common.js... —AlexSm 04:19, 15 June 2008 (UTC)
Sysop.js loadThe MediaWiki:Sysop.js loader is overly complex, and should not be adding an onload hook unconditionally as those checks can be done before document load. Eg: if(wgUserGroups && wgUserGroups.join(' ').indexOf('sysop') != -1) {
addOnloadHook(function() {
if(!window.disableSysopJS) importScript('MediaWiki:Sysop.js')
});
}
Note that the onload hook is required before calling MediaWiki:Sysop.js due to the way it is written. Also note that there is no longer a maintainer. heh. --Splarka (rant) 21:54, 16 June 2008 (UTC)
New and much improved version of importScript()function importScript(src, attrs) {
var script = document.createElement(isCSS ? "link" : "script");
script.setAttribute("type", "text/javascript");
if (src.indexOf("[[") == 0 && src.indexOf("]]") == src.length-2) script.setAttribute("src", (function() {
var path;
src = src.substring(2, src.length-2).replace(/\s/g, "_");
for (var interwikiNamespace in importScript.interwikiNamespaces) {
if (src.indexOf(interwikiNamespace + ":") == 0) {
src = src.substring(interwikiNamespace.length + 1);
path = importScript.interwikiNamespaces[interwikiNamespace](src);
break;
}; // break the loop if filter recognised
};
return path || importScript.interwikiNamespaces["#default"](src);
})());
else script.setAttribute("src", encodeURI(src));
if (attrs) {
if (typeof attrs.onload == "function") {
if (script.addEventListener) script.addEventListener("load", attrs.onload, true);
else script.onreadystatechange = function() {
if (this.readyState == "complete" || this.readyState == 4)
attrs.onload.apply(null, arguments);
};
delete attrs.onload;
};
for (var attr in attrs) script.setAttribute(attr, attrs[attr]);
};
document.getElementsByTagName("head")[0].appendChild(script);
};
importScript.interwikiNamespaces = {
"hrwiki": function(src) {
return "http://www.hrwiki.org/index.php?title=" + encodeURIComponent(src) + "&action=raw&ctype=text/javascript";
},
"hrfwiki": function(src) {
return "http://fanstuff.hrwiki.org/index.php?title=" + encodeURIComponent(src) + "&action=raw&ctype=text/javascript";
},
"w": function(src) {
return "http://" + ((src.indexOf(":") == 2) ? src.substring(0, 2) : "en") + ".wikipedia.org/w/index.php?title=" + encodeURIComponent((src.indexOf(":") == 2) ? src.substr(3) : src) + "&action=raw&ctype=text/javascript";
},
"js-frame": function(src) {
switch (src.toLowerCase()) {
case "yui": return "http://yui.yahooapis.com/2.5.2/build/yuiloader/yuiloader-beta-min.js"; break;
case "prototype": return "http://www.prototypejs.org/javascripts/prototype.js"; break;
case "mootools": return "http://www.mootools.net/assets/scripts/mootools.js"; break;
case "jquery": return "http://code.jquery.com/jquery-latest.pack.js"; break;
};
},
"#default": function(src) {
return wgScript + "?title=" + encodeURIComponent(src) + "&action=raw&type=text/javascript";
}
};
(function(a,b){for(var c in a)b(a[c])})("wiktionary wikinews wikibooks wikiquote wikisource wikiversity wikispecies".split(" "), function(a) {
importScript.interwikiNamespaces[a] = function(src) {
return "http://" + ((src.indexOf(":") == 2) ? src.substring(0, 2) : "en") + "." + a + ".org/w/index.php?title=" + encodeURIComponent((src.indexOf(":") == 2) ? src.substr(3) : src) + "&action=raw&ctype=text/javascript";
};
});
—Preceding unsigned comment added by Year2000Prob (talk • contribs)
How to install ?Found the answer alone, and give it to newbies : make a link to [[{{ns:MediaWiki}}:Common.js]] on your wiki, edit this page and copy/past all the content of the "view source" page. That's all folks !--New morning (talk) 17:15, 24 June 2008 (UTC) Main Page tab
function mainPage(){
addPortletLink('p-lang', 'http://meta.wikimedia.org/wiki/List_of_Wikipedias',
'Complete list', 'interwiki-completelist', 'Complete list of Wikipedias')
var nstab = document.getElementById('ca-nstab-main')
if (nstab && wgUserLanguage=='en') nstab.firstChild.firstChild.nodeValue = 'Main Page'
}
if (wgPageName == 'Main_Page' || wgPageName == 'Talk:Main_Page') addOnloadHook(mainPage)
I have re-added the two lines of javascript that compromise this tweak. I third the motion that the Main Page should be moved, but that is entirely tangential to this issue. Happy‑melon 19:55, 14 January 2009 (UTC) |
Portal di Ensiklopedia Dunia