LLWiki正在建设中,欢迎加入我们

“Widget:As-song”的版本间差异

来自LLWiki
跳转到导航 跳转到搜索
第4行: 第4行:
document.querySelectorAll( '.as-song-container' ).forEach(function(ele) {
document.querySelectorAll( '.as-song-container' ).forEach(function(ele) {
var select = document.createElement('select'),
var select = document.createElement('select'),
nodeList = ele.querySelectorAll('.as-song');
nodeList = ele.querySelectorAll('.as-song'),
optionArray = [];
ele.insertBefore(select, ele.firstChild);
ele.insertBefore(select, ele.firstChild);
select.lang = 'ja';
select.lang = 'ja';
select.dataset.oldIndex = 0;
nodeList.forEach(function(table, i) {
var option = new Option(table.querySelector('big').textContent, i);
nodeList[0].style.display = 'table';
nodeList.forEach(function(table) {
optionArray.push(option);
});
var option = new Option(table.querySelector('big').textContent);
optionArray = optionArray.sort(function(a, b) {
return a.text <= b.text ? -1 : 1;
});
optionArray.forEach(function(option) {
select.add(option);
select.add(option);
});
});
select.dataset.oldIndex = optionArray[0].value;
nodeList[select.dataset.oldIndex].style.display = 'table';
select.onchange = function() {
select.onchange = function() {
nodeList[select.dataset.oldIndex].style.display = 'none';
nodeList[select.dataset.oldIndex].style.display = 'none';
nodeList[select.selectedIndex].style.display = 'table';
select.dataset.oldIndex = optionArray[select.selectedIndex].value;
select.dataset.oldIndex = select.selectedIndex;
nodeList[select.dataset.oldIndex].style.display = 'table';
};
};
});
});

2020年10月30日 (五) 04:46的版本

Template-info.png 小部件文档
这个文档是内联文档。

用于LoveLive!学园偶像祭ALL STARS歌曲列表,请使用{{AS song select}}调用。

JavaScript脚本:

window.addEventListener('load', function() {
    document.querySelectorAll( '.as-song-container' ).forEach(function(ele) {
        var select = document.createElement('select'),
            nodeList = ele.querySelectorAll('.as-song'),
            optionArray = [];
        ele.insertBefore(select, ele.firstChild);
        select.lang = 'ja';
        nodeList.forEach(function(table, i) {
            var option = new Option(table.querySelector('big').textContent, i);
            optionArray.push(option);
        });
        optionArray = optionArray.sort(function(a, b) {
            return a.text <= b.text ? -1 : 1;
        });
        optionArray.forEach(function(option) {
            select.add(option);
        });
        select.dataset.oldIndex = optionArray[0].value;
        nodeList[select.dataset.oldIndex].style.display = 'table';
        select.onchange = function() {
            nodeList[select.dataset.oldIndex].style.display = 'none';
            select.dataset.oldIndex = optionArray[select.selectedIndex].value;
            nodeList[select.dataset.oldIndex].style.display = 'table';
        };
    });
});
//

CSS样式表:

 */
.as-song-container select {
	font-size: 1rem;
	padding: 2px;
	margin-right: 1em;
	font-family: 'ヒラギノ角ゴ ProN' , 'Hiragino Kaku Gothic ProN' , '游ゴシック' , '游ゴシック体' , YuGothic , 'Yu Gothic' , 'メイリオ' , Meiryo , 'MS ゴシック' , 'MS Gothic' , HiraKakuProN-W3 , 'TakaoExゴシック' , TakaoExGothic , 'MotoyaLCedar' , 'Droid Sans Japanese' , sans-serif;
}
.as-song-container select + div {
	display: inline-block;
	vertical-align: top;
}
.as-song-container .as-song {
	display: none;
}
/*