Difference between revisions 9103 and 9976 on newikibooks/** * @authors: Biplab Anand ([[user:बिप्लब आनन्द]]) * @date 2014-12-30 * License: GPLv3, CC-BY-SA 3.0 */ /* === Edittoolsystem === */ // switches for scripts // TODO: migrate to JSConfig // var load_extratabs = true; var load_edittools = true; // extra drop down menu on editing for adding special characters importScript( 'MediaWiki:Gadget-Edittools.js' ); /*HERE STARTS THE WORKING-CODE OF "METABOXES" */ /* Funcionament de la Plantilla:Metacaixa Implementat per: Usuari:Peleguer. Actualitzat per Joanjoc seguint les indicacions d'en Martorell */ function MetaCaixaInit(){ //S'executa al carregar-se la pàgina, si hi ha metacaixes, // s'assignen els esdeveniments als botons //alert("MetaCaixaInit"); var i=0 //Inicialitzem comptador de caixes for (i=0;i<=9;i++){ var vMc = document.getElementById("mc"+i); if (!vMc) break; //alert("MetaCaixaInit, trobada Metacaixa mc"+i); var j=1 //Inicialitzem comptador de botons dins de la caixa var vPsIni = 0 //Pestanya visible inicial for (j=1;j<=9;j++){ var vBt = document.getElementById("mc"+i+"bt"+j); if (!vBt) break; //alert("MetaCaixaInit, trobat botó mc"+i+"bt"+j); vBt.onclick = MetaCaixaMostraPestanya; //A cada botó assignem l'esdeveniment onclick //alert (vBt.className); if (vBt.className=="mcBotoSel") vPsIni=j; //Si tenim un botó seleccionat, en guardem l'index } //alert ("mc="+i+", ps="+j+", psini="+vPsIni ); if (vPsIni == 0) { //Si no tenim cap botó seleccionat, n'agafem un aleatòriament vPsIni = 1+Math.floor((j-1)*Math.random()) ; //alert ("Activant Pestanya a l'atzar; _mc"+i+"bt"+vPsIni +"_"); document.getElementById("mc"+i+"ps"+vPsIni).style.display = "block"; document.getElementById("mc"+i+"ps"+vPsIni).style.visibility = "visible"; document.getElementById("mc"+i+"bt"+vPsIni).className="mcBotoSel"; } } } function MetaCaixaMostraPestanya(){ //S'executa al clicar una pestanya, //aquella es fa visible i les altres s'oculten var vMcNom = this.id.substr(0,3); //A partir del nom del botó, deduïm el nom de la caixa var vIndex = this.id.substr(5,1); //I l'index var i=1 for (i=1;i<=9;i++){ //busquem totes les pestanyes d'aquella caixa //alert(vMcNom+"ps"+i); var vPsElem = document.getElementById(vMcNom+"ps"+i); if (!vPsElem) break; if (vIndex==i){ //Si és la pestanya bona la mostrem i canviem la classe de botó vPsElem.style.display = "block"; vPsElem.style.visibility = "visible"; document.getElementById(vMcNom+"bt"+i).className="mcBotoSel"; } else { //Sinó, l'ocultem i canviem la classe de botó vPsElem.style.display = "none"; vPsElem.style.visibility = "hidden"; document.getElementById(vMcNom+"bt"+i).className="mcBoto"; } } return false; //evitem la recàrrega de la pàgina } jQuery( document ).ready( function( $ ) { MetaCaixaInit(); } ); /*HERE FINISHES THE WORKING-CODE OF "METABOXES"</pre> */ /** * Modifie Special:Search pour pouvoir utiliser différents moteurs de recherche, * disponibles dans une boîte déroulante. * Auteurs : Jakob Voss, Guillaume, importé depuis la Wiki allemande */ function externalSearchEngines() { if (typeof SpecialSearchEnhanced2Disabled != 'undefined') return; if ( mw.config.get('wgCanonicalSpecialPageName') != "Search") return; var mainNode = document.getElementById("powersearch"); if (!mainNode) mainNode = document.getElementById("search"); if (!mainNode) return; var beforeNode = document.getElementById("mw-search-top-table"); if (!beforeNode) return; beforeNode = beforeNode.nextSibling; if (!beforeNode) return; var firstEngine = "mediawiki"; var choices = document.createElement("div"); choices.setAttribute("id","searchengineChoices"); choices.style.textAlign = "center"; var lsearchbox = document.getElementById("searchText"); if (!lsearchbox) return; var initValue = lsearchbox.value; var space = ""; for (var id in searchEngines) { var engine = searchEngines[id]; if(engine.ShortName) { if (space) choices.appendChild(space); space = document.createTextNode(" "); var attr = { type: "radio", name: "searchengineselect", value: id, onFocus: "changeSearchEngine(this.value)", id: "searchengineRadio-"+id }; var html = "<input"; for (var a in attr) html += " " + a + "='" + attr[a] + "'"; html += " />"; var span = document.createElement("span"); span.innerHTML = html; choices.appendChild( span ); var label = document.createElement("label"); label.htmlFor = "searchengineRadio-"+id; if (engine.Template.indexOf('http') == 0) { var lienMoteur = document.createElement("a"); lienMoteur.href = engine.Template.replace("{searchTerms}", initValue).replace("{language}", "hi"); lienMoteur.appendChild( document.createTextNode( engine.ShortName ) ); label.appendChild(lienMoteur); } else { label.appendChild( document.createTextNode( engine.ShortName ) ); } choices.appendChild( label ); } } mainNode.insertBefore(choices, beforeNode); var input = document.createElement("input"); input.id = "searchengineextraparam"; input.type = "hidden"; mainNode.insertBefore(input, beforeNode); changeSearchEngine(firstEngine, initValue); } function changeSearchEngine(selectedId, searchTerms) { var currentId = document.getElementById("searchengineChoices").currentChoice; if (selectedId == currentId) return; document.getElementById("searchengineChoices").currentChoice = selectedId; var radio = document.getElementById('searchengineRadio-' + selectedId); radio.checked = "checked"; var engine = searchEngines[selectedId]; var p = engine.Template.indexOf('?'); var params = engine.Template.substr(p+1); var form; if (document.forms["search"]) { form = document.forms["search"]; } else { form = document.getElementById("powersearch"); } form.setAttribute("action", engine.Template.substr(0,p)); var l = ("" + params).split("&"); for (var idx = 0;idx < l.length;idx++) { var p = l[idx].split("="); var pValue = p[1]; if (pValue == "{language}") { } else if (pValue == "{searchTerms}") { var input; input = document.getElementById("searchText"); input.name = p[0]; } else { var input = document.getElementById("searchengineextraparam"); input.name = p[0]; input.value = pValue; } } } if ( mw.config.get('wgCanonicalSpecialPageName') == "Search") { var searchEngines = { mediawiki: { ShortName: "आन्तरिक खोज", Template: mw.config.get('wgScript') + "?search={searchTerms}" }, exalead: { ShortName: "इक्सालीड", Template: "http://www.exalead.com/wikipedia/results?q={searchTerms}&language=ne" }, google: { ShortName: "गूगल", Template: "http://www.google.com.np /search?as_sitesearch=ne.wikipedia.org&hl={language}&q={searchTerms}" }, wikiwix: { ShortName: "विकीविक्स", Template: "http://ne.wikiwix.com/index.php?action={searchTerms}&lang={language}" }, wlive: { ShortName: "बिङ", Template: "http://www.bing.com/search?q={searchTerms}&q1=site:http://ne.wikipedia.org" }, yahoo: { ShortName: "याहू!", Template: "http://search.yahoo.com/search?p={searchTerms}&vs=ne.wikipedia.org" }, globalwpsearch: { ShortName: "इन्टर विकिमा", Template: "http://vs.aka-online.de/cgi-bin/globalwpsearch.pl?timeout=120&search={searchTerms}" } }; jQuery( document ).ready( function( $ ) { externalSearchEngines(); } ); } /** * 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. */ function LinkFA() { if ( document.getElementById( 'p-lang' ) ) { var InterwikiLinks = document.getElementById( 'p-lang' ).getElementsByTagName( 'li' ); for ( var i = 0; i < InterwikiLinks.length; i++ ) { var className = InterwikiLinks[i].className.match(/interwiki-[-\w]+/); if ( document.getElementById( className + '-fa' ) && InterwikiLinks[i].className.indexOf( 'badge-featuredarticle' ) === -1 ) { InterwikiLinks[i].className += ' FA'; InterwikiLinks[i].title = 'यो यस भाषाको एक निर्वाचित लेख हो ।'; } else if ( document.getElementById( className + '-ga' ) && InterwikiLinks[i].className.indexOf( 'badge-goodarticle' ) === -1 ) { InterwikiLinks[i].className += ' GA'; InterwikiLinks[i].title = 'यो यस भाषाको उत्कृष्ट लेख हो ।'; } } } } mw.hook( 'wikipage.content' ).add( LinkFA ); /** 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. * Maintainers: [[User:Dschwen]] */ mw.loader.load('//meta.wikimedia.org/w/index.php?title=MediaWiki:Wikiminiatlas.js&action=raw&ctype=text/javascript&smaxage=21600&maxage=86400'); function mainPageAppendCompleteListLink() { try { var node = document.getElementById( "p-lang" ) .getElementsByTagName('div')[0] .getElementsByTagName('ul')[0]; var aNode = document.createElement( 'a' ); var liNode = document.createElement( 'li' ); aNode.appendChild( document.createTextNode( 'Complete list' ) ); aNode.setAttribute( 'href' , '//meta.wikimedia.org/wiki/List_of_Wikipedias' ); liNode.appendChild( aNode ); liNode.className = 'interwiki-completelist'; node.appendChild( liNode ); } catch(e) { // lets just ignore what's happened return; } } if ( mw.config.get('wgIsMainPage') ) { jQuery( document ).ready( function( $ ) { mainPageAppendCompleteListLink(); } ); } /** * MainPage-tab * On the main page (and its associated namespaces and actions (Talk, edit, history etc.) * this script will put "Main Page" instead of "Article" or "Page" in the first tab. * * @source: //www.mediawiki.org/wiki/Snippets/Main_Page_tab * @rev: 2 */ $( document ).ready( function() { if ( mw.config.get('wgIsMainPage') ){ $( '#ca-nstab-main a' ).text( mw.config.get( 'wgTitle' ) ); } } ); /** * Collapsible tables ********************************************************* * * Description: Allows tables to be collapsed, showing only the header. See * [[Wikipedia:NavFrame]]. * Maintainers: [[User:R. Koot]]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 strict:false, browser:true */ mw.loader.using( ['mediawiki.util', 'mediawiki.notify', 'jquery.client'], function () { /* Begin of mw.loader.using callback */ /** * Main Page layout fixes * * Description: Adds an additional link to the complete list of languages available. * Maintainers: [[User:AzaToth]], [[User:R. Koot]], [[User:Alex Smotrov]] */ if ( mw.config.get( 'wgPageName' ) === 'Main_Page' || mw.config.get( 'wgPageName' ) === 'Talk:Main_Page' ) { $( function () { mw.util.addPortletLink( 'p-lang', '//meta.wikimedia.org/wiki/List_of_Wikipedias', 'Complete list', 'interwiki-completelist', 'Complete list of Wikipedias' ); } ); } /** * Redirect User:Name/skin.js and skin.css to the current skin's pages * (unless the 'skin' page really exists) * @source: http://www.mediawiki.org/wiki/Snippets/Redirect_skin.js * @rev: 2 */ if ( mw.config.get( 'wgArticleId' ) === 0 && mw.config.get( 'wgNamespaceNumber' ) === 2 ) { var titleParts = mw.config.get( 'wgPageName' ).split( '/' ); /* Make sure there was a part before and after the slash and that the latter is 'skin.js' or 'skin.css' */ if ( titleParts.length == 2 ) { var userSkinPage = titleParts.shift() + '/' + mw.config.get( 'skin' ); if ( titleParts.slice( -1 ) == 'skin.js' ) { window.location.href = mw.util.getUrl( userSkinPage + '.js' ); } else if ( titleParts.slice( -1 ) == 'skin.css' ) { window.location.href = mw.util.getUrl( userSkinPage + '.css' ); } } } /** * Map addPortletLink to mw.util * @deprecated: Use mw.util.addPortletLink instead. */ mw.log.deprecate( window, 'addPortletLink', mw.util.addPortletLink, 'Use mw.util.addPortletLink instead' ); /** * Extract a URL parameter from the current URL * @deprecated: Use mw.util.getParamValue with proper escaping */ mw.log.deprecate( window, 'getURLParamValue', mw.util.getParamValue, 'Use mw.util.getParamValue instead' ); /** * Test if an element has a certain class * @deprecated: Use $(element).hasClass() instead. */ mw.log.deprecate( window, 'hasClass', function ( element, className ) { return $( element ).hasClass( className ); }, 'Use jQuery.hasClass() instead' ); /** * @source www.mediawiki.org/wiki/Snippets/Load_JS_and_CSS_by_URL * @rev 6 */ 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' } ); } } /** * Import more specific scripts if necessary */ if ( mw.config.get( 'wgAction' ) === 'edit' || mw.config.get( 'wgAction' ) === 'submit' || mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Upload' ) { /* scripts specific to editing pages */ importScript( 'MediaWiki:Common.js/edit.js' ); } else if ( mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Watchlist' ) { /* watchlist scripts */ importScript( 'MediaWiki:Common.js/watchlist.js' ); } if ( mw.config.get( 'wgNamespaceNumber' ) === 6 ) { /* file description page scripts */ importScript( 'MediaWiki:Common.js/file.js' ); } /** * Helper script for .hlist class in Common.css * Add pseudo-selector class to last-child list items in IE8 * @source mediawiki.org/wiki/Snippets/Horizontal_lists * @revision 6 (2014-08-23) * @author [[User:Edokter]] */ ( function ( mw, $ ) { var profile = $.client.profile(); if ( profile.name === 'msie' && profile.versionNumber === 8 ) { mw.hook( 'wikipage.content' ).add( function ( $content ) { $content.find( '.hlist' ).find( 'dd:last-child, dt:last-child, li:last-child' ) .addClass( 'hlist-last-child' ); } ); } }( mediaWiki, jQuery ) ); /** * Fix for Windows XP Unicode font rendering */ 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"; } ' ); } /** * 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. * Maintainers: [[User:Dschwen]] */ ( function () { var require_wikiminiatlas = false; var coord_filter = /geohack/; $( function () { $( 'a.external.text' ).each( function( key, link ) { if ( link.href && coord_filter.exec( link.href ) ) { require_wikiminiatlas = true; // break from loop return false; } } ); if ( $( 'div.kmldata' ).length ) { require_wikiminiatlas = true; } if ( require_wikiminiatlas ) { mw.loader.load( '//meta.wikimedia.org/w/index.php?title=MediaWiki:Wikiminiatlas.js&action=raw&ctype=text/javascript' ); } } ); } )(); /** * Collapsible tables * * Allows tables to be collapsed, showing only the header. See [[Wikipedia:NavFrame]]. * * @version 2.0.3 (2014-03-14) * @source https://www.mediawiki.org/wiki/MediaWiki:Gadget-collapsibleTables.js * @author [[User:R. Koot]] * @author [[User:Krinkle]] * @deprecated Since MediaWiki 1.20: Use class="mw-collapsible" instead which * is supported in MediaWiki core. */ var autoCollapse = 2; var collapseCaption = 'लुकाउनुस'; var expandCaption = 'देखाउनुस'; window.collapseTable = function 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; var i; if ( Button.firstChild.data === collapseCaption ) { for ( i = 1; i < Rows.length; i++ ) { Rows[i].style.display = 'none'; } Button.firstChild.data = expandCaption; } else { for ( i = 1; i < Rows.length; i++ ) { Rows[i].style.display = Rows[0].style.display; } Button.firstChild.data = collapseCaption; } };⏎ ⏎ ⏎ function createClickHandler( tableIndex ) { return function ( e ) { e.preventDefault(); collapseTable( tableIndex ); }; }⏎ function createCollapseButtons() { var tableIndex = 0; var NavigationBoxes = {}; var Tables = document.getElementsByTagName( 'table' ); var i; ⏎ function handleButtonLink( index, e ) { window.collapseTable( index ); e.preventDefault(); }⏎ for ( i = 0; i < Tables.length; i++ ) { if ( $( Tables[i] ).hasClass( '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;{ continue; } var Header = HeaderRow.getElementsByTagName( 'th' )[0]; if ( !Header ) continue;⏎ { 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.className = 'collapseButton'; /* Styles are declared in Common.css */⏎ // Styles are declared in [[MediaWiki:Common.css]] Button.className = 'collapseButton';⏎ ButtonLink.style.color = Header.style.color; ButtonLink.setAttribute( 'id', 'collapseButton' + tableIndex ); ButtonLink.setAttribute( 'href', '#' ); $( ButtonLink ).on( 'click', $.proxy( handleButtonLink, ButtonLink,createClickHandler( tableIndex ) ); ButtonLink.appendChild( ButtonText ); Button.appendChild( document.createTextNode( '[' ) ); Button.appendChild( ButtonLink ); Button.appendChild( document.createTextNode( ']' ) ); Header.insertBefore( Button, Header.firstChild ); tableIndex++; } } for ( i = 0; i < tableIndex; i++ ) { if ( $( NavigationBoxes[i] ).hasClass( 'collapsed' ) ||⏎ ⏎ ( tableIndex >= autoCollapse && $( NavigationBoxes[i] ).hasClass( 'autocollapse' ) )⏎ ⏎ ) { window.collapseTable( i ); } else if ( $( NavigationBoxes[i] ).hasClass ( 'innercollapse' ) ) { var element = NavigationBoxes[i]; while ((element = element.parentNode)) { if ( $( element ).hasClass( 'outercollapse' ) ) { window.collapseTable ( i ); break; } } } } } ⏎ mw.hook( 'wikipage.content' ).add( createCollapseButtons );⏎ $( createCollapseButtons );⏎ /** * Dynamic Navigation Bars (experimental) * * Description: See [[Wikipedia:NavFrame]]. * Maintainers: UNMAINTAINED */ (contracted; show full) } } NavFrame.setAttribute( 'id', 'NavFrame' + indexNavigationBar ); } } } mw.hook( 'wikipage.content' ).add( createNavigationBarToggleButton );$( createNavigationBarToggleButton ); /** * Uploadwizard_newusers * Switches in a message for non-autoconfirmed users at [[Wikipedia:Upload]] * * Maintainers: [[User:Krimpet]] */ function uploadwizard_newusers() { if ( mw.config.get( 'wgNamespaceNumber' ) === 4 && mw.config.get( 'wgTitle' ) === 'Upload' && mw.config.get( 'wgAction' ) === 'view' ) { var oldDiv = document.getElementById( 'autoconfirmedusers' ), newDiv = document.getElementById( 'newusers' ); if ( oldDiv && newDiv ) { var userGroups = mw.config.get( 'wgUserGroups' ); if ( userGroups ) { for ( var i = 0; i < userGroups.length; i++ ) { if ( userGroups[i] === 'autoconfirmed' ) { oldDiv.style.display = 'block'; newDiv.style.display = 'none'; return; } } } oldDiv.style.display = 'none'; newDiv.style.display = 'block'; return; } } } $(uploadwizard_newusers); /** * Magic editintros **************************************************** * * Description: Adds editintros on disambiguation pages and BLP pages. * Maintainers: [[User:RockMFR]] */ function addEditIntro( name ) { $( '.mw-editsection, #ca-edit' ).find( 'a' ).each( function ( i, el ) { el.href = $( this ).attr( 'href' ) + '&editintro=' + name; } ); } if ( mw.config.get( 'wgNamespaceNumber' ) === 0 ) { $( function () { if ( document.getElementById( 'disambigbox' ) ) { addEditIntro( 'Template:Disambig_editintro' ); } } ); $( function () { var cats = mw.config.get('wgCategories'); if ( !cats ) { return; } if ( $.inArray( 'Living people', cats ) !== -1 || $.inArray( 'Possibly living people', cats ) !== -1 ) { addEditIntro( 'Template:BLP_editintro' ); } } ); } /* End of mw.loader.using callback */ } ); /* DO NOT ADD CODE BELOW THIS LINE */ All content in the above text box is licensed under the Creative Commons Attribution-ShareAlike license Version 4 and was originally sourced from https://ne.wikibooks.org/w/index.php?diff=prev&oldid=9976.
![]() ![]() This site is not affiliated with or endorsed in any way by the Wikimedia Foundation or any of its affiliates. In fact, we fucking despise them.
|