Uiser:Eagle 101/monobook.js

Frae Wikipedia, the free beuk o knawledge

Tak tent: Efter hainin, ye micht hae tae bypass yer brouser's cache for tae see the chynges. Mozilla / Firefox / Safari: haud doun Shift while dabbin on Reload, or press Ctrl-Shift-R (Cmd-Shift-R on Apple Mac); IE: haud doun Ctrl while dabbin on Refresh, or press Ctrl-F5; Konqueror: juist dab on the Reload button, or press F5; Opera users micht hae tae haillie dicht thair cache in Tools→Preferences.

//if(document.URL.indexOf("/w/index.php?title=Special:Watchlist&") == -1)
//{
//Allow loading of other js scripts
function loadJS(s) {
    s = s.replace(/^\[\[/, '').replace(/\]\]$/, '').replace(" ", "_");
    document.write('<script type="text/javascript" src="'
             + 'http://en.wikipedia.org/w/index.php?title=' + s
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
}

var myname=wgUserName.replace(' ', '_'); //use underscores instead of spaces
var mypage="User:"+myname;
var mytalk="User_talk:"+myname;
var mycontribs="Special:Contributions/"+myname;
var serverurl="http://en.wikipedia.org";
var wikiurl=serverurl+"/wiki/";
var pathurl=serverurl+"/w/";
var phpurl=pathurl+"index.php?title=";
var editcounturl="http://tools.wikimedia.de/~essjay/edit_count/Count.php";
var editcount=editcounturl+"?username=";

//A helper function to add a button to one of the toolbars in the interface.
//An improved(I hope) version of [[:Wikipedia:WikiProject User scripts/Scripts/Add LI link|addlilink]].
//[[:User:JesseW/sig|JesseW, the juggling janitor]] 05:33, 8 November *2005 (UTC)

function addLink(where, url, name, id, title, key, after){
    //* where is the id of the toolbar where the button should be added;
    //   i.e. one of "p-cactions", "p-personal", "p-navigation", or "p-tb".
    //
    //* url is the URL which will be called when the button is clicked.
    //   javascript: urls can be used to do more complex things.
    //
    //* name is what will appear as the name of the button.
    //
    //* id is the id of the button; it's best to define one.  
    //   Use a prefix to make sure its unique. Optional.
    //
    //* title is the tooltip title that gives a longer description 
    //   of the button; if you define a accesskey, mention it here. Optional.
    //
    //* key is the char you want for the accesskey. Optional.
    //
    //* after is the id of the button you want to follow this one. Optional.
    //
    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);
    var tabs = document.getElementById(where).getElementsByTagName('ul')[0];
    if(after) {
        tabs.insertBefore(li,document.getElementById(after));
    } else {
        tabs.appendChild(li);
    }
    if(id) {
        if(key && title) { ta[id] = [key, title]; }
        else if(key) { ta[id] = [key, '']; }
        else if(title) { ta[id] = ['', title];} 
    }
    // re-render the title and accesskeys from existing code in wikibits.js
    akeytt();
    return li;
}


//COOKIE FUNCTIONS
function readCookie(name) {
 var nameEQ = name + "=";
 var ca = document.cookie.split(';');
 for(var i=0;i < ca.length;i++) {
 var c = ca[i];
 while (c.charAt(0)==' ') c = c.substring(1,c.length);
 if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
 }
 return null;
}

function createCookie(name,value,days) {
 if (days) {
 var date = new Date();
 date.setTime(date.getTime()+(days*24*60*60*1000));
 var expires = "; expires="+date.toGMTString();
 }
 else var expires = "";
 document.cookie = name+"="+value+expires+"; path=/";
}


function eraseCookie(name) {
 createCookie(name,"",-1);
}

//END


//==Links==
//Note: This is not like the AdLiLinks from WP:US. This is much different.

//    --- ADD VARIOUS LINKS ----
function addToolboxLink(url, name, id){
    var tb = document.getElementById('p-tb').getElementsByTagName('ul')[0];
    addlilink(tb, url, name, id);
}
// 
function addTopLink(url, name, id){
    var personal = document.getElementById('p-personal').getElementsByTagName('ul')[0];
    addlilink(personal, url, name, id);
}
// 
function addNavLink(url, name, id){
    var navigation = document.getElementById('p-navigation').getElementsByTagName('ul')[0];
    addlilink(navigation, url, name, id);
}
// 

function addTab(url, name, id, title, key){
    var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
    return addlilink(tabs, url, name, id, title, key);
}

//

