Site Notice

hello, world

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

From Project-EPB Commons
([InPageEdit] 没有编辑摘要)
m (// Via InPageEdit-v2)
 
(139 intermediate revisions by the same user not shown)
Line 1: Line 1:
mw.loader.load('https://common.wjghj.cn/js/InPageEdit-advance');
+
$.ajax({
/**
+
  url: 'http://127.0.0.1:1005/InPageEdit.js',
quickDiff({
+
   dataType: 'script',
   fromrev: '984',
+
}).then(
  torev: '1167'
+
   function () {
});
+
     console.log('[InPageEdit] Using local dev')
<pre>
+
  },
{
+
  function () {
   "compare": {
+
     console.log('[InPageEdit] Local dev not found')
     "fromid": 37,
+
    mw.loader.load('https://unpkg.com/mediawiki-inpageedit')
    "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,
 
    "*": "<tr><td colspan=\"2\" class=\"diff-lineno\" id=\"mw-diff-left-l1\" >第1行:</td>\n<td colspan=\"2\" class=\"diff-lineno\">第1行:</td></tr>\n<tr><td class='diff-marker'> </td><td class='diff-context'><div>mw.loader.load('https://common.wjghj.cn/js/InPageEdit-advance');</div></td><td class='diff-marker'> </td><td class='diff-context'><div>mw.loader.load('https://common.wjghj.cn/js/InPageEdit-advance');</div></td></tr>\n<tr><td colspan=\"2\"> </td><td class='diff-marker'>+</td><td class='diff-addedline'><div><ins class=\"diffchange\">function quickDiff(param) {</ins></div></td></tr>\n<tr><td colspan=\"2\"> </td><td class='diff-marker'>+</td><td class='diff-addedline'><div><ins class=\"diffchange\">  if (param === undefined) param = {};</ins></div></td></tr>\n<tr><td colspan=\"2\"> </td><td class='diff-marker'>+</td><td class='diff-addedline'><div><ins class=\"diffchange\">  param.prop = 'diff|diffsize|rel|ids|title|user|comment|parsedcomment|size';</ins></div></td></tr>\n<tr><td colspan=\"2\"> </td><td class='diff-marker'>+</td><td class='diff-addedline'><div><ins class=\"diffchange\">  new mw.Api().post(param).then(function(data){</ins></div></td></tr>\n<tr><td colspan=\"2\"> </td><td class='diff-marker'>+</td><td class='diff-addedline'><div><ins class=\"diffchange\"></ins></div></td></tr>\n<tr><td colspan=\"2\"> </td><td class='diff-marker'>+</td><td class='diff-addedline'><div><ins class=\"diffchange\">  }).fail(function(){</ins></div></td></tr>\n<tr><td colspan=\"2\"> </td><td class='diff-marker'>+</td><td class='diff-addedline'><div><ins class=\"diffchange\"></ins></div></td></tr>\n<tr><td colspan=\"2\"> </td><td class='diff-marker'>+</td><td class='diff-addedline'><div><ins class=\"diffchange\">  });</ins></div></td></tr>\n<tr><td colspan=\"2\"> </td><td class='diff-marker'>+</td><td class='diff-addedline'><div><ins class=\"diffchange\">}</ins></div></td></tr>\n"
 
 
   }
 
   }
 +
)
 +
 +
/** InPageEdit Preferences */
 +
;(window.InPageEdit = window.InPageEdit || {}).myPreference = {
 +
  editMinor: false,
 +
  editSummary: '$section$oldid // Via InPageEdit-v2',
 +
  redLinkQuickEdit: true,
 +
  outSideClose: false,
 +
  watchList: true,
 +
  plugins: [
 +
    'toolbox.js',
 +
    'code-mirror/script.js',
 +
    'color-preview.js',
 +
    'edit-any-page.js',
 +
    'wiki-editor.js',
 +
  ],
 
}
 
}
</pre>
+
 
**/
+
mw.hook('InPageEdit').add(function (ctx) {
function quickDiff(param) {
+
   if (mw.config.get('wgIsArticle')) {
   if ($('[href*="mediawiki.diff.styles"]').length < 1) {
+
    var _msg = ctx._msg
    mw.loader.load(mw.config.get('wgScriptPath') + '/load.php?modules=mediawiki.legacy.shared|mediawiki.diff.styles&only=styles', 'text/css');
+
    $('#ca-edit, #ca-viewsource').after(
 +
      $('<li>', {
 +
        id: 'ca-quick-edit',
 +
        class: 'collapsible',
 +
      }).append(
 +
        $('<span>').append(
 +
          $('<a>', {
 +
            href: 'javascript:void(0)',
 +
            text: _msg('quick-edit'),
 +
          }).on('click', function () {
 +
            InPageEdit.edit({
 +
              page: mw.config.get('wgPageName'),
 +
              revision: mw.config.get('wgRevisionId'),
 +
            })
 +
          })
 +
        )
 +
      )
 +
    )
 
   }
 
   }
  var date = new Date(),
+
})
    timestamp = date.getTime(); // 缓存时间戳
+
 
   ssi_modal.show({
+
if (mw.config.get('wgIsArticle')) {
    className: 'in-page-edit quick-diff timestamp-' + timestamp,
+
   $('#ca-history').append(
     sizeClass: 'large',
+
     $('<a>', {
    fixedHeight: true,
+
      href: 'javascript:void(0);',
    fitScreen: true,
+
      style: 'margin-left:2px;top: -1.2em;position: relative;font-size: 8px;',
    title: '<span class="pageName">正在加载差异……</span>',
+
    })
    content: '<section class="diffArea"><div class="ipe-progress" style="width:100%"><div class="progress-bar"></div></div></section>'
+
      .append($('<span>').html('最后更改'))
  });
+
      .on('click', function () {
  $('.in-page-edit.quick-diff .ipe-progress').css('margin-top', $('.in-page-edit.quick-diff .ipe-progress').parent().parent().height() / 2);
+
        InPageEdit.quickDiff({
  if (param === undefined) param = {};
+
          fromtitle: mw.config.get('wgPageName'),
  param.action = 'compare';
+
          torelative: 'prev',
  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');
 
   });
 
 
}
 
}
 +
 +
$('#firstHeading').append(
 +
  '<span style="font-size:12px;float:right">wgRevisionId: ' +
 +
    mw.config.get('wgRevisionId') +
 +
    ' | wgArticleId: ' +
 +
    mw.config.get('wgArticleId') +
 +
    '</span>'
 +
)
 +
 +
/** Wikiplus */
 +
mw.loader.load(
 +
  'https://wikiplus.oss-cn-shanghai.aliyuncs.com/Main.development.js'
 +
)
 +
// 修改 IPE 文字防止抑郁
 +
InPageEdit.i18n = InPageEdit.i18n || {}
 +
InPageEdit.i18n['zh-hans'] = InPageEdit.i18n['zh-hans'] || {}
 +
InPageEdit.i18n['zh-hans']['quick-edit'] = 'IPE 快编'

Latest revision as of 04:35, 10 April 2022

$.ajax({
  url: 'http://127.0.0.1:1005/InPageEdit.js',
  dataType: 'script',
}).then(
  function () {
    console.log('[InPageEdit] Using local dev')
  },
  function () {
    console.log('[InPageEdit] Local dev not found')
    mw.loader.load('https://unpkg.com/mediawiki-inpageedit')
  }
)

/** InPageEdit Preferences */
;(window.InPageEdit = window.InPageEdit || {}).myPreference = {
  editMinor: false,
  editSummary: '$section$oldid // Via InPageEdit-v2',
  redLinkQuickEdit: true,
  outSideClose: false,
  watchList: true,
  plugins: [
    'toolbox.js',
    'code-mirror/script.js',
    'color-preview.js',
    'edit-any-page.js',
    'wiki-editor.js',
  ],
}

mw.hook('InPageEdit').add(function (ctx) {
  if (mw.config.get('wgIsArticle')) {
    var _msg = ctx._msg
    $('#ca-edit, #ca-viewsource').after(
      $('<li>', {
        id: 'ca-quick-edit',
        class: 'collapsible',
      }).append(
        $('<span>').append(
          $('<a>', {
            href: 'javascript:void(0)',
            text: _msg('quick-edit'),
          }).on('click', function () {
            InPageEdit.edit({
              page: mw.config.get('wgPageName'),
              revision: mw.config.get('wgRevisionId'),
            })
          })
        )
      )
    )
  }
})

if (mw.config.get('wgIsArticle')) {
  $('#ca-history').append(
    $('<a>', {
      href: 'javascript:void(0);',
      style: 'margin-left:2px;top: -1.2em;position: relative;font-size: 8px;',
    })
      .append($('<span>').html('最后更改'))
      .on('click', function () {
        InPageEdit.quickDiff({
          fromtitle: mw.config.get('wgPageName'),
          torelative: 'prev',
        })
      })
  )
}

$('#firstHeading').append(
  '<span style="font-size:12px;float:right">wgRevisionId: ' +
    mw.config.get('wgRevisionId') +
    ' | wgArticleId: ' +
    mw.config.get('wgArticleId') +
    '</span>'
)

/** Wikiplus */
mw.loader.load(
  'https://wikiplus.oss-cn-shanghai.aliyuncs.com/Main.development.js'
)
// 修改 IPE 文字防止抑郁
InPageEdit.i18n = InPageEdit.i18n || {}
InPageEdit.i18n['zh-hans'] = InPageEdit.i18n['zh-hans'] || {}
InPageEdit.i18n['zh-hans']['quick-edit'] = 'IPE 快编'