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

Content deleted Content added
honestly don't even need the extra spacer
more modernizations
Line 1:
$mw.hook(document'wikipage.content').readyadd(function()
{
if(mw.config.get("wgAction") === "edit" || mw.config.get("wgAction") === "submit" )
Line 7:
mw.loader.load('mediawiki.action.history.diff');
$("#wikiPreview").before('<h2>Your changes</h2><table class="diff" id="ajaxDiff"><colgroup><col class="diff-marker"><col class="diff-content"><col class="diff-marker"><col class="diff-content"></colgroup></table>');
var requestString="/w/api.php";
var requestDatadiffData = {action:"query", prop:"revisions", format:"json", rvcontentformat:"text/x-wiki", revids:$("input[name='baseRevId']").attr("value"), rvdifftotext:$("textarea#wpTextbox1").text()};
if(var wpSectionElement = $("input[name='wpSection']").attr("value") !== "");
if(typeof wpSectionElement.attr("value") !== "undefined")
{
requestDatadiffData.rvsection = $("input[name='wpSection']")wpSectionElement.attr("value");
}
var mwApi = new mw.Api();
$.post(requestString, requestData, function(response, status)
mwApi.get(diffData).done(function (response)
{
$("#ajaxDiff").append(response.query.pages[Object.keys(response.query.pages)[0]].revisions[0].diff["*"]);