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

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

来自小鱼君和他的朋友们
第6行: 第6行:
 
     $('<a>').attr('href', 'javascript:void(0)').text('查看Fandom代码').click(function () {
 
     $('<a>').attr('href', 'javascript:void(0)').text('查看Fandom代码').click(function () {
 
      ssi_modal.show({
 
      ssi_modal.show({
       content: '<textarea id="getFandomCode" style="width:100%;min-height:350px;" readonly="">正在加载……</textarea>',
+
       content: $('<div>').append(
 +
       $('<textarea>', { style: 'width:100%;min-height:350px;', readonly: true, val: 'Loading...' })
 +
      ),
 
       center: true,
 
       center: true,
 
       title: 'Fandom上的' + pageName,
 
       title: 'Fandom上的' + pageName,
第19行: 第21行:
 
       }],
 
       }],
 
       onShow: function (modal) {
 
       onShow: function (modal) {
 +
       var $modal = $('#' + modal.modalId);
 
        $.ajax({
 
        $.ajax({
 
         url: 'https://epbureau.fandom.com/api.php',
 
         url: 'https://epbureau.fandom.com/api.php',
第36行: 第39行:
 
           wikitext = '<!-- 错误:无法读取Fandom上的同名页面。 -->'
 
           wikitext = '<!-- 错误:无法读取Fandom上的同名页面。 -->'
 
          }
 
          }
          modal.setContent(wikitext);
+
          $modal.find('textarea').val(wikitext);
 
         }
 
         }
 
        });
 
        });

2020年10月1日 (四) 06:09的版本

/** Get Fandom Code **/
$(function () {
  var pageName = mw.config.get('wgPageName');
  $('#p-userpagetools 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;', readonly: true, val: 'Loading...' })
          ),
          center: true,
          title: 'Fandom上的' + pageName,
          buttons: [{
            label: '关闭',
            className: 'btn btn-danger',
            method: function (a, modal) { modal.close() }
          }, {
            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);
              }
            });
          }
        });
      })
    )
  );
});