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

“MediaWiki:Common.js”的版本间的差异

来自小鱼君和他的朋友们
([InPageEdit] 没有编辑摘要)
第44行: 第44行:
 
  * Apache licenses https://www.echartsjs.com
 
  * Apache licenses https://www.echartsjs.com
 
  **/
 
  **/
$(async function () {
+
 
 +
$(function () {
 
   if ($('.echarts, .ECharts, .Echarts').length > 0) {
 
   if ($('.echarts, .ECharts, .Echarts').length > 0) {
    await mw.loader.load('https://cdn.bootcss.com/echarts/4.4.0-rc.1/echarts.min.js'); // ECharts CDN
+
    $('body').apend(
   $('.echarts, .ECharts, .Echarts').each(function () {
+
    $('<script>',{ src: 'https://cdn.bootcss.com/echarts/4.4.0-rc.1/echarts.min.js' })
     var $this = $(this),
+
    .load(()=>{
      option = eval("(" + $this.text() + ")"),
+
     $('.echarts, .ECharts, .Echarts').each(function () {
      echartsElement = 'echartsElement-' + $this.index();
+
      var $this = $(this),
     $this.attr({ 'id': echartsElement });
+
       option = eval("(" + $this.text() + ")"),
     echarts.init(document.getElementById(echartsElement)).setOption(option);
+
       echartsElement = 'echartsElement-' + $this.index();
     });
+
      $this.attr({ 'id': echartsElement });
 +
      echarts.init(document.getElementById(echartsElement)).setOption(option);
 +
     });
 +
     })
 +
   );
 
   }
 
   }
 
});
 
});

2020年6月21日 (日) 07:00的版本

/** 分享按钮 **/
mw.loader.load('/index.php?title=MediaWiki:Share-btn.js&action=raw&ctype=text/javascript');

/** ssi-modal **/
mw.loader.load('https://cdn.bootcss.com/ssi-modal/1.0.27/js/ssi-modal.min.js');
mw.loader.load('https://cdn.bootcss.com/ssi-modal/1.0.27/styles/ssi-modal.min.css','text/css');

/** 版权提示 **/
mw.loader.load('/index.php?title=MediaWiki:NotifyWhenCopy.js&action=raw&ctype=text/javascript');

/** 外部链接 **/
mw.loader.using(['oojs-ui-windows', 'oojs-ui-core'],
function() {
  $('a.external').each(function() {
    var href = $(this).attr('href'),
        href1 = href.split('/')[2];
    if (href1.substring(href1.length-8) === 'wjghj.cn') return;
    $(this).click(function(e) {
      e.preventDefault();
      OO.ui.confirm('你确定要访问这个外部链接吗: ' + href).done(function(confirmed) {
        if (confirmed) {
          location.href = href;
        }
      });
    });
  });
});

/** Code Prettyprint **/
$(function(){
  var pagename = mw.config.get('wgPageName');
  if ( pagename.substr(pagename.length-3,3) === '.js' ) {
    $('#mw-content-text pre').addClass('prettyprint lang-js linenums');
  } else if ( pagename.substr(pagename.length-4,4) === '.css' ) {
    $('#mw-content-text pre').addClass('prettyprint lang-css linenums');
  }
  mw.loader.load('https://common.wjghj.cn/js/prettify');
  mw.loader.load('https://common.wjghj.cn/css/prettify','text/css');
});

/**
 * ECharts
 * Put ECharts on wiki pages
 * Apache licenses https://www.echartsjs.com
 **/

$(function () {
  if ($('.echarts, .ECharts, .Echarts').length > 0) {
    $('body').apend(
      $('<script>',{ src: 'https://cdn.bootcss.com/echarts/4.4.0-rc.1/echarts.min.js' })
      .load(()=>{
        $('.echarts, .ECharts, .Echarts').each(function () {
          var $this = $(this),
            option = eval("(" + $this.text() + ")"),
            echartsElement = 'echartsElement-' + $this.index();
          $this.attr({ 'id': echartsElement });
          echarts.init(document.getElementById(echartsElement)).setOption(option);
        });
      })
    );
  }
});

/** Global script (gtag.js) - Google Analytics **/
mw.loader.load('https://www.googletagmanager.com/gtag/js?id=UA-148909815-1');
$(window).load(function(){
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'UA-148909815-1');
});

