মিডিয়াউইকি আলোচনা:Common.js
The following should be removed as being no longer required/superseded.
/** 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 ); }
Part of the Mediawiki software now, no longer required.
/** 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();
This page view counter has long since (2004/2005 ish?) been deprecated. The code doesn't do anything anymore.
/** "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. */ } }); }
This has been replace with the MediaWiki feature {{DISPLAYTITLE:}}. The code is no longer needed and should be removed.
/** Numeric sorting *************************************************** * * Description: Fixes a bug (part of [[bugzilla:8115]]) * in http://svn.wikimedia.org/viewvc/mediawiki/trunk/phase3/skins/common/wikibits.js * regarding [[Help:Sorting|table sorting]]: * it allows sorting of numbers with more than one comma (thousands separator). * Maintainer: [[User:Patrick|Patrick]] */ function ts_parseFloat(num) { if (!num) return 0; num = parseFloat(num.replace(/,/g, "")); return (isNaN(num) ? 0 : num); }
This was a temporary fix. It is now fixed in the core software.
** 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 );
I think this may no longer be needed. If I remember correctly, it isn't possibly even for sysops to delete the main page of a project these days. Not 100% sure however.
/** 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>')}));
This code is outdated. It never worked on this wiki either. TheDJ (আলাপ) ১৫:৪৮, ৫ আগস্ট ২০১০ (ইউটিসি)
// SVG images: adds links to rendered PNG images in different resolutions function SVGThumbs() { var file = document.getElementById("file"); // might fail if MediaWiki can't render the SVG if (file && wgIsArticle && wgTitle.match(/\.svg$/i)) { var thumbu = file.getElementsByTagName('IMG')[0].src; if(!thumbu) return; function svgAltSize( w, title) { var path = thumbu.replace(/\/\d+(px-[^\/]+$)/, "/" + w + "$1"); var a = document.createElement("A"); a.setAttribute("href", path); a.appendChild(document.createTextNode(title)); return a; } var p = document.createElement("p"); p.className = "SVGThumbs"; p.appendChild(document.createTextNode("এই চিত্রটি পিএনজি ফরম্যাটে আরও কিছু আকারে পাওয়া যাবে"+": ")); var l = [200, 500, 1000, 2000]; var b = ['translation1', 'translation2', 'translation3', 'translation4']; for( var i = 0; i < l.length; i++ ) { p.appendChild(svgAltSize( l[i], b[i])); if( i < l.length-1 ) p.appendChild(document.createTextNode(", ")); } p.appendChild(document.createTextNode("।")); var info = getElementsByClassName( file.parentNode, 'div', 'fullMedia' )[0]; if( info ) info.appendChild(p); } }; addOnloadHook( SVGThumbs );
In this code replace the 'translation' parts with the bengali translation, of the number 200, 500, 1000, 2000. TheDJ (আলাপ) ১৬:১৬, ৫ আগস্ট ২০১০ (ইউটিসি)