मिडियाविकी चर्चा:Monobook.js

Page contents not supported in other languages.
Wiktionary कडून

/*

MediaWiki tooltips and access keys[संपादन]

*/

/* 

Top row - user buttons[संपादन]

 */

ta = new Object();
ta['pt-userpage'] = new Array('.','My user page');
ta['pt-anonuserpage'] = new Array('.','The user page for the ip you\'re editing as');
ta['pt-mytalk'] = new Array('n','My talk page');
ta['pt-anontalk'] = new Array('n','Discussion about edits from this ip address');
ta['pt-preferences'] = new Array('','My preferences');
ta['pt-watchlist'] = new Array('l','The list of pages you\'re monitoring for changes.');
ta['pt-mycontris'] = new Array('y','List of my contributions');
ta['pt-login'] = new Array('o','You are encouraged to log in, it is not mandatory however.');
ta['pt-anonlogin'] = new Array('o','You are encouraged to log in, it is not mandatory however.');
ta['pt-logout'] = new Array('o','Log out');

/* 

/*

Tabs[संपादन]

 */
ta['ca-talk'] = new Array('t','Discussion about the content page');
ta['ca-edit'] = new Array('e','You can edit this page. Please use the preview button before saving.');
ta['ca-addsection'] = new Array('+','Add a comment to this discussion.');
ta['ca-viewsource'] = new Array('e','This page is protected. You can view its source.');
ta['ca-history'] = new Array('h','Past versions of this page.');
ta['ca-protect'] = new Array('=','Protect this page');
ta['ca-delete'] = new Array('d','Delete this page');
ta['ca-undelete'] = new Array('d','Restore the edits done to this page before it was deleted');
ta['ca-move'] = new Array('m','Move this page');
ta['ca-nomove'] = new Array('','You don\'t have the permissions to move this page');
ta['ca-watch'] = new Array('w','Add this page to your watchlist');
ta['ca-unwatch'] = new Array('w','Remove this page from your watchlist');

/* 

/*

addLoadEvent[संपादन]

 */
function addLoadEvent(func) 
{
  if (window.addEventListener) 
    window.addEventListener("load", func, false);
  else if (window.attachEvent) 
    window.attachEvent("onload", func);
}

/* 

addOnloadHook[संपादन]

 */
//use both names for it, for Wikipedia compatability (just in case)
function addOnloadHook(f) {
  addLoadEvent(f);
}

/* 

Dynamic Navigation Bars (experimental)[संपादन]

 */
 // ============================================================
 // BEGIN Dynamic Navigation Bars (experimental)
 // FIXME: currently only works for one nav bar on a page at a time
 
 // set up the words in your language
 var NavigationBarHide = '[लपवा]';
 var NavigationBarShow = '[दाखवा]';
 
 // set up max count of Navigation Bars on page,
 // if there are more, all will be hidden
 // NavigationBarShowDefault = 0; // all bars will be hidden
 // NavigationBarShowDefault = 1; // on pages with more than 1 bar all bars will be hidden
 var NavigationBarShowDefault = 1;
 //Honor the User Preferences
 if ( ( getCookie('WiktionaryUseJSPreferences') != 'true' ) || ( getCookie('WiktionaryPreferencesShowNav') != 'true' ) ) {
         NavigationBarShowDefault = 0;
    } else {
      if ( wgNamespaceNumber == 0 ) NavigationBarShowDefault = 999 ;
    }
  
/* 

toggleNavigationBar[संपादन]

 */
 // 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;
                NavChild = NavChild.nextSibling
            ) {
            if (NavChild.className == 'NavPic') {
                NavChild.style.display = 'none';
            }
            if (NavChild.className == 'NavContent') {
                NavChild.style.display = 'none';
            }
        }
    NavToggle.firstChild.data = NavigationBarShow;
 
    // if hidden now
    } else if (NavToggle.firstChild.data == NavigationBarShow) {
        for (
                var NavChild = NavFrame.firstChild;
                NavChild;
                NavChild = NavChild.nextSibling
            ) {
            if (NavChild.className == 'NavPic') {
                NavChild.style.display = 'block';
            }
            if (NavChild.className == 'NavContent') {
                NavChild.style.display = 'block';
            }
        }
    NavToggle.firstChild.data = NavigationBarHide;
    }
 }
 
