MediaWiki

MediaWiki:Vaniquotes.js

Revision as of 12:31, 24 March 2008 by Eivind (talk | contribs)

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
/*Any JavaScript here will be loaded for all users on every page load.
Vanipedia Toolbar Ver. 1.0 
Changes: Headings and codes for Quotes
*/

// define  custom buttons (id, class, popup title, image src, width, height, alt text, onClick and parameters)
 
var wikEdButton = [];  

wikEdButton[100] = ['Vaniquotes', 'wikEdButton', 'Vaniquotes cleanup', 'http://vanipedia.org/images/icons/edit-clear.png', '16', '16', 'Vaniquotes', 'javascript:WikEdEditButton(this, this.id, null, Vaniquotes);' ];

//wikEdButton[101] = ['BaltoUni', 'wikEdButton', 'Convert Balaram fonts to Unicode', 'http://upload.wikimedia.org/wikipedia/commons/6/67/WikEd_logo.png', '16', '16', 'Test', 'javascript:WikEdEditButton(this, this.id, null, BaltoUni);' ];

wikEdButton[102] = ['Vani_codes', 'wikEdButton', 'Vani_codes', 'http://vanipedia.org/images/icons/edit-paste.png', '16', '16', 'Vani_codes', 'javascript:WikEdEditButton(this, this.id, null, Vani_codes);' ];   

//wikEdButton[103] = ['Test', 'wikEdButton', 'QUOTES', 'http://upload.wikimedia.org/wikipedia/commons/6/67/WikEd_logo.png', '16', '16', 'Vanifi', 'javascript:WikEdEditButton(this, this.id, null, Test);' ]; 

// define custom button bars (id outer, class outer, id inner, class inner, height, grip title, button numbers)
var wikEdButtonBar = []; 


wikEdButtonBar['custom2'] = ['wikEdButtonBarCustom2',  'wikEdButtonBarCustom2',  'wikEdButtonsCustom2',  'wikEdButtonsCustom2',  44, 'Vaniformat buttons', [100, 'br', 102] ]; 

 
//
//Codes Table for compilers
//
function Vani_codes() {
	
  var win1 = window.open('http://vanipedia.org/vani_codes.htm','codes','width=1000, height=600, scrollbars=yes, resizable=yes');
  self.blur(); 
  win1.focus();
}



//
//Vedabase Quotes reference formating
//

