◆少前百科是非盈利性、非官方的少女前线维基百科。 ◆如果您发现某些内容错误/空缺,请勇于修正/添加!参与进来其实很容易!点这里 加入少前百科。 ◆有任何意见、建议、纠错,欢迎在 GFwiki:反馈与建议 提出和讨论。编辑事务讨论QQ群:597764980,微博@GFwiki少前百科 ◆To foreigners,You can use twitter to contact us. |
“MediaWiki:Mobile.js”的版本间的差异
Mikumikuer(讨论 | 贡献) |
(add collapse) |
||
(未显示1个用户的13个中间版本) | |||
第1行: | 第1行: | ||
/* 这里的任何JavaScript将为使用移动版网站的用户加载 */ | /* 这里的任何JavaScript将为使用移动版网站的用户加载 */ | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | // | + | /** |
− | /* | + | * Countdown |
− | $(' | + | * |
− | var | + | * @version 2.1 |
− | + | * | |
− | setTimeout(function(){ | + | * @author Pecoes <https://c.wikia.com/wiki/User:Pecoes> |
− | + | * @author Asaba <https://dev.wikia.com/wiki/User:Asaba> | |
− | }, | + | * |
− | }); | + | * Version 1 authors: |
+ | * - Splarka <https://c.wikia.com/wiki/User:Splarka> | ||
+ | * - Eladkse <https://c.wikia.com/wiki/User:Eladkse> | ||
+ | * | ||
+ | * documentation and examples at: | ||
+ | * <https://dev.wikia.com/wiki/Countdown> | ||
+ | */ | ||
+ | |||
+ | /*jshint jquery:true, browser:true, devel:true, camelcase:true, curly:false, undef:true, bitwise:true, eqeqeq:true, forin:true, immed:true, latedef:true, newcap:true, noarg:true, unused:true, regexp:true, strict:true, trailing:false */ | ||
+ | /*global mediaWiki:true*/ | ||
+ | |||
+ | ;(function (module, mw, $, undefined) { | ||
+ | |||
+ | 'use strict'; | ||
+ | |||
+ | var translations = $.extend(true, { | ||
+ | // English (English) | ||
+ | en: { | ||
+ | and: 'and', | ||
+ | second: 'second', | ||
+ | seconds: 'seconds', | ||
+ | minute: 'minute', | ||
+ | minutes: 'minutes', | ||
+ | hour: 'hour', | ||
+ | hours: 'hours', | ||
+ | day: 'day', | ||
+ | days: 'days' | ||
+ | }, | ||
+ | zh: { | ||
+ | and: '', | ||
+ | second: '秒', | ||
+ | seconds: '秒', | ||
+ | minute: '分钟', | ||
+ | minutes: '分钟', | ||
+ | hour: '小时', | ||
+ | hours: '小时', | ||
+ | day: '天', | ||
+ | days: '天' | ||
+ | } | ||
+ | }, module.translations || {}), | ||
+ | i18n = translations[ | ||
+ | mw.config.get('wgContentLanguage') | ||
+ | ] || translations.zh; | ||
+ | |||
+ | var countdowns = []; | ||
+ | |||
+ | var NO_LEADING_ZEROS = 1, | ||
+ | SHORT_FORMAT = 2, | ||
+ | NO_ZEROS = 4; | ||
+ | |||
+ | function output (i, diff) { | ||
+ | /*jshint bitwise:false*/ | ||
+ | var delta, result, parts = []; | ||
+ | delta = diff % 60; | ||
+ | //parts.unshift(delta + ' ' + i18n[delta === 1 ? 'second' : 'seconds']); | ||
+ | result = ' ' + i18n[delta === 1 ? 'second' : 'seconds']; | ||
+ | if (countdowns[i].opts & SHORT_FORMAT) result = result.charAt(1); | ||
+ | parts.unshift(delta + result); | ||
+ | diff = Math.floor(diff / 60); | ||
+ | delta = diff % 60; | ||
+ | //if (delta>0){ parts.unshift(delta + ' ' + i18n[delta === 1 ? 'minute' : 'minutes']);} | ||
+ | result = ' ' + i18n[delta === 1 ? 'minute' : 'minutes']; | ||
+ | if (countdowns[i].opts & SHORT_FORMAT) result = result.charAt(1); | ||
+ | parts.unshift(delta + result); | ||
+ | diff = Math.floor(diff / 60); | ||
+ | delta = diff % 24; | ||
+ | //if (delta>0){ parts.unshift(delta + ' ' + i18n[delta === 1 ? 'hour' : 'hours' ]);} | ||
+ | result = ' ' + i18n[delta === 1 ? 'hour' : 'hours' ]; | ||
+ | if (countdowns[i].opts & SHORT_FORMAT) result = result.charAt(1); | ||
+ | parts.unshift(delta + result); | ||
+ | diff = Math.floor(diff / 24); | ||
+ | //if (diff>0){ parts.unshift(diff + ' ' + i18n[diff === 1 ? 'day' : 'days' ]);} | ||
+ | result = ' ' + i18n[diff === 1 ? 'day' : 'days' ]; | ||
+ | if (countdowns[i].opts & SHORT_FORMAT) result = result.charAt(1); | ||
+ | parts.unshift(diff + result); | ||
+ | result = parts.pop(); | ||
+ | if (countdowns[i].opts & NO_LEADING_ZEROS) { | ||
+ | while (parts.length && parts[0][0] === '0') { | ||
+ | parts.shift(); | ||
+ | } | ||
+ | } | ||
+ | if (countdowns[i].opts & NO_ZEROS) { | ||
+ | parts = parts.filter(function(part) { | ||
+ | return part[0] !== '0'; | ||
+ | }); | ||
+ | } | ||
+ | if (parts.length) { | ||
+ | if (countdowns[i].opts & SHORT_FORMAT) { | ||
+ | result = parts.join(' ') + ' ' + result; | ||
+ | } else { | ||
+ | result = parts.join(', ') + ' ' + i18n.and + ' ' + result; | ||
+ | } | ||
+ | } | ||
+ | countdowns[i].node.text(result); | ||
+ | } | ||
+ | |||
+ | function end(i) { | ||
+ | var c = countdowns[i].node.parent(); | ||
+ | switch (c.attr('data-end')) { | ||
+ | case 'remove': | ||
+ | c.remove(); | ||
+ | return true; | ||
+ | case 'stop': | ||
+ | output(i, 0); | ||
+ | return true; | ||
+ | case 'toggle': | ||
+ | var toggle = c.attr('data-toggle'); | ||
+ | if (toggle && toggle == 'next') { | ||
+ | c.next().css('display', 'inline'); | ||
+ | c.css('display', 'none'); | ||
+ | return true; | ||
+ | } | ||
+ | if (toggle && $(toggle).length) { | ||
+ | $(toggle).css('display', 'inline'); | ||
+ | c.css('display', 'none'); | ||
+ | return true; | ||
+ | } | ||
+ | break; | ||
+ | case 'callback': | ||
+ | var callback = c.attr('data-callback'); | ||
+ | if (callback && $.isFunction(module[callback])) { | ||
+ | output(i, 0); | ||
+ | module[callback].call(c); | ||
+ | return true; | ||
+ | } | ||
+ | break; | ||
+ | } | ||
+ | countdowns[i].countup = true; | ||
+ | output(i, 0); | ||
+ | return false; | ||
+ | } | ||
+ | |||
+ | function update () { | ||
+ | var now = Date.now(); | ||
+ | var countdownsToRemove = []; | ||
+ | $.each(countdowns.slice(0), function (i, countdown) { | ||
+ | var diff = Math.floor((countdown.date - now) / 1000); | ||
+ | if (diff <= 0 && !countdown.countup) { | ||
+ | if (end(i)) countdownsToRemove.push(i); | ||
+ | } else { | ||
+ | output(i, Math.abs(diff)); | ||
+ | } | ||
+ | }); | ||
+ | var x; | ||
+ | while((x = countdownsToRemove.pop()) !== undefined) { | ||
+ | countdowns.splice(x, 1); | ||
+ | } | ||
+ | if (countdowns.length) { | ||
+ | window.setTimeout(function () { | ||
+ | update(); | ||
+ | }, 1000); | ||
+ | } | ||
+ | } | ||
+ | |||
+ | function getOptions (node) { | ||
+ | /*jshint bitwise:false*/ | ||
+ | var text = node.parent().attr('data-options'), | ||
+ | opts = 0; | ||
+ | if (text) { | ||
+ | if (/no-leading-zeros/.test(text)) { | ||
+ | opts |= NO_LEADING_ZEROS; | ||
+ | } | ||
+ | if (/short-format/.test(text)) { | ||
+ | opts |= SHORT_FORMAT; | ||
+ | } | ||
+ | if (/no-zeros/.test(text)) { | ||
+ | opts |= NO_ZEROS; | ||
+ | } | ||
+ | } | ||
+ | return opts; | ||
+ | } | ||
+ | |||
+ | function init() { | ||
+ | var countdown = $('.countdown:not(.handled)'); | ||
+ | if (!countdown.length) return; | ||
+ | $('.nocountdown').css('display', 'none'); | ||
+ | countdown | ||
+ | .css('display', 'inline') | ||
+ | .find('.countdowndate') | ||
+ | .each(function () { | ||
+ | var $this = $(this), | ||
+ | date = (new Date($this.text())).valueOf(); | ||
+ | if (isNaN(date)) { | ||
+ | $this.text('BAD DATE'); | ||
+ | return; | ||
+ | } | ||
+ | countdowns.push({ | ||
+ | node: $this, | ||
+ | opts: getOptions($this), | ||
+ | date: date, | ||
+ | }); | ||
+ | }); | ||
+ | countdown.addClass('handled'); | ||
+ | if (countdowns.length) { | ||
+ | update(); | ||
+ | } | ||
+ | } | ||
+ | |||
+ | mw.hook('wikipage.content').add(init); | ||
+ | |||
+ | }(window.countdownTimer = window.countdownTimer || {}, mediaWiki, jQuery)); | ||
+ | |||
+ | // End Countdown | ||
+ | |||
+ | |||
+ | |||
/* 固钉菜单 */ | /* 固钉菜单 */ | ||
document.addEventListener('scroll',function(e){ | document.addEventListener('scroll',function(e){ | ||
第62行: | 第225行: | ||
} | } | ||
}) | }) | ||
− | |||
− | |||
/* 折叠标签 */ | /* 折叠标签 */ | ||
mw.loader.load("jquery.makeCollapsible") | mw.loader.load("jquery.makeCollapsible") | ||
/* 标签式图标图鉴首列元素侦测 */ | /* 标签式图标图鉴首列元素侦测 */ | ||
− | RLQ.push(function(){$(function () { | + | RLQ.push(function(){ |
+ | mw.user.getGroups(function(data){window.currentUserGroups = data}); | ||
+ | $(function () { | ||
var iconbox = document.querySelectorAll('table.iconbox tr > td:last-child');var iconcontainer = document.querySelectorAll('table.iconbox tr'); | var iconbox = document.querySelectorAll('table.iconbox tr > td:last-child');var iconcontainer = document.querySelectorAll('table.iconbox tr'); | ||
if (iconbox.length == 0) {return;} | if (iconbox.length == 0) {return;} | ||
第100行: | 第263行: | ||
})}); | })}); | ||
/* Mobile Navmenu */ | /* Mobile Navmenu */ | ||
+ | RLQ.push(function(){ | ||
function menuadjust(){var a = $("body").height()+"px";document.getElementById("mw-mf-page-left").style.height = a;}; | function menuadjust(){var a = $("body").height()+"px";document.getElementById("mw-mf-page-left").style.height = a;}; | ||
$(function(){menuadjust();}); | $(function(){menuadjust();}); | ||
第105行: | 第269行: | ||
var navbar = function(data, textStatus, jqxhr) { | var navbar = function(data, textStatus, jqxhr) { | ||
var navlist = data.parse.text["*"]; | var navlist = data.parse.text["*"]; | ||
− | $(navlist).insertBefore(".menu > .hlist") | + | $(navlist).insertBefore(".menu > .hlist");document.querySelector('.mw-ui-icon-minerva-settings').parentNode.parentNode.style.display="none"; |
}; | }; | ||
var mfSidebar = function() { | var mfSidebar = function() { | ||
第117行: | 第281行: | ||
}; | }; | ||
$(function(){mfSidebar();}); | $(function(){mfSidebar();}); | ||
+ | }) | ||
/* Spine Loader */ | /* Spine Loader */ | ||
− | mw.loader.load("/index.php?title=MediaWiki:Gadget- | + | mw.loader.load("/index.php?title=MediaWiki:Gadget-jquery.jcarousel.js&action=raw&ctype=text/javascript"); |
+ | mw.loader.load("/index.php?title=MediaWiki:Gadget-Modernizr.js&action=raw&ctype=text/javascript"); | ||
/* 黑幕 */ | /* 黑幕 */ | ||
第130行: | 第296行: | ||
/* 返回顶部按钮 */ | /* 返回顶部按钮 */ | ||
− | $(function() { | + | RLQ.push(function(){$(function() { |
var txt = " ", | var txt = " ", | ||
btn = $('<div/>', { | btn = $('<div/>', { | ||
第153行: | 第319行: | ||
}).scroll(); | }).scroll(); | ||
}); | }); | ||
+ | }) | ||
/* goTop END */ | /* goTop END */ | ||
第277行: | 第444行: | ||
//collapse 折叠和图标折叠 | //collapse 折叠和图标折叠 | ||
− | + | RLQ.push(function(){ | |
$(".simpleCollapse").click(function(e){ | $(".simpleCollapse").click(function(e){ | ||
var dest=$(this).next(), | var dest=$(this).next(), | ||
第294行: | 第461行: | ||
} | } | ||
}); | }); | ||
− | + | }) | |
+ | |||
+ | |||
+ | //collapse 折叠2 | ||
+ | $(function(){ | ||
+ | $(".gfCollapse").click(function(e){ | ||
+ | if($(this).next().prop("nodeName") == "P" && !($(this).next().html())){ | ||
+ | var nextElement = $(this).next().next(); | ||
+ | $(this).next().css("display", "none"); | ||
+ | }else var nextElement = $(this).next(); | ||
+ | |||
+ | if($(this).attr("status") == "none"){ | ||
+ | $(this).attr("status", "visible"); | ||
+ | var signElement = $(this).children().children(".gfCollapseSign"); | ||
+ | signElement.html(signElement.attr("data-visible")); | ||
+ | nextElement.slideDown("fast");} | ||
+ | else{ | ||
+ | $(this).attr("status", "none"); | ||
+ | var signElement = $(this).children().children(".gfCollapseSign"); | ||
+ | signElement.html(signElement.attr("data-none")); | ||
+ | nextElement.slideUp("fast");} | ||
+ | }); | ||
+ | }); | ||
+ | |||
+ | window.addEventListener("resize", function() { | ||
+ | $(".gfCollapse").children().css("max-width", parseInt(Number($(".gfCollapse").parent().width()) -40));}); | ||
+ | window.addEventListener("load", function() { | ||
+ | $(".gfCollapse").children().css("max-width", parseInt(Number($(".gfCollapse").parent().width()) -40));}); |
2021年8月31日 (二) 18:31的最新版本
/* 这里的任何JavaScript将为使用移动版网站的用户加载 */
/**
* Countdown
*
* @version 2.1
*
* @author Pecoes <https://c.wikia.com/wiki/User:Pecoes>
* @author Asaba <https://dev.wikia.com/wiki/User:Asaba>
*
* Version 1 authors:
* - Splarka <https://c.wikia.com/wiki/User:Splarka>
* - Eladkse <https://c.wikia.com/wiki/User:Eladkse>
*
* documentation and examples at:
* <https://dev.wikia.com/wiki/Countdown>
*/
/*jshint jquery:true, browser:true, devel:true, camelcase:true, curly:false, undef:true, bitwise:true, eqeqeq:true, forin:true, immed:true, latedef:true, newcap:true, noarg:true, unused:true, regexp:true, strict:true, trailing:false */
/*global mediaWiki:true*/
;(function (module, mw, $, undefined) {
'use strict';
var translations = $.extend(true, {
// English (English)
en: {
and: 'and',
second: 'second',
seconds: 'seconds',
minute: 'minute',
minutes: 'minutes',
hour: 'hour',
hours: 'hours',
day: 'day',
days: 'days'
},
zh: {
and: '',
second: '秒',
seconds: '秒',
minute: '分钟',
minutes: '分钟',
hour: '小时',
hours: '小时',
day: '天',
days: '天'
}
}, module.translations || {}),
i18n = translations[
mw.config.get('wgContentLanguage')
] || translations.zh;
var countdowns = [];
var NO_LEADING_ZEROS = 1,
SHORT_FORMAT = 2,
NO_ZEROS = 4;
function output (i, diff) {
/*jshint bitwise:false*/
var delta, result, parts = [];
delta = diff % 60;
//parts.unshift(delta + ' ' + i18n[delta === 1 ? 'second' : 'seconds']);
result = ' ' + i18n[delta === 1 ? 'second' : 'seconds'];
if (countdowns[i].opts & SHORT_FORMAT) result = result.charAt(1);
parts.unshift(delta + result);
diff = Math.floor(diff / 60);
delta = diff % 60;
//if (delta>0){ parts.unshift(delta + ' ' + i18n[delta === 1 ? 'minute' : 'minutes']);}
result = ' ' + i18n[delta === 1 ? 'minute' : 'minutes'];
if (countdowns[i].opts & SHORT_FORMAT) result = result.charAt(1);
parts.unshift(delta + result);
diff = Math.floor(diff / 60);
delta = diff % 24;
//if (delta>0){ parts.unshift(delta + ' ' + i18n[delta === 1 ? 'hour' : 'hours' ]);}
result = ' ' + i18n[delta === 1 ? 'hour' : 'hours' ];
if (countdowns[i].opts & SHORT_FORMAT) result = result.charAt(1);
parts.unshift(delta + result);
diff = Math.floor(diff / 24);
//if (diff>0){ parts.unshift(diff + ' ' + i18n[diff === 1 ? 'day' : 'days' ]);}
result = ' ' + i18n[diff === 1 ? 'day' : 'days' ];
if (countdowns[i].opts & SHORT_FORMAT) result = result.charAt(1);
parts.unshift(diff + result);
result = parts.pop();
if (countdowns[i].opts & NO_LEADING_ZEROS) {
while (parts.length && parts[0][0] === '0') {
parts.shift();
}
}
if (countdowns[i].opts & NO_ZEROS) {
parts = parts.filter(function(part) {
return part[0] !== '0';
});
}
if (parts.length) {
if (countdowns[i].opts & SHORT_FORMAT) {
result = parts.join(' ') + ' ' + result;
} else {
result = parts.join(', ') + ' ' + i18n.and + ' ' + result;
}
}
countdowns[i].node.text(result);
}
function end(i) {
var c = countdowns[i].node.parent();
switch (c.attr('data-end')) {
case 'remove':
c.remove();
return true;
case 'stop':
output(i, 0);
return true;
case 'toggle':
var toggle = c.attr('data-toggle');
if (toggle && toggle == 'next') {
c.next().css('display', 'inline');
c.css('display', 'none');
return true;
}
if (toggle && $(toggle).length) {
$(toggle).css('display', 'inline');
c.css('display', 'none');
return true;
}
break;
case 'callback':
var callback = c.attr('data-callback');
if (callback && $.isFunction(module[callback])) {
output(i, 0);
module[callback].call(c);
return true;
}
break;
}
countdowns[i].countup = true;
output(i, 0);
return false;
}
function update () {
var now = Date.now();
var countdownsToRemove = [];
$.each(countdowns.slice(0), function (i, countdown) {
var diff = Math.floor((countdown.date - now) / 1000);
if (diff <= 0 && !countdown.countup) {
if (end(i)) countdownsToRemove.push(i);
} else {
output(i, Math.abs(diff));
}
});
var x;
while((x = countdownsToRemove.pop()) !== undefined) {
countdowns.splice(x, 1);
}
if (countdowns.length) {
window.setTimeout(function () {
update();
}, 1000);
}
}
function getOptions (node) {
/*jshint bitwise:false*/
var text = node.parent().attr('data-options'),
opts = 0;
if (text) {
if (/no-leading-zeros/.test(text)) {
opts |= NO_LEADING_ZEROS;
}
if (/short-format/.test(text)) {
opts |= SHORT_FORMAT;
}
if (/no-zeros/.test(text)) {
opts |= NO_ZEROS;
}
}
return opts;
}
function init() {
var countdown = $('.countdown:not(.handled)');
if (!countdown.length) return;
$('.nocountdown').css('display', 'none');
countdown
.css('display', 'inline')
.find('.countdowndate')
.each(function () {
var $this = $(this),
date = (new Date($this.text())).valueOf();
if (isNaN(date)) {
$this.text('BAD DATE');
return;
}
countdowns.push({
node: $this,
opts: getOptions($this),
date: date,
});
});
countdown.addClass('handled');
if (countdowns.length) {
update();
}
}
mw.hook('wikipage.content').add(init);
}(window.countdownTimer = window.countdownTimer || {}, mediaWiki, jQuery));
// End Countdown
/* 固钉菜单 */
document.addEventListener('scroll',function(e){
var scrollTop = document.body.scrollTop || window.pageYOffset || document.documentElement.scrollTop
var header = document.querySelector("#mw-mf-page-center > .header-container")
if(scrollTop > 50){
header.classList.add("pinned")
} else {
header.classList.remove("pinned")
}
})
/* 折叠标签 */
mw.loader.load("jquery.makeCollapsible")
/* 标签式图标图鉴首列元素侦测 */
RLQ.push(function(){
mw.user.getGroups(function(data){window.currentUserGroups = data});
$(function () {
var iconbox = document.querySelectorAll('table.iconbox tr > td:last-child');var iconcontainer = document.querySelectorAll('table.iconbox tr');
if (iconbox.length == 0) {return;}
for (var i = 0; i < iconbox.length; i++)
{
var len = iconbox[i].offsetWidth;var test= iconbox[i].getElementsByTagName("div").length;if(test==0){console.log(iconbox[i],test);iconcontainer[i].remove();continue}
var num = Math.floor( len / 67);if(num==0){continue}
for (var j = 0; j < iconbox[i].getElementsByClassName("TDnavbox").length;j += num) {;
iconbox[i].getElementsByClassName("TDnavbox")[j].classList.add("lead");
if(!!iconbox[i].getElementsByClassName("TDnavbox")[j+1]){iconbox[i].getElementsByClassName("TDnavbox")[j+1].classList.add("lead");}
}
}
})
$(window).resize(function () {
var iconbox = document.querySelectorAll('table.iconbox tr > td:last-child');
var iconcontainer = document.querySelectorAll('table.iconbox tr');
var leadicon = document.querySelectorAll('table.iconbox tr > td:last-child div.lead');
for (var i = 0; i < leadicon.length; i++) {
leadicon[i].classList.remove("lead")
}
if (iconbox.length == 0) {return;}
for (var i = 0; i < iconbox.length; i++)
{
var len = iconbox[i].offsetWidth;
var num = Math.floor( len / 67);if(num==0){continue}
for (var j = 0; j < iconbox[i].getElementsByClassName("TDnavbox").length;j += num) {;
iconbox[i].getElementsByClassName("TDnavbox")[j].classList.add("lead");
if(!!iconbox[i].getElementsByClassName("TDnavbox")[j+1]){iconbox[i].getElementsByClassName("TDnavbox")[j+1].classList.add("lead");}
if(!!iconbox[i].getElementsByClassName("TDnavbox")[j+2]){iconbox[i].getElementsByClassName("TDnavbox")[j+2].classList.add("lead");}
}
}
})});
/* Mobile Navmenu */
RLQ.push(function(){
function menuadjust(){var a = $("body").height()+"px";document.getElementById("mw-mf-page-left").style.height = a;};
$(function(){menuadjust();});
$(window).resize(function(){menuadjust()});
var navbar = function(data, textStatus, jqxhr) {
var navlist = data.parse.text["*"];
$(navlist).insertBefore(".menu > .hlist");document.querySelector('.mw-ui-icon-minerva-settings').parentNode.parentNode.style.display="none";
};
var mfSidebar = function() {
var purl = "/api.php?action=parse&page=MediaWiki:MFSidebar&format=json";
$.ajax({
url: purl,
success: navbar,
error: function () {console.error("can\'t load customized navmenu")},
dataType: "json"
});
};
$(function(){mfSidebar();});
})
/* Spine Loader */
mw.loader.load("/index.php?title=MediaWiki:Gadget-jquery.jcarousel.js&action=raw&ctype=text/javascript");
mw.loader.load("/index.php?title=MediaWiki:Gadget-Modernizr.js&action=raw&ctype=text/javascript");
/* 黑幕 */
var heimu = document.getElementsByClassName("black-black");
function overMouse(){this.style.color="white"}
function leftMouse(){this.style.color="black"}
for(var i=0;i<heimu.length;i++){
heimu[i].addEventListener("mouseover", overMouse);
heimu[i].addEventListener("mouseleave", leftMouse);}
/* 返回顶部按钮 */
RLQ.push(function(){$(function() {
var txt = " ",
btn = $('<div/>', {
'text': txt,
'attr': {
'title': txt,
'class': 'backToTop'
},
'css': {
'user-select': 'none'
},
'on': {
'click': function() {
$("html, body").animate({
scrollTop: 0
}, 120);
}
}
}).appendTo(document.body);
$(window).on('scroll', function() {
$(document).scrollTop() > 0 ? btn.fadeIn() : btn.fadeOut();
}).scroll();
});
})
/* goTop END */
/**
* Dynamic Navigation Bars (experimental)
*
* Description: See [[Wikipedia:NavFrame]].
* Maintainers: UNMAINTAINED
*/
/* set up the words in your language */
var collapseCaption = '隐藏';
var expandCaption = '显示';
var NavigationBarHide = '[' + collapseCaption + ']';
var NavigationBarShow = '[' + expandCaption + ']';
var indexNavigationBar = 0;
/**
* Shows and hides content and picture (if available) of navigation bars
* Parameters:
* indexNavigationBar: the index of navigation bar to be toggled
**/
window.toggleNavigationBar = function ( indexNavigationBar, event ) {
var NavToggle = document.getElementById( 'NavToggle' + indexNavigationBar );
var NavFrame = document.getElementById( 'NavFrame' + indexNavigationBar );
var NavChild;
if ( !NavFrame || !NavToggle ) {
return false;
}
/* if shown now */
if ( NavToggle.firstChild.data === NavigationBarHide ) {
for ( NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling ) {
if ( $( NavChild ).hasClass( 'NavContent' ) || $( NavChild ).hasClass( 'NavPic' ) ) {
NavChild.style.display = 'none';
}
}
NavToggle.firstChild.data = NavigationBarShow;
/* if hidden now */
} else if ( NavToggle.firstChild.data === NavigationBarShow ) {
for ( NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling ) {
if ( $( NavChild ).hasClass( 'NavContent' ) || $( NavChild ).hasClass( 'NavPic' ) ) {
NavChild.style.display = 'block';
}
}
NavToggle.firstChild.data = NavigationBarHide;
}
event.preventDefault();
};
/* adds show/hide-button to navigation bars */
function createNavigationBarToggleButton( $content ) {
var NavChild;
/* iterate over all < div >-elements */
var $divs = $content.find( 'div' );
$divs.each( function ( i, NavFrame ) {
/* if found a navigation bar */
if ( $( NavFrame ).hasClass( 'NavFrame' ) ) {
indexNavigationBar++;
var NavToggle = document.createElement( 'a' );
NavToggle.className = 'NavToggle';
NavToggle.setAttribute( 'id', 'NavToggle' + indexNavigationBar );
NavToggle.setAttribute( 'href', '#' );
$( NavToggle ).on( 'click', $.proxy( window.toggleNavigationBar, window, indexNavigationBar ) );
var isCollapsed = $( NavFrame ).hasClass( 'collapsed' );
/**
* Check if any children are already hidden. This loop is here for backwards compatibility:
* the old way of making NavFrames start out collapsed was to manually add style="display:none"
* to all the NavPic/NavContent elements. Since this was bad for accessibility (no way to make
* the content visible without JavaScript support), the new recommended way is to add the class
* "collapsed" to the NavFrame itself, just like with collapsible tables.
*/
for ( NavChild = NavFrame.firstChild; NavChild != null && !isCollapsed; NavChild = NavChild.nextSibling ) {
if ( $( NavChild ).hasClass( 'NavPic' ) || $( NavChild ).hasClass( 'NavContent' ) ) {
if ( NavChild.style.display === 'none' ) {
isCollapsed = true;
}
}
}
if ( isCollapsed ) {
for ( NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling ) {
if ( $( NavChild ).hasClass( 'NavPic' ) || $( NavChild ).hasClass( 'NavContent' ) ) {
NavChild.style.display = 'none';
}
}
}
var NavToggleText = document.createTextNode( isCollapsed ? NavigationBarShow : NavigationBarHide );
NavToggle.appendChild( NavToggleText );
/* Find the NavHead and attach the toggle link (Must be this complicated because Moz's firstChild handling is borked) */
for( var j = 0; j < NavFrame.childNodes.length; j++ ) {
if ( $( NavFrame.childNodes[j] ).hasClass( 'NavHead' ) ) {
NavToggle.style.color = NavFrame.childNodes[j].style.color;
NavFrame.childNodes[j].appendChild( NavToggle );
}
}
NavFrame.setAttribute( 'id', 'NavFrame' + indexNavigationBar );
}
} );
}
mw.hook( 'wikipage.content' ).add( createNavigationBarToggleButton );
//Hide End
//隐藏内容,该部分代码复制自萌娘百科
//阅读更多:https://zh.moegirl.org/MediaWiki:Common.js
//文字内容遵守【知识共享 署名-非商业性使用-相同方式共享 3.0】协议。
//由于mw的锅导致部分文字可能超出#mw-content-text的范围,为这些文字的{{hide}}补上隐藏效果
function missedHideFun(obj) {
$('<span class="mw-collapsible-toggle"><span class="mw-collapsible-bracket">[</span><a href="javascript:void(0);"/><span class="mw-collapsible-bracket">]</span></span>').appendTo(obj.find('tr:first > :last'));
obj.find('.mw-collapsible-toggle a').text('隐藏').bind('click', function() {
var a = $(this).closest('table.mw-collapsible').find('tr').not(':first');
"none" == a.css("display") ? a.show() && $(this).text("显示") : a.hide() && $(this).text("隐藏");
});
obj.filter('.mw-collapsed').find('.mw-collapsible-toggle a').click();
}
//collapse 折叠和图标折叠
RLQ.push(function(){
$(".simpleCollapse").click(function(e){
var dest=$(this).next(),
spen=$(this).children('span'),
i=$(this).children("i");
if(dest.is(":visible")){
dest.slideUp('fast',function(){
spen.html(spen.attr('data-ht'));
i.removeClass("fa-minus-square").addClass("fa-plus-square").html(" 详细");
});
}else {
dest.slideDown('fast',function(){
spen.html(spen.attr('data-st'));
i.removeClass("fa-plus-square").addClass("fa-minus-square").html("");
});
}
});
})
//collapse 折叠2
$(function(){
$(".gfCollapse").click(function(e){
if($(this).next().prop("nodeName") == "P" && !($(this).next().html())){
var nextElement = $(this).next().next();
$(this).next().css("display", "none");
}else var nextElement = $(this).next();
if($(this).attr("status") == "none"){
$(this).attr("status", "visible");
var signElement = $(this).children().children(".gfCollapseSign");
signElement.html(signElement.attr("data-visible"));
nextElement.slideDown("fast");}
else{
$(this).attr("status", "none");
var signElement = $(this).children().children(".gfCollapseSign");
signElement.html(signElement.attr("data-none"));
nextElement.slideUp("fast");}
});
});
window.addEventListener("resize", function() {
$(".gfCollapse").children().css("max-width", parseInt(Number($(".gfCollapse").parent().width()) -40));});
window.addEventListener("load", function() {
$(".gfCollapse").children().css("max-width", parseInt(Number($(".gfCollapse").parent().width()) -40));});