/* 

createNavigationBarToggleButton[संपादन]

 */
 // adds show/hide-button to navigation bars
 function createNavigationBarToggleButton()
 {
    var indexNavigationBar = 0;
    // iterate over all < div >-elements
    for(
            var i=0; 
            NavFrame = document.getElementsByTagName("div")[i]; 
            i++
        ) {
        // if found a navigation bar
        if (NavFrame.className == "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);
            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 (NavFrame.childNodes[j].className == "NavHead") {
                NavFrame.childNodes[j].appendChild(NavToggle);
              }
            }
            NavFrame.setAttribute('id', 'NavFrame' + indexNavigationBar);
        }
    }
    // if more Navigation Bars found than Default: hide all
    if (NavigationBarShowDefault < indexNavigationBar) {
        for(
                var i=1; 
                i<=indexNavigationBar; 
                i++
        ) {
            toggleNavigationBar(i);
        }
    }
 
 }
 
 addLoadEvent(createNavigationBarToggleButton);
 
 // END Dynamic Navigation Bars
 // ============================================================

/* 
 */

//Cookie helpers
function setCookie(cookieName, cookieValue) {
 var today = new Date();
 var expire = new Date();
 var nDays = 30;
 expire.setTime( today.getTime() + (3600000 * 24 * nDays) );
 document.cookie = cookieName + "=" + escape(cookieValue)
                 + ";path=/w"
                 + ";expires="+expire.toGMTString();
 document.cookie = cookieName + "=" + escape(cookieValue)
                 + ";path=/wiki"
                 + ";expires="+expire.toGMTString();
}

function getCookie(cookieName) {
  var start = document.cookie.indexOf( cookieName + "=" );
  if ( start == -1 ) return "";
  var len = start + cookieName.length + 1;
  if ( ( !start ) &&
    ( cookieName != document.cookie.substring( 0, cookieName.length ) ) )
      {
        return "";
      }
  var end = document.cookie.indexOf( ";", len );
  if ( end == -1 ) end = document.cookie.length;
  return unescape( document.cookie.substring( len, end ) );
}

function deleteCookie(cookieName) {
  if ( getCookie(cookieName) ) {
    document.cookie = cookieName + "=" + ";path=/w" +
    ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
    document.cookie = cookieName + "=" + ";path=/wiki" +
    ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
  }
}

