用户:RedDragon/Test2:修订间差异
来自Rizline中文维基
更多操作
RedDragon(留言 | 贡献) (创建页面,内容为“此页面对Rizline中文维基中的文本与素材所拥有的所有权进行说明。 == Rizline游戏素材 == Rizline游戏素材指构成Rizline的所有材料,包括现有材料(如Rizline应用图标等)、已删除材料(如"探索"界面按钮等)及尚未加入的材料。 我们(即[https://rizwiki.cn/index.php?title=%E7%89%B9%E6%AE%8A:%E7%94%A8%E6%88%B7%E5%88%97%E8%A1%A8&group=sysop Rizline中文维基管理组],下同)对Rizline所有的…”) |
小 |
||
| 第1行: | 第1行: | ||
== | <html> | ||
<table class="infobox" cellspacing="3" style="border-collapse:separate;border-spacing:2px;float:right;"><tbody><tr class="infobox-title"><th colspan="2" style="padding:8px;background:#ccc;">曲目</th></tr><tr><td colspan="2" style="text-align:center;"> | |||
<span typeof="mw:File"><a href="/index.php/%E6%96%87%E4%BB%B6:%E6%8F%92%E7%94%BB%E5%9B%BE%E6%A0%87.png" class="mw-file-description"><img src="/images/thumb/4/41/%E6%8F%92%E7%94%BB%E5%9B%BE%E6%A0%87.png/200px-%E6%8F%92%E7%94%BB%E5%9B%BE%E6%A0%87.png" decoding="async" width="200" height="200" class="mw-file-element" srcset="/images/thumb/4/41/%E6%8F%92%E7%94%BB%E5%9B%BE%E6%A0%87.png/300px-%E6%8F%92%E7%94%BB%E5%9B%BE%E6%A0%87.png 1.5x, /images/thumb/4/41/%E6%8F%92%E7%94%BB%E5%9B%BE%E6%A0%87.png/400px-%E6%8F%92%E7%94%BB%E5%9B%BE%E6%A0%87.png 2x" data-file-width="512" data-file-height="512"></a></span></td></tr><tr class="infobox-header"><th colspan="2" style="padding:8px;background:#ccf;">限制</th></tr><tr><th scope="row" class="infobox-label" style="width:90px;background:#ddf;">难度</th><td class="infobox-data"> | |||
a</td></tr><tr><th scope="row" class="infobox-label" style="width:90px;background:#ddf;">流速</th><td class="infobox-data"> | |||
b</td></tr><tr><th scope="row" class="infobox-label" style="width:90px;background:#ddf;">MOD</th><td class="infobox-data"> | |||
c</td></tr><tr><th scope="row" class="infobox-label" style="width:90px;background:#ddf;">其他</th><td class="infobox-data"> | |||
d</td></tr></tbody></table> | |||
<script> | |||
$(document).ready(function () { | |||
$.ajax({ | |||
url: mw.util.wikiScript('api'), | |||
data: { | |||
action: 'parse', | |||
page: '曲目列表', | |||
prop: 'text', | |||
format: 'json' | |||
}, | |||
success: function (data) { | |||
var content = data.parse.text['*'] | |||
var $content = $('<div>').html(content) | |||
var songs = [] | |||
=== | $content.find('.wikitable tr').each(function (index) { | ||
if (index === 0) return | |||
var $cells = $(this).find('td, th') | |||
if ($cells.length >= 7) { | |||
var song = { | |||
image: extractImageUrl($cells.eq(0)), | |||
title: $cells.eq(1).text().trim(), | |||
ez: $cells.eq(4).text().trim(), | |||
hd: $cells.eq(5).text().trim(), | |||
in: $cells.eq(6).text().trim() | |||
} | |||
if (song.title) songs.push(song) | |||
} | |||
}) | |||
= | if (songs.length > 0) { | ||
var randomSong = songs[Math.floor(Math.random() * songs.length)] | |||
loadSongDetails(randomSong) | |||
} | |||
} | |||
}) | |||
= | function extractImageUrl($cell) { | ||
var $img = $cell.find('img') | |||
if ($img.length > 0) return $img.attr('src') || $img.attr('data-src') | |||
return $cell.text().trim() | |||
} | |||
=== | function loadSongDetails(song) { | ||
updateSongInfo(song) | |||
$.ajax({ | |||
url: mw.util.wikiScript('api'), | |||
data: { | |||
action: 'parse', | |||
page: song.title, | |||
prop: 'text', | |||
format: 'json' | |||
}, | |||
success: function (data) { | |||
var content = data.parse.text['*'] | |||
var $content = $('<div>').html(content) | |||
updateStyles({ | |||
titleStyle: getBackgroundColor($content.find('.infobox-title')) || '#94E1FF', | |||
headerStyle: getBackgroundColor($content.find('.infobox-header')) || '#A3E5FF', | |||
labelStyle: getBackgroundColor($content.find('.infobox-label')) || '#B2E9FE' | |||
}) | |||
}, | |||
error: function () { | |||
updateStyles({ | |||
titleStyle: '#94E1FF', | |||
headerStyle: '#A3E5FF', | |||
labelStyle: '#B2E9FE' | |||
}) | |||
} | |||
}) | |||
} | |||
function getBackgroundColor($element) { | |||
if ($element.length === 0) return null | |||
var bgColor = $element.css('background-color') | |||
if (bgColor && bgColor.startsWith('rgb')) { | |||
var rgb = bgColor.match(/\d+/g) | |||
if (rgb && rgb.length === 3) { | |||
return '#' + | |||
('0' + parseInt(rgb[0]).toString(16)).slice(-2) + | |||
('0' + parseInt(rgb[1]).toString(16)).slice(-2) + | |||
('0' + parseInt(rgb[2]).toString(16)).slice(-2) | |||
} | |||
} | |||
return bgColor | |||
} | |||
function updateSongInfo(song) { | |||
$('.infobox-title th').text(song.title) | |||
if (song.image) $('#song-image').attr('src', song.image) | |||
window.difficultyArray = [ | |||
createDiffSpan("EZ", song.ez), | |||
createDiffSpan("HD", song.hd), | |||
createDiffSpan("IN", song.in), | |||
'<span style="width: max-content;text-align:center;display:inline-block;border-radius:1em;color:white;background-color:#53D6FF;padding:0 0.80em;margin:0.1em 0.50em;">无限制</span>' | |||
] | |||
generateRandomRestrictions() | |||
} | |||
function createDiffSpan(diff, level) { | |||
var colors = { EZ: '#57E4C4', HD: '#FDBA61', IN: '#FE8661', AT: '#4C364B' } | |||
return '<span style="width: max-content;text-align:center;display:inline-block;border-radius:1em;color:white;background-color:' + colors[diff] + ';padding:0 0.80em;margin:0.1em 0.50em;">' + diff + ' ' + level + '</span>' | |||
} | |||
function updateStyles(styles) { | |||
$('.infobox-title th').css('background', styles.titleStyle) | |||
$('.infobox-header th').css('background', styles.headerStyle) | |||
$('.infobox-label').css('background', styles.labelStyle) | |||
} | |||
function generateRandomRestrictions() { | |||
var randomDifficulty = window.difficultyArray[Math.floor(Math.random() * window.difficultyArray.length)] | |||
$('#difficulty-data').html(randomDifficulty) | |||
var speedOptions = ["无限制", "无限制", "无限制"].concat(Array.from({ length: 91 }, (_, i) => (i + 10) / 10.0)) | |||
$('#speed-data').text(speedOptions[Math.floor(Math.random() * speedOptions.length)]) | |||
var modOptions = ["无MOD"] | |||
var otherOptions = ["无限制"] | |||
$('#mod-data').text(modOptions[Math.floor(Math.random() * modOptions.length)]) | |||
$('#other-data').text(otherOptions[Math.floor(Math.random() * otherOptions.length)]) | |||
} | |||
}) | |||
</script> | |||
</html> | |||
神秘的随机挑战! | |||
---- | |||
[[User:RedDragon/Test]] | |||
[[User:RedDragon/Test1]] | |||
[[User:RedDragon/Test2]] | |||