This article will address the topic of
User:Quarl/diffsince.js, an issue of great relevance today that has gained great importance in different areas.
User:Quarl/diffsince.js is a topic that has aroused the interest of both experts and society in general, since its impact is significant in various aspects of daily life. Along these lines, the importance of
User:Quarl/diffsince.js, its implications and possible solutions, as well as its influence on current society, will be analyzed in depth. In addition, different perspectives on this topic will be examined, with the aim of offering a comprehensive vision that allows us to better understand its scope and significance.
// ] - utility functions for doing a "diff since I
// last edited"
// depends: wikipage.js, util.js
// Synopsis:
// url = diffsince.makeUrl(wikiPage);
// href = '<a onclick="javascript:diffsince.diffThis()" href="'+url+'">diff since</a>';
// Or:
// url = diffsince.makeUrl(wp);
// href = '<a onclick="javascript:diffsince.diffPageAsync(wp)" href="'+url+'">diff since</a>';
// Navigating to the value of makeUrl will open a history page, parse it, and
// jump to the appropriate diff.
// The diffPageAsync() function asynchronously downloads the history page and
// then navigates to the diff. It is appropriate as an onClick handler.
// The diffThis() function does the diff directly if already looking at a
// history page, else calls diffPageAsync(wikiPage).
// diffPageAsync and diffThis take status_node and status_text parameters for
// showing progress.
// quarl 2006-01-16 (asynchronous code originally written in show_diff_since.js)
// quarl 2006-02-03 factored as library
// <pre><nowiki>
var diffsince = new Object();
diffsince.historyLimit = ;
// return a URL that points to a "fakeaction" page for doing a diff.
diffsince.makeUrl = function(wp) {
return wp.qurl + '&fakeaction=diffsince&action=history&limit='+diffsince.historyLimit;
}
diffsince._load = function() {
if (WikiPage.queryVars.fakeaction == 'diffsince') {
diffsince._parseHistory(document);
}
}
diffsince.diffPageAsync = function(wp, statusNode, statusText) {
var url = wp.qurl + '&action=history&limit='+diffsince.historyLimit;
var req = new XMLHttpRequest();
// change the button to show the user we're doing something and
// prevent another click
buttonShowStatus(statusNode, statusText); // (statusNode, statusText are optional)
asyncDownloadXML(url, diffsince._handleHistoryPage,
{ statusNode: statusNode });
return false;
}
diffsince.diffThis = function(statusNode, statusText) {
if (wikiDoc.historyP) {
// already looking at a history page
diffsince._parseHistory(document);
} else {
// not yet a history page -- asynchronously download it first
diffsince.diffPageAsync(wikiPage, statusNode, statusText);
}
return false;
}
diffsince._handleHistoryPage = function(req) {
// restore button in case this fails, so user can click again
buttonRestoreStatus(req.statusNode);
if (req.status == 200) {
diffsince._parseHistory(req.responseXML);
} else {
alert("Error downloading history page!");
}
}
diffsince._parseHistory = function(doc) {
if (!doc) { alert ("## no doc?!"); return; }
var hists = doc.getElementById("pagehistory").childNodes;
if (!hists) { alert("Couldn't parse history from page"); return; }
for (n=0;n<hists.length;n++) {
// window.username is defined in wikipage.js
if (hists.getElementsByTagName &&
hists.getElementsByTagName("span").textContent==wikiDoc.username)
{
document.location = hists.childNodes.href;
return;
}
}
alert("diffsince: Couldn't find your entry in the history page; you haven't edited recently!");
// TODO: retry with a larger limit
}
$(diffsince._load);
// </nowiki></pre>