Site Notice

hello, world

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

From Project-EPB Commons
([InPageEdit] 没有编辑摘要)
Line 69: Line 69:
 
}());
 
}());
  
 
+
mw.loader.load('/index.php?action=raw&ctype=text/javascript&title=User:机智的小鱼君/js/asyncTest.js')
/******/ !(function() { // webpackBootstrap
 
/*!******************!*\
 
  !*** ./index.js ***!
 
  \******************/
 
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
 
 
 
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
 
 
 
window.asyncTest = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
 
  var a;
 
  return regeneratorRuntime.wrap(function _callee$(_context) {
 
    while (1) {
 
      switch (_context.prev = _context.next) {
 
        case 0:
 
          console.log('async test start');
 
 
 
          a = function a() {
 
            console.log('a()');
 
            return new Promise(function (resolve) {
 
              setTimeout(function () {
 
                resolve();
 
              }, 3000);
 
            });
 
          };
 
 
 
          console.log('await a()');
 
          _context.next = 5;
 
          return a();
 
 
 
        case 5:
 
          console.log('a() done');
 
 
 
        case 6:
 
        case "end":
 
          return _context.stop();
 
      }
 
    }
 
  }, _callee);
 
}));
 
/******/ })()
 
;
 

Revision as of 21:08, 27 December 2020

mw.loader.load('https://cdn.jsdelivr.net/npm/[email protected]/dist/InPageEdit.min.js');

/** InPageEdit Preferences **/
window.InPageEdit = window.InPageEdit || {}; // Keep this line
InPageEdit.myPreference = {
  "editMinor": false,
  "editSummary": "[InPageEdit] $section 没有编辑摘要 $oldid",
  "redLinkQuickEdit": true,
  "watchList": true,
  "plugins": [
    "toolbox.js",
    "edit-any-page.js",
    "color-preview.js"
  ]
}
InPageEdit.buttons =[{
  open: '<-- ', // 添加到光标前的内容
  middle: '注释文字', // 选区内容占位符,选填
  close: ' -->', // 添加到光标后的内容
  text: '<span class="material-icons">description</span>' // 按钮文字,被解析为html
}, { // 再举个栗子
  open: '<s>',
  middle: '删除线',
  close: '</s>',
  text: '<span class="material-icons">strikethrough_s</span>'
}];

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')
            }).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('最后更改')
    ).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>');

!(function(){
  // $.getScript('https://cdn.jsdelivr.net/npm/[email protected]/dist/vconsole.min.js',function(){new VConsole();});
}());

mw.loader.load('/index.php?action=raw&ctype=text/javascript&title=User:机智的小鱼君/js/asyncTest.js')