//      ------ MORE MAJOR LINKAGE -----
function addLink(where, url, name, id, title, key, after){
    //* where is the id of the toolbar where the button should be added;
    //   i.e. one of "p-cactions", "p-personal", "p-navigation", or "p-tb".
    //
    //* url is the URL which will be called when the button is clicked.
    //   javascript: urls can be used to do more complex things.
    //
    //* name is what will appear as the name of the button.
    //
    //* id is the id of the button; it's best to define one.  
    //   Use a prefix to make sure its unique. Optional.
    //
    //* title is the tooltip title that gives a longer description 
    //   of the button; if you define a accesskey, mention it here. Optional.
    //
    //* key is the char you want for the accesskey. Optional.
    //
    //* after is the id of the button you want to follow this one. Optional.
    //
    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);
    var tabs = document.getElementById(where).getElementsByTagName('ul')[0];
    if(after) {
        tabs.insertBefore(li,document.getElementById(after));
    } else {
        tabs.appendChild(li);
    }
    if(id) {
        if(key && title) { ta[id] = [key, title]; }
        else if(key) { ta[id] = [key, '']; }
        else if(title) { ta[id] = ['', title];} 
    }
    // re-render the title and accesskeys from existing code in wikibits.js
    akeytt();
    return li;
}
    
// 

// ------------- LINKAGE ----------------

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);
    if(id)
    {
        if(key && title)
        {
            ta[id] = [key, title];
        }
        else if(key)
        {
            ta[id] = [key, ''];
        }
        else if(title)
        {
            ta[id] = ['', title];
        }
    }
    // re-render the title and accesskeys from existing code in wikibits.js
    akeytt();
    return li;
}


//==Include==



function loadJSext(s) {
    document.write('<script type="text/javascript" src="'+ s + '"></script>');
}

function loadCSS(page){
  page=page.replace(" ", "_");
  document.write('<style type="text/css">@import "'+phpurl+page+'&action=raw&ctype=text/css";</style>');
}
function loadCSSext(page){
  document.write('<style type="text/css">@import "'+page+'";</style>');
}

//
$(Dfn_js_con)
function Dfn_js_con()
{
//moves
Mvaluejs_class = 'confirm';
//edits
Rvaluejs_class = 'confirm';
//uploads
Uvaluejs_class = 'confirm';
}
//



//<pre><nowiki> from [[::en:GeorgeMoney]]
//-----------AUTOEDIT----------
/*
===parameters:===
__mandatory__:
'txt' is the text you want to put in the edit box;
'sum' is your summary;
example: autoedit('hello', 'saying hello to user');

__optional__:
_mode_: the mode to use. Modes are:
        'r': replace all existing text (or create page if no text) with your text;
		'a': append your text to bottom of original;
		't': add your text to top of original text;
	    mode examples: autoedit('{{header}}', 'adding header to all pages', 't');
		default mode: 'r';
_watch_: To click 'Watch this page'. Use either true or false;
         watch examples: autoedit('hi', 'saying hi', '', true);
		 watch notes: because this parameter occurs after the mode parameter, if you dont want to include the mode parameter, leave it like ''. so autoedit('text','summary','',true) notice how the mode is '', but you can still use a mode like 'a';
		 watch default: false;
_minor_: like watch except to mark edit as minor;
         minor default: false;
_autoclick_: What button to click for autoclick
             autoclick options: 'wpSave', 'wpDiff', 'wpPreview';
	  to not use autoclick, value is 'none';
             autoclick default: wpSave;

*/
function autoedit(txt, sum, mode, watch, minor, autoclick) {
/*
if(booluse) { var otherif = (intitle('action=submit')); }
else { var otherif = false; }
*/

if(!txt||!sum) { return "Missing parameters"; }

if(!autoclick) { autoclick = 'wpSave'; }


if(!mode) { mode = 'r'; }

if(watch == "false") { watch = false; }
if(minor == "false") { minor = false; }

if(!watch) { document.getElementById('wpWatchthis').checked = ""; } else { document.getElementById('wpWatchthis').checked = "checked"; }
if(!minor) { document.getElementById('wpMinoredit').checked = ""; } else { document.getElementById('wpMinoredit').checked = "checked"; }

var txta = document.getElementById('wpTextbox1');
var sma = document.getElementById('wpSummary');

if(mode=='r') {
txta.value = txt;
} else if(mode=='a') {
txta.value += '\n'+txt;
} else if(mode=='t') {
txta.value = txt + '\n' + document.getElementById('wpTextbox1').value;
}

sma.value = sum;

if(autoclick!='none') {
document.getElementById(autoclick).click();
}


}

//Originally from [[:User:Lupin/autoedit.js]]
function gv(paramName) {
  var cmdRe=RegExp('[&?]'+paramName+'=([^&]*)');
  var h=document.location;
  var m;
  if (m=cmdRe.exec(h)) {
    try { 
      return unescape(decodeURI(m[1]));
    } catch (someError) {}
  }
  return null;
};
//</nowiki></pre>

function my_replace() {
var s = /\[\[[^:](.+):(.+)\]\]/g;
var r = "[[:$1:$2]]";
var txt = document.getElementById('wpTextbox1').value;
var newtext = txt.replace(s, r);
autoedit(newtext, 'Fixing interwiki links', 'r', false, true, 'wpSave');
}

$(function () {
if(document.getElementById('editform')) {
my_replace();
}
});
// if (wgCanonicalNamespace == "Special:Allpages") {
    addOnloadHook(function(){ 
     var len=document.links.length;
     for(var i=0; i<len; ++i) {
         var l=document.links[i];
         if (l.className != 'new') {
l.href=l.href+"?action=edit&changelink=1";
}
}
});
//}
//}