「Widget:BilibiliVideo」の版間の差分
1行目: | 1行目: | ||
<noinclude><poem> | <noinclude><poem> | ||
− | + | Name: Bilibili Video Plugin | |
− | + | Author: 加大号的猫 | |
− | + | Revised: [[zhmoegirl:User:Boxsnake|Boxsnake]] | |
− | + | Re-revised: [[zhmoegirl:User:AnnAngela|AnnAngela]] | |
− | + | Re-re-revised for HTML5: [[zhmoegirl:User:AnnAngela|AnnAngela]] | |
− | + | Copyright agreement: MIT | |
− | + | Mobile support: [[zhmoegirl:User:Nbdd0121|XYZ指示物]] | |
− | + | Release date: 1st version on 2012/06/29, 2nd versionon on 2015/02/06, major update on 2016/11/29, HTML5 version on 2017/04/10 | |
− | + | Release at: zh.moegirl.org/Widget:BilibiliVideo && zh.moegirl.org/Template:BilibiliVideo | |
− | + | Note: If there are any questions, please contact the author. | |
− | ''' | + | '''THIS WIDGET CAN NOT BE USED ALONE''', PLEASE USE {{tl|BilibiliVideo}}! |
</poem></noinclude><includeonly> | </poem></noinclude><includeonly> | ||
<!--{if !isset($wgBilibili) || !$wgBilibili}--> | <!--{if !isset($wgBilibili) || !$wgBilibili}--> | ||
135行目: | 135行目: | ||
}); | }); | ||
else { | else { | ||
− | var global_autoplay = false, | + | var EPSILON = Number.EPSILON || 2.220446049250313e-16, |
+ | global_autoplay = false, | ||
global_element = $('#mw-content-text'); | global_element = $('#mw-content-text'); | ||
window.widget = window.widget || {}; | window.widget = window.widget || {}; | ||
window.widget.bilibili = { | window.widget.bilibili = { | ||
− | iframes: new(window.Map || mw.Map)() | + | iframes: new(window.Map || mw.Map)(), |
+ | i18n: { | ||
+ | ja: { | ||
+ | showVideo: '動画表示', | ||
+ | hideVideo: '動画隠す', | ||
+ | wideMode: 'シアターモード', | ||
+ | wideModeExit: 'デフォルト表示', | ||
+ | errorMessage: '申し訳ありませんが、ビデオ情報を取得できませんでした', | ||
+ | loading: 'Loading...', | ||
+ | reload: 'Reload' | ||
+ | }, | ||
+ | zh: { | ||
+ | showVideo: '显示视频', | ||
+ | hideVideo: '隐藏视频', | ||
+ | wideMode: '显示宽屏', | ||
+ | wideModeExit: '隐藏宽屏', | ||
+ | errorMessage: '“Bilibili采用会员制,大部分投稿视频会员与游客都可以观看,\n 但部分视频在UP主设定下只有会员才可以观看(这些视频常被称为‘只有会员才知道的世界’)。”\n - Bilibili#用户制度 @ ZhMoegirl\n在这种情况下我们无法为您解析视频及其分P标题、分P数量等,也不能强制使用H5播放器。\n但如果您已经登录B站并且设置默认播放器为H5播放器时此处仍会是H5播放器。', | ||
+ | loading: '正在加载,请稍候……', | ||
+ | reload: '重新加载' | ||
+ | } | ||
+ | } | ||
}; | }; | ||
− | var | + | var i18nkey = mw.config.get('wgUserLanguage') === 'ja' ? 'ja' : 'zh'; |
− | + | var rememberWH = function rememberWH(ele) { | |
ele.data({ width: ele.width(), height: ele.height() }); | ele.data({ width: ele.width(), height: ele.height() }); | ||
}, | }, | ||
161行目: | 182行目: | ||
t += $(this).outerHeight(true); | t += $(this).outerHeight(true); | ||
}); | }); | ||
− | target.css('max-height', 'calc(100% - ' + (parseInt(t - h + 2 - | + | target.css('max-height', 'calc(100% - ' + (parseInt(t - h + 2 - EPSILON)) + 'px)'); |
}; | }; | ||
$('.bilibili-video-container').addClass('exec').each(function() { | $('.bilibili-video-container').addClass('exec').each(function() { | ||
200行目: | 221行目: | ||
width: width, | width: width, | ||
height: height | height: height | ||
− | }).text( | + | }).text(window.widget.bilibili.i18n[i18nkey].loading); |
$.extend(iframe, { | $.extend(iframe, { | ||
execAppend: function execAppend() { | execAppend: function execAppend() { | ||
var iframe = this, | var iframe = this, | ||
− | retryLink = $('<a/>').text( | + | retryLink = $('<a/>').text(window.widget.bilibili.i18n[i18nkey].reload).addClass('bilibili-iframe-retry-link').on('click', function() { |
var container = $(this).closest('.bilibili-iframe-container'), | var container = $(this).closest('.bilibili-iframe-container'), | ||
iframe = container.find('iframe'), | iframe = container.find('iframe'), | ||
266行目: | 287行目: | ||
error: function(e) { | error: function(e) { | ||
title_text.text(title || 'av' + id + ([0, 1].indexOf(page) !== -1 ? '' : ' (' + page + ')')); | title_text.text(title || 'av' + id + ([0, 1].indexOf(page) !== -1 ? '' : ' (' + page + ')')); | ||
− | if (e && e.responseJSON && e.responseJSON.message && e.responseJSON.message === "Authentication is required for accessing this video.") title_text.parent().append('<span style="display: inline-block;" title=" | + | if (e && e.responseJSON && e.responseJSON.message && e.responseJSON.message === "Authentication is required for accessing this video.") title_text.parent().append('<span style="display: inline-block;" title="' + window.widget.bilibili.i18n[i18nkey].errorMessage + '"><sup>(注)</sup></span>'); |
iframe.attr('src', 'https://www.bilibili.com/blackboard/player.html?aid=' + id + '&page=' + page + '&enable_ssl=1&as_wide=1' + (autoplay === 'true' ? '&autoplay=true' : '') + (isNaN(t) || t <= 0 ? '' : '&t=' + t)); | iframe.attr('src', 'https://www.bilibili.com/blackboard/player.html?aid=' + id + '&page=' + page + '&enable_ssl=1&as_wide=1' + (autoplay === 'true' ? '&autoplay=true' : '') + (isNaN(t) || t <= 0 ? '' : '&t=' + t)); | ||
if (iframeContainer.is(':visible')) iframe.execAppend(); | if (iframeContainer.is(':visible')) iframe.execAppend(); | ||
278行目: | 299行目: | ||
selfbox.toggleClass('onshow'); | selfbox.toggleClass('onshow'); | ||
iframeContainer.toggle(); | iframeContainer.toggle(); | ||
− | if ($(this).text() === ' | + | if ($(this).text() === '') { |
− | $(this).text( | + | $(this).text(window.widget.bilibili.i18n[i18nkey].hideVideo); |
if (iframe.data('ready') === true) iframe.execAppend(); | if (iframe.data('ready') === true) iframe.execAppend(); | ||
$(window).resize(); | $(window).resize(); | ||
} else { | } else { | ||
− | $(this).text( | + | $(this).text(window.widget.bilibili.i18n[i18nkey].showVideo); |
selfbox.removeAttr('style'); | selfbox.removeAttr('style'); | ||
} | } | ||
291行目: | 312行目: | ||
if (selfbox.is('.widescreen')) { | if (selfbox.is('.widescreen')) { | ||
selfbox.removeClass('widescreen'); | selfbox.removeClass('widescreen'); | ||
− | $(this).text( | + | $(this).text(window.widget.bilibili.i18n[i18nkey].wideMode); |
recallWH(iframeContainer); | recallWH(iframeContainer); | ||
recallWH(iframe); | recallWH(iframe); | ||
297行目: | 318行目: | ||
} else { | } else { | ||
selfbox.addClass('widescreen'); | selfbox.addClass('widescreen'); | ||
− | $(this).text( | + | $(this).text(window.widget.bilibili.i18n[i18nkey].wideModeExit); |
rememberWH(selfbox); | rememberWH(selfbox); | ||
selfbox.css('width', selfbox.parent().width() > Math.min(911, global_element.width()) ? '73%' : '100%'); //可以看见按钮的最小宽度 665 的 1/0.73 倍 | selfbox.css('width', selfbox.parent().width() > Math.min(911, global_element.width()) ? '73%' : '100%'); //可以看见按钮的最小宽度 665 的 1/0.73 倍 |
2017年12月31日 (日) 13:58時点における版
Name: Bilibili Video Plugin
Author: 加大号的猫
Revised: Boxsnake
Re-revised: AnnAngela
Re-re-revised for HTML5: AnnAngela
Copyright agreement: MIT
Mobile support: XYZ指示物
Release date: 1st version on 2012/06/29, 2nd versionon on 2015/02/06, major update on 2016/11/29, HTML5 version on 2017/04/10
Release at: zh.moegirl.org/Widget:BilibiliVideo && zh.moegirl.org/Template:BilibiliVideo
Note: If there are any questions, please contact the author.
THIS WIDGET CAN NOT BE USED ALONE, PLEASE USE {{BilibiliVideo}}!