মিডিয়াউইকি আলোচনা:Common.js

পাতাটির বিষয়বস্তু অন্যান্য ভাষায় নেই।
উইকিসংকলন থেকে

Give search results even when page doesn't exist[সম্পাদনা]

Screenshot of the Earth test search, with this script adding links to Wikidata, Reasonator, Commons, and Wikipedia.

Hello, I propose to enable the tool created by Magnus Manske (creator of MediaWiki) to provide results from other languages and Commons (via Wikidata) when a page doesn't exist here: links are added to Special:Search and noarticletext. This helps to encourage translation and to make readers use your wiki more, because they can be sure to find something even if it's not local (rather than searching directly on the biggest wiki). The Italian and Polish Wikipedias, among others already enabled it by default.
Examples: [১] [২] [৩]. More information: Magnus blog.
How to: just add the following line at the end of Common.js.

// Results from Wikidata
// 
if ( mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Search' ||  ( mw.config.get( 'wgArticleId' ) === 0 && mw.config.get( 'wgCanonicalSpecialPageName' ) === false ) ) {
	importScriptURI("//en.wikipedia.org/w/index.php?title=MediaWiki:Wdsearch.js&action=raw&ctype=text/javascript");
}
--Nemo ~~~~~ (comments, translations and last instructions)

