LLWiki正在建设中,欢迎加入我们!
“Widget:Sandbox”的版本间差异
跳转到导航
跳转到搜索
(创建页面,内容为“<includeonly><!--{if !isset($wgWidgetBiliVideo) || !$wgWidgetBiliVideo}--><!--{assign var="wgWidgetBiliVideo" value=true scope="global"}--> <script> window.addEventL…”) |
小 (// Edit via Wikiplus) |
||
第1行: | 第1行: | ||
<includeonly><!--{if !isset($ |
<includeonly><!--{if !isset($wgWidgetSandbox) || !$wgWidgetSandbox}--><!--{assign var="wgWidgetSandbox" value=true scope="global"}--> |
||
<script> |
<script> |
||
<iframe allowfullscreen="true" scrolling="no" class="bili-show" src="//player.bilibili.com/player.html?bvid=15x411N7Yy&page=1" frameborder="0"></iframe> |
|||
window.addEventListener('load', function () { |
|||
$('.BiliVideo').html(function () { |
|||
var av = this.dataset.av; |
|||
if (!av) { |
|||
$(this).html('<span style="font-weight:800;color:red">Error in Widget: Bv id undefined</span>'); |
|||
} else { |
|||
if (!/^\w+$/.test(av)) { |
|||
$(this).html('<span style="font-weight:800;color:red">Error in Widget: Invalid bv id.</span>'); |
|||
} else { |
|||
var param = this.dataset.param; |
|||
if (!param) { |
|||
param = '1'; |
|||
} |
|||
var size = this.dataset.size; |
|||
if (!size) { |
|||
size = '80%'; |
|||
} |
|||
if (!/^Av\d+$/.test(av)) { |
|||
$(this).html('<iframe src="//player.bilibili.com/player.html?bvid=' + av + '&page=' + param + '" scrolling="no" border="0" frameborder="no" framespacing="0" allowfullscreen="true" style="width:' + size + ';" class="bili-show"></iframe>'); |
|||
} else { |
|||
$(this).html('<iframe src="//player.bilibili.com/player.html?aid=' + av.substring(2) + '&page=' + param + '" scrolling="no" border="0" frameborder="no" framespacing="0" allowfullscreen="true" style="width:' + size + ';" class="bili-show"></iframe>'); |
|||
} |
|||
//优化iframe大小,因为用css无法定义长宽比 |
|||
var biliwidth = $('.bili-show').width(); |
|||
var biliheight = biliwidth / 4 * 3; |
|||
$('.bili-show').height(biliheight); |
|||
} |
|||
} |
|||
}); |
|||
window.addEventListener('resize', function () { |
|||
var biliwidth = $('.bili-show').width(); |
|||
var biliheight = biliwidth / 4 * 3; |
|||
$('.bili-show').height(biliheight); |
|||
}, false); |
|||
}); |
|||
</script> |
</script> |
||
<!--{/if}--></includeonly> |
<!--{/if}--></includeonly> |