MediaWiki:Common.js:修订间差异

(创建页面,内容为“→‎这里的任何JavaScript将为所有用户在每次页面加载时加载。:​ →‎这里的任何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…”
 
无编辑摘要
第1行: 第1行:
/* 这里的任何JavaScript将为所有用户在每次页面加载时加载。 */
/* 命令复制功能 */
/* 这里的任何JavaScript将为所有用户在每次页面载入时加载。 */
$("table .copyBtn").click(function () {
 
   let index = $("table .copyBtn").index(this);
/* -- 为页面加载JS脚本或CSS样式表 -- */
   let preArray = $("table pre");
/* 参见[[模板:ResourceLoader]]*/
   let preEle = preArray[index];
/* 来源:碧蓝航线WIKI*/
   window.getSelection().selectAllChildren(preEle);
$('.resourceLoader').each(function () {
   document.execCommand("Copy");
   var $x = $(this);
  alert("复制成功,可直接粘贴");
  var text = $.trim($x.text());
   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:32的版本

/* 命令复制功能 */
$("table .copyBtn").click(function () {
  let index = $("table .copyBtn").index(this);
  let preArray = $("table pre");
  let preEle = preArray[index];
  window.getSelection().selectAllChildren(preEle);
  document.execCommand("Copy");
  alert("复制成功,可直接粘贴");
  console.log("已经复制");
});