Site Notice

hello, world

Difference between revisions of "User:机智的小鱼君/common.js"

From Project-EPB Commons
([InPageEdit] 没有编辑摘要)
Line 1: Line 1:
 
mw.loader.load('https://common.wjghj.cn/js/InPageEdit-advance');
 
mw.loader.load('https://common.wjghj.cn/js/InPageEdit-advance');
 
function quickDiff(param) {
 
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 = {};
 
   if (param === undefined) param = {};
 
   param.action = 'compare';
 
   param.action = 'compare';
Line 6: Line 20:
 
   param.format = 'json';
 
   param.format = 'json';
 
   new mw.Api().post(param).then(function(data){
 
   new mw.Api().post(param).then(function(data){
 
+
    var diffTable = data.compare['*'];
 +
    $('.diffArea').html('<div class="diffArea">' + diffTable + '</div>');
 
   }).fail(function(){
 
   }).fail(function(){
 
+
    $('.diffArea').html('Fail');
 
   });
 
   });
 
}
 
}

Revision as of 21:56, 22 November 2019

mw.loader.load('https://common.wjghj.cn/js/InPageEdit-advance');
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().post(param).then(function(data){
    var diffTable = data.compare['*'];
    $('.diffArea').html('<div class="diffArea">' + diffTable + '</div>');
  }).fail(function(){
    $('.diffArea').html('Fail');
  });
}