/* 

/* tooltips and access keys */ var ta = new Object(); ta['pt-userpage'] = new Array('.','सदस्य पान'); ta['pt-anonuserpage'] = new Array('.','The user page for the ip you\'re editing as'); ta['pt-mytalk'] = new Array('n','My talk page'); ta['pt-anontalk'] = new Array('n','Discussion about edits from this ip address'); ta['pt-preferences'] = new Array(,'माझ्या पसंती'); ta['pt-watchlist'] = new Array('l','The list of pages you\'re monitoring for changes.'); ta['pt-mycontris'] = new Array('y','List of my contributions'); ta['pt-login'] = new Array('o','You are encouraged to log in, it is not mandatory however.'); ta['pt-anonlogin'] = new Array('o','You are encouraged to log in, it is not mandatory however.'); ta['pt-logout'] = new Array('o','Log out'); ta['ca-talk'] = new Array('t','Discussion about the content page'); ta['ca-edit'] = new Array('e','You can edit this page. Please use the preview button before saving.'); ta['ca-addsection'] = new Array('+','Add a comment to this discussion.'); ta['ca-viewsource'] = new Array('e','This page is protected. You can view its source.'); ta['ca-history'] = new Array('h','Past versions of this page.'); ta['ca-protect'] = new Array('=','Protect this page'); ta['ca-delete'] = new Array('d','Delete this page'); ta['ca-undelete'] = new Array('d','Restore the edits done to this page before it was deleted'); ta['ca-move'] = new Array('m','Move this page'); ta['ca-watch'] = new Array('w','Add this page to your watchlist'); ta['ca-unwatch'] = new Array('w','Remove this page from your watchlist'); ta['search'] = new Array('f','Search this wiki'); ta['p-logo'] = new Array(,'Main Page'); ta['n-mainpage'] = new Array('z','Visit the Main Page'); ta['n-portal'] = new Array(,'About the project, what you can do, where to find things'); ta['n-currentevents'] = new Array(,'Find background information on current events'); ta['n-recentchanges'] = new Array('r','The list of recent changes in the wiki.'); ta['n-randompage'] = new Array('x','Load a random page'); ta['n-help'] = new Array(,'The place to find out.'); ta['n-sitesupport'] = new Array(,'Support us'); ta['t-whatlinkshere'] = new Array('j','List of all wiki pages that link here'); ta['t-recentchangeslinked'] = new Array('k','Recent changes in pages linked from this page'); ta['feed-rss'] = new Array(,'RSS feed for this page'); ta['feed-atom'] = new Array(,'Atom feed for this page'); ta['t-contributions'] = new Array(,'View the list of contributions of this user'); ta['t-emailuser'] = new Array(,'Send a mail to this user'); ta['t-upload'] = new Array('u','Upload images or media files'); ta['t-specialpages'] = new Array('q','List of all special pages'); ta['ca-nstab-main'] = new Array('c','View the content page'); ta['ca-nstab-user'] = new Array('c','View the user page'); ta['ca-nstab-media'] = new Array('c','View the media page'); ta['ca-nstab-special'] = new Array(,'This is a special page, you can\'t edit the page itself.'); ta['ca-nstab-project'] = new Array('a','View the project page'); ta['ca-nstab-image'] = new Array('c','View the image page'); ta['ca-nstab-mediawiki'] = new Array('c','View the system message'); ta['ca-nstab-template'] = new Array('c','View the template'); ta['ca-nstab-help'] = new Array('c','View the help page'); ta['ca-nstab-category'] = new Array('c','View the category page');

//

//============================================================
// en: ADD SOME EXTRA BUTTONS TO THE EDITPANEL
// de: FÜGE NEUE BUTTON IN DIE WERKZEUGLEISTE
//============================================================
// Vorschläge für neue Buttons werden gerne entgegengenommen
// Die Reihenfolge und Anzahl der Buttons ist über die (alphabetische) Variable XEBOrder wählbar.

if (typeof XEBOrder == 'undefined') // can be modified
	XEBOrder="A,B,D,C,D1,F,U,S,I1,I2,J1,E,G,Q,W,X,K,L,M,H,O,R,T,V";

if (XEBOrder == 'all') 
        XEBOrder="A,B,D,C,D1,F,U,S,I1,I2,J1,E,G,Q,W,X,K,L,M,H,O,R,T,V,FS,J2,N,P,P1,R1,R2,R3,R4,T1,Y1,Y2,Z,AI";

//fills the variable mwCustomEditButtons (s. function in /wikibits.js), with buttons for the Toolbar  
function addCustomButton(imageFile, speedTip, tagOpen, tagClose, sampleText){
 mwCustomEditButtons.push({
  "imageFile": imageFile,
  "speedTip": speedTip,
  "tagOpen": tagOpen,
  "tagClose": tagClose,
  "sampleText": sampleText});
}

var Isrc='http://upload.wikimedia.org/wikipedia/commons/';