/** * Keep code in MediaWiki:Common.js to a minimum as it is unconditionally * loaded for all users on every wiki page. If possible create a gadget that is * enabled by default instead of adding it here (since gadgets are fully * optimized ResourceLoader modules with possibility to add dependencies etc.) * * Since Common.js isn't a gadget, there is no place to declare its * dependencies, so we have to lazy load them with mw.loader.using on demand and * then execute the rest in the callback. In most cases these dependencies will * be loaded (or loading) already and the callback will not be delayed. In case a * dependency hasn't arrived yet it'll make sure those are loaded before this. */ /* global mw, $, importStylesheet, importScript */ /* jshint curly:false eqnull:true, strict:false, browser:true, */ mw.loader.using( ['mediawiki.util', 'mediawiki.notify', 'jquery.client'], function () { /* Begin of mw.loader.using callback */ /** * Scripts imported from wikisource.org * see oldwikisource:Wikisource:Shared Scripts for details */ jQuery.getScript('//wikisource.org/w/index.php?title=MediaWiki:Base.js&action=raw&ctype=text/javascript', function() { mw.loader.load('//en.wikisource.org/w/index.php?title=MediaWiki:DisplayFooter.js&action=raw&ctype=text/javascript'); mw.loader.load('//en.wikisource.org/w/index.php?title=MediaWiki:PageNumbers.js&action=raw&ctype=text/javascript'); mw.loader.load('//en.wikisource.org/w/index.php?title=MediaWiki:IndexForm.js&action=raw&ctype=text/javascript'); mw.loader.load('//wikisource.org/w/index.php?title=MediaWiki:OCR.js&action=raw&ctype=text/javascript'); // Dictionary.js used for DL-type links, as per A Dictionary of Music and Musicians/A mw.loader.load('//wikisource.org/w/index.php?title=MediaWiki:Dictionary.js&action=raw&ctype=text/javascript'); // mw.loader.load('//wikisource.org/w/index.php?title=MediaWiki:Corrections.js&action=raw&ctype=text/javascript'); mw.loader.load('//wikisource.org/w/index.php?title=MediaWiki:InterWikiTransclusion.js&action=raw&ctype=text/javascript'); } ); /** * Messages are configurable here */ self.ws_messages = { 'optlist':'প্রদর্শন পছন্দ', 'hide_page_numbers':'পাতার লিঙ্ক লুকাও', 'show_page_numbers':'পাতার লিঙ্ক দেখাও', 'page_numbers_inline':'লেখার মধ্যে পাতা সংযোগ', 'page_numbers_beside':'লেখার বাইরে পাতা সংযোগ', 'layout':'বিন্যাস', 'author':'লেখক', 'translator':'অনুবাদক', 'editor':'সম্পাদক', 'publisher':'প্রকাশক', 'place':'স্থান', 'volume':'খণ্ড', 'school':'বিদ্যালয়', 'book':'বই', 'collection':'সংকলন', 'journal':'জার্নাল বা ম্যাগাজিন', 'phdthesis':'থিসিস,রিপোর্ট', 'dictionary':'শব্দকোষ', 'progress':'প্রগতি', 'progress_T':'Done', 'progress_V':'To be validated', 'progress_C':'To be proofread', 'progress_MS':'Ready for Match & Split', 'progress_OCR':'Source file needs an OCR text layer', 'progress_L':'Source file is incorrect (missing pages, unordered pages, etc)', 'progress_X':'Pagelist needed (to verify file is complete and correct before commencing proofreading)', '▲':'পৃষ্ঠার উপরে ফিরে যান', 'corr_list':'List of typos identified on this page', 'corr_link':'Typos Marked', 'corr_one':'One typo</a> has been marked.', 'corr_many':' typos</a> have been marked.', 'corr_close':'Close.', 'iwtrans':'Its text comes from', 'iwtrans2':'Its text comes from other Wikisource subdomains.' }; // Dynamic layouts if ( !self.ws_layouts ) { self.ws_layouts = {}; } self.ws_layouts['বিন্যাস ১'] = { '#text-wrap':"position:relative; margin-left:3.0em;", '#text-container':"position:relative;", '#text':"", '.sidenote-right':"float:right; margin:0.5em; padding:3px; border:solid 1px gray; max-width:9em; text-indent:0em; text-align:left;", '.sidenote-left':"float:left; margin:0.5em; padding:3px; border:solid 1px gray; max-width:9em; text-indent:0em; text-align:left;", '.mw-editsection':"display:none;", '#headertemplate':"" }; self.ws_layouts['বিন্যাস ২'] = { '#text-wrap':"position:relative; margin-left:3.0em; margin-right:3.0em;", '#text-container':"position:relative;width:36em; margin:0 auto 0 auto; font-family:Georgia,serif;", '#text':"text-align:justify;", '.sidenote-right':"position:absolute; left:37em; width:16em; text-indent:0em; text-align:left;", '.sidenote-left':"position:absolute; left:37em; width:16em; text-indent:0em; text-align:left;", '.mw-editsection':"display:none;", '#headertemplate':"font-family:sans-serif;" }; self.ws_layouts['বিন্যাস ৩'] = { '#text-wrap':"position:relative; margin-left:3.0em;", '#text-container':"position:relative; min-width:60em; float:left; width:100%; margin-right:-23em;", '#text':"position:relative; text-align:justify; margin-right:23em; text-indent:0em; padding-left:0px; padding-right:0px; width:auto;", '.sidenote-right':"position:absolute; right:-10em; width:9em; background-color:#eeeeee; text-indent:0em; text-align:left;", '.sidenote-left':"position:absolute; right:-10em; width:9em; background-color:#eeeeee; text-indent:0em; text-align:left;", '.mw-editsection':"display:none;", '#headertemplate':"position:absolute; top:0em; right:-23em; width:21em; float:right; text-align:left;" }; self.ws_layouts['বিন্যাস প্রস্তাবিত'] = { '#text-wrap':"position:relative; margin-left:3.00em;", '#text-container':"position:relative; margin-right:-20em; min-width:60em; width:100%;", '#text':"position:relative; width:auto; margin-right:20em; padding-right:0px; padding-left:0px; text-indent:0.00em; text-align:justify;", '.sidenote-right':"position:absolute; right:-10em; width:9.00em; background-color:#eeeeee; text-indent:0.00em; text-align:left;", '.sidenote-left':"position:absolute; right:-10em; width:9.00em; background-color:#eeeeee; text-indent:0.00em; text-align:left;", '.mw-editsection':"display:none;", '#headertemplate':"position:relative; font-family:sans-serif; margin-bottom:1.33em;" }; /** * Quality indicators on "article" tab * by user:ThomasV */ // Return src for icon given percentage function icon_src(t){ var src='//upload.wikimedia.org/wikipedia/commons/'; switch(t){ case '0%': src+='8/8f/00'; break; case '25%': src+='5/5b/25'; break; case '50%': src+='3/3a/50'; break; case '75%': src+='c/cd/75'; break; case '100%': src+='6/64/100'; break; } return src + '%25.png'; } // add indicator function pageQuality() { var a = document.getElementById('ca-nstab-main'); if(!a) return; var pr_index = document.getElementById('pr_index'); if(pr_index) return; var q = document.getElementById('textquality'); var new_img; if(q) { new_img = document.createElement('img'); new_img.setAttribute('src', icon_src(q.className)); a.firstChild.appendChild(new_img); } for(var i=0; spanElem = document.getElementsByTagName('span')[i]; i++) { if (spanElem.className == 'pagequality') { new_img = document.createElement('img'); new_img.setAttribute('src', icon_src(spanElem.title)); if(wgCanonicalNamespace == 'Page') { a.firstChild.appendChild(new_img); } else { s1 = spanElem.parentNode.previousSibling; opttext = s1.firstChild.firstChild; img = opttext.firstChild.nextSibling.nextSibling.nextSibling; next = img.nextSibling; opttext.removeChild(img); opttext.insertBefore(new_img,next); } } } } jQuery( document ).ready(pageQuality); // Add link to the extension user:sanbeg function pr_add_quality_buttons_link(){ if(typeof proofreadPageMessageStatus == 'undefined') return; if( self.proofreadpage_no_quality_buttons ) return; var ig = document.getElementById("wpWatchthis"); if( !ig ) return; var f = document.createElement("span"); f.innerHTML = ' (<a href="/wiki/Help:Page Status">help</a>)'; ig.parentNode.insertBefore(f,ig.nextSibling.nextSibling.nextSibling.nextSibling); } jQuery( document ).ready(pr_add_quality_buttons_link); /** * Allows extra script to run in Special:Watchlist — addition of announcements * script allows users to dismiss Mediawiki:watchlist-announcements, as per sitenotice * user:billinghurst 20100522, as hacked from WP script */ if ( mw.config.get('wgCanonicalSpecialPageName') == 'Watchlist' ) { importScript('MediaWiki:Common.js/watchlist.js'); } /* * port from he:mediawiki:common.js for mediawiki:edittools -Steve */ /* פונקציה שמשמשת לאיפשור ניקוד במדיה ויקי:edittools */ function nikud(){ if (document.getElementById('edit-templates')!=null){ for(var i=0; a = document.getElementsByTagName("span")[i]; i++) { if(a.className == "nikud") { a.onclick=function(){insertTags(, this.title, );return false;}; } } } } jQuery( document ).ready(nikud); /** * Icons on the top right of the article title * See also CSS * * @source: www.mediawiki.org/wiki/Snippets/Top_icons * @rev: 4 */ jQuery( document ).ready( function ( $ ) { $( '.Top_icon_raw' ) .removeClass( 'Top_icon_raw' ) .addClass( 'Top_icon_dynamic' ) .prependTo( '#firstHeading' ); } ); /** * Force license-tags & authority-control out of dynamic layouts. * See also ___ */ jQuery( document ).ready( function ( $ ) { $( 'body.ns-0 div#licenseTag' ) .insertAfter( $ ( 'div.printfooter' ) ); $( 'body.ns-0 table#authorityControl' ) .insertBefore( $ ( 'div#catlinks' ) ); } ); /* IE fixes as required @ included to allow for hlist fixes mw:Snippets/Horizontal lists */ if ( $.client.profile().name === 'msie' ) { importScript( 'MediaWiki:Common.js/IEFixes.js' ); } /** * Fix for Windows XP Unicode font rendering */ mw.loader.using( 'mediawiki.util', function () { if ( navigator.appVersion.search(/windows nt 5/i) !== -1 ) { mw.util.addCSS( '.IPA { font-family: "Lucida Sans Unicode", "Arial Unicode MS"; } ' + '.Unicode { font-family: "Arial Unicode MS", "Lucida Sans Unicode"; } ' ); } } ) /** * @source www.mediawiki.org/wiki/Snippets/Load_JS_and_CSS_by_URL * @rev 6 */ mw.loader.using( ['mediawiki.util', 'mediawiki.notify', 'mediawiki.legacy.wikibits' ], function () { var extraCSS = mw.util.getParamValue( 'withCSS' ), extraJS = mw.util.getParamValue( 'withJS' ); if ( extraCSS ) { if ( extraCSS.match( /^MediaWiki:[^&<>=%#]*\.css$/ ) ) { importStylesheet( extraCSS ); } else { mw.notify( 'Only pages from the MediaWiki namespace are allowed.', { title: 'Invalid withCSS value' } ); } } if ( extraJS ) { if ( extraJS.match( /^MediaWiki:[^&<>=%#]*\.js$/ ) ) { importScript( extraJS ); } else { mw.notify( 'Only pages from the MediaWiki namespace are allowed.', { title: 'Invalid withJS value' } ); } } } ); /* * Load CSS and JS files temporarily through URL. * &use=File1.css|File2.css|File3.js * * @source www.mediawiki.org/wiki/Snippets/Load_JS_and_CSS_by_URL#Load_multiple_files * @rev 6 */ mw.loader.using( ['mediawiki.util','mediawiki.legacy.wikibits'], function () { var files = mw.util.getParamValue( 'use' ), user, FileRE; if ( !files ) { return; } user = $.escapeRE( mw.config.get( 'wgUserName', ) ); FileRE = new RegExp( '^(?=MediaWiki:' + ( user ? '|User:' + user + '/' : ) + ').*\\.(js|css)$' ); $.each( files.split( '|' ), function(k, v) { var f = $.trim( v ), what = FileRE.exec( f ) || [, ]; switch ( what[1] ) { case 'js': importScript(f); break; case 'css': importStylesheet(f); break; } }); }); /* End of mw.loader.using callback */ } ); /* DO NOT ADD CODE BELOW THIS LINE */