Site Notice

hello, world

User:机智的小鱼君/common.js

From Project-EPB Commons
< User:机智的小鱼君
Revision as of 04:35, 10 April 2022 by 机智的小鱼君 (talk | contribs) (// Via InPageEdit-v2)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


Note: After saving, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Go to Menu → Settings (Opera → Preferences on a Mac) and then to Privacy & security → Clear browsing data → Cached images and files.
$.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 快编'