var BDict={
'A':['e/e9/Button_headline2.png','दुय्यम मथळा','\n===','===','Secondary headline'],
'B':['1/13/Button_enter.png','नवीन ओळ','<br />','',''],
'C':['5/5f/Button_center.png','Center','<div style="text-align: center;">\n','\n<\/div>','Centred text'],
'D':['e/ea/Button_align_left.png','Left-Align','<div style="text-align: left; direction: ltr; margin-left: 1em;">\n','\n<\/div>','Left-aligned text'],
'D1':['a/a5/Button_align_right.png','Right-Align','<div style="text-align: right; direction: ltr; margin-left: 1em;">\n','\n<\/div>','Right-aligned text'],
'E':['0/04/Button_array.png','तक्ता','\n{| class="wikitable" \n|- \n| 1 || 2\n|- \n| 3 || 4','\n|}\n',''],
'F':['1/1e/Button_font_color.png','रंगीत मजकूर','<span style="color: ','">Coloured text<\/span>','ColourName'],
'FS':['1/1b/Button_miss_signature.png','Unsigned post','{{subst:unsigned|','|date}}','user name or IP'],
'G':['9/9e/Btn_toolbar_gallery.png','Picture gallery',"\n<gallery>\nImage:","|[[M63]]\nImage:Mona Lisa.jpg|[[Mona Lisa]]\nImage:Truite arc-en-ciel.jpg|Eine [[Forelle ]]\n<\/gallery>",'M63.jpg'],
'H':['7/74/Button_comment.png','Comment',"<!--","-->",'Comment'],
'I1':['6/6a/Button_sup_letter.png','Superscript','<sup>','<\/sup>','Superscript text'],
'I2':['a/aa/Button_sub_letter.png','Subscript','<sub>','<\/sub>','Subscript text'],
'J1':['5/58/Button_small.png','लहान आकाराचा मजकूर','<small>','<\/small>','Small Text'],
'J2':['5/56/Button_big.png','मोठ्या आकाराचा मजकूर','<big>','<\/big>','Big text'],
'K':['b/b4/Button_category03.png','Category',"[[Category:","]]",'Category name'],
'L':['8/8e/Button_shifting.png','Insert tab(s)',':','',':'],
'M':['f/fd/Button_blockquote.png','Insert block of quoted text','<blockquote style="border: 1px solid blue; padding: 2em;">\n','\n<\/blockquote>','Block quote'],
'N':['4/4b/Button_nbsp.png','nonbreaking space',' ','',''],
'O':['2/23/Button_code.png','Insert code','<code>','<\/code>','Code'],
'P':['3/3c/Button_pre.png','Pre formatted Text','<pre>','<\/pre>','Pre formatted text'],
'P1':['9/93/Button_sub_link.png','Insert link to sub-page','[[','/Sub_Page]]','Page'],
'Q':['d/d3/Button_definition_list.png','Insert definition list','\n; ','\n: Item 1\n: Item 2','Definition'],
'R':['7/79/Button_reflink.png','Insert a reference','<ref>','<\/ref>','Insert reference material'],
'R1':['7/79/Button_reflink.png','Start a reference','<ref name="','','Reference name'],
'R2':['1/1c/Button_reflink_advanced_2.gif','Insert reference material','">','</ref>','Reference material'],
'R3':['2/28/Button_reflink_advanced_3.gif','No reference material','','"/>',''],
'R4':['9/9a/Button_references.png','Reference footer',"\n==Notes==\n<!--See http://en.wikipedia.org/wiki/Wikipedia:Footnotes for an explanation of how to generate footnotes using the <ref(erences/)> tags-->\n<div class=\'references-small\'>\n<references/>\n</div>",'',''],
'S':['c/c9/Button_strike.png','काट मारलेला मजकूर','<s>','<\/s>','Struck out text'],
'T':['e/eb/Button_plantilla.png','Template','{{','}}','Template name'],
'T1':['3/30/Tt_icon.png','Teletype text','<tt>','<\/tt>','Teletype Text'],
'U':['f/fd/Button_underline.png','अधोरेखित मजकूर',"<u>","<\/u>",'Underlined text'],
'V':['c/c8/Button_redirect.png','Redirect',"#REDIRECT [[","]]",'Article Name'],
'W':['8/88/Btn_toolbar_enum.png','Numbering',"\n# ","\n# Element 2\n# Element 3",'Element 1'],
'X':['1/11/Btn_toolbar_liste.png','यादी',"\n* ","\n* Element B\n* Element C",'Element A'],
'Y1':['c/ce/Button_no_include.png','No Include',"<noinclude>","<\/noinclude>",'Text'],
'Y2':['7/79/Button_include.png','Include only',"<includeonly>","<\/includeonly>",'Text'],
'Z':['3/35/Button_substitute.png','Substitute',"{{subst:","}}",'Template'],
'AI':['1/1c/Button_advanced_image.png','Advanaced Image',"[[Image:","|thumb|right|px|Caption]]",'FileName.jpg']
}

