|
|
(23 intermediate revisions by the same user not shown) |
Line 1: |
Line 1: |
| /* <pre> <nowiki> */ | | /* <pre> <nowiki> */ |
| /* WikEd text editor */ | | /* WikEd text editor */ |
| document.write('<script type="text/javascript" src="' | | document.write('<script type="text/javascript" src="' |
Line 5: |
Line 5: |
| + '&action=raw&ctype=text/javascript&dontcountme=s"></script>'); | | + '&action=raw&ctype=text/javascript&dontcountme=s"></script>'); |
|
| |
|
| | var hasClass = (function () { |
| | var reCache = {}; |
| | return function (element, className) { |
| | return (reCache[className] ? reCache[className] : (reCache[className] = new RegExp("(?:\\s|^)" + className + "(?:\\s|$)"))).test(element.className); |
| | }; |
| | })(); |
|
| |
|
| | /* Twinkle */ |
| | importScript('http://en.wikipedia.org/wiki/User:AzaToth/twinkle.js'); |
|
| |
|
| function addTab(id, after, caption, url) {
| | /** Title rewrite ******************************************************** |
| if (!document.getElementById(id)) {
| | * Rewrites the page's title, used by [[Template:Title]] |
| var edit = document.getElementById(after);
| | * Credits to Uncyclopedia's Sikon |
| if (!edit) return; //If the previous tab doesn't exist, don't add this one
| | */ |
| var editparent = edit.parentNode;
| |
| var aseclinkcaption = document.createTextNode(caption)
| |
| var aseclink = document.createElement('a');
| |
| aseclink.setAttribute('href',url);
| |
| var addsectionlinkcaption = aseclink.appendChild(aseclinkcaption);
| |
| var asec = document.createElement('li');
| |
| asec.setAttribute('id',id);
| |
| var addsectionlink = asec.appendChild(aseclink);
| |
| var addsection = editparent.insertBefore(asec,edit.nextSibling);
| |
| }
| |
| }
| |
| //source: http://en.wikipedia.org/wiki/User:Flex/welcome_newuser.js | |
| function welcome() {
| |
|
| |
|
| // Find the edit box
| | function rewriteTitle() |
| var txt = document.editform.wpTextbox1;
| | { |
| | if(typeof(SKIP_TITLE_REWRITE) != 'undefined' && SKIP_TITLE_REWRITE) |
| | return; |
|
| |
|
| //The welcome *template* you want to use
| | var titleDiv = document.getElementById('title-meta'); |
| var welcome_user = 'Jdrowlands'; | |
| var welcome_summary = 'Welcome';
| |
| var welcome_watch = false;
| |
|
| |
|
| var tag = '{{welcome|'+ welcome_user +'}}';
| | if(titleDiv == null || titleDiv == undefined) |
| | return; |
|
| |
|
| if (txt.value.indexOf(tag) == -1) {
| | var cloneNode = titleDiv.cloneNode(true); |
| | var firstHeading = getElementsByClass('firstHeading', document.getElementById('content'), 'h1')[0]; |
| | var node = firstHeading.childNodes[0]; |
|
| |
|
| txt.value += tag;
| | // new, then old! |
| | firstHeading.replaceChild(cloneNode, node); |
| | cloneNode.style.display = "inline"; |
|
| |
|
| document.editform.wpSummary.value = welcome_summary;
| | var titleAlign = document.getElementById('title-align'); |
| document.editform.wpWatchthis.checked = welcome_watch;
| | firstHeading.style.textAlign = titleAlign.childNodes[0].nodeValue; |
| | |
| document.editform.submit();
| |
| }
| |
| else {
| |
| document.getElementById('ca-unverified').firstChild.style.backgroundColor = "#ff4444"; | |
| document.getElementById('ca-unverified').style.backgroundColor = "#ff4444";
| |
| } | | } |
| }
| |
| addOnloadHook(
| |
| function ()
| |
| {
| |
| if(document.title.indexOf("Editing User talk:") == 0)
| |
| {
| |
| addPortletLink('p-cactions', 'javascript:welcome()', 'welcome', 'ca-welcome', 'Adds a welcome note to the new user', '', '');
| |
| }
| |
| }
| |
| );
| |
| // [[user:Where/usertabs]]
| |
| // This is a good one!
| |
|
| |
| addOnloadHook(function() {
| |
| if (wgTitle.indexOf("/") != -1 || document.title.indexOf("- History -") != -1) //no subpages or history
| |
| return;
| |
| if (wgCanonicalNamespace == "User" || wgCanonicalNamespace == "User_talk") {
| |
| var username = encodeURIComponent( wgTitle );
| |
| addPortletLink("p-cactions", wgServer + "/Special:Contributions/" + username, "Edits", "ca-contrib", "User contributions");
| |
| addPortletLink("p-cactions", "/index.php?title=Special:EditCount&target="+ username + "&doeditcount=Show+count", "Edit count", "ca-editcount", "Get this user's edit count.");
| |
| addPortletLink("p-cactions", wgServer + "/index.php?title=Special:Log&type=move&user=" + username, "Moves", "ca-pagemoves", "Page moves by this user");
| |
| addPortletLink("p-cactions", wgServer + "/index.php?title=Special:Log&type=block&page=User:" + username, "Blocks", "ca-blog", "Blocks received by this user");
| |
| addPortletLink("p-cactions", wgServer + "/index.php?title=Special:Prefixindex&from=" + username + "&namespace=2", "Userspace", "", "List of pages in this user's userspace");
| |
| addPortletLink("p-cactions", wgServer + "/index.php?title=Special:Log&type=block&user=" + username, "Block Log", "", "Blocks by this user");
| |
| addPortletLink("p-cactions", wgServer + "/index.php?title=Special:Log&type=protect&user=" + username, "Protections", "", "Protections by this user");
| |
| addPortletLink("p-cactions", wgServer + "/index.php?title=Special:Log&type=delete&user=" + username, "Deletions", "", "Deletions by this user");
| |
| }
| |
|
| |
|
| | | addOnloadHook(rewriteTitle, false); |
| | |
| var rcp_http;
| |
| var rcp_enabled;
| |
| var rcp_num_pages;
| |
| var rcp_refresh;
| |
|
| |
| addOnloadHook( rcp_init ); | |
|
| |
| /* initalise */
| |
| function rcp_init() {
| |
|
| |
| // allow user settings through
| |
| if(rcp_enabled == null) {
| |
| rcp_enabled = false;
| |
| }
| |
| if(rcp_num_pages == null) {
| |
| rcp_num_pages = 10;
| |
| }
| |
| if(rcp_refresh == null) {
| |
| rcp_refresh = 5;
| |
| }
| |
|
| |
| // A few limits to be nice to the servers
| |
| if (rcp_num_pages > 50) {
| |
| rcp_num_pages = 50;
| |
| }
| |
| if (rcp_num_pages < 1) {
| |
| rcp_num_pages = 1;
| |
| }
| |
| if (rcp_refresh < 2) {
| |
| rcp_refresh = 2;
| |
| }
| |
|
| |
| // get our cookie
| |
| if (document.cookie.length > 0) {
| |
| var c_start = document.cookie.indexOf("rcp_show_box=");
| |
| if (c_start != -1) {
| |
| c_start = c_start + 13;
| |
| var c_end = document.cookie.indexOf(";", c_start);
| |
| if (c_end == -1) {
| |
| c_end = document.cookie.length;
| |
| }
| |
|
| |
| if (document.cookie.substring(c_start, c_end) == "yes") {
| |
| rcp_enabled = true;
| |
| } else {
| |
| rcp_enabled = false;
| |
| }
| |
| }
| |
| }
| |
|
| |
| // Either make a request or show nothing
| |
| if (rcp_enabled == true) {
| |
| rcp_ajax_request();
| |
| } else {
| |
| rcp_draw_disabled_box();
| |
| }
| |
| }
| |
|
| |
| /* init ajax */
| |
| function rcp_create_request() {
| |
| try {
| |
| rcp_http = new XMLHttpRequest();
| |
|
| |
| } catch (e) {
| |
| try {
| |
| rcp_http = new ActiveXObject("Msxml2.XMLHTTP");
| |
| } catch (e) {
| |
| try {
| |
| rcp_http = new ActiveXObject("Microsoft.XMLHTTP");
| |
| } catch (e) {
| |
| alert("Your browser does not support AJAX!");
| |
| return false;
| |
| }
| |
| }
| |
| }
| |
|
| |
| rcp_http.onreadystatechange = function() {
| |
| if(rcp_http.readyState == 4) rcp_ajax_response();
| |
| }
| |
|
| |
| return true;
| |
| }
| |
|
| |
| /* make a request */
| |
| function rcp_ajax_request() {
| |
| // check we are enabled
| |
| if (rcp_enabled == false) return;
| |
|
| |
| // firstly, inform the user
| |
| var cur_box = document.getElementById('p-recentchanges');
| |
| if (cur_box != null) {
| |
| cur_box.firstChild.firstChild.data = 'Recent Changes (updating)';
| |
| }
| |
|
| |
| if (rcp_create_request () == false) {
| |
| if (cur_box != null) {
| |
| cur_box.firstChild.firstChild.data = 'Recent Changes (update failed)';
| |
| } else {
| |
| alert ("There seems to be a problem using the RecentChangePatrol script. I can't make AJAX objects, so I'm just going to complain. God Bless!");
| |
| }
| |
| }
| |
|
| |
| // Then make the request
| |
| rcp_http.open("GET", "http://en.wikipedia.org/w/api.php?action=query&list=recentchanges&format=xml&rcnamespace=0&rcshow=!bot&rcshow=!minor&rclimit=" + rcp_num_pages, true);
| |
| rcp_http.send(null);
| |
| }
| |
|
| |
| /* we have received a response */
| |
| function rcp_ajax_response() {
| |
|
| |
| var items = rcp_http.responseXML.getElementsByTagName('rc');
| |
|
| |
| // create the div that holds all the recentchanges links
| |
| var link_div = document.createElement('div');
| |
| link_div.className = 'pBody';
| |
| var list = document.createElement('ul');
| |
| link_div.appendChild(list);
| |
|
| |
| // populate the list with 10 links.
| |
| for (var i = 0; i < items.length; i++) {
| |
| var item_name = items[i].getAttribute('title');
| |
| var item_url = 'http://www.mariowiki.com/index.php?diff=cur&oldid=prev&title=' + escape(item_name);
| |
|
| |
| a = document.createElement('a');
| |
| a.setAttribute('href', item_url);
| |
| a.appendChild(document.createTextNode(item_name));
| |
|
| |
| var li = document.createElement('li');
| |
| li.appendChild(a);
| |
| list.appendChild(li);
| |
| }
| |
|
| |
| // Container div
| |
| var div = document.createElement('div');
| |
| div.setAttribute('id', 'p-recentchanges');
| |
| div.className = 'portlet';
| |
| var heading = document.createElement('h5');
| |
| heading.appendChild(document.createTextNode('Recent Changes'));
| |
| div.appendChild(heading);
| |
| div.appendChild(link_div);
| |
|
| |
| // disable link
| |
| var p = document.createElement('p');
| |
| p.style.fontSize = 'x-small';
| |
| p.style.margin = '0px';
| |
| p.style.textAlign = 'right';
| |
| a = document.createElement('a');
| |
| a.appendChild(document.createTextNode('disable this box'));
| |
| a.onclick = rcp_disable_box;
| |
| p.appendChild(a);
| |
| link_div.appendChild(p);
| |
|
| |
| // now replace the div
| |
| var old_div = document.getElementById('p-recentchanges');
| |
| var side_col = document.getElementById('column-one');
| |
| if (old_div != null) {
| |
| side_col.replaceChild(div, old_div);
| |
| } else {
| |
| var node = document.getElementById('p-search');
| |
| side_col.insertBefore(div, node);
| |
| }
| |
|
| |
| // and do it again in 5 secs
| |
| setTimeout("rcp_ajax_request()", rcp_refresh * 1000);
| |
| }
| |
|
| |
| function rcp_disable_box() {
| |
| rcp_enabled = false;
| |
| rcp_draw_disabled_box();
| |
| document.cookie = "rcp_show_box=no; path=/";
| |
| }
| |
|
| |
| function rcp_enable_box() {
| |
| rcp_enabled = true;
| |
| document.cookie = "rcp_show_box=yes; path=/";
| |
| rcp_ajax_request();
| |
| }
| |
|
| |
| function rcp_draw_disabled_box() {
| |
| // Container div
| |
| var link_div = document.createElement('div');
| |
| link_div.className = 'pBody';
| |
| var div = document.createElement('div');
| |
| div.setAttribute('id', 'p-recentchanges');
| |
| div.className = 'portlet';
| |
| var heading = document.createElement('h5');
| |
| heading.appendChild(document.createTextNode('Recent Changes'));
| |
| div.appendChild(heading);
| |
| div.appendChild(link_div);
| |
|
| |
| // enable link
| |
| var p = document.createElement('p');
| |
| p.style.fontSize = 'x-small';
| |
| p.style.margin = '0px';
| |
| var a = document.createElement('a');
| |
| a.appendChild(document.createTextNode('enable this box'));
| |
| a.onclick = rcp_enable_box;
| |
| p.appendChild(a);
| |
| link_div.appendChild(p);
| |
|
| |
| // now replace the div
| |
| var old_div = document.getElementById('p-recentchanges');
| |
| var side_col = document.getElementById('column-one');
| |
| if (old_div != null) {
| |
| side_col.replaceChild(div, old_div);
| |
| } else {
| |
| var node = document.getElementById('p-search');
| |
| side_col.insertBefore(div, node);
| |
| }
| |
| }
| |
| /* </nowiki> </pre> */ | | /* </nowiki> </pre> */ |