//<pre><nowiki>
//This function sets the selected values on the Confirm protection page
addOnloadHook(WP_PP_helper);
function WP_PP_helper()
{
if (document.title.indexOf('/') !=-1) return;
if (___location.href.search(/&action=/) !=-1) return;
addTab("javascript:addProtectReasons()", "Show reasons", "ca-reasons", "Show reasons", "");
}
//
var li_prot = 0;
function addProtectReasons()
{
if (!document.getElementsByTagName('ul')[0])
{alert('There are no elements in this list.'); return;}
if (!document.getElementsByTagName('ul')[0].getElementsByTagName('li')[0])
{alert('There are no elements in this list.'); return;}
var ls = document.getElementsByTagName('ul')[0].getElementsByTagName('li');
if (document.getElementById('contentSub').innerHTML.indexOf('Inserting log date and reasons for these items.') !=-1)
{alert('Results already shown.'); return;}
document.getElementById('contentSub').innerHTML += '<br>Inserting log date and reasons for these items.<br>';
consec_addReasons();
}
function consec_addReasons()
{
if (document.getElementsByTagName('ul')[0].getElementsByTagName('li')[li_prot])
{
var name = document.getElementsByTagName('ul')[0].getElementsByTagName('li')[li_prot].getElementsByTagName('a')[0].innerHTML;
var URL = '/w/index.php?title=Special:Log&limit=1&type=protect&page=' + escape(name) + '&useskin=standard';
xml_http = HTTPClient();
xml_http.open("GET", URL, true);
xml_http.onreadystatechange = fetch_log_contents;
xml_http.send(null);
}
else
{
document.getElementById('bodyContent').innerHTML = '<strong><span style="color:darkblue;">Log comments and dates inserted</span></strong><br>' + document.getElementById('bodyContent').innerHTML;
var l =document.getElementById('bodyContent').getElementsByTagName('li');
for (var i=0; i<l.length; i++)
{
var title = l[i].getElementsByTagName('a')[0].title;
var href = l[i].getElementsByTagName('a')[0].href;
if (title)
{
l[i].innerHTML = '<a href=javascript:WP_PP_unprotect("' + href.split('/wiki/')[1] + '")><strong>(release)</strong></a> ' + l[i].innerHTML;
}
}
}
}
function fetch_log_contents()
{
if (xml_http.readyState != 4) return;
var Done=0;
var xmlpage = xml_http.responseText.split("<div id='article'>")[1].split('<!-- end content -->')[0];
//UTC done
if (xmlpage.indexOf('<ul>') == -1)
{
document.getElementsByTagName('li')[li_prot].innerHTML += '<span style="color:red;"><strong> (error)</strong></span>';
}
else
{
//Current time
xmlpage = xmlpage.split('<ul>')[1].split('</ul>')[0];
if (xmlpage.indexOf('<li>') == -1)
{
document.getElementsByTagName('li')[li_prot].innerHTML += '<span style="color:red;"><strong> (error)</strong></span>';
}
else
{
var now = new Date();
var curtime = now.toUTCString().replace(/GMT/, "UTC");
var li_html = xmlpage.split('<li>')[1].split('</li>')[0];
var lasttime = li_html.split(' <a href=')[0].split(' <A href=')[0].split('<a href=')[0].split('<A href=')[0];
var totdays = getElapsedTime(curtime,lasttime);
totdays = Math.round((100)*totdays)/100;
var reason = li_html.split('<span class="comment">(')[1].split(')</span>')[0];
reason = reason.split(' [edit=')[0].split(' [move=')[0].split('[edit=')[0].split('[move=')[0];
if ( reason=='' ) reason = 'none given';
document.getElementsByTagName('li')[li_prot].innerHTML += '<br>[<strong>' + totdays + ' days old</strong>] <i>(' + reason + ')</i>';
}
}
li_prot += 1;
consec_addReasons();
}
function WP_PP_unprotect(title)
{
var URL = mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/index.php?title=' + escape(title) + '&action=edit&jsaction=release';
window.open(URL,'WP:AUTOunpro:' + title,'___location=no,toolbar=no,status=no,directories=no,scrollbars=yes,fullscreen=yes');
}
function jssubmitclose()
{
var form = document.getElementById('editform').submit();
form.submit();
}
{
var original = document.editform.wpTextbox1.value;
jstarget = URLEncoding(mw.config.get('wgTitle'));
if(m = document.editform.wpTextbox1.value.match(/\{\{(\w\w-|)semi-protected(2|)\}\}/) )
{
{
alert("Error: There is no recognized protection tag on this page.");
___location.href = 'http://en.wikipedia.org/w/index.php?title=' + mw.config.get('wgTitle').replace(/&/g,"%26") + '&action=protect&jsaction=unprotect';
return;
}
document.editform.wpSummary.value += 'Unprotected page -- removing tag';
document.editform.wpTextbox1.value = document.editform.wpTextbox1.value.replace(whattag,'');
window.open('http://en.wikipedia.org/w/index.php?title=' + mw.config.get('wgTitle').replace(/&/g,"%26") + '&action=protect&jsaction=unprotect' + auto,
'WP:unpro:' + mw.config.get('wgTitle'),
'___location=no,toolbar=no,status=no,directories=no,scrollbars=yes,fullscreen=yes');
jssubmitclose();
}
}
else if (document___location.titlehref.indexOf('Confirm protection&action=protect') !==0-1)
{
var auto = '0';
|