MediaWiki:Common.js:修订间差异

无编辑摘要
无编辑摘要
 
第1行: 第1行:
/* 命令复制功能 */
/* 这里的任何JavaScript将为所有用户在每次页面载入时加载。 */
$("table .copyBtn").click(function () {
/* -- 为页面加载JS脚本或CSS样式表 -- */
   let index = $("table .copyBtn").index(this);
/* 参见[[模板:ResourceLoader]]*/
   let preArray = $("table pre");
/* 来源:碧蓝航线WIKI*/
   let preEle = preArray[index];
$('.resourceLoader').each(function () {
   window.getSelection().selectAllChildren(preEle);
   var $x = $(this);
   document.execCommand("Copy");
  var text = $.trim($x.text());
   alert("复制成功,可直接粘贴");
 
   console.log("已经复制");
  if (!text) return;
 
  //加载模块
  if ($x.data('isModule') === true)
    return mw.loader.load(text);
 
  //自动补充MediaWiki命名空间
  var ns = text.match('^.*?:');
   if (!ns) text = 'MediaWiki:' + text;
 
  //加载CSS样式表
  var mime = ($x.data('mime') || "text/javascript").toLowerCase();
   if (mime == "text/css") {
    if (text.slice(-4).toLowerCase() !== '.css') text = text + '.css';
    //if ($x.data('debug') !== true) text = text + '&debug=false';
    return mw.loader.load("//wiki.17173.com/afkjourney/index.php?title=" + text + "&action=raw&ctype=text/css", "text/css");
   }
 
  //加载JS脚本
  if (ns && ns[0].toLowerCase() !== 'mediawiki:') {
    return console.log('ResourceLoader: 不允许加载MediaWiki以外的js脚本');
   }
  if (text.slice(-3).toLowerCase() !== '.js') text = text + '.js';
   //if ($x.data('debug') !== true) text = text + '&debug=false';
   return mw.loader.load("//wiki.17173.com/afkjourney/index.php?title=" + text + "&action=raw&ctype=text/javascript", "text/javascript");
});
});

2024年8月5日 (一) 14:34的最新版本

/* 这里的任何JavaScript将为所有用户在每次页面载入时加载。 */
/* -- 为页面加载JS脚本或CSS样式表 -- */
/* 参见[[模板:ResourceLoader]]*/
/* 来源:碧蓝航线WIKI*/
$('.resourceLoader').each(function () {
  var $x = $(this);
  var text = $.trim($x.text());

  if (!text) return;

  //加载模块
  if ($x.data('isModule') === true)
    return mw.loader.load(text);

  //自动补充MediaWiki命名空间
  var ns = text.match('^.*?:');
  if (!ns) text = 'MediaWiki:' + text;

  //加载CSS样式表
  var mime = ($x.data('mime') || "text/javascript").toLowerCase();
  if (mime == "text/css") {
    if (text.slice(-4).toLowerCase() !== '.css') text = text + '.css';
    //if ($x.data('debug') !== true) text = text + '&debug=false';
    return mw.loader.load("//wiki.17173.com/afkjourney/index.php?title=" + text + "&action=raw&ctype=text/css", "text/css");
  }

  //加载JS脚本
  if (ns && ns[0].toLowerCase() !== 'mediawiki:') {
    return console.log('ResourceLoader: 不允许加载MediaWiki以外的js脚本');
  }
  if (text.slice(-3).toLowerCase() !== '.js') text = text + '.js';
  //if ($x.data('debug') !== true) text = text + '&debug=false';
  return mw.loader.load("//wiki.17173.com/afkjourney/index.php?title=" + text + "&action=raw&ctype=text/javascript", "text/javascript");
});