मीडियाविकि:Common.js
भारत डिस्कवरी प्रस्तुति
ध्यान दें: प्रकाशित करने के बाद बदलाव देखने के लिए आपको अपने ब्राउज़र के कैश को हटाना पड़ सकता है।
- Firefox/Safari: Reload क्लिक समय Shift दबाएँ, या फिर Ctrl-F5 या Ctrl-R दबाएँ (Mac पर ⌘-R)
- Google Chrome: Ctrl-Shift-R दबाएँ (Mac पर ⌘-Shift-R)
- Internet Explorer/Edge: Refresh पर क्लिक करते समय Ctrl दबाएँ, या Ctrl-F5 दबाएँ
- Opera: Ctrl-F5 दबाएँ।
/* यहां लिखी गई जावास्क्रीप्ट सभी सदस्योंके लिये इस्तेमाल में लाई जायेगी। */ function includePage( name ) { document.write('<script type="text/javascript" src="' + wgScript + '?title=' + name + '&action=raw&ctype=text/javascript"><\/script>' ); } /* End of includePage */ /* Including extra .js pages */ // switches for scripts // var load_extratabs = true; var load_edittools = true; // extra drop down menu on editing for adding special characters includePage( 'MediaWiki:Edittools.js' ); /** Collapsible tables ********************************************************* * * Description: Allows tables to be collapsed, showing only the header. See * http://www.mediawiki.org/wiki/Manual:Collapsible_tables. * Maintainers: [[**MAINTAINERS**]] */ var autoCollapse = 2; var collapseCaption = 'छिपाएँ'; var expandCaption = 'दिखाएँ'; 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.className = 'collapseButton'; // Styles are declared in MediaWiki:Common.css 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 ); /** 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); }; })(); /** 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, 'NavContent') || hasClass(NavChild, 'NavPic')) { 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, 'NavContent') || hasClass(NavChild, 'NavPic')) { 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 isCollapsed = hasClass( NavFrame, "collapsed" ); /* * Check if any children are already hidden. This loop is here for backwards compatibility: * the old way of making NavFrames start out collapsed was to manually add style="display:none" * to all the NavPic/NavContent elements. Since this was bad for accessibility (no way to make * the content visible without JavaScript support), the new recommended way is to add the class * "collapsed" to the NavFrame itself, just like with collapsible tables. */ for (var NavChild = NavFrame.firstChild; NavChild != null && !isCollapsed; NavChild = NavChild.nextSibling) { if ( hasClass( NavChild, 'NavPic' ) || hasClass( NavChild, 'NavContent' ) ) { if ( NavChild.style.display == 'none' ) { isCollapsed = true; } } } if (isCollapsed) { for (var NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling) { if ( hasClass( NavChild, 'NavPic' ) || hasClass( NavChild, 'NavContent' ) ) { NavChild.style.display = 'none'; } } } var NavToggleText = document.createTextNode(isCollapsed ? NavigationBarShow : NavigationBarHide); 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 ); /* Any JavaScript here will be loaded for all users on every page load. */ if (!window.$j) { $j = jQuery; } /* == jQuery.hoverIntent == * Copyright (c) 2007 Brian Cherne * http://cherne.net/brian/resources/jquery.hoverIntent.html * Dual licensed under the MIT and GPL licenses */ (function($) { $.fn.hoverIntent = function(f,g) { // default configuration options var cfg = { sensitivity: 7, interval: 100, timeout: 0 }; // override configuration options with user supplied object cfg = $.extend(cfg, g ? { over: f, out: g } : f ); // instantiate variables // cX, cY = current X and Y position of mouse, updated by mousemove event // pX, pY = previous X and Y position of mouse, set by mouseover and polling interval var cX, cY, pX, pY; // A private function for getting mouse position var track = function(ev) { cX = ev.pageX; cY = ev.pageY; }; // A private function for comparing current and previous mouse position var compare = function(ev,ob) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); // compare mouse positions to see if they've crossed the threshold if ( ( Math.abs(pX-cX) + Math.abs(pY-cY) ) < cfg.sensitivity ) { $(ob).unbind("mousemove",track); // set hoverIntent state to true (so mouseOut can be called) ob.hoverIntent_s = 1; return cfg.over.apply(ob,[ev]); } else { // set previous coordinates for next time pX = cX; pY = cY; // use self-calling timeout, guarantees intervals are spaced out properly (avoids JavaScript timer bugs) ob.hoverIntent_t = setTimeout( function(){compare(ev, ob);} , cfg.interval ); } }; // A private function for delaying the mouseOut function var delay = function(ev,ob) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); ob.hoverIntent_s = 0; return cfg.out.apply(ob,[ev]); }; // A private function for handling mouse 'hovering' var handleHover = function(e) { // next three lines copied from jQuery.hover, ignore children onMouseOver/onMouseOut var p = (e.type == "mouseover" ? e.fromElement : e.toElement) || e.relatedTarget; while ( p && p != this ) { try { p = p.parentNode; } catch(e) { p = this; } } if ( p == this ) { return false; } // copy objects to be passed into t (required for event object to be passed in IE) var ev = jQuery.extend({},e); var ob = this; // cancel hoverIntent timer if it exists if (ob.hoverIntent_t) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); } // else e.type == "onmouseover" if (e.type == "mouseover") { // set "previous" X and Y position based on initial entry point pX = ev.pageX; pY = ev.pageY; // update "current" X and Y position based on mousemove $(ob).bind("mousemove",track); // start polling interval (self-calling timeout) to compare mouse coordinates over time if (ob.hoverIntent_s != 1) { ob.hoverIntent_t = setTimeout( function(){compare(ev,ob);} , cfg.interval );} // else e.type == "onmouseout" } else { // unbind expensive mousemove event $(ob).unbind("mousemove",track); // if hoverIntent state is true, then call the mouseOut function after the specified delay if (ob.hoverIntent_s == 1) { ob.hoverIntent_t = setTimeout( function(){delay(ev,ob);} , cfg.timeout );} } }; // bind the function to the two event listeners return this.mouseover(handleHover).mouseout(handleHover); }; })(jQuery); /* == Supersubs == * Supersubs v0.2b - jQuery plugin * Copyright (c) 2008 Joel Birch * Dual licensed under the MIT and GPL licenses: */ ;(function($){ // $ will refer to jQuery within this closure $.fn.supersubs = function(options){ var opts = $.extend({}, $.fn.supersubs.defaults, options); // return original object to support chaining return this.each(function() { // cache selections var $$ = $(this); // support metadata var o = $.meta ? $.extend({}, opts, $$.data()) : opts; // get the font size of menu. // .css('fontSize') returns various results cross-browser, so measure an em dash instead var fontsize = $('<li id="menu-fontsize">—</li>').css({ 'padding' : 0, 'position' : 'absolute', 'top' : '-999em', 'width' : 'auto' }).appendTo($$).width(); //clientWidth is faster, but was incorrect here // remove em dash $('#menu-fontsize').remove(); // cache all ul elements $ULs = $$.find('ul'); // loop through each ul in menu $ULs.each(function(i) { // cache this ul var $ul = $ULs.eq(i); // get all (li) children of this ul var $LIs = $ul.children(); // get all anchor grand-children var $As = $LIs.children('a'); // force content to one line and save current float property var liFloat = $LIs.css('white-space','nowrap').css('float'); // remove width restrictions and floats so elements remain vertically stacked var emWidth = $ul.add($LIs).add($As).css({ 'float' : 'none', 'width' : 'auto' }) // this ul will now be shrink-wrapped to longest li due to position:absolute // so save its width as ems. Clientwidth is 2 times faster than .width() - thanks Dan Switzer .end().end()[0].clientWidth / fontsize; // add more width to ensure lines don't turn over at certain sizes in various browsers emWidth += o.extraWidth; // restrict to at least minWidth and at most maxWidth if (emWidth > o.maxWidth) { emWidth = o.maxWidth; } else if (emWidth < o.minWidth) { emWidth = o.minWidth; } emWidth += 'em'; // set ul to width in ems $ul.css('width',emWidth); // restore li floats to avoid IE bugs // set li width to full width of this ul // revert white-space to normal $LIs.css({ 'float' : liFloat, 'width' : '100%', 'white-space' : 'normal' }) // update offset position of descendant ul to reflect new width of parent .each(function(){ var $childUl = $('>ul',this); var offsetDirection = $childUl.css('left')!==undefined ? 'left' : 'right'; $childUl.css(offsetDirection,emWidth); }); }); }); }; // expose defaults $.fn.supersubs.defaults = { minWidth : 9, // requires em unit. maxWidth : 25, // requires em unit. extraWidth : 0 // extra width can ensure lines don't sometimes turn over due to slight browser differences in how they round-off values }; })(jQuery); /* == Superfish == * Superfish v1.4.8 - jQuery menu widget * Copyright (c) 2008 Joel Birch * Dual licensed under the MIT and GPL licenses */ ;(function($){ $.fn.superfish = function(op){ var sf = $.fn.superfish, c = sf.c, $arrow = $(['<span class="',c.arrowClass,'"> »</span>'].join('')), over = function(){ var $$ = $(this), menu = getMenu($$); clearTimeout(menu.sfTimer); $$.showSuperfishUl().siblings().hideSuperfishUl(); }, out = function(){ var $$ = $(this), menu = getMenu($$), o = sf.op; clearTimeout(menu.sfTimer); menu.sfTimer=setTimeout(function(){ o.retainPath=($.inArray($$[0],o.$path)>-1); $$.hideSuperfishUl(); if (o.$path.length && $$.parents(['li.',o.hoverClass].join('')).length<1){over.call(o.$path);} },o.delay); }, getMenu = function($menu){ var menu = $menu.parents(['ul.',c.menuClass,':first'].join(''))[0]; sf.op = sf.o[menu.serial]; return menu; }, addArrow = function($a){ $a.addClass(c.anchorClass).append($arrow.clone()); }; return this.each(function() { var s = this.serial = sf.o.length; var o = $.extend({},sf.defaults,op); o.$path = $('li.'+o.pathClass,this).slice(0,o.pathLevels).each(function(){ $(this).addClass([o.hoverClass,c.bcClass].join(' ')) .filter('li:has(ul)').removeClass(o.pathClass); }); sf.o[s] = sf.op = o; $('li:has(ul)',this)[($.fn.hoverIntent && !o.disableHI) ? 'hoverIntent' : 'hover'](over,out).each(function() { if (o.autoArrows) addArrow( $('>a:first-child',this) ); }) .not('.'+c.bcClass) .hideSuperfishUl(); var $a = $('a',this); $a.each(function(i){ var $li = $a.eq(i).parents('li'); $a.eq(i).focus(function(){over.call($li);}).blur(function(){out.call($li);}); }); o.onInit.call(this); }).each(function() { var menuClasses = [c.menuClass]; if (sf.op.dropShadows && !($.browser.msie && $.browser.version < 7)) menuClasses.push(c.shadowClass); $(this).addClass(menuClasses.join(' ')); }); }; var sf = $.fn.superfish; sf.o = []; sf.op = {}; sf.IE7fix = function(){ var o = sf.op; if ($.browser.msie && $.browser.version > 6 && o.dropShadows && o.animation.opacity!=undefined) this.toggleClass(sf.c.shadowClass+'-off'); }; sf.c = { bcClass : 'sf-breadcrumb', menuClass : 'sf-js-enabled', anchorClass : 'sf-with-ul', arrowClass : 'sf-sub-indicator', shadowClass : 'sf-shadow' }; sf.defaults = { hoverClass : 'sfHover', pathClass : 'overideThisToUse', pathLevels : 1, delay : 800, animation : {opacity:'show'}, speed : 'normal', autoArrows : true, dropShadows : true, disableHI : false, // true disables hoverIntent detection onInit : function(){}, // callback functions onBeforeShow: function(){}, onShow : function(){}, onHide : function(){} }; $.fn.extend({ hideSuperfishUl : function(){ var o = sf.op, not = (o.retainPath===true) ? o.$path : ''; o.retainPath = false; var $ul = $(['li.',o.hoverClass].join(''),this).add(this).not(not).removeClass(o.hoverClass) .find('>ul').hide().css('visibility','hidden'); o.onHide.call($ul); return this; }, showSuperfishUl : function(){ var o = sf.op, sh = sf.c.shadowClass+'-off', $ul = this.addClass(o.hoverClass) .find('>ul:hidden').css('visibility','visible'); sf.IE7fix.call($ul); o.onBeforeShow.call($ul); $ul.animate(o.animation,o.speed,function(){ sf.IE7fix.call($ul); o.onShow.call($ul); }); return this; } }); })(jQuery); /* == jQuery Tools == * jQuery Tools 1.2.2 - The missing UI library for the Web * [tabs] * http://flowplayer.org/tools/ */ /* tabs */ (function(c){function p(d,a,b){var e=this,l=d.add(this),h=d.find(b.tabs),j=a.jquery?a:d.children(a),i;h.length||(h=d.children());j.length||(j=d.parent().find(a));j.length||(j=c(a));c.extend(this,{click:function(f,g){var k=h.eq(f);if(typeof f=="string"&&f.replace("#","")){k=h.filter("[href*="+f.replace("#","")+"]");f=Math.max(h.index(k),0)}if(b.rotate){var n=h.length-1;if(f<0)return e.click(n,g);if(f>n)return e.click(0,g)}if(!k.length){if(i>=0)return e;f=b.initialIndex;k=h.eq(f)}if(f===i)return e; g=g||c.Event();g.type="onBeforeClick";l.trigger(g,[f]);if(!g.isDefaultPrevented()){o[b.effect].call(e,f,function(){g.type="onClick";l.trigger(g,[f])});i=f;h.removeClass(b.current);k.addClass(b.current);return e}},getConf:function(){return b},getTabs:function(){return h},getPanes:function(){return j},getCurrentPane:function(){return j.eq(i)},getCurrentTab:function(){return h.eq(i)},getIndex:function(){return i},next:function(){return e.click(i+1)},prev:function(){return e.click(i-1)}});c.each("onBeforeClick,onClick".split(","), function(f,g){c.isFunction(b[g])&&c(e).bind(g,b[g]);e[g]=function(k){c(e).bind(g,k);return e}});if(b.history&&c.fn.history){c.tools.history.init(h);b.event="history"}h.each(function(f){c(this).bind(b.event,function(g){e.click(f,g);return g.preventDefault()})});j.find("a[href^=#]").click(function(f){e.click(c(this).attr("href"),f)});if(location.hash)e.click(location.hash);else if(b.initialIndex===0||b.initialIndex>0)e.click(b.initialIndex)}c.tools=c.tools||{version:"1.2.2"};c.tools.tabs={conf:{tabs:"a", current:"current",onBeforeClick:null,onClick:null,effect:"default",initialIndex:0,event:"click",rotate:false,history:false},addEffect:function(d,a){o[d]=a}};var o={"default":function(d,a){this.getPanes().hide().eq(d).show();a.call()},fade:function(d,a){var b=this.getConf(),e=b.fadeOutSpeed,l=this.getPanes();e?l.fadeOut(e):l.hide();l.eq(d).fadeIn(b.fadeInSpeed,a)},slide:function(d,a){this.getPanes().slideUp(200);this.getPanes().eq(d).slideDown(400,a)},ajax:function(d,a){this.getPanes().eq(0).load(this.getTabs().eq(d).attr("href"), a)}},m;c.tools.tabs.addEffect("horizontal",function(d,a){m||(m=this.getPanes().eq(0).width());this.getCurrentPane().animate({width:0},function(){c(this).hide()});this.getPanes().eq(d).animate({width:m},function(){c(this).show();a.call()})});c.fn.tabs=function(d,a){var b=this.data("tabs");if(b)return b;if(c.isFunction(a))a={onBeforeClick:a};a=c.extend({},c.tools.tabs.conf,a);this.each(function(){b=new p(c(this),d,a);c(this).data("tabs",b)});return a.api?b:this}})(jQuery); /* Wikis függvények és segédletek ($.wiki) */ (function($){ $.wiki = {}; /* $.wiki.contentSelector: visszaadja magát a szócikket tartalmazó elem szelektorát a skintől függően */ if (skin == "modern") $.wiki.contentSelector = "#mw_contentholder"; else if (skin == "standard" || skin == "nostalgia" || skin == "cologneblue") $.wiki.contentSelector = "#article"; else $.wiki.contentSelector = "#bodyContent"; /* Ajaxon keresztül lekéri a megadott oldalt opcionális paraméterekkel */ $.wiki.getPage = function(settings) { if (typeof(settings.pageName) == "undefined" || settings.pageName == "") settings.error.call(); var ajaxSettings = { url: $.wiki.wikiEntryLink(settings.pageName, (typeof(settings.params) == "undefined" ? {} : settings.params)) } if (typeof(settings.async) != "undefined") ajaxSettings = $.extend(ajaxSettings, {async: settings.async}); if (typeof(settings.success) != "undefined") ajaxSettings = $.extend(ajaxSettings, {success: settings.success}); if (typeof(settings.error) != "undefined") ajaxSettings = $.extend(ajaxSettings, {error: settings.error}); return $.ajax(ajaxSettings); }; /* Ajaxon keresztül lekéri a megadott oldal nyers változatát opcionális további paraméterekkel */ $.wiki.getPageRaw = function(settings) { if (typeof(settings.params) != "undefined") settings.params.action = "raw"; else settings.params = {action: "raw"}; return $.wiki.getPage(settings); }; /* Egyszerű wikilink generálása lapnévből: http://hu.wikipedia.org/wiki/Pagename */ $.wiki.wikiLink = function(page) { var prep = page.replace(/ /g, "_"); return wgServer + wgArticlePath.replace(/\$1/g, prep); }; /* Link a belépési ponthoz (index.php): http://hu.wikipedia.org/w/index.php?title=Pagename Opcionálisan további paraméterekkel */ $.wiki.wikiEntryLink = function(page, args) { var prep = page.replace(/ /g, "_"); prep = wgServer + wgScript + "?title=" + prep; $.each(args, function(key, value) { prep = prep + "&" + key + "=" + value; }); return prep; } })(jQuery); /* == Segédfüggvények == */ window.$ = jQuery; // bugfix - $ valamiért nem látszik /* Chrome sniffing */ var is_chrome = /Chrome/.test(navigator.userAgent); /* kell a sablonmesternek */ var is_khtml = false; function addLoadEvent(func) { $j(func); } var hasClass = (function () { var reCache = {}; return function (element, className) { return (reCache[className] ? reCache[className] : (reCache[className] = new RegExp("(?:\\s|^)" + className + "(?:\\s|$)"))).test(element.className); }; })(); function escapeRegexp(s) { return s.replace(/([.*+?^${}()|[\]\/\\])/g, '\\$1'); } function getCookie(name) { var cookieText; var cookiePos = document.cookie.indexOf(name + '='); if(cookiePos!=-1) { var results = document.cookie.match(name+'=(.*?)(;|$)'); if(results) cookieText = unescape(results[1]); return cookieText; } else return null; } function setCookie(name, text, expires) { if(text) { if(expires) { document.cookie = name + '=' + escape(text) + '; expires=' + expires.toUTCString() + '; path=/'; } else { document.cookie = name + '=' + escape(text) + '; path=/'; } } else { document.cookie = name + '=; expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/'; // delete cookie } } /* A wikibits.js importScriptjének emulálása az új betöltőrendszer használatával */ function mwImportScript(page) { mw.loader.load(mw.config.get('wgServer') + mw.config.get('wgScript') + '?title=' + encodeURIComponent(page.replace(/ /g,'_')).replace(/%2F/ig,'/').replace(/%3A/ig,':') + '&action=raw&ctype=text/javascript'); } $j.fn.log = function(msg) { if (!window.console || !console.log) return; if (msg) { if (typeof msg == 'string') { console.log('%s: %o', msg, this); } else { console.log('%o -> %o', this, msg); } } else { console.log(this); } }; /* == Kezdőlap RSS == */ if (wgPageName == 'Kezdőlap') { $j(function addFeaturedRSS() { var feeds = { 'kiemelt': 'Kiemelt szócikkek', 'kiemelt-kep': 'Kiemelt képek', 'evfordulok': 'Évfordulók' } for (i in feeds) { var url = 'http://feeds.feedburner.com/huwiki-' + i; $('head').append('<link href="'+url+'" title="'+feeds[i]+'" type="application/rss+xml" rel="alternate">'); } }); } if (wgTitle == wgMainPageTitle) $j(function () { if (wgNamespaceNumber == 0) addPortletLink('p-lang', 'http://meta.wikimedia.org/wiki/List_of_Wikipedias', 'Teljes lista', 'interwiki-completelist', 'A Wikipédiák teljes listája'); var nstab = document.getElementById('ca-nstab-main'); if (nstab && wgUserLanguage == 'hu') { while (nstab.firstChild) nstab = nstab.firstChild; nstab.nodeValue = 'Kezdőlap'; } } ); /* == Cím elrejtése == */ function hideArticleTitle() { if (document.getElementById("HideTitle")) { if (skin=="modern") return; var h1 = document.getElementsByTagName("h1")[0]; if (h1) { h1.style.display = "none"; } var siteSub = document.getElementById("siteSub"); if (siteSub) { siteSub.style.display = "none"; } } } /* == Menük és tabsetek inicializálása == */ function generateMenuLayout(desti, level) { if (level > 2) return 0; // max. 2 szint var curr = $("<ul></ul>"); $("div", desti).each(function() { var cdiv = $(this); if (cdiv.hasClass("menuItem")) { $("<li>").html(cdiv.html()).appendTo(curr); } else { var ret = generateMenuLayout($("#wikiMenu-" + cdiv.attr("title")), level+1); if (ret != 0) { $("<li>").html(cdiv.html()).append(ret).appendTo(curr); } } }); if (level == 0) { desti.after(curr); var destid = "menu-" + desti.attr("id").substring(10); curr.attr("id", destid) .addClass("sf-menu"); desti.remove(); if (mw.config.get('wikimenu.useCustomMenu', false) == true && wgUserName != null && curr.parents("#header-menu").length > 0) { $.wiki.getPageRaw({ pageName: "User:" + wgUserName + "/Saját menü", async: false, success: function(data) { var items = data.split("\n"); if (items.length == 0 || items.length == 1 && items[0] == "") return; var cmenu = $('<ul></ul>'); var ccount = 0; for (var zs = 0; zs < items.length; zs++) { if (items[zs] == "" || items[zs].substring(0,1) != '#') continue; var foo = items[zs].substring(1); if (foo.indexOf("|") > -1) { var splitem = foo.split("|"); $('<li><a href="' + $.wiki.wikiLink(splitem[0], false) + '">' + splitem[1] + '</a></li>').appendTo(cmenu); } else { $('<li><a href="' + $.wiki.wikiLink(foo, false) + '">' + foo + '</a></li>').appendTo(cmenu); } ccount++; } if (ccount > 0) { $('<li><a href="#">Saját</a></li>').append(cmenu).appendTo(curr); } } }); } return destid; } else { return curr; } } $(function() { if (wgNamespaceNumber != -1) { /* Sima cím eltüntetése, ha a menü alatt van helyettesítő */ if (wgAction != "edit" && wgAction != "submit" && $("#header-title").length > 0) { if (skin != "modern") { $("#firstHeading").css("display", "none"); $("#siteSub").css("display", "none"); } if ($("#contentSub").length > 0 && $("#mw-revision-info").length == 0) $("#contentSub").css("display", "none"); } /* Gombok */ var bigButtons = $(".bigButton", $($.wiki.contentSelector)); if (bigButtons.length > 0) { bigButtons.each(function() { var link = $("a:first", $(this)); if (link.length > 0) { var curLink = link.attr("href"); link.parent().html(link.html()); $(this).css("cursor", "pointer") .wrap('<a class="buttonWrapperAnchor" href="' + curLink + '"></a>'); } }); } /* Eligazítólapok */ var eliItems = $(".eligazitoLap > .eligazitoElem", $($.wiki.contentSelector)); if (eliItems.length > 0) { /* IE6 miaza:hover??-bugfix */ if ($.browser.msie && $.browser.version == 6) { eliItems.hover( function() { $(this).addClass("eeHover"); }, function() { $(this).removeClass("eeHover"); } ); } eliItems.each(function() { var link = $(".eligazitoTovabb > a", $(this)); if (link.length > 0) { var curLink = link.attr("href"); link.parent().html(link.html()); $(this).css("cursor", "pointer") .wrap('<a href="' + curLink + '" class="eligazitoWrapLink"></a>'); } }); } /* Tabok felépítése */ $(".tabset-tabs", $($.wiki.contentSelector)).each(function() { var tabul = $("<ul></ul>"); var curid = $(this).attr("id").substring(10); var tabCount = 0; $("#" + curid + "-content > div").each(function() { var cdiv = $(this); if (cdiv.hasClass("tab-nojs")) cdiv.removeClass("tab-nojs"); if (cdiv.attr("title") != "") { $("<li></li>").html("<a>" + cdiv.attr("title") + "</a>").appendTo(tabul); tabCount++; } else { cdiv.remove(); } }); if (tabCount > 0) { $(this).after(tabul); tabul.attr("id", curid); tabul.addClass("tabset-tabs"); tabul.tabs("#" + curid + "-content > div"); tabul.trigger('tabsetReady'); } else { $("#" + curid + "-content").remove(); } $(this).remove(); }); /* Menük felépítése */ if (mw.config.get('wikimenu.disabled', false) == false) { var menuRoots = $(".wikiMenu-rootContainer", $($.wiki.contentSelector)); if (menuRoots.length > 0) { menuRoots.each(function() { var destid = generateMenuLayout($(this), 0); if (jQuery.browser.msie && jQuery.browser.version == 6) { $("#" + destid).superfish(); } else { $("#" + destid).supersubs({ minWidth: 12, // minimum width of sub-menus in em units maxWidth: 27, // maximum width of sub-menus in em units extraWidth: 2 // extra width can ensure lines don't sometimes turn over // due to slight rounding differences and font-family }).superfish(); } }); } $(".wikiMenu-container", $($.wiki.contentSelector)).remove(); } } }); /* Kapcsolódó lapok */ $j(function() { $j('.buborekGomb').each(function() { if (wgNamespaceNumber===0) return; var $this = $j(this); var contentDivSelector = '#' + $this.attr('id').replace(/^button-/, '') + '-content'; var contentDiv = $j(contentDivSelector); var bodySelector = 'body'; if (skin==='monobook') bodySelector = '#globalWrapper'; $j(contentDivSelector).appendTo(bodySelector); var contentDivWidth = 0; $j.swap(contentDiv.get(0), {display: 'block'}, function() { contentDivWidth = $j(this).outerWidth(); }); function reposBuborek() { var contentDivLeft = $this.offset().left + contentDivWidth > $j(window).width() ? $this.offset().left + $this.outerWidth() - contentDivWidth : $this.offset().left; $j(contentDivSelector).css({ position: 'absolute', top: $this.offset().top + $this.outerHeight(), left: contentDivLeft }); } reposBuborek(); $j(contentDivSelector).find('.buborekTitlebar').prepend( $j('<div>').addClass('buborekCloseButton') .html('x') .click(function() { $this.removeClass('button-active'); contentDiv.stop().fadeTo(200, 0).removeClass('buborekVisible').hide(); }) ); $this.click(function() { if(contentDiv.hasClass('buborekVisible')) { $this.removeClass('button-active'); contentDiv.stop().fadeTo(200, 0).removeClass('buborekVisible').hide(); } else { reposBuborek(); $this.addClass('button-active'); contentDiv.stop().show().fadeTo(200, 1).addClass('buborekVisible'); } }); }); }); /* == Képannotációk == */ if (wgNamespaceNumber != -1 && wgAction && (wgAction == 'view' || wgAction == 'purge') && document.URL.search (/[?&]oldid=/) < 0 && document.URL.search (/[?&]diff=/) < 0 && mw.config.get('imageAnnotator.disabled', false) != true) { mwImportScript ('MediaWiki:Gadget-ImageAnnotator.js'); } /* == Elrejthető üzenetek == */ function hideElement(e) { var name = this.id.slice(5); // 'hide-' elhagyása var element = document.getElementById(name); var expires = new Date(); expires.setTime( expires.getTime() + (7*24*60*60*1000) ); // 1 hét setCookie('hide-' + name, '1', expires); element.style.display = "none"; this.style.display = "none"; return false; } function addHideButton(element) { if (!element) return; var isHidden = getCookie('hide-' + element.id); if(isHidden) { element.style.display = "none"; } else { var button = document.createElement( "a" ); button.setAttribute( "id", "hide-" + element.id); button.setAttribute( "class", "hideButton" ); button.setAttribute( "href", "#" ); button.setAttribute( "title", "Üzenet elrejtése egy hétre" ); button.onclick = hideElement; button.appendChild( document.createTextNode("[elrejt]") ); element.appendChild( button ); } } /* == WikiMiniAtlas == */ mw.loader.load( 'http://meta.wikimedia.org/w/index.php?title=MediaWiki:Wikiminiatlas.js' + '&action=raw&ctype=text/javascript&dontcountme=s&smaxage=3600'); /* == Képfeltöltés == */ // Nincslicenc sablon beszúrása, ha a semmilyen sablon opciót választotta function ForceLicenseInstall(){ // Check browser capabilities if(!document.forms || !document.getElementById) return; // User explicitly turned it off if (typeof noForceLicense != 'undefined') return; if(!document.forms.upload) return; document.forms.upload.wpUpload.onclick = ForceLicense; }; function ForceLicense(){ if ((document.forms.upload.wpLicense.selectedIndex == 0) && (!/\{\{[^{}]+\}\}/.test(document.forms.upload.wpUploadDescription.value))) { document.forms.upload.wpUploadDescription.value += ("\n==Licenc==\n{"+"{nincslicenc}"+"}"); } return true; }; $j(ForceLicenseInstall); // bugfix: lehessen az utolsó opciót is választani function licenseSelectorEnableLast() { var selector = document.getElementById("wpLicense"); if ((selector) && (selector.selectedIndex != selector.options.length - 1 )) { // call original handler licenseSelectorCheck(); } } function licenseSelectorEnableLastInstall() { var selector = document.getElementById("wpLicense"); if (selector) { selector.options[selector.options.length-1].style.disabled = 'false'; selector.onchange = licenseSelectorEnableLast; } } $j(licenseSelectorEnableLastInstall); // ne írja át a célfájlnevet forrásfájl kiválasztásakor, ha van wgDestFile paraméter if (window.toggleFilenameFiller) { $j(toggleFilenameFiller); } $(document).ready(function(){ window.setInterval(function(){ //$(".advert li:first-child").slideToggle(); $(.advert).children('.li').slideToggle(); // $(".advert li:second-child").slideToggle(); },5000); $(".advert").height($(".advert").width()/10.4+"px"); $("#mw-head-base").height($("#mw-head-base").height()+$(".advert").height()+"px"); $("#left-navigation").css("top",(parseInt($("#left-navigation").css("top"))+parseInt($(".advert").height())+"px")); $("#right-navigation").css("margin-top",(parseInt($("#right-navigation").css("margin-top"))+parseInt($(".advert").height())+"px")); });