Site Notice
hello, world
Difference between revisions of "User:机智的小鱼君/common.js"
From Project-EPB Commons
([InPageEdit] 没有编辑摘要) |
([InPageEdit] 没有编辑摘要) |
||
Line 5: | Line 5: | ||
torev: '1167' | torev: '1167' | ||
}); | }); | ||
+ | 返回数据如下: | ||
<pre> | <pre> | ||
{ | { | ||
Line 29: | Line 30: | ||
"next": 1168, | "next": 1168, | ||
"diffsize": 1862, | "diffsize": 1862, | ||
− | "*": " | + | "*": "这里是diff的表格" |
} | } | ||
} | } |
Revision as of 22:13, 22 November 2019
mw.loader.load('https://common.wjghj.cn/js/InPageEdit-advance');
/**
quickDiff({
fromrev: '984',
torev: '1167'
});
返回数据如下:
<pre>
{
"compare": {
"fromid": 37,
"fromrevid": 984,
"fromns": 2,
"fromtitle": "User:机智的小鱼君/common.js",
"fromsize": 64,
"fromuser": "机智的小鱼君",
"fromuserid": 1,
"fromcomment": "",
"fromparsedcomment": "",
"toid": 37,
"torevid": 1167,
"tons": 2,
"totitle": "User:机智的小鱼君/common.js",
"tosize": 289,
"touser": "机智的小鱼君",
"touserid": 1,
"tocomment": "[InPageEdit] 没有编辑摘要",
"toparsedcomment": "[InPageEdit] 没有编辑摘要",
"prev": 983,
"next": 1168,
"diffsize": 1862,
"*": "这里是diff的表格"
}
}
</pre>
**/
function quickDiff(param) {
if ($('[href*="mediawiki.diff.styles"]').length < 1) {
mw.loader.load(mw.config.get('wgScriptPath') + '/load.php?modules=mediawiki.legacy.shared|mediawiki.diff.styles&only=styles', 'text/css');
}
var date = new Date(),
timestamp = date.getTime(); // 缓存时间戳
ssi_modal.show({
className: 'in-page-edit quick-diff timestamp-' + timestamp,
sizeClass: 'large',
fixedHeight: true,
fitScreen: true,
title: '<span class="pageName">正在加载差异……</span>',
content: '<section class="diffArea"><div class="ipe-progress" style="width:100%"><div class="progress-bar"></div></div></section>'
});
$('.in-page-edit.quick-diff .ipe-progress').css('margin-top', $('.in-page-edit.quick-diff .ipe-progress').parent().parent().height() / 2);
if (param === undefined) param = {};
param.action = 'compare';
param.prop = 'diff|diffsize|rel|ids|title|user|comment|parsedcomment|size';
param.format = 'json';
new mw.Api().get(param).then(function (data) {
var diffTable = data.compare['*'];
var toTitle = data.compare.totitle;
$('.quick-diff .pageName').html('比较差异:<u>'+totitle+'</u>');
$('.quick-diff .diffArea').html(
'<table class="diff diffTable">' +
'<colgroup>' +
'<col class="diff-marker">' +
'<col class="diff-content">' +
'<col class="diff-marker">' +
'<col class="diff-content">' +
'</colgroup>' +
'<tbody>' +
'<tr class="diff-title">' +
'<td colspan="2" class="diff-otitle">diff-otitle</td>' +
'<td colspan="2" class="diff-ntitle">diff-ntitle</td>' +
'</tr>' +
diffTable +
'</tbody>' +
'</table>'
);
}).fail(function () {
$('.diffArea').html('Fail');
});
}