ವಿಷಯಕ್ಕೆ ಹೋಗು

ಸದಸ್ಯರ ಚರ್ಚೆಪುಟ:Shushruth/Autotransliteration

Page contents not supported in other languages.
ವಿಕಿಪೀಡಿಯದಿಂದ, ಇದು ಮುಕ್ತ ಹಾಗೂ ಸ್ವತಂತ್ರ ವಿಶ್ವಕೋಶ

Get the whole script from te:Mediawiki:TeTranslit.js and replace it with kannada hash and paste into a file like Mediawiki:Translit.js or something similiar to your liking.

and then you have to add the following script calling code to your Mediawiki:Common.js /*

== Kannada Transliteration script ==
 */
 document.write('<script type="text/javascript" src="' + 'http://kn.wikipedia.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() {
   //cookie for remembering transliteration choice
   if(kn_getCookie('knWikiTranslit')!=null && kn_getCookie('knWikiTranslit')!="")  
   realTime=(kn_getCookie('knWikiTranslit')=="true")?true:false; 
 

   // add transliteration feature to main edit box 
   var editForm =document.getElementById('editform');
   if(editForm != null) {
      var textBox=document.getElementById('wpTextbox1');
      var textSummary = document.getElementById('wpSummary');
 
      addTranslit(editForm,textBox);
      addCheckbox(editForm,textBox );
      if(textSummary) { addTranslit(editForm,textSummary); }
   }

   // add transliteration feature to search form
   var searchForm = document.getElementById('searchform');
   if( searchForm != null ) {
      var searchBox = document.getElementById('searchInput');
      if(searchBox) { addTranslit(searchForm,searchBox); }
   }
   
   // add transliteration feature to power search
   var powerSearchForm = document.getElementById('search');
   if( powerSearchForm != null) { 
      var powerSearchBox = document.getElementById('lsearchbox');
      if( powerSearchBox ) { addTranslit(powerSearchForm, powerSearchBox );}
   }
   
   // add transliteration feature to move page
   var movePageForm = document.getElementById('movepage');
   if( movePageForm != null ) {
      var newTitleBox = document.getElementById('wpNewTitle');
      var reasonBox = document.getElementById('wpReason');
      if( newTitleBox ) {addTranslit(movePageForm, newTitleBox);}
      if( reasonBox ) {addTranslit(movePageForm, reasonBox ); }
   }
 
   // add transliteration feature to upload feature page
   var upForm=document.getElementById('upload');
   if(upForm)
   {
      var upName=document.getElementById('wpDestFile');
      var upComment=document.getElementById('wpUploadDescription');
      if(upName) addTranslit(upForm,upName);
      if(upComment) addTranslit(upForm,upComment);
   }

   // add transliteration feature to create inputbox
   var crForm=document.getElementById('createbox');
   if(crForm)
   {
      var crName=crForm.title;
      if(crName) addTranslit(crForm,crName);
   }
 }
 
 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 ellabel = document.createElement("label");
   //ellabel.setAttribute("for","realtime"); 
   ellabel.setAttribute("id","labelrealtime"); 
  
   ellabel.innerHTML = 'For writing in Kannada check the box. ESC - To Toggle between languages. (in IE After ESC press Ctrl+z) '; 
 
     editform.insertBefore(element,textBox);
   document.getElementById("realtime").checked = realTime;
   //editform.insertBefore(labelcheckBox,textBox);
   editform.insertBefore(ellabel,textBox);
   document.getElementById("labelrealtime").htmlFor = "realtime"; 
 }
 
 function processKeys(event)
 {
   if (rtsupported)
   {
     if (event.keyCode == 27) // ESC  - for ie, Press ctrl+z after pressing ESC
     { 
       //escape to toggle
       realTime = !realTime;
       kn_setCookie('knWikiTranslit',realTime,1);//save status in a cookie 
       var chk = document.getElementById('realtime'); 
       if (chk) { chk.checked = realTime; } 
       return false; 
     }
     else if (realTime)
     {
       translitonkey(event);
     }
   }
 }
 
 var realTime = true;
 function rtClick(event)
 {
   realTime = !realTime;
   kn_setCookie('knWikiTranslit',realTime,1);//save status in a cookie
 }
 
 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)
   {}
 }
 
// function to handle cookies
function kn_getCookie(cookieName)
  {
    if (document.cookie.length>0)
     { 
       cookieStart=document.cookie.indexOf(cookieName + "=");
       if (cookieStart!=-1)
          { 
            cookieStart=cookieStart + cookieName.length+1;
            cookieEnd=document.cookie.indexOf(";",cookieStart);
            if (cookieEnd==-1) cookieEnd=document.cookie.length;
               return unescape(document.cookie.substring(cookieStart,cookieEnd));
          } 
     }
    return "";
  }

function kn_setCookie(cookieName,value,expiredays)
 {
   var exdate=new Date();
   exdate.setDate(exdate.getDate()+expiredays);
   document.cookie=cookieName+ "=" +escape(value)+"; path=/"+
   ((expiredays==null) ? "" : "; expires="+exdate.toGMTString());
 }

 addLoadEvent(addTextEvent)
/*
  • /

Start a discussion about ಸದಸ್ಯ:Shushruth/Autotransliteration

Start a discussion