भारत की संस्कृति के लिए... भाषा की उन्नति के लिए... साहित्य के प्रसार के लिए

मीडियाविकि:Common.js

Kavita Kosh से
यहाँ जाएँ: भ्रमण, खोज

ध्यान दें: संजोने के बाद बदलाव देखने के लिए आपको अपने ब्राउज़र की कैश खाली करनी पड़ सकती है।

  • फ़ायरफ़ॉक्स / सफ़ारी: Reload (रीलोड) दबाते समय Shift (शिफ़्ट) दबा के रखें, या फिर Ctrl-F5 (कंट्रोल-F5) या Ctrl-R (कंट्रोल-R) दबाएँ (मैक पर ⌘-R)
  • गूगल क्रोम: Ctrl-Shift-R (कंट्रोल-शिफ़्ट-R) दबाएँ (मैक पर ⌘-Shift-R)
  • इन्टर्नेट एक्सप्लोरर: Ctrl (कंट्रोल) दबाकर Refresh (रिफ़्रेश) करें या Ctrl-F5 (कंट्रोल-F5) दबाएँ
  • ऑपेरा: Tools → Preferences (उपकरण → वरीयताएँ) में कैश साफ़ करें
if (mwCustomEditButtons) {
   mwCustomEditButtons[mwCustomEditButtons.length] = {
     "imageFile": "http://upload.wikimedia.org/wikipedia/en/8/80/Button_upper_letter.png",
     "speedTip": "Insert Superscript",
     "tagOpen": "<sup>",
     "tagClose": "</sup>",
     "sampleText": ""};

   mwCustomEditButtons[mwCustomEditButtons.length] = {
     "imageFile": "http://upload.wikimedia.org/wikipedia/en/1/13/Button_enter.png",
     "speedTip": "Line break",
     "tagOpen": "<br />",
     "tagClose": "",
     "sampleText": ""};

    mwCustomEditButtons[mwCustomEditButtons.length] = {
        "imageFile": "http://upload.wikimedia.org/wikipedia/en/c/c8/Button_redirect.png",
        "speedTip": "Redirect",
        "tagOpen": "#REDIRECT [[",
        "tagClose": "]]",
        "sampleText": "Insert text"};

    mwCustomEditButtons[mwCustomEditButtons.length] = {
        "imageFile": "http://www.kavitakosh.org/kk/images/c/cd/Button_poem.png",
        "speedTip": "Poem tag",
        "tagOpen": "<poem>",
        "tagClose": "</poem>",
        "sampleText": "रचना यहाँ टाइप करें"};
}




/* ***************************************************************************
Function to insert text in a textarea (may be on click of a link or button
*************************************************************************** */
function insertAtCaret(areaId,text) {
    var txtarea = document.getElementById(areaId);
    var scrollPos = txtarea.scrollTop;
    var strPos = 0;
    var br = ((txtarea.selectionStart || txtarea.selectionStart == '0') ? 
        "ff" : (document.selection ? "ie" : false ) );
    if (br == "ie") { 
        txtarea.focus();
        var range = document.selection.createRange();
        range.moveStart ('character', -txtarea.value.length);
        strPos = range.text.length;
    }
    else if (br == "ff") strPos = txtarea.selectionStart;

    var front = (txtarea.value).substring(0,strPos);  
    var back = (txtarea.value).substring(strPos,txtarea.value.length); 
    txtarea.value=front+text+back;
    strPos = strPos + text.length;
    if (br == "ie") { 
        txtarea.focus();
        var range = document.selection.createRange();
        range.moveStart ('character', -txtarea.value.length);
        range.moveStart ('character', strPos);
        range.moveEnd ('character', 0);
        range.select();
    }
    else if (br == "ff") {
        txtarea.selectionStart = strPos;
        txtarea.selectionEnd = strPos;
        txtarea.focus();
    }
    txtarea.scrollTop = scrollPos;
}
/*  *************************************************************************** */



