User:Zyxw/test.js

// function formatInfobox {

var txt = document.editform.wpTextbox1; //or: document.getElementById('wpTextbox1').value;

alert('Test'); alert(txt);

if (txt.match(/Infobox/i)) { start = txt.lastIndexOf('',start); next = txt.indexOf('{{',start+1) //Correctly handle other templates used within the infobox while (next < stop && txt.indexOf('{{',start+1)!= -1){ next = txt.indexOf('{{',stop+1); stop = txt.indexOf('}}',stop+1); }       template = txt.substring(start,stop); alert(template); } } $(function {    if (document.forms.editform) {        mw.util.addPortletLink('p-tb', 'javascript:formatInfobox', '\{\{Infobox\}\}', 'ca-formatinfobox', 'Format infobox');    } }); //