User:Mathwizard1232/monobook.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
![]() | The accompanying .css page for this skin can be added at User:Mathwizard1232/monobook.css. |
//<pre><nowiki>
function title()
{
return document.title.substr(0, document.title.lastIndexOf(' - Wikipedia, the free'));
}
function article()
{
return document.title.substring(8, document.title.lastIndexOf(' - Wikipedia, the free')-1);
}
function addlilink(tabs, url, name, id, title, key)
{
var na = document.createElement('a');
na.href = url;
na.appendChild(document.createTextNode(name));
var li = document.createElement('li');
if(id) li.id = id;
li.appendChild(na);
tabs.appendChild(li);
na.accesskey = key;
var pref = 'alt-';
if(((clientPC.indexOf('AppleWebKit')!=-1) && (clientPC.indexOf('spoofer')==-1)) || navigator.userAgent.toLowerCase().indexOf( 'mac' ) != -1 ) pref = 'control-';
if(clientPC.indexOf('opera')!=-1) pref = 'shift-esc-';
if(key && title) na.title = title + ' [' + pref + key + ']';
else if(title) na.title = title;
else if(key) na.title = '[' + pref + key + ']';
return li;
}
function addTab(url, name, id, title, key)
{
var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
addlilink(tabs, url, name, id, title, key);
}
function addText(text)
{
document.editform.wpTextbox1.value = document.editform.wpTextbox1.value + text;
}
function replace(str,txt,replace)
{
while(str.indexOf(txt)!=-1)
{
str = str.replace(txt,replace);
}
return str;
}
function Convert(text)
{
//Add links, convert names
text = replace(text,"Wis.","Wisconsin");
text = replace(text,"Md.","Maryland");
return text;
}
function Insert(str, pos, newstr)
{
return (str.substr(0,pos) + newstr + str.substr(pos));
}
function Delete(str, pos, length)
{
if (pos + length < str.length)
{
return (str.substr(0,pos) + str.substr(pos+length));
}
else
{
return str.substr(0,pos);
}
}
function doStart()
{
/*if (document.editform.wpTextbox1.value != "")
{
window.alert('Data found, template not added.');
}
else
{*/
var Bio = document.editform.wpTextbox1.value;
document.editform.wpTextbox1.value = Convert(Bio);
//window.alert(article());
addText('[[Image:|thumb|right|Caption Here]]' + "\n");
addText("'''Subject'''");
addText("\n\n==Early Life==\n\n==Political Life==\n\n==Sources==\n{{CongBio|}}\n\n");
addText("{{start box}}\n\n{{succession box | before=[[]] | title=[[List of United States Senators from |United States Senator (Class ) from ]] | years=[[]]– | after=}}\n\n");
addText("{{end box}}\n\n");
addText("[[Category: births|]]\n");
addText("[[Category: deaths|]]\n");
addText("[[Category:United States Senators from |]]\n");
addText("{{politician-stub}}");
document.editform.wpSummary.value = 'Created for [[WP:USC]]';
//window.alert('Adding template.');
//}
}
function addStart()
{
addTab("Javascript:doStart()", "Start Senator Page", "ca-start", "Creates an outline for a page for a former Senator.", "");
akeytt();
}
function doGoStart()
{
location.href = 'http://en.wikipedia.org/w/index.php?title=' + title() + '&action=edit&other=StartSen';
}
function GoStart()
{
addTab("Javascript:doGoStart()", "Start Senator Page", "ca-start", "Creates an outline for a page for a former Senator.", "");
}
function CheckStart()
{
var end = location.href.substr(location.href.lastIndexOf('=edit',100));
if (end == '=edit')
return;
else if (end == '=edit&other=StartSen')
{
doStart();
}
else
{
//window.alert('Unrecognized command: ' + end);
}
}
if (document.title.indexOf("Editing ") == 0)
{
addOnloadHook(addStart);
}
else
{
//addOnloadHook(GoStart);
}
if (document.title.indexOf("Editing ") == 0)
{
addOnloadHook(CheckStart);
}
//</nowiki></pre>