/** 方便上传相册缺少的图片 **/
$('.gallery .thumb').prepend(function () {
  var galleryfile = $(this).text();
  if (galleryfile == '') {
    return;
  } else {
    $(this).html('<a href="https://wjghj.cn/index.php?title=Special:Upload&wpDestFile='+galleryfile+'" class="new" target="_blank">点击上传<br/>' + galleryfile + '</a>')
  }
});

/** In page dialog **/
$(function () {
  var DialogId,
  BtnId,
  NextId,
  LastId;
  $('.ipd').html(function () {
    DialogId = this.dataset.dialogid;
    if (DialogId != '1') {
      $(this).hide();
    }
  });
  $('.ipd-next-btn').click(function () {
    BtnId = this.dataset.btnid;
    LastId = this.dataset.lastid;
    if (LastId === 'last') {
      $('#game-selector').show(300);
      $(this).css('color', 'green');
    } else {
      BtnId = parseInt(BtnId);
      NextId = ++BtnId;
      $(this).css('color', 'green');
      $('.ipd[data-dialogid=' + NextId + ']').show(300);
    }
  });
});

/** Game saver **/
$('.GameSaver').html(function(){
  var game,time,user,title,page;
  if ( wgUserName =='' || wgUserName == null ) {
    unlogin = true ;
  } else {
    user = 'User:'+wgUserName ;
}
  game = this.dataset.game;
  time = this.dataset.time;
  title = this.dataset.title;
  page = this.dataset.page;
  $(this).html('<input type=button class="save" value="保存游戏"/>&nbsp;&nbsp;<input type=button class="load" value="读取存档"/>');
  if ( unlogin ) {
    $('.GameSaver .load').click(function(){alert('无法读取存档,请登录后再试');});
  } else {
    $('.GameSaver .load').click(function(){location.href='/wiki/'+user+'/gamesave/'+game});
  }
  $('.GameSaver .save').click(function() {
    if ( unlogin ) {
      $('.GameSaver .save').unbind().attr({'value':'存档失败,请登录后再试','disabled':''});
      return;
    }
    var note = prompt('有什么要备注的吗?','无');
    if (note === null||note === 'null') {
      return;
    }
    $('.GameSaver .save').attr('value','SILI努力帮你存档中…');
    new mw.Api().post({
      action: 'edit',
      title: user+'/gamesave/'+game,
      summary: '\/*' + title+' | '+ time +'*\/新增游戏'+ game +'存档',
      appendtext: '\n== '+ title +' | '+ time +' ==\n*游戏:[[Game:'+ game +']]\n*时间:'+ time +'\n*[['+ page +'|继续游戏]]\n*备注:'+ note +'\n\n',
      token: mw.user.tokens.get('editToken')
    })
    .done(function(){
      $('.GameSaver .save').unbind().attr({'value':'存档完毕!','disabled':''});
    })
    .fail(function(){
      alert('啊哦,存档失败了!\n1)请检查您的网络连接?\n2)您是否没有登录?\n3)刷新页面再试?');
      $('.GameSaver .save').attr('value','重试');
    });
  });
});

/** 顶部公告 **/
function siteNoticeScroll(obj,interval) {
  $(obj).animate({
    height: 'show',
    paddingTop: 'show',
    marginTop: 'show',
    paddingBottom: 'show',
    marginBottom: 'show',
  });
  setInterval(function() {
    $(obj).find('ul:first').animate({
      marginTop: '-25px'
    },
    300,
    function() {
      $(this).css({
        marginTop: '0px',
      }).find('li:first').appendTo(this);
    });
  },
  interval);
}
siteNoticeScroll('.siteNoticeScroll',5000);

/** 头像系统 **/
$(function() {
  $('#personal h2').prepend($('<a>', {
    href: '/wiki/Special:Uploadavatar',
    class: 'user-avatar-link',
  }).click(function(e){
    href = $(this).attr('href');
    e.preventDefault();
    if ($(window).width() > 1100) {
      location.href = href;
    }
  }).append($('<img>', {
    src: '/avatar/' + mw.config.get('wgUserName'),
    class: 'user-avatar'
  })));
  $('.mw-userlink').before(function() {
    var user = $(this).attr('title'),
    avatar = $('<img>', {
      src: '/avatar/' + user,
      class: 'user-avatar'
    });
    return avatar;
  });
});

//ALL CLEAR