Widget:GameSwitcher:修订间差异
来自OGAS数据中枢
更多操作
无编辑摘要 |
无编辑摘要 |
||
| 第1行: | 第1行: | ||
<noinclude> | <noinclude> | ||
少女前线系列多游戏首页切换Widget。调用方式:<code><nowiki>{{#widget:GameSwitcher}}</nowiki></code> | |||
</noinclude><includeonly><script> | </noinclude><includeonly><script> | ||
( function () { | ( function () { | ||
| 第59行: | 第58行: | ||
var currentGame = 'gf'; | var currentGame = 'gf'; | ||
var switching = false; | var switching = false; | ||
var pending = null; | var pending = null; | ||
function doSwitch( game, tabEl ) { | function doSwitch( game, tabEl ) { | ||
| 第69行: | 第68行: | ||
var inSlide = document.getElementById( 'hero-' + game ); | var inSlide = document.getElementById( 'hero-' + game ); | ||
if ( inSlide ) { | if ( inSlide ) { | ||
inSlide.style.zIndex = '1'; | inSlide.style.zIndex = '1'; | ||
| 第92行: | 第77行: | ||
} | } | ||
tabs.forEach( function ( t ) { | tabs.forEach( function ( t ) { | ||
var on = t.getAttribute( 'data-game' ) === game; | var on = t.getAttribute( 'data-game' ) === game; | ||
| 第100行: | 第84行: | ||
if ( tabEl ) { moveIndicator( tabEl ); } | if ( tabEl ) { moveIndicator( tabEl ); } | ||
panels.forEach( function ( p ) { | panels.forEach( function ( p ) { | ||
p.classList.toggle( 'active', p.id === 'content-' + game ); | p.classList.toggle( 'active', p.id === 'content-' + game ); | ||
| 第111行: | 第94行: | ||
slides.forEach( function ( s ) { s.style.zIndex = ''; } ); | slides.forEach( function ( s ) { s.style.zIndex = ''; } ); | ||
switching = false; | switching = false; | ||
if ( pending && pending.game !== currentGame ) { | if ( pending && pending.game !== currentGame ) { | ||
var p = pending; | var p = pending; | ||
| 第120行: | 第101行: | ||
pending = null; | pending = null; | ||
} | } | ||
}, | }, 520 ); | ||
} | } | ||
| 第126行: | 第107行: | ||
if ( game === currentGame ) { return; } | if ( game === currentGame ) { return; } | ||
if ( switching ) { | if ( switching ) { | ||
pending = { game: game, tabEl: tabEl }; | pending = { game: game, tabEl: tabEl }; | ||
var tabs = document.querySelectorAll( '#gf-homepage .gf-tab' ); | var tabs = document.querySelectorAll( '#gf-homepage .gf-tab' ); | ||
tabs.forEach( function ( t ) { | tabs.forEach( function ( t ) { | ||
2026年6月20日 (六) 22:23的版本
少女前线系列多游戏首页切换Widget。调用方式:{{#widget:GameSwitcher}}