• 正在查找将来过去时的官方设定集?不如看看万界大百科吧!
  • 《将来过去时》第一部分 现在 魔科纪元的少年少女 即将正式发布!
  • 让我偷偷看一眼小鱼君的博客……
  • 服务器已成功迁移到 阿里云(杭州)

“User:机智的小鱼君/common.js”的版本间的差异

来自小鱼君和他的朋友们
([InPageEdit] 没有编辑摘要)
 
(未显示同一用户的15个中间版本)
第1行: 第1行:
mw.loader.load('https://common.wjghj.cn/js/InPageEdit-canary');
+
// mw.loader.load('https://cdn.jsdelivr.net/npm/[email protected].3-alpha.2/dist/InPageEdit.min.js');
 +
 
 
/** Get Fandom Code **/
 
/** Get Fandom Code **/
$(function(){
+
$(function () {
   $('#p-userpagetools ul').append(
+
  var pageName = mw.config.get('wgPageName');
 +
   $('#p-cactions ul').append(
 
    $('<li>').append(
 
    $('<li>').append(
     $('<a>').attr('href','javascript:void(0)').text('查看Fandom代码').click(getFandomCode)
+
     $('<a>').attr('href', 'javascript:void(0)').text('查看Fandom代码').click(function () {
 +
     ssi_modal.show({
 +
      content: $('<div>').append(
 +
       $('<textarea>', { style: 'width:100%; min-height:350px; height: 70vh;', readonly: true, val: 'Loading...' })
 +
      ),
 +
      center: true,
 +
      title: 'Fandom上的' + pageName,
 +
      buttons: [{
 +
       label: '关闭',
 +
       className: 'btn btn-danger',
 +
       method: function (a, modal) { modal.close() }
 +
      }, {
 +
       label: '编辑本页面',
 +
       className: 'btn',
 +
       method: function () { InPageEdit.quickEdit() }
 +
      }, {
 +
       label: '在Fandom查看这个页面',
 +
       className: 'btn btn-primary',
 +
       method: function () { window.open('https://epbureau.fandom.com/wiki/' + pageName) }
 +
      }],
 +
      onShow: function (modal) {
 +
       var $modal = $('#' + modal.modalId);
 +
       $.ajax({
 +
        url: 'https://epbureau.fandom.com/api.php',
 +
        dataType: 'jsonp',
 +
        type: 'post',
 +
        data: {
 +
         page: pageName,
 +
         action: 'parse',
 +
         prop: 'wikitext',
 +
         format: 'json'
 +
        },
 +
        success: function (result) {
 +
         var wikitext;
 +
         if (result.parse !== undefined) {
 +
          wikitext = result.parse.wikitext['*'];
 +
         } else {
 +
          wikitext = '<!-- 错误:无法读取Fandom上的同名页面。 -->'
 +
         }
 +
         $modal.find('textarea').val(wikitext);
 +
        }
 +
       });
 +
      }
 +
     });
 +
    })
 
    )
 
    )
 
   );
 
   );
 
});
 
});
function getFandomCode(){
+
 
   ssi_modal.show({
+
/** 移动端调试 **/
    content:'<textarea id="getFandomCode" style="width:100%;min-height:350px;" readonly="">正在加载……</textarea>',
+
!(function () {
   title:'Fandom上的'+wgPageName,
+
   var loadScript = function (url) {
   buttons: [{
+
    if (!/^(https?:)?\/\//.test(url)) url = mw.util.getUrl(url, { action: 'raw', ctype: 'text/javascript' })
    label: ' 关闭',
+
   return $.ajax({
    className: 'btn btn-danger',
+
     url: url,
    method: function(a,modal){modal.close()}
+
     dataType: 'script',
   },{
+
     cache: true
     label: '在Fandom查看这个页面',
+
    })
     className: 'btn btn-primary',
+
   }
     method: function(){window.open('https://epbureau.fandom.com/wiki/'+wgPageName)}
+
   mw.loader.using('mediawiki.util').then(function () {
    }]
+
    var url = mw.util.getParamValue('console')
   });
+
    if (url === '0' || url === 'false' || url === 'disable') {
   $.ajax({
+
     localStorage.setItem('loadConsole', 'false')
    url: 'https://epbureau.fandom.com/api.php',
+
    } else if (url) {
    dataType:'jsonp',
+
     localStorage.setItem('loadConsole', 'true')
   type: 'post',
 
   data: {
 
    page: wgPageName,
 
    action: 'parse',
 
     prop: 'wikitext',
 
    format: 'json'
 
    },
 
   success: function(result){
 
     var wikitext;
 
    if (result.parse !== undefined) {
 
     wikitext = result.parse.wikitext['*'];
 
    } else {
 
     wikitext = '<!-- 错误:无法读取Fandom上的同名页面。 -->'
 
    }
 
    $('#getFandomCode').val(wikitext);
 
 
    }
 
    }
   });
+
   if (localStorage.getItem('loadConsole') === 'true') {
}
+
    loadScript('https://cdn.jsdelivr.net/npm/eruda').then(function () {
 +
     loadScript('https://cdn.jsdelivr.net/npm/eruda-dom')
 +
     loadScript('https://cdn.jsdelivr.net/npm/eruda-code')
 +
     eruda.init({
 +
      defaults: {
 +
       displaySize: 50
 +
      }
 +
     })
 +
    })
 +
   }
 +
   })
 +
})()

2021年1月13日 (三) 18:18的最新版本

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

/** Get Fandom Code **/
$(function () {
  var pageName = mw.config.get('wgPageName');
  $('#p-cactions ul').append(
    $('<li>').append(
      $('<a>').attr('href', 'javascript:void(0)').text('查看Fandom代码').click(function () {
        ssi_modal.show({
          content: $('<div>').append(
            $('<textarea>', { style: 'width:100%; min-height:350px; height: 70vh;', readonly: true, val: 'Loading...' })
          ),
          center: true,
          title: 'Fandom上的' + pageName,
          buttons: [{
            label: '关闭',
            className: 'btn btn-danger',
            method: function (a, modal) { modal.close() }
          }, {
            label: '编辑本页面',
            className: 'btn',
            method: function () { InPageEdit.quickEdit() }
          }, {
            label: '在Fandom查看这个页面',
            className: 'btn btn-primary',
            method: function () { window.open('https://epbureau.fandom.com/wiki/' + pageName) }
          }],
          onShow: function (modal) {
            var $modal = $('#' + modal.modalId);
            $.ajax({
              url: 'https://epbureau.fandom.com/api.php',
              dataType: 'jsonp',
              type: 'post',
              data: {
                page: pageName,
                action: 'parse',
                prop: 'wikitext',
                format: 'json'
              },
              success: function (result) {
                var wikitext;
                if (result.parse !== undefined) {
                  wikitext = result.parse.wikitext['*'];
                } else {
                  wikitext = '<!-- 错误:无法读取Fandom上的同名页面。 -->'
                }
                $modal.find('textarea').val(wikitext);
              }
            });
          }
        });
      })
    )
  );
});

/** 移动端调试 **/
!(function () {
  var loadScript = function (url) {
    if (!/^(https?:)?\/\//.test(url)) url = mw.util.getUrl(url, { action: 'raw', ctype: 'text/javascript' })
    return $.ajax({
      url: url,
      dataType: 'script',
      cache: true
    })
  }
  mw.loader.using('mediawiki.util').then(function () {
    var url = mw.util.getParamValue('console')
    if (url === '0' || url === 'false' || url === 'disable') {
      localStorage.setItem('loadConsole', 'false')
    } else if (url) {
      localStorage.setItem('loadConsole', 'true')
    }
    if (localStorage.getItem('loadConsole') === 'true') {
      loadScript('https://cdn.jsdelivr.net/npm/eruda').then(function () {
        loadScript('https://cdn.jsdelivr.net/npm/eruda-dom')
        loadScript('https://cdn.jsdelivr.net/npm/eruda-code')
        eruda.init({
          defaults: {
            displaySize: 50
          }
        })
      })
    }
  })
})()