User:Writ Keeper/Scripts/contribsHistory.js: Difference between revisions

Content deleted Content added
test
fx
 
(9 intermediate revisions by the same user not shown)
Line 1:
diffRequestLocked = "f";
if(mw.config.get("wgCanonicalSpecialPageName") == "Contributions")
{
Line 8:
$("#mw-content-text ul").children("li").each(function(index, element)
{
if($(element).children('[href*="diff=prev"]').length > 0 && !(/(\.js|\.css)$/.test($(element).children('.mw-changeslist-date').attr('title'))))
{
var diffURL = $(element).children('.mw-changeslist-date').attr("href");
var regex = /\?title=(.+)&oldid=(\d+)/.exec(diffURL);
var diffPagediffID = regex[1];
var diffID = regex[2]inlineDiffButton;
if(typeof inlineDiffSmallUI != "undefined")
var inlineDiffButton = document.createElement("input");
{
inlineDiffButton.type = "button";
inlineDiffButton.id = diffPage+document.createElement(";;a"+diffID);
inlineDiffButton.valuehref = "Inspect edit#";
inlineDiffButton.innerHTML = '<b><span style="color:black;">[</span><span style="color:MidnightBlue;">inspect diff</span><span style="color:black;">]</span></b>';
$(inlineDiffButton).click(function(){ inspectContribsDiff(this);});
}
else
{
var inlineDiffButton = document.createElement("input");
inlineDiffButton.type = "button";
inlineDiffButton.value = "Inspect edit";
}
inlineDiffButton.id = diffID;
$(inlineDiffButton).click(function(){ return inspectContribsDiff(this);});
element.appendChild(inlineDiffButton);
}
Line 31 ⟶ 40:
{
alert("An old request is still being processed, please wait...");
return false;
}
else
{
diffRequestLocked = "t";
$.getJSON("/w/api.php?action=query&prop=revisions&format=json&rvprop=timestamp&rvlimit=1&rvstartid="+diffID+"&rvendid="+diffID+"&rvtoken=rollback&rvdiffto=prev&titlesrevids="+diffPagebutton.id, function(response, status){
var regex = /(.+);;(\d+)/.exec(button.id);
var diffPage = regex[1];
var diffID = regex[2];
$.getJSON("/w/api.php?action=query&prop=revisions&format=json&rvprop=timestamp&rvlimit=1&rvstartid="+diffID+"&rvendid="+diffID+"&rvtoken=rollback&rvdiffto=prev&titles="+diffPage, function(response, status){
var diffString = response.query.pages[Object.keys(response.query.pages)[0]].revisions[0].diff["*"];
Line 72 ⟶ 78:
newTable.id = button.id + "display";
$(button).attr("value","Hide edit");
$(button).unbind("click");
if(typeof inlineDiffSmallUI != "undefined")
$(button).click(function(){ hideEditInspection(this);});
{
$(button).html('<b><span style="color:black;">[</span><span style="color:MidnightBlue;">hide diff</span><span style="color:black;">]</span></b>');
$(button).click(function(){ return hideSmallEditInspection(this);});
}
else
{
$(button).attr("value","Hide edit");
$(button).click(function(){ return hideEditInspection(this);});
}
diffRequestLocked = "f";
Line 81 ⟶ 94:
}
return false;
}
Line 88 ⟶ 102:
$(button).attr("value","Hide edit");
$(button).unbind("click");
$(button).click(function(){ return hideEditInspection(this);});
return false;
}
function hideEditInspection( button)
{
$("#"+button.id+"display").css("display", "none");
$(button).attr("value","Show edit");
$(button).unbind("click");
$(button).click(function(){ return showEditInspection(this);});
return false;
}
 
function showSmallEditInspection( button)
{
$("#"+button.id+"display").css("display", "");
$(button).html('<b><span style="color:black;">[</span><span style="color:MidnightBlue;">hide diff</span><span style="color:black;">]</span></b>');
$(button).unbind("click");
$(button).click(function(){ return hideSmallEditInspection(this);});
return false;
}
function hideSmallEditInspection( button)
{
$("#"+button.id+"display").css("display", "none");
$(button).html('<b><span style="color:black;">[</span><span style="color:MidnightBlue;">show diff</span><span style="color:black;">]</span></b>');
$(button).unbind("click");
$(button).click(function(){ return showSmallEditInspection(this);});
return false;
}
 
$(document).ready(addContribsInspectionBoxes);
}