function Vaniquotes(obj) {
  
  //Call BaltoUni
  
  BaltoUni(obj);
  
  
  //Select whole document
  
  
WikEdGetText(obj, 'whole');
  
obj.changed = obj.whole;
  
  //Call FixBAsic function for tidying up before replacements * MOVED TO END OF function *
  //WikEdFixBasic(obj.changed);
  
  //Regexes
  
  //
  //Codes for linking to Vanisource. Search will be base on these codes and the ref. given by Vedabase
  //
  //Get rid off unwanted data
  obj.changed.plain = obj.changed.plain.replace(/^[\ ]/mg, "");
  obj.changed.plain = obj.changed.plain.replace(/\=> /g, "");
  obj.changed.plain = obj.changed.plain.replace(/\n+(>){3}\s/g, "\n");
  obj.changed.plain = obj.changed.plain.replace(/SYNONYMS/g, "");
  obj.changed.plain = obj.changed.plain.replace(/TRANSLATION/g, "");
  obj.changed.plain = obj.changed.plain.replace(/PURPORT/g, "");
  //clean this kind of refs: Ref. VedaBase Bg 2.42, Bg 2.43, Bg 2.42-43
  obj.changed.plain = obj.changed.plain.replace(/Ref. VedaBase.+, (.+\d+-\d+)/g, "Ref. VedaBase $1");
  
  
  //Titles
  obj.changed.plain = obj.changed.plain.replace(/TT:(.+)\b[\W]?$/mg, "====== $1 ======\n");
  obj.changed.plain = obj.changed.plain.replace(/H1:(.+)\b[\W]?$/mg, "= $1 =\n");
  obj.changed.plain = obj.changed.plain.replace(/H2:(.+)\b[\W]?$/mg, "== $1 ==\n");
  obj.changed.plain = obj.changed.plain.replace(/H3:(.+)\b[\W]?$/mg, "=== $1 ===\n");
  obj.changed.plain = obj.changed.plain.replace(/H4:(.+)\b[\W]?$/mg, "==== $1 ====\n");
  obj.changed.plain = obj.changed.plain.replace(/H5:(.+)\b[\W]?$/mg, "===== $1 =====\n");
  
  //get rid off the newlines \n(temporarily) for easier regex find and replace
  var nl = "YYY";
  obj.changed.plain = obj.changed.plain.replace(/\n/g, nl);
  
  //Array with codes
  var codes = new Array("BGS","BGT","BGP","BGTP","BGF","BGI","BGL","BGG","CCS","CCT","CCP","CCTP","CCF","CCI","CCL","EJF","EJC","KBF","KBI","KBC","LBT","LBP","LBTP","LBF","MGI","MGC","NDF","NDI","NDC","NIS","NIT","NIP","NITP","NIF","RWI","RWC","SIS","SIT","SIP","SITP","SII","SBS","SBT","SBP","SBTP","SBF","SBI","SBM","TCF","TCI","TCC","TCL","AA","CM","CO","LE","DL","DI","FL","GL","IL","BSL","SIL","NDL","SBL","LD","PD","SP","WC");
  var avoid = new RegExp('(BGS:|BGT:|BGP:|BGTP:|BGF:|BGI:|BGL:|BGG:|CCS:|CCT:|CCP:|CCTP:|CCF:|CCI:|CCL:|EJF:|EJC:|KBF:|KBI:|KBC:|LBT:|LBP:|LBTP:|LBF:|MGI:|MGC:|NDF:|NDI:|NDC:|NIS:|NIT:|NIP:|NITP:|NIF:|RWI:|RWC:|SIS:|SIT:|SIP:|SITP:|SII:|SBS:|SBT:|SBP:|SBTP:|SBF:|SBI:|TCF:|TCI:|TCC:|TCL:|AA:|CM:|CO:|LE:|DL:|DI:|FL:|GL:|IL:|BGL:|BSL:|SIL:|NDL:|SBL:|LD:|PD:|SP:|WC:)', "g");
  
  for (i = 0; i < codes.length; i++) {
    var re = new RegExp(codes[i]);
    if (re.test(obj.changed.plain)) { 
      var index = codes[i].substring(0,2);
      switch (index) {
	//GENERAL cases BG, CC, SB, ND, etc.
        
case 'BG':    
  var re2 = new RegExp(nl+codes[i]+':(.+?)Ref. VedaBase (.+?)'+nl, 'g');
	var rearray = re2.exec(obj.changed.plain);
	if (rearray) {
	  var result = rearray[1];
	  var quote = rearray[2];
	 // win1.document.write("found for "+codes[i]+":<br>"+rearray[1]+"<br><br>");
	  
	  var found = result.match(avoid);
	  if (!found) {
	    switch (codes[i].charAt(2)) {
	    //Cases within this object: BGS, BGT, BGP, etc.                
	    case 'S':
        var re2 = new RegExp(nl+codes[i]+':(.+?)Ref. VedaBase.+?(?:Bg)? (.+?)'+nl, 'g');
	      obj.changed.plain = obj.changed.plain.replace(re2, "'''[[Vanisource:BG $2|BG $2 Synonyms]]: $1'''"+nl+nl);
	    case 'T':
	      if (codes[i].charAt(3) == 'P') {
          var re2 = new RegExp(nl+codes[i]+':(.+?)'+nl+'{2,}(.+?)Ref. VedaBase Bg (.+?)'+nl, "g");
          obj.changed.plain = obj.changed.plain.replace(re2, "'''[[Vanisource:BG $3|BG $3, Tanslation and Purport]]: $1''' "+nl+nl+"$2 "+nl+nl);
	      } else {
          var re2 = new RegExp(nl+codes[i]+':(.+?)Ref. VedaBase.+?(?:Bg)? (.+?)'+nl, 'g');
        	obj.changed.plain = obj.changed.plain.replace(re2, "'''[[Vanisource:BG $2|BG $2, Translation]]: $1'''"+nl+nl);
	      }
	    case 'P':
        var re2 = new RegExp(nl+codes[i]+':(.+?)Ref. VedaBase.+?(?:Bg)? (.+?)'+nl, 'g');
	      obj.changed.plain = obj.changed.plain.replace(re2, "'''[[Vanisource:BG $2|BG $2, Purport]]:''' $1"+nl+nl); 
	    case 'F':
        var re2 = new RegExp(nl+codes[i]+':(.+?)Ref. VedaBase.+?(?:Bg)? (.+?)'+nl, 'g');
	      obj.changed.plain = obj.changed.plain.replace(re2, "'''[[Vanisource:BG $2|BG $2]]:''' $1 "+nl+nl);
	    case 'I':
        var re2 = new RegExp(nl+codes[i]+':(.+?)Ref. VedaBase.+?(?:Bg)? (.+?)'+nl, 'g');
	      obj.changed.plain = obj.changed.plain.replace(re2, "'''[[Vanisource:BG $2|BG $2]]:''' $1 "+nl+nl);
      
      case 'L':
          var re2 = new RegExp(nl+codes[i]+':(.+?)Ref. VedaBase.+?Bhagavad-gītā (.+?) -- (.+?)'+nl, "g");
          obj.changed.plain = obj.changed.plain.replace(re2, "'''[[Vanisource:BGL $3|Bhagavad-Gita Lecture, text $2, $3]]:''' $1 "+nl+nl);
      case 'G':  
          var re2 = new RegExp(nl+codes[i]+':(.+?)Ref. VedaBase.+?'+nl, "g");
          obj.changed.plain = obj.changed.plain.replace(re2, "'''[[Vanisource:BGL ITG|Bhagavad-Gita Lecture, Introduction to Gītopaniṣad]]:''' $1 "+nl+nl);
        
	     
	    }
	  }
	}	                	
	break;
        
case 'CC':
	var re2 = new RegExp(nl+codes[i]+':(.+?)Ref. VedaBase[\ ]+(?:Cc )?(Adi|Madhya|Antya)(.+?)'+nl, "g");
	var rearray = re2.exec(obj.changed.plain);
	if (rearray) {
	  var result = rearray[1];
	  var quote = rearray[2];
	 // win1.document.write("found for "+codes[i]+":<br>"+rearray[1]+"<br><br>");
	  
	  var found = result.match(avoid);
	  if (!found) {
	    switch (codes[i].charAt(2)) {
	    //Cases within this object: BGS, BGT, BGP, etc.                
	    case 'S':
	      obj.changed.plain = obj.changed.plain.replace(re2, "'''[[Vanisource:CC $2$3|CC $2$3 Synonyms]]: $1''' "+nl+nl);
	    case 'T':
	      if (codes[i].charAt(3) == 'P') {
		var re2 = new RegExp(nl+codes[i]+':(.+?)'+nl+'{2,}(.+?)Ref. VedaBase[\ ]+(?:Cc )?(Ādi|Madhya|Antya)(.+?)'+nl, "g");
		obj.changed.plain = obj.changed.plain.replace(re2, "'''[[Vanisource:CC $3$4|CC $3$4, Tanslation and Purport]]: $1''' "+nl+nl+"$2 "+nl+nl);
	      } else {
		obj.changed.plain = obj.changed.plain.replace(re2, "'''[[Vanisource:CC $2$3|CC $2$3, Translation]]: $1''' "+nl+nl);
	      }
	    case 'P':
	      obj.changed.plain = obj.changed.plain.replace(re2, "'''[[Vanisource:CC $2$3|CC $2$3, Purport]]:''' $1 "+nl+nl);
	    case 'F':
	      obj.changed.plain = obj.changed.plain.replace(re2, "'''[[Vanisource:CC $2$3|CC $2,$3]]:''' $1 "+nl+nl);
	    case 'I':
	      obj.changed.plain = obj.changed.plain.replace(re2, "'''[[Vanisource:CC $2$3|CC $2,$3]]:''' $1 "+nl+nl);
	    case 'L':
	var re2 = new RegExp(nl+codes[i]+':(.+?)Ref. VedaBase.(.+?) -- (.+?)'+nl, "g");
	//Ref. VedaBase Ādi-līlā 3.87-88 -- New York, December 27, 1966
	//Ref. VedaBase Madhya-līlā 6.149-50 -- Gorakhpur, February 13, 1971
	obj.changed.plain = obj.changed.plain.replace(re2, "'''[[Vanisource:CCL $2|Lectures on CC $2, $3]]:''' $1 "+nl+nl);
	  
	    }
	  }
	}
	break;
        
case 'EJ':
	var re2 = new RegExp(nl+codes[i]+':(.+?)Ref. VedaBase[\ ]+EJ (.+?).+?'+nl, "g");//Ref. VedaBase EJ 2: Varieties of Planetary Systems				
	var rearray = re2.exec(obj.changed.plain);
	if (rearray) {
	  var result = rearray[1];
	  var quote = rearray[2];
	 // win1.document.write("found for "+codes[i]+":<br>"+rearray[1]+"<br><br>");
	  
	  var found = result.match(avoid);
	  if (!found) {
	    
	    switch (codes[i].charAt(2)) {
	    //Cases within this object: BGS, BGT, BGP, etc.                
	    case 'F':
	      obj.changed.plain = obj.changed.plain.replace(re2, "'''[[Vanisource:EJ Preface|Easy Journey to other Planets, Preface]]:''' $1YYY");
	    case 'C':
	      obj.changed.plain = obj.changed.plain.replace(re2, "'''[[Vanisource:EJ $2|Easy Journey to other Planets, Chapter $2]]:''' $1 "+nl+nl);
	      
	    }
	  }
	}
	break;
        
case 'KB':
	var re2 = new RegExp(nl+codes[i]+':(.+?)Ref. VedaBase[\ ]+KB.+?'+nl, "g");
	var rearray = re2.exec(obj.changed.plain);
	if (rearray) {
	  var result = rearray[1];
	  var quote = rearray[2];
	 // win1.document.write("found for "+codes[i]+":<br>"+rearray[1]+"<br><br>");
	  
	  var found = result.match(avoid);
	  if (!found) {
	    
	    switch (codes[i].charAt(2)) {
	    //Cases within this object: BGS, BGT, BGP, etc.                
	    case 'F':
	      obj.changed.plain = obj.changed.plain.replace(re2, "'''[[Vanisource:KB Preface|Kṛṣṇa Book, Preface]]:''' $1 "+nl+nl);
	    case 'I':
	      obj.changed.plain = obj.changed.plain.replace(re2, "'''[[Vanisource:KB Introduction|Kṛṣṇa Book, Introduction]]:''' $1 "+nl+nl);
	    case 'C':
	      var re2 = new RegExp(nl+codes[i]+':(.+?)Ref. VedaBase[\ ]+KB (.+?):.+?'+nl,'g'); // Ref. VedaBase => KB 3: The Birth of Lord Kåñëa
	      obj.changed.plain = obj.changed.plain.replace(re2, "'''[[Vanisource:KB $2|Kṛṣṇa Book, Chapter $2]]:''' $1 "+nl+nl);
	      
	    }
	    
	  }
	}
	break;
	
case 'LB':
	var re2 = new RegExp(nl+codes[i]+':(.+?)Ref. VedaBase[\ ]+LoB (?:verse )?(.+?)'+nl, "g");
	var rearray = re2.exec(obj.changed.plain);
	if (rearray) {
	  var result = rearray[1];
	  var quote = rearray[2];
	 // win1.document.write("found for "+codes[i]+":<br>"+rearray[1]+"<br><br>");
	  
	  var found = result.match(avoid);
	  if (!found) {
	    
	    switch (codes[i].charAt(2)) {
	    //Cases within this object: BGS, BGT, BGP, etc.                
	    case 'T':
	      if (codes[i].charAt(3) == 'P') {
		var re2 = new RegExp(nl+codes[i]+':(.+?)'+nl+'{2,}(.+?)Ref. VedaBase[\ ]+LoB (?:verse )?(.+?)'+nl, "g");
		obj.changed.plain = obj.changed.plain.replace(re2, "'''[[Vanisource:LB $3|Light of the Bhāgavata, text $3, Tanslation and Purport]]: $1''' "+nl+nl+"$2 "+nl+nl);
	      } else {
		obj.changed.plain = obj.changed.plain.replace(re2, "'''[[Vanisource:LB $2|Light of the Bhāgavata, text $2, Translation]]: $1''' "+nl+nl);
	      }
	    case 'P':
	      obj.changed.plain = obj.changed.plain.replace(re2, "'''[[Vanisource:LB $2|Light of the Bhāgavata, text $2, Purport]]:''' $1 "+nl+nl);
	    case 'F':
	      obj.changed.plain = obj.changed.plain.replace(re2, "'''[[Vanisource:LB $2|Light of the Bhāgavata, $2]]:''' $1 "+nl+nl);
	      
	    }
	  }
	}
	break;
	
case 'MG':
	var re2 = new RegExp(nl+codes[i]+':(.+?)Ref. VedaBase[\ ]+MoG .+?'+nl, "g");
	var rearray = re2.exec(obj.changed.plain);
	if (rearray) {
	  var result = rearray[1];
	  var quote = rearray[2];
	 // win1.document.write("found for "+codes[i]+":<br>"+rearray[1]+"<br><br>");
	  
	  var found = result.match(avoid);
	  if (!found) {
	    switch (codes[i].charAt(2)) {
	    //Cases within this object: BGS, BGT, BGP, etc.        
	    case 'I':
	      obj.changed.plain = obj.changed.plain.replace(re2, "'''[[Vanisource:MG Introduction|Message of Godhead, Introduction]]:''' $1 "+nl+nl);
	    case 'C':
	      var re2 = new RegExp(nl+codes[i]+':(.+?)Ref. VedaBase[\ ]+MoG (.+?):.+?'+nl,'g'); // Ref. VedaBase => KB 3: The Birth of Lord Kåñëa
	      obj.changed.plain = obj.changed.plain.replace(re2, "'''[[Vanisource:MG $2|Message of Godhead, Chapter $2]]:''' $1 "+nl+nl);
	      
	    }
	  }
	}
	break;
	
case 'ND':
	var re2 = new RegExp(nl+codes[i]+':(.+?)Ref. VedaBase.+?'+nl, "g");//NoD 15: Spontaneous Devotional Service
	var rearray = re2.exec(obj.changed.plain);
	if (rearray) {
	  var result = rearray[1];
	  var quote = rearray[2];
	 // win1.document.write("found for "+codes[i]+":<br>"+rearray[1]+"<br><br>");
	  
	  var found = result.match(avoid);
	  if (!found) {
	    switch (codes[i].charAt(2)) {
	    //Cases within this object: BGS, BGT, BGP, etc.                
	    case 'F':
		  	var re2 = new RegExp(nl+codes[i]+':(.+?)Ref. VedaBase[\ ]+NoD (.+?)'+nl, "g");//NoD 15: Spontaneous Devotional Service
	      obj.changed.plain = obj.changed.plain.replace(re2, "'''[[Vanisource:ND Preface|Nectar of Devotion, Preface]]:''' $1 "+nl+nl);
	    case 'I':
		  	var re2 = new RegExp(nl+codes[i]+':(.+?)Ref. VedaBase[\ ]+NoD (.+?)'+nl, "g");//NoD 15: Spontaneous Devotional Service
	      obj.changed.plain = obj.changed.plain.replace(re2, "'''[[Vanisource:ND Introduction|Nectar of Devotion, Introduction]]:''' $1 "+nl+nl);
	    case 'C':
	      var re2 = new RegExp(nl+codes[i]+':(.+?)Ref. VedaBase[\ ]+NoD (.+?):.+?'+nl,'g'); // Ref. VedaBase => Ref. VedaBase NoD 15: Spontaneous Devotional Service
	      obj.changed.plain = obj.changed.plain.replace(re2, "'''[[Vanisource:ND $2|Nectar of Devotion, Chapter $2]]:''' $1 "+nl+nl);
	    case 'L':
		  var re2 = new RegExp(nl+codes[i]+':(.+?)Ref. VedaBase.+? -- (.+?)'+nl, "g");
		  //Ref. VedaBase The Nectar of Devotion -- Vṛndāvana, October 16, 1972
		  //Ref. VedaBase The Nectar of Devotion -- Bombay, January 2, 1973
		  obj.changed.plain = obj.changed.plain.replace(re2, "'''[[Vanisource:NDL $2|Lectures on Nectar of Devotion, $2]]:''' $1 "+nl+nl);
	  
	    }
	  }
	}
	break;
	
case 'NI':
  var re2 = new RegExp(nl+codes[i]+':(.+?)Ref. VedaBase[\ ]+NoI(?:: verse)? (.+?)'+nl, "g");//Ref. VedaBase NoI: verse 2

	var rearray = re2.exec(obj.changed.plain);
	if (rearray) {
	  var result = rearray[1];
	  var quote = rearray[2];
	 // win1.document.write("found for "+codes[i]+":<br>"+rearray[1]+"<br><br>");
	  
	  var found = result.match(avoid);
	  if (!found) {
	    switch (codes[i].charAt(2)) {
	    //Cases within this object: BGS, BGT, BGP, etc.                
	    case 'S':
	      obj.changed.plain = obj.changed.plain.replace(re2, "'''[[Vanisource:NI $2|Nectar of Instruction text $2, Synonyms]]: $1''' "+nl+nl);
	    case 'T':
	      if (codes[i].charAt(3) == 'P') {
		var re2 = new RegExp(nl+codes[i]+':(.+?)'+nl+'{2,}(.+?)Ref. VedaBase[\ ]+NoI: (?:verse)? (.+?)'+nl, "g");
		obj.changed.plain = obj.changed.plain.replace(re2, "'''[[Vanisource:NI $3|Nectar of Instruction, text $3, Tanslation and Purport]]: $1''' "+nl+nl+"$2 "+nl+nl);
	      } else {
		obj.changed.plain = obj.changed.plain.replace(re2, "'''[[Vanisource:NI $2|Nectar of Instruction, text $2, Translation]]: $1''' "+nl+nl);
	      }
	    case 'P':
	      obj.changed.plain = obj.changed.plain.replace(re2, "'''[[Vanisource:NI $2|Nectar of Instruction, text $2, Purport]]:''' $1 "+nl+nl);
	    case 'F':
	      var re2 = new RegExp(nl+codes[i]+':(.+?)Ref. VedaBase.+?'+nl, "g");//Ref. VedaBase NoI Preface
	      obj.changed.plain = obj.changed.plain.replace(re2, "'''[[Vanisource:NI Preface|Nectar of Instruction, Preface]]:''' $1 "+nl+nl);
	      
	    }
	  }
	}
	break;
	
case 'RW':
	var re2 = new RegExp(nl+codes[i]+':(.+?)VedaBase[\ ]+.+?'+nl, "g");
	var rearray = re2.exec(obj.changed.plain);
	if (rearray) {
	  var result = rearray[1];
	  var quote = rearray[2];
	 // win1.document.write("found for "+codes[i]+":<br>"+rearray[1]+"<br><br>");
	  
	  var found = result.match(avoid);
	  if (!found) {
	    switch (codes[i].charAt(2)) {
	    //Cases within this object: BGS, BGT, BGP, etc.            
	    case 'I':
	      var re2 = new RegExp(nl+codes[i]+':(.+?)Ref. VedaBase[\ ]+.+?'+nl, "g");
	      obj.changed.plain = obj.changed.plain.replace(re2, "'''[[Vanisource:RW Introduction|Renunciation Through Wisdom, Introduction]]:''' $1 "+nl+nl);
	    case 'C':
	      var re2 = new RegExp(nl+codes[i]+':(.+?)Ref. VedaBase[\ ]+RTW (.+?):.+?'+nl, "g");// Ref. VedaBase => RTW 3.1: Extinguishing the Flames of
	      
	      obj.changed.plain = obj.changed.plain.replace(re2, "'''[[Vanisource:RW $2|Renunciation Through Wisdom, $2]]:''' $1 "+nl+nl);
	    }
	  }
	}
	break;
	
 case 'SI': 
  var re2 = new RegExp(nl+codes[i]+':(.+?)Ref. VedaBase.+?'+nl, "g"); // Ref. VedaBase => Iso mantra 4
      var rearray = re2.exec(obj.changed.plain);
      if (rearray) {
        var result = rearray[1];
        var quote = rearray[2];
       // win1.document.write("found for "+codes[i]+":<br>"+rearray[1]+"<br><br>");
	  
	  var found = result.match(avoid);
	  if (!found) {
	    switch (codes[i].charAt(2)) {
	    //Cases within this object: BGS, BGT, BGP, etc.                
	    case 'S':
		  var re2 = new RegExp(nl+codes[i]+':(.+?)Ref. VedaBase.+?Iso.+?mantra (.+?)'+nl, "g"); 
		  obj.changed.plain = obj.changed.plain.replace(re2, "'''[[Vanisource:SI $2|Sri Isopanisad, text $2, Synonyms]]:''' $1 "+nl+nl);
	    case 'T':
	      if (codes[i].charAt(3) == 'P') {
			var re2 = new RegExp(nl+codes[i]+':(.+?)'+nl+'{2,}(.+?)Ref. VedaBase.+?Iso.+?mantra (.+?)'+nl, "g"); 
			obj.changed.plain = obj.changed.plain.replace(re2, "'''[[Vanisource:SI $3|Sri Isopanisad, text $3, Tanslation and Purport]]: $1''' "+nl+nl+"$2 "+nl+nl);
	      } else {
			var re2 = new RegExp(nl+codes[i]+':(.+?)Ref. VedaBase.+?Iso.+?mantra (.+?)'+nl, "g"); 
			obj.changed.plain = obj.changed.plain.replace(re2, "'''[[Vanisource:SI $2|Sri Isopanisad, text $2, Translation]]: $1''' "+nl+nl);
	      }
	    case 'P':
	      var re2 = new RegExp(nl+codes[i]+':(.+?)Ref. VedaBase.+?Iso.+?mantra (.+?)'+nl, "g"); 
		  obj.changed.plain = obj.changed.plain.replace(re2, "'''[[Vanisource:SI $2|Sri Isopanisad, text $2, Purport]]:''' $1 "+nl+nl);
	    case 'I':
	      var re2 = new RegExp(nl+codes[i]+':(.+?)Ref. VedaBase.+?'+nl, "g");
	      obj.changed.plain = obj.changed.plain.replace(re2, "'''[[Vanisource:SI Introduction|Sri Isopanisad, Introduction]]:''' $1 "+nl+nl);
	     case 'L':
		  var re2 = new RegExp(nl+codes[i]+':(.+?)Ref. VedaBase.+?Mantra (.+?) -- (.+?)'+nl, "g");
		  //Ref. VedaBase Śrī Īśopaniṣad, Mantra 1 -- Los Angeles, May 2, 1970
		  //Ref. VedaBase Śrī Īśopaniṣad, Mantra 8 -- Los Angeles, May 12, 1970
		  obj.changed.plain = obj.changed.plain.replace(re2, "'''[[Vanisource:SIL $3|Lectures on Śrī Īśopaniṣad, text $2, $3]]:''' $1 "+nl+nl);
		  
        }
	  }
	}
	break;
	
case 'SB':
	var re2 = new RegExp(nl+codes[i]+':(.+?)Ref. VedaBase[\ ]+(.+?)'+nl, "g");
	var rearray = re2.exec(obj.changed.plain);
	if (rearray) {
	  var result = rearray[1];
	  var quote = rearray[2];
	 // win1.document.write("found for "+codes[i]+":<br>"+rearray[1]+"<br><br>");
	  
	  var found = result.match(avoid);
	  if (!found) {
	    switch (codes[i].charAt(2)) {
	    //Cases within this object: BGS, BGT, BGP, etc.                
	    case 'S':
	      obj.changed.plain = obj.changed.plain.replace(re2, "'''[[Vanisource:$2|$2 Synonyms]]: $1''' "+nl+nl);
	    case 'T':
	      if (codes[i].charAt(3) == 'P') {
		var re2 = new RegExp(nl+codes[i]+':(.+?)'+nl+nl+'(.+?)Ref. VedaBase[\ ]+(.+?)'+nl, "g");
		obj.changed.plain = obj.changed.plain.replace(re2, "'''[[Vanisource:$3|$3, Tanslation and Purport]]: $1''' YYYYYY$2 "+nl+nl);
	      } else {
		obj.changed.plain = obj.changed.plain.replace(re2, "'''[[Vanisource:$2|$2, Translation]]: $1''' "+nl+nl);
	      }
	    case 'P':
	      obj.changed.plain = obj.changed.plain.replace(re2, "'''[[Vanisource:$2|$2, Purport]]:''' $1 "+nl+nl);
	    case 'F':
	      obj.changed.plain = obj.changed.plain.replace(re2, "'''[[Vanisource:$2|$2]]:''' $1 "+nl+nl);
	    case 'I':
	      obj.changed.plain = obj.changed.plain.replace(re2, "'''[[Vanisource:$2|$2]]:''' $1 "+nl+nl);
	    case 'M':
	      obj.changed.plain = obj.changed.plain.replace(re2, "'''[[Vanisource:$2|$2]]:''' $1 "+nl+nl);
            case 'L':
	      var re2 = new RegExp(nl+codes[i]+':(.+?)Ref. VedaBase (.+?) -- (.+?)'+nl, "g");
	      //Ref. VedaBase Śrīmad-Bhāgavatam 4.14.14 -- November 16, 1971, Delhi
	      //Ref. VedaBase Śrīmad-Bhāgavatam 11.3.21 -- New York, April 13, 1969
	      obj.changed.plain = obj.changed.plain.replace(re2, "'''[[Vanisource:SBL $3|$2, $3]]:''' $1 "+nl+nl);

	    }
	  }
	}
	break;
	
case 'TC':
	var re2 = new RegExp(nl+codes[i]+':(.+?)Ref. VedaBase[\ ]+TLC (.+?)(:.+?)?'+nl, "g");
	var rearray = re2.exec(obj.changed.plain);
	if (rearray) {
	  var result = rearray[1];
	  var quote = rearray[2];
	 // win1.document.write("found for "+codes[i]+":<br>"+rearray[1]+"<br><br>");
	  
	  var found = result.match(avoid);
	  if (!found) {
	    switch (codes[i].charAt(2)) {
	    //Cases within this object: BGS, BGT, BGP, etc.                
	    case 'F':
	      obj.changed.plain = obj.changed.plain.replace(re2, "'''[[Vanisource:TC $2|Teachings of Lord Caitanya, $2]]:''' $1 "+nl+nl);
	    case 'I':
	      obj.changed.plain = obj.changed.plain.replace(re2, "'''[[Vanisource:TC $2|Teachings of Lord Caitanya, $2]]:''' $1 "+nl+nl);
	    case 'C':
	      obj.changed.plain = obj.changed.plain.replace(re2, "'''[[Vanisource:TC $2|Teachings of Lord Caitanya, Chapter $2]]:''' $1 "+nl+nl);
	    case 'L':
	      obj.changed.plain = obj.changed.plain.replace(re2, "'''[[Vanisource:TC $2|Teachings of Lord Caitanya, $2]]:''' $1 "+nl+nl);
	      
	    }
	  }
	}
	break;
        
    //Lectures
case 'AA':
	var re2 = new RegExp(nl+codes[i]+':(.+?)Ref. VedaBase.+?-- (.+?)'+nl, "g");
	//Ref. VedaBase Arrival Address -- London, September 11, 1969
	//Ref. VedaBase Arrival Lecture -- New Delhi, November 10, 1971
	//Ref. VedaBase Śrīla Prabhupāda Welcomed by Governor at Hotel De Ville -- Geneva, May 30, 1974
	var rearray = re2.exec(obj.changed.plain);
	if (rearray) {
	  var result = rearray[1];
	  var quote = rearray[2];
	 // win1.document.write("found for "+codes[i]+":<br>"+rearray[1]+"<br><br>");
	  var found = result.match(avoid);
	  if (!found) {
	    obj.changed.plain = obj.changed.plain.replace(re2, "'''[[Vanisource:AA $2|Arrival Addresses and Talks, $2]]:''' $1 "+nl+nl);
	  }
	}
	break;
        
case 'CM':
	var re2 = new RegExp(nl+codes[i]+':(.+?)Ref. VedaBase (.+?) -- (.+?)'+nl, "g");
	//Ref. VedaBase Interview -- February 1, 1968, Los Angeles
	//Ref. VedaBase Morning Walk -- February 3, 1975, Hawaii
	var rearray = re2.exec(obj.changed.plain);
	if (rearray) {
	  var result = rearray[1];
	  var quote = rearray[2];
	 // win1.document.write("found for "+codes[i]+":<br>"+rearray[1]+"<br><br>");
	  
	  var found = result.match(avoid);
	  if (!found) {
	    obj.changed.plain = obj.changed.plain.replace(re2, "'''[[Vanisource:CM $3|Conversations and Morning Walks, $3]]:''' $1 "+nl+nl);
	  }
	}
	break;

case 'CO':
	var re2 = new RegExp(nl+codes[i]+':(.+?)Ref. VedaBase.+?-- (.+?)'+nl, "g");
	//Ref. VedaBase Cornerstone Laying -- Bombay, January 23, 1975
	//Ref. VedaBase Cornerstone Laying -- Bombay, January 23, 1975
	//Ref. VedaBase Foundation Stone Ceremony Speech -- Bhuvaneśvara, February 2, 1977
	var rearray = re2.exec(obj.changed.plain);
	if (rearray) {
	  var result = rearray[1];
	  var quote = rearray[2];
	 // win1.document.write("found for "+codes[i]+":<br>"+rearray[1]+"<br><br>");
	  
	  var found = result.match(avoid);
	  if (!found) {
	    obj.changed.plain = obj.changed.plain.replace(re2, "'''[[Vanisource:CO $2|Cornerstone Ceremonies, $2]]:''' $1 "+nl+nl);
	  }
	}
	break;

case 'LE':
	var re2 = new RegExp(nl+codes[i]+':(.+?)Ref. VedaBase.+?: (.+?)'+nl, "g");
	//Ref. VedaBase Letter to: Mathura Prasad — Vrindaban 23 May, 1964
	//Ref. VedaBase Letter to: Svati — India
	var rearray = re2.exec(obj.changed.plain);
	if (rearray) {
	  var result = rearray[1];
	  var quote = rearray[2];
	 // win1.document.write("found for "+codes[i]+":<br>"+rearray[1]+"<br><br>");
	  
	  var found = result.match(avoid);
	  if (!found) {
	    obj.changed.plain = obj.changed.plain.replace(re2, "'''[[Vanisource:LE $2|Letter to $2]]:''' $1 "+nl+nl+nl);
	   }
	}
	break;

case 'DL':
  var re2 = new RegExp(nl+codes[i]+':(.+?)Ref. VedaBase.+?-- (.+?)'+nl, "g");
	//Ref. VedaBase Departure Lecture -- Caracas, February 25, 1975
	//Ref. VedaBase Conversation -- Hawaii, June 20, 1975
	var rearray = re2.exec(obj.changed.plain);
	if (rearray) {
	  var result = rearray[1];
	  var quote = rearray[2];
	 // win1.document.write("found for "+codes[i]+":<br>"+rearray[1]+"<br><br>");
	  
	  var found = result.match(avoid);
	  if (!found) {
	    obj.changed.plain = obj.changed.plain.replace(re2, "'''[[Vanisource:DL $2|Departure Talks, $2]]:''' $1 "+nl+nl);
	  }
	}
	break;

// Sould be edited after imported on Vanisource. Naming not defined yet.
//case 'DI':
	var re2 = new RegExp(nl+codes[i]+':(.+?)Ref. VedaBase[ ]+EJ (.+?).+?'+nl, "g");
	//Ref. VedaBase JD: Preface
	//Ref. VedaBase JD: Introduction
	//Ref. VedaBase JD 5: The Journey- The Jaladuta sets sail for America
	var rearray = re2.exec(obj.changed.plain);
	if (rearray) {
	  var result = rearray[1];
	  var quote = rearray[2];
	 // win1.document.write("found for "+codes[i]+":<br>"+rearray[1]+"<br><br>");
	  
	  var found = result.match(avoid);
	  if (!found) {
	    
	    switch (codes[i].charAt(2)) {
	    //Cases within this object: BGS, BGT, BGP, etc.                
	    case 'F':
	      obj.changed.plain = obj.changed.plain.replace(re2, "'''[[Vanisource:EJ Preface|Easy Journey to other Planets, Preface]]:''' $1YYY");
	    case 'C':
	      obj.changed.plain = obj.changed.plain.replace(re2, "'''[[Vanisource:EJ $2|Easy Journey to other Planets, Chapter $2]]:''' $1 "+nl+nl);
	      
	    }
	  }
	}
	break;

case 'FL':
	var re2 = new RegExp(nl+codes[i]+':(.+?)Ref. VedaBase.+? -- (.+?)'+nl, "g");
	//Ref. VedaBase Lecture-Day after Śrī Gaura-Pūrṇimā -- Hawaii, March 5, 1969
	//Ref. VedaBase Nṛsiṁha-caturdaśī Lord Nṛsiṁhadeva's Appearance Day -- Bombay, May 5, 1974
	//Ref. VedaBase Ratha-yātrā Lecture at The Family Dog Auditorium -- San Francisco, July 27, 1969
	var rearray = re2.exec(obj.changed.plain);
	if (rearray) {
	  var result = rearray[1];
	  var quote = rearray[2];
	 // win1.document.write("found for "+codes[i]+":<br>"+rearray[1]+"<br><br>");
	  
	  var found = result.match(avoid);
	  if (!found) {
	   obj.changed.plain = obj.changed.plain.replace(re2, "'''[[Vanisource:FL $2|Festival Lectures, $2]]:''' $1 "+nl+nl);
	  }
	}
	break;

case 'GL':
	var re2 = new RegExp(nl+codes[i]+':(.+?)Ref. VedaBase.+? -- (.+?)'+nl, "g");
	//Ref. VedaBase Lecture on Mahā-mantra -- New York, September 8, 1966	
	//Ref. VedaBase Lecture -- Montreal, June 26, 1968
	
	var rearray = re2.exec(obj.changed.plain);
	if (rearray) {
	  var result = rearray[1];
	  var quote = rearray[2];
	 // win1.document.write("found for "+codes[i]+":<br>"+rearray[1]+"<br><br>");
	  
	  var found = result.match(avoid);
	  if (!found) {
	    obj.changed.plain = obj.changed.plain.replace(re2, "'''[[Vanisource:GL $2|General Lectures, $2]]:''' $1 "+nl+nl);
	  }
	}
	break;

case 'IL':
	var re2 = new RegExp(nl+codes[i]+':(.+?)Ref. VedaBase.+? -- (.+?)'+nl, "g");
	//Ref. VedaBase Initiation of Rukmiṇī Dāsī -- Montreal, August 15, 1968
	//Ref. VedaBase Initiations -- Los Angeles, January 10, 1969
	var rearray = re2.exec(obj.changed.plain);
	if (rearray) {
	  var result = rearray[1];
	  var quote = rearray[2];
	 // win1.document.write("found for "+codes[i]+":<br>"+rearray[1]+"<br><br>");
	  
	  var found = result.match(avoid);
	  if (!found) {
	      obj.changed.plain = obj.changed.plain.replace(re2, "'''[[Vanisource:IL $2|Initiations, $2]]:''' $1 "+nl+nl);
	  }
	}
	break;
        
case 'BS':
	var re2 = new RegExp(nl+codes[i]+':(.+?)Ref. VedaBase.+? -- (.+?)'+nl, "g");
	//Ref. VedaBase Śrī Brahma-saṁhitā, Verse 32 -- New York, July 26, 1971
	//Ref. VedaBase Śrī Brahma-saṁhitā, Lecture -- Los Angeles, November 9, 1968
	var rearray = re2.exec(obj.changed.plain);
	if (rearray) {
	  var result = rearray[1];
	  var quote = rearray[2];
	 // win1.document.write("found for "+codes[i]+":<br>"+rearray[1]+"<br><br>");
	  
	  var found = result.match(avoid);
	  if (!found) {
	  	obj.changed.plain = obj.changed.plain.replace(re2, "'''[[Vanisource:BSL $2|Lectures on Brahma Samhita, $2]]:''' $1 "+nl+nl);
	  }
	}
	break;
case 'LD':
	var re2 = new RegExp(nl+codes[i]+':(.+?)Ref. VedaBase (.+?):(.+?)'+nl, "g");
	//Ref. VedaBase LD 6: Declaration of Will, June 1977	
	var rearray = re2.exec(obj.changed.plain);
	if (rearray) {
	  var result = rearray[1];
	  var quote = rearray[2];
	 // win1.document.write("found for "+codes[i]+":<br>"+rearray[1]+"<br><br>");
	  
	  var found = result.match(avoid);
	  if (!found) {
		obj.changed.plain = obj.changed.plain.replace(re2, "'''[[Vanisource:$2|Legal Documents, $3]]:''' $1 "+nl+nl);
	  }
	}
	break;

case 'PD':
	var re2 = new RegExp(nl+codes[i]+':(.+?)Ref. VedaBase (.+?)'+nl, "g");
	//Ref. VedaBase Immanuel Kant
	//Ref. VedaBase Jeremy Bentham
	//Ref. VedaBase St. Augustine
	var rearray = re2.exec(obj.changed.plain);
	if (rearray) {
	  var result = rearray[1];
	  var quote = rearray[2];
	 // win1.document.write("found for "+codes[i]+":<br>"+rearray[1]+"<br><br>");
	  
	  var found = result.match(avoid);
	  if (!found) {
	      obj.changed.plain = obj.changed.plain.replace(re2, "'''[[Vanisource:PD $2|, Philosophy Discussions, $2]]:''' $1 "+nl+nl);
	      
	  }
	}
	break;

case 'SP':
	var re2 = new RegExp(nl+codes[i]+':(.+?)Ref. VedaBase Purport to (.+?) --.+?'+nl, "g");
	//Ref. VedaBase Purport to Bhajahu Re Mana -- San Francisco, March 16, 1967
	//Ref. VedaBase Purport to Nitāi-Pada-Kamala -- Los Angeles, December 21, 1968
	//Ref. VedaBase Spelling of Prayers to the Six Gosvāmīs -- Los Angeles, December 26, 1968
	var rearray = re2.exec(obj.changed.plain);
	if (rearray) {
	  var result = rearray[1];
	  var quote = rearray[2];
	 // win1.document.write("found for "+codes[i]+":<br>"+rearray[1]+"<br><br>");
	  
	  var found = result.match(avoid);
	  if (!found) {
	      obj.changed.plain = obj.changed.plain.replace(re2, "'''[[Vanisource:SP $2|Song Purports, $2]]:''' $1 "+nl+nl);
	      
	  }
	}
	break;

case 'WC':
	var re2 = new RegExp(nl+codes[i]+':(.+?)Ref. VedaBase.+? -- (.+?)'+nl, "g");
	//Ref. VedaBase Wedding of Śyāma dāsī and Hayagrīva -- Los Angeles, December 25, 1968
	//Ref. VedaBase Initiation of Śrī-Caitanya dāsa and Wedding of Pradyumna and Arundhatī -- Columbus, May 14, 1969
	//ef. VedaBase Wedding of Śyāma dāsī and Hayagrīva -- Los Angeles, December 25, 1968
	var rearray = re2.exec(obj.changed.plain);
	if (rearray) {
	  var result = rearray[1];
	  var quote = rearray[2];
	 // win1.document.write("found for "+codes[i]+":<br>"+rearray[1]+"<br><br>");
	  
	  var found = result.match(avoid);
	  if (!found) {
	   obj.changed.plain = obj.changed.plain.replace(re2, "'''[[Vanisource:WC $2|Wedding Ceremonies, $2]]:''' $1 "+nl+nl);
	  }
	}
	break;
        
      }
    }
  }
  
  //Replace intentionally removed newlines \n
  obj.changed.plain = obj.changed.plain.replace(/YYY/g, "\n");

  //Clean up after function
  WikEdFixBasic(obj.changed);

  // keep the changed text selected, needed to remove the formatting with a second click
  obj.changed.keepSel = true;
  
  return;	
}

