Jump to content

User:Sock of Steel359/unblock.js: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
No edit summary
No edit summary
Line 54: Line 54:
});
});


function queryString(p) {
var re = RegExp('[&?]' + p + '=([^&]*)');
var matches;
if (matches = re.exec(document.location)) {
try {
return decodeURI(matches[1]);
} catch (e) {
}
}
return null;
};


//}
//}

Revision as of 14:59, 19 May 2007

// <pre>

function addLink(where, url, name, id, title, key, after) {
    // addLink() accepts either an id or a DOM node, addPortletLink() only takes a node
    if (after && !after.cloneNode)
        after = document.getElementById(after);

    return addPortletLink(where, url, name, id, title, key, after);
}

//  if (document.title.indexOf("Editing User talk:") != -1) {


// -----------------------------------------------------------------------------------------------------------

function declineunblock()
{
  var reason1 = prompt("Reason for declining?");
  if ( !reason1 ) {
  return;
 } else {
  var url = wgServer + '/wiki/' + wgPageName + '?action=edit';
  window.open(url);
  var f = document.editform, t = f.wpTextbox1;
  var unblock = RegExp("\{\{[U|u]nblock\|(.*?)\}\}");
  var reviewed = "{"+"{Unblock reviewed|1=" + $1 + "|decline=" + reason1 + "}}";
  t.value = t.value.split(unblock).join(reviewed);
  document.forms[0].wpDiff.click();
 }
}

function declineunblock_tagging()
{
  addPortletLink('p-interaction', 'javascript:declineunblock()', "Decline unblock");
}

addOnloadHook(declineunblock_tagging);

// -----------------------------------------------------------------------------------------------------------

addOnloadHook(function (){
  if(queryString("jsaction")=="decline") {
  var reason1 = prompt("Reason for declining?");
  if ( !reason1 ) {
  return;
 } else {
  var f = document.editform, t = f.wpTextbox1;
  var unblock = RegExp("\{\{[U|u]nblock\|(.*?)\}\}");
  var reviewed = "{"+"{Unblock reviewed|1=$1|decline=" + reason1 + "}}";
  t.value = t.value.split(unblock).join(reviewed);
  document.forms[0].wpDiff.click();
 }
}
});

	function queryString(p) {
		var re = RegExp('[&?]' + p + '=([^&]*)');
		var matches;
		if (matches = re.exec(document.location)) {
			try { 
				return decodeURI(matches[1]);
			} catch (e) {
			}
		}
		return null;
	};

//}
// </pre>