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 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 replace(str,txt,replace)
{
while(str.indexOf(txt)!=-1)
{
str = str.replace(txt,replace);
}
return str;
}
function FindPrev(str, txt, pos)
{
pos--;
while (pos > -1)
{
var Char = str.substr(pos,1);
if (Char == txt)
{
return pos;
}
pos--;
}
return -1;
}
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'));
}
function reversetitle()
{
var str = article();
var pos = str.lastIndexOf(' ');
var last = str.substr(pos+1);
var first = str.substring(0,pos);
return last + "," + first;
}
function party()
{
var endpos = document.editform.wpTextbox1.value.indexOf(" to the United States Senate");
var startpos = FindPrev(document.editform.wpTextbox1.value, " ", endpos);
return document.editform.wpTextbox1.value.substring(startpos+1,endpos);
}
function state()
{
var pos = document.editform.wpTextbox1.value.indexOf('a Senator from ');
var end = document.editform.wpTextbox1.value.indexOf(';');
var state = document.editform.wpTextbox1.value.substring(pos+15,end);
return state;
}
function CongressConvert()
{
var str = document.editform.wpTextbox1.value;
var pos = -1;
while (str.indexOf("Congress", pos) != -1)
{
var currpos = str.indexOf("Congress", pos) - 1;
var startpos1 = str.lastIndexOf("(",currpos);
var startpos2 = str.lastIndexOf(" ",currpos);
var startpos;
if (startpos1 < startpos2)
{
startpos = startpos2;
}
else
{
startpos = startpos1;
}
window.alert(str.substring(startpos,currpos));
pos = currpos + 9;
}
document.editform.wpTextbox1.value = str;
}
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 Convert(text)
{
//Add links, convert names
text = replace(text,"Wis.","Wisconsin");
text = replace(text,"Md.","Maryland");
CongressConvert();
return text;
}
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('\n[[Image:|thumb|right|Caption Here]]' + "\n");
addText("'''" + article() + "'''" + " was an [[American]] [[politician]]. A [[" + party() + " Party (United States)|" + party() + "]],");
addText(" he served as a [[United States Senator]] from [[" + state() + "]].\n");
addText("==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 " + state() + "|United States Senator (Class ) from ]] | years=[[]]– | after=}}\n\n");
addText("{{end box}}\n\n");
addText("[[Category: births|" + reversetitle() + "]]\n");
addText("[[Category: deaths|" + reversetitle() + "]]\n");
addText("[[Category:United States Senators from " +state() + "|" + reversetitle() + "]]\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>