/* <pre><nowiki> */
var fsection = '0';
var aclass;
var iclass;
function doQft(iclass) {
if (!iclass) {
aclass = prompt('Type Class:');
if (!aclass) {
return;
}
} else {
aclass = iclass;
}
/*
var nurl = 'http://en.wikipedia.org/w/index.php?title=Talk:' + getPname() + '&action=edit' + '§ion=' + section;
document.location = nurl;
*/
document.getElementById('bodyContent').innerHTML = 'Please wait' + '...';
gml_xmlhttp = HTTPClient();
if (!gml_xmlhttp) {
return;
}
document.getElementById('bodyContent').innerHTML += '<br />Grabbing page...';
gml_xmlhttp.open('GET', 'http://en.wikipedia.org/w/index.php?title=Talk:' + getPname() + '&action=edit' + '§ion=' + fsection + '', true);
gml_xmlhttp.onreadystatechange = doQft_more;
gml_xmlhttp.send(null);
}
function doQft_more() {
if (gml_xmlhttp.readyState != 4){
document.getElementById('bodyContent').innerHTML += '.';
return
}
var form, newform, l;
doc = gml_XMLParse(gml_xmlhttp.responseText);
form = doc.getElementById('editform');
var x;
var t = form.wpTextbox1.value;
myArray = t.split(" ");
var addClass;
addClass = false;
document.getElementById('bodyContent').innerHTML += '<br />Searching for existing tag...';
var testTag = "{{FilmsWikiProject}}";
for (x in myArray) {
myArray2 = myArray[x].split(/\n/);
for (y in myArray2) {
if (myArray2[y] == testTag) {
addClass = true;
}
}
}
if (addClass == true) {
document.getElementById('bodyContent').innerHTML += '<br />Adding class to FilmsWikiProject tag...';
} else {
document.getElementById('bodyContent').innerHTML += '<br />FilmsWikiProject Tag already modified...';
return;
}
allData = form.wpTextbox1.value;
form.wpTextbox1.value = allData.replace(/{{FilmsWikiProject}}/, "{{FilmsWikiProject|class="+aclass+"}}");
//alert("Test Data:" + form.wpTextbox1.value);
form.wpSummary.value = 'Changed {{FilmsWikiProject}} tag with a class';
newform = document.createElement('form');
l = form.getElementsByTagName('textarea');
for (i = l.length; i--; ) {
var t = document.createElement('input');
t.type = 'hidden';
t.name = l[i].name;
t.value = l[i].value;
newform.appendChild(t);
}
l = form.getElementsByTagName('input');
for (i = l.length; i--; ) {
if (l[i].name == 'wpSummary') {
l[i].value = 'Changed {{FilmsWikiProject}} tag with a class';
} else if (l[i].name == 'wpMinoredit') {
l[i].value = '1';
} else if (l[i].name == 'wpWatchthis') {
if (!l[i].checked) {
continue;
}
l[i].value = "on";
} else if (l[i].name == 'wpPreview') {
continue;
} else if (l[i].name == 'wpDiff') {
continue;
}
l[i].type = 'hidden';
newform.appendChild(l[i]);
}
newform.name = form.name;
newform.method = form.method;
newform.id = form.id;
newform.action = form.action;
document.getElementById('bodyContent').innerHTML += '<br />Submitting form...';
document.getElementById('bodyContent').appendChild(newform);
// Submit the form
newform.submit();
}
/* </nowiki></pre> */