// Last update: 18:53, 24 February 2006 (UTC)
// <pre><nowiki>
// Automatic soft-redirect
// Uses [[w:WP:JS]] addlilink
$(function (){
if(document.forms.editform) {
var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
addlilink(tabs, 'javascript:UBX();', 'Convert to Template:User UBM UBX to', 'ca-UBM');
}
});
function UBX(){
var txt = document.editform.wpTextbox1;
var r = txt.value.replace(new RegExp("[\\S\\s]*#[Rr][Ee][Dd][Ii][Rr][Ee][Cc][Tt][_ ]?\\[\\[([^\\]]*)\\]\\][\\S\\s]*|[\\s\\S]*", "g"), "$1");
r = r.slice(5);
if (r==""){
var r = "[["+prompt('What page should the redirect point to?')+"]]";
}
var s = wgTitle.slice(5);
txt.value = "{{User UBM UBX to|"+s+"|"+r+"}}";
var editform = document.editform;
editform.wpSummary.value = "Converted to Template:User UBM UBX to";
editform.wpWatchthis.click();
editform.wpSave.focus();
}
/*** Add generic tab ***/
function addlilink(tabs, url, name, id){
var na = document.createElement('a');
na.href = url;
na.appendChild(document.createTextNode(name));
var li = document.createElement('li');
li.id = id;
li.appendChild(na);
tabs.appendChild(li);
return li;
}
// </nowiki></pre>