MediaWiki:Common.js:修订间差异
外观
小无编辑摘要 标签:已被回退 |
小无编辑摘要 标签:已被回退 |
||
| 第27行: | 第27行: | ||
}) | }) | ||
}); | }); | ||
//模板文章盒点击 | |||
$(function () { | |||
var scrollWidth = document.documentElement.scrollWidth || document.body.scrollWidth; | |||
if ( scrollWidth <= 750){ | |||
var QBOX = document.getElementsByClassName('QWIKI-BOX') | |||
var oDiv = document.getElementsByClassName('BOX-N') | |||
var oDivLenght = [] | |||
for (var i = 0; i < QBOX.length; i++) { | |||
// 判断内容长度 | |||
for (var q = 0; q < oDiv.length; q++) { | |||
oDivLenght.push(oDiv[q].childNodes.length/2) | |||
} | |||
var maxLenght = Math.max.apply(null , oDivLenght); | |||
console.log(maxLenght) | |||
QBOX[i].style.height =80+30*maxLenght+"px"; | |||
var oTitArr =[]; | |||
var oConArr =[]; | |||
var oCons = QBOX[i].children[0].children; | |||
for (var h = 0; h < oCons.length; h++) { | |||
if(h !=0){ | |||
if((h+1)%2==0){ | |||
oTitArr.push(oCons[h]) | |||
}else{ | |||
oConArr.push(oCons[h]); | |||
}}} | |||
if(oConArr[0].clientWidth <= 750){ | |||
for (var g = 0 ;g < oConArr.length; g++) { | |||
if(g != 0){ | |||
oConArr[g].style.display = 'none' | |||
}else{ | |||
oTitArr[g].style.borderBottom = '4px solid #0099FF' | |||
oTitArr[g].style.color = '#000000' | |||
} | |||
} | |||
} | |||
QBOX[i].index = i | |||
QBOX[i].onmouseover = function () { | |||
var oDivArr=[]; | |||
var oBtnArr=[]; | |||
var oConBOX= QBOX[this.index] | |||
var oCon = QBOX[this.index].children[0].children; | |||
for (var f = 0; f < oCon.length; f++) { | |||
if(f !=0){ | |||
if((f+1)%2==0){ | |||
oBtnArr.push(oCon[f]); | |||
}else{ | |||
oDivArr.push(oCon[f]); | |||
}} | |||
for (var e = 0; e < oBtnArr.length; e++) { | |||
oBtnArr[e].indexOBT = e | |||
oBtnArr[e].onclick = function (event) { | |||
event.stopPropagation(); | |||
for (var d = 0; d < oDivArr.length; d++) { | |||
oDivArr[d].style.display = 'none'; | |||
oBtnArr[d].style.color = '#AEB4C2'; | |||
oBtnArr[d].style.borderBottom = 'none'; | |||
} | |||
oDivArr[this.indexOBT].style.display = 'block'; | |||
oBtnArr[this.indexOBT].style.color = 'black'; | |||
oBtnArr[this.indexOBT].style.borderBottom = '4px solid #0099FF'; | |||
} | |||
} | |||
} | |||
} | |||
} | |||
} | |||
}) | |||
$(function () { | $(function () { | ||
2023年3月26日 (日) 22:43的版本
/* 这里的任何JavaScript将为所有用户在每次页面载入时加载。 */
/* UTC时钟使用本地时区。 */
window.LiveClockTimeZone = 'Asia/Shanghai';
/* 优化 */
if (location.pathname === '/') {
history.replaceState({}, document.title, 'Index');
}
//轮播图滚动
$(function () {
var $carousels = $('.carousel');
var startX,endX;
var offset = 50;
$carousels.on('touchstart',function (e) {
startX = e.originalEvent.touches[0].clientX;
});
$carousels.on('touchmove',function (e) {
endX = e.originalEvent.touches[0].clientX;
});
$carousels.on('touchend',function (e) {
var distance = Math.abs(startX - endX);
if (distance > offset){
$(this).carousel(startX >endX ? 'next':'prev');
}
})
});
//模板文章盒点击
$(function () {
var scrollWidth = document.documentElement.scrollWidth || document.body.scrollWidth;
if ( scrollWidth <= 750){
var QBOX = document.getElementsByClassName('QWIKI-BOX')
var oDiv = document.getElementsByClassName('BOX-N')
var oDivLenght = []
for (var i = 0; i < QBOX.length; i++) {
// 判断内容长度
for (var q = 0; q < oDiv.length; q++) {
oDivLenght.push(oDiv[q].childNodes.length/2)
}
var maxLenght = Math.max.apply(null , oDivLenght);
console.log(maxLenght)
QBOX[i].style.height =80+30*maxLenght+"px";
var oTitArr =[];
var oConArr =[];
var oCons = QBOX[i].children[0].children;
for (var h = 0; h < oCons.length; h++) {
if(h !=0){
if((h+1)%2==0){
oTitArr.push(oCons[h])
}else{
oConArr.push(oCons[h]);
}}}
if(oConArr[0].clientWidth <= 750){
for (var g = 0 ;g < oConArr.length; g++) {
if(g != 0){
oConArr[g].style.display = 'none'
}else{
oTitArr[g].style.borderBottom = '4px solid #0099FF'
oTitArr[g].style.color = '#000000'
}
}
}
QBOX[i].index = i
QBOX[i].onmouseover = function () {
var oDivArr=[];
var oBtnArr=[];
var oConBOX= QBOX[this.index]
var oCon = QBOX[this.index].children[0].children;
for (var f = 0; f < oCon.length; f++) {
if(f !=0){
if((f+1)%2==0){
oBtnArr.push(oCon[f]);
}else{
oDivArr.push(oCon[f]);
}}
for (var e = 0; e < oBtnArr.length; e++) {
oBtnArr[e].indexOBT = e
oBtnArr[e].onclick = function (event) {
event.stopPropagation();
for (var d = 0; d < oDivArr.length; d++) {
oDivArr[d].style.display = 'none';
oBtnArr[d].style.color = '#AEB4C2';
oBtnArr[d].style.borderBottom = 'none';
}
oDivArr[this.indexOBT].style.display = 'block';
oBtnArr[this.indexOBT].style.color = 'black';
oBtnArr[this.indexOBT].style.borderBottom = '4px solid #0099FF';
}
}
}
}
}
}
})
$(function () {
//鼠标的移入移出
$('.carousel').mouseover(function (){
$(".jt_right").show();
$(".jt_left").show();
}).mouseout(function (){
$(".jt_right").hide();
$(".jt_left").hide();
});
$('.jt_right').mouseover(function (){
$(".jt_right").show();
$(".jt_left").show();
}).mouseout(function (){
$(".jt_right").hide();
$(".jt_left").hide();
});
$('.jt_left').mouseover(function (){
$(".jt_right").show();
$(".jt_left").show();
}).mouseout(function (){
$(".jt_right").hide();
$(".jt_left").hide();
});
});
$(function(){
var scrollWidth = document.documentElement.scrollWidth || document.body.scrollWidth;
var i=0;
var timer=null;
for (var j = 0; j < $('.img li').length; j++) { //创建圆点
$('.num').append('<li></li>')
}
$('.num li').first().addClass('active'); //给第一个圆点添加样式
var firstimg=$('.img li').first().clone(); //复制第一张图片
$('.img').append(firstimg).width($('.img li').length*($('.img img').width())); //将第一张图片放到最后一张图片后,设置ul的宽度为图片张数*图片宽度
$('.des').width($('.img li').length*($('.img img').width()));
// 下一个按钮
$('.next').click(function(){
i++;
if (i==$('.img li').length) {
i=1; //这里不是i=0
$('.img').css({left:0}); //保证无缝轮播,设置left值
};
$('.img').stop().animate({left:-i*scrollWidth},300);
if (i==$('.img li').length-1) { //设置小圆点指示
$('.num li').eq(0).addClass('active').siblings().removeClass('active');
$('.des li').eq(0).removeClass('hide').siblings().addClass('hide');
}else{
$('.num li').eq(i).addClass('active').siblings().removeClass('active');
$('.des li').eq(i).removeClass('hide').siblings().addClass('hide');
}
})
// 上一个按钮
$('.prev').click(function(){
i--;
if (i==-1) {
i=$('.img li').length-2;
$('.img').css({left:-($('.img li').length-1)*scrollWidth});
}
$('.img').stop().animate({left:-i*scrollWidth},300);
$('.num li').eq(i).addClass('active').siblings().removeClass('active');
$('.des li').eq(i).removeClass('hide').siblings().addClass('hide');
})
//设置按钮的显示和隐藏
$('.banner').hover(function(){
$('.btn').show();
},function(){
$('.btn').hide();
})
//鼠标划入圆点
$('.num li').mouseover(function(){
var _index=$(this).index();
$('.img').stop().animate({left:-_index*scrollWidth},150);
$('.num li').eq(_index).addClass('active').siblings().removeClass('active');
$('.des li').eq(_index).removeClass('hide').siblings().addClass('hide');
})
//定时器自动播放
// timer=setInterval(function(){
// i++;
// if (i==$('.img li').length) {
// i=1;
// $('.img').css({left:0});
// };
// $('.img').stop().animate({left:-i*600},300);
// if (i==$('.img li').length-1) {
// $('.num li').eq(0).addClass('active').siblings().removeClass('active');
// $('.des li').eq(0).removeClass('hide').siblings().addClass('hide');
// }else{
// $('.num li').eq(i).addClass('active').siblings().removeClass('active');
// $('.des li').eq(i).removeClass('hide').siblings().addClass('hide');
// }
// },1000)
// //鼠标移入,暂停自动播放,移出,开始自动播放
// $('.banner').hover(function(){
// clearInterval(timer);
// },function(){
// timer=setInterval(function(){
// i++;
// if (i==$('.img li').length) {
// i=1;
// $('.img').css({left:0});
// };
// $('.img').stop().animate({left:-i*600},300);
// if (i==$('.img li').length-1) {
// $('.num li').eq(0).addClass('active').siblings().removeClass('active');
// $('.des li').eq(0).removeClass('hide').siblings().addClass('hide');
// }else{
// $('.num li').eq(i).addClass('active').siblings().removeClass('active');
// $('.des li').eq(i).removeClass('hide').siblings().addClass('hide');
// }
// },1000)
// })
})