function Test(obj) {
  
  WikEdGetText(obj, 'whole');
  obj.changed = obj.whole;
  
  //GEt rid off empty unwanted spaces
  obj.changed.plain = obj.changed.plain.replace(/(\s){2,}(?=&gt;{3})/mg, "$1");
  
  return;
  
}


//Format Balaram fonts to Unicode

function BaltoUni(obj) {
  
  WikEdGetText(obj, 'whole'); 
  obj.changed = obj.whole; 
  obj_array = obj.changed.plain.split('\n');
  re = /[äéüåèìïöòëçàùÿûÄÉÜÅÈÌÑÏÖÒËÇÀÙß]/g; 
  
  for ($i = 0; $i < obj_array.length; $i++) {
    
    if (re.test (obj_array[$i])) { 
      
      
      
      obj_array[$i] = obj_array[$i].replace (/ä/g, "ā"); // long a
      obj_array[$i] = obj_array[$i].replace (/é/g, "ī"); // long i
      obj_array[$i] = obj_array[$i].replace (/ü/g, "ū"); // long u
      obj_array[$i] = obj_array[$i].replace (/å/g, "ṛ"); // r cedilla
      obj_array[$i] = obj_array[$i].replace (/è/g, "ṟ"); // long r cedilla
      obj_array[$i] = obj_array[$i].replace (/ì/g, "ṅ"); // n dot over
      
      obj_array[$i] = obj_array[$i].replace (/ñ/g, "ṣ"); // s cedilla
      obj_array[$i] = obj_array[$i].replace (/ï/g, "ñ"); // n tilde
      
      obj_array[$i] = obj_array[$i].replace (/ö/g, "ṭ"); // t cedilla
      obj_array[$i] = obj_array[$i].replace (/ò/g, "ḍ"); // d cedilla
      obj_array[$i] = obj_array[$i].replace (/ë/g, "ṇ"); // n cedilla
      obj_array[$i] = obj_array[$i].replace (/ç/g, "ś"); // s accent
      
      obj_array[$i] = obj_array[$i].replace (/à/g, "ṁ"); // m dot over (anusvara)
      obj_array[$i] = obj_array[$i].replace (/ù/g, "ḥ"); // h cedilla (visarga)
      obj_array[$i] = obj_array[$i].replace (/ÿ/g, "ḷ"); // l cedilla
      obj_array[$i] = obj_array[$i].replace (/û/g, "ḻ"); // long l cedilla
      
      obj_array[$i] = obj_array[$i].replace (/Ä/g, "Ā"); // long a
      obj_array[$i] = obj_array[$i].replace (/É/g, "Ī"); // long i
      obj_array[$i] = obj_array[$i].replace (/Ü/g, "Ū"); // long u
      obj_array[$i] = obj_array[$i].replace (/Å/g, "Ṛ"); // r cedilla
      obj_array[$i] = obj_array[$i].replace (/È/g, "Ṟ"); // long r cedilla
      obj_array[$i] = obj_array[$i].replace (/Ì/g, "&#7748;"); // n dot over
      
      obj_array[$i] = obj_array[$i].replace (/Ñ/g, "Ṣ"); // s cedilla
      obj_array[$i] = obj_array[$i].replace (/Ï/g, "Ñ"); // n tilde
      
      obj_array[$i] = obj_array[$i].replace (/Ö/g, "Ṭ"); // t cedilla
      obj_array[$i] = obj_array[$i].replace (/Ò/g, "Ḍ"); // d cedilla
      obj_array[$i] = obj_array[$i].replace (/Ë/g, "Ṇ"); // n cedilla
      obj_array[$i] = obj_array[$i].replace (/Ç/g, "Ś"); // s accent
      
      obj_array[$i] = obj_array[$i].replace (/À/g, "Ṁ"); // m dot over (anusvara)
      obj_array[$i] = obj_array[$i].replace (/Ù/g, "Ḥ"); // h cedilla (visarga)
      obj_array[$i] = obj_array[$i].replace (/ß/g, "Ḷ"); // l cedilla 
      
      
    }
    
  }
  
  obj.changed.plain = obj_array.join('\n');
  
  // keep the changed text selected, needed to remove the formatting with a second click
  obj.changed.keepSel = true;
  
  return;
  
}


// install [[User:Cacycle/wikEd]] in-browser text editor
document.write('<script type="text/javascript" src="'
  + 'http://en.wikipedia.org/w/index.php?title=User:Cacycle/wikEd.js'
  + '&action=raw&ctype=text/javascript"></' + 'script>');