XEBOrder=XEBOrder.split(",");
for (var b in XEBOrder) {
	var bc = BDict[XEBOrder[b]];
	addCustomButton(Isrc+bc[0],bc[1],bc[2],bc[3],bc[4])
}
document.write('<script type="text/javascript" src="' + 'http://mr.wiktionary.org/w/index.php?title=MediaWiki:translit.js&action=raw&ctype=text/javascript&dontcountme=s"' + '&action="raw"></script>');
 
 
  function addLoadEvent(func) 
     {
        if (window.addEventListener) 
            window.addEventListener("load", func, false);
        else if (window.attachEvent) 
            window.attachEvent("onload", func);
     }
 
function addTranslit(editForm,textBox){
checkrt(editForm);
 
        if (textBox.addEventListener) 
            textBox .addEventListener("keypress", processKeys, false);
        else if (textBox .attachEvent) 
            textBox.attachEvent("onkeypress", processKeys);
 
}
 
function addTextEvent() {
var editForm =document.editform;
if(document.editform){
var textBox=document.editform.wpTextbox1;
addTranslit(editForm,textBox);
addCheckbox(editForm,textBox ); 
 
}
var searchform=document.getElementById('searchform');
 
var searchInput=document.getElementById('searchInput');
if(searchInput)
addTranslit(searchform,searchInput);
 
}
 
function addCheckbox(editform,textBox ){
 
var element = document.createElement("input");
element.setAttribute("type","checkbox");
element.setAttribute("id","realtime");
 
 
if (element.addEventListener) 
            element.addEventListener("click", rtClick, false);
         else if (element.attachEvent) 
            element.attachEvent("onclick", rtClick);
 
var labelcheckBox = document.createTextNode('परीक्षणार्थ — ध्वन्यात्मक देवनागरी लिपीत लिहिण्याकरिता या खिडकीत टिचकी मारा (परीक्षण आवस्था)');
 
editform.insertBefore(element,textBox);
document.getElementById("realtime").checked = realTime;
editform.insertBefore(labelcheckBox,textBox);
}
 
function processKeys(event) {
 if (rtsupported)
 { if (event.keyCode == 27 && !isExplorer()) 
{ //escape to toggle
 
realTime = !realTime;
document.getElementById("realtime").checked = realTime;
 
}
 
else if (realTime) translitonkey(event); 
} 
}
 
 
var realTime = false;
function rtClick(event) {
realTime = !realTime;
}
 
var rtsupported = false;
var error; 
function checkrt(editform){
try {
 
/*
var nav = navigator.userAgent.toUpperCase();
rtsupported = (nav.indexOf("GECKO") >= 0 || nav.indexOf("OPERA") >= 0 || nav.indexOf("SAFARI") >= 0);
*/
 
 
rtsupported = (document.selection != undefined)
 
if (!rtsupported) {
var element = document.createElement("TEXTAREA");
editform.appendChild(element);
if (element.selectionStart != undefined)
rtsupported = true;
editform.removeChild(element);
}
 
} catch (error) {
 
}
}
addLoadEvent(addTextEvent)


//