/* ***************************************************************************
Functions for transliteration
*************************************************************************** */
function decideLipi(rootEl){
var curkklipi=getCookie("kklipi");
var defaultkklipi="hi";
if (curkklipi=="en"){walkTheDomAndTranslit(rootEl);}
else{setCookie("kklipi",defaultkklipi,365);}
}
function walkTheDomAndTranslit(rootEl){
var rootnode=document.getElementById(rootEl);
var walker=document.createTreeWalker(rootnode, NodeFilter.SHOW_TEXT, null, false);
while (walker.nextNode()){
var tstr=unicode2itrans(walker.currentNode.textContent);
walker.currentNode.textContent=tstr;
}
var tButton=document.getElementById('translitButton');
tButton.innerHTML="देवनागरी में बदलें";
tButton.onclick = function() {setCookie('kklipi', 'hi'); window.location.reload();};
setCookie('kklipi', 'en');
}
function unicode2itrans(strText){
var array_one = new Array( "आ", "ऑ", "अ", "ई", "इ", "ऊ", "उ", "ऋ", "ए", "ऐ", "ओ", "औ","ा", "ि", "ी", "ु", "ू", "ृ", "े", "ै", "ो", "ौ", "ं", "ँ", ":", "्", "ऽ", "ॉ","क़", "ख़", "ग़", "ज़", "ड़", "ढ़", "फ़","क", "ख", "ग", "घ", "ङ", "च", "छ", "ज", "झ", "ञ", "ट", "ठ", "ड", "ढ", "ण","त", "थ", "द", "ध", "न", "प", "फ", "ब", "भ", "म","य", "र", "ल", "व", "श", "ष", "स", "ह","Z.hY", "ZY", "ZV", "aV", "V", "W", "Y", "Z","०", "१", "२", "३", "४", "५", "६", "७", "८", "९", "।", "ॐ" );
var array_two= new Array( "VaaW", "Vaa.uW", "VaW", "VeeW", "ViW", "VooW", "VuW", "VRRiW", "VeW", "VaiW", "VoW", "VauW","aa", "i", "ee", "u", "oo", "Ri", "e", "ai", "o", "au", ".n", ".N", "aH", ".h", ".a", " aa.u","YqZ", "YKhZ", "YGZ", "YzZ", " Y.DZ", "Y.DhZ", "YfZ", "YkZ", "YkhZ", "YgZ", "YghZ", "Y~NZ", "YchZ", "YchhZ", "YjZ", "YjhZ", "Y~nZ", "YTZ", "YThZ", "YDZ", "YDhZ", "YNZ","YtZ", "YthZ", "YdZ", "YdhZ", "YnZ", "YpZ", "YphZ", "YbZ", "YbhZ", "YmZ","YyZ", "YrZ",  "YlZ", "YvZ", "YshZ", "YShZ", "YsZ", "YhZ","", "a", "a_", "a_", "", "", "", "","0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ".", "OM" );
text2BProcessed = strText;
for (ctr=0; ctr < 95; ctr++){
var idx = 0;
while ( idx != -1 ){
text2BProcessed = text2BProcessed.replace(array_one[ctr] , array_two[ctr]);
idx = text2BProcessed.indexOf(array_one[ctr]);}
}
return text2BProcessed;
}
function setCookie(cname,cvalue,exdays){
var d = new Date();
d.setTime(d.getTime()+(exdays*24*60*60*1000));
var expires = "expires="+d.toGMTString();
document.cookie = cname+"="+cvalue+"; "+expires;
}
function getCookie(cname){
var name = cname + "=";
var ca = document.cookie.split(';');
for(var i=0; i<ca.length; i++){
var c = ca[i].trim();
if (c.indexOf(name)==0) return c.substring(name.length,c.length);
}
return "";
}
/*  *************************************************************************** */




//Call function to decide which lipi is to be used for displaying the page.
$(function() {
decideLipi('globalWrapper');
});




// This function opens a page based on the value of option selected by user from a SELECT html dropdown box
function gotoPageOnSelect(wrapperElement, selectElement){
var wrapperElement=document.getElementById(wrapperElement);
var selectedOption=document.getElementById(selectElement).value;
if (selectedOption!="") {
var baseloc = "http://kavitakosh.org/kk/";
wrapperElement.innerHTML=""
wrapperElement.innerHTML="लोडिंग... " + selectedOption;
self.location.href=baseloc+selectedOption;
}
}


////////////////////////////


// To float anchor list in Rachnakaaro Ki Soochi
$(document).ready( function() {
    $(window).scroll( function() {
        if ($(window).scrollTop() > $('#poet-list-anchors-container').offset().top)
            $('#poet-list-anchors').addClass('floating');
        else
            $('#poet-list-anchors').removeClass('floating');
    } );
} );

// To togle the anchor list visibility
$(document).ready(function(){
  $("#poet-list-letter-set-toggle").click(function(){
    $("#poet-list-letter-set").toggle(1000);
  });
});

////////////////////////////