Jump to content

User:TheFearow/ajax.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by TheFearow (talk | contribs) at 22:57, 15 August 2007 (Added move). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
// TheFearow's similair-to-ajax framework for Wikipedia

function createFrame(href){
 var frame = document.createElement('iframe');
 frame.setAttribute('src', href);
 frame.setAttribute('width', '0');
 frame.setAttribute('height', '0');
 frame.setAttribute('style', 'display:none;');
 frame.setAttribute('id', 'tfajaxframe');
 return frame;
}

function addFrame(frame){
 document.childNodes[1].appendChild(frame);
}

function getFrameDocument(){
 return document.getElementByID('tfajaxframe').contentDocument;
}

function finaliseFrame(){
 document.getElementByID('tfajaxframe') = null;
}

function getPageText(pagename){
 var name = unescape(pagename);
 var frame = createFrame(wgServer + wgScript + "?title=" + name + "&action=edit");
 addFrame(frame);
 var doc = getFrameDocument();
 var content = doc.editform.wpTextbox1.value;
 finaliseFrame();
 return content;
}

function editPage(pagename, newtext, summary, minor, watch){
 var name = unescape(pagename);
 var frame = createFrame(wgServer + wgScript + "?title=" + name + "&action=edit");
 addFrame(frame);
 var doc = getFrameDocument();http://en.wikipedia.org/w/index.php?title=User:TheFearow/ajax.js&action=edit
 doc.editform.wpTextbox1.value = newtext;
 doc.editform.wpSummary.value = summary;
 doc.editform.wpMinoredit.value = minor;
 doc.editform.wpWatchthis.value = watch;
 doc.editform.wpSave.click();
 finaliseFrame();
}

function movePage(pagename, newname, reason, watch){
 var name = unescape(pagename);
 var frame = createFrame(wgServer + wgScript + "?title=Special:Movepage/" + name);
 addFrame(frame);
 var doc = getFrameDocument();
 doc.editform.wpNewTitle.value = newname;
 doc.editform.wpReason.value = reason;
 doc.editform.wpWatch.value = watch;
 doc.editform.wpMove.click();
 finaliseFrame();
}