Add hitbox and update mixed content errors
This commit is contained in:
parent
b279a41122
commit
8dd3280305
5 changed files with 90 additions and 41 deletions
|
|
@ -1,3 +1,10 @@
|
|||
DEFAULT_ERROR = 'You are currently connected via HTTPS but the embedded content
|
||||
uses non-secure plain HTTP. Your browser therefore blocks it from
|
||||
loading due to mixed content policy. To fix this, embed the video using a
|
||||
secure link if available (https://...), or load this page over plain HTTP by
|
||||
replacing "https://" with "http://" in the address bar (your websocket will
|
||||
still be secured using HTTPS, but this will permit non-secure content to load).'
|
||||
|
||||
genParam = (name, value) ->
|
||||
$('<param/>').attr(
|
||||
name: name
|
||||
|
|
@ -38,9 +45,19 @@ window.CustomEmbedPlayer = class CustomEmbedPlayer extends Player
|
|||
return object
|
||||
|
||||
loadIframe: (embed) ->
|
||||
iframe = $('<iframe/>').attr(
|
||||
src: embed.src
|
||||
frameborder: '0'
|
||||
)
|
||||
if embed.src.indexOf('http:') == 0 and location.protocol == 'https:'
|
||||
if embed.mixedContentError?
|
||||
error = embed.mixedContentError
|
||||
else
|
||||
error = DEFAULT_ERROR
|
||||
alert = makeAlert('Mixed Content Error', error, 'alert-danger')
|
||||
.removeClass('col-md-12')
|
||||
alert.find('.close').remove()
|
||||
return alert
|
||||
else
|
||||
iframe = $('<iframe/>').attr(
|
||||
src: embed.src
|
||||
frameborder: '0'
|
||||
)
|
||||
|
||||
return iframe
|
||||
return iframe
|
||||
|
|
|
|||
|
|
@ -1,28 +0,0 @@
|
|||
DEFAULT_WARNING = 'You are currently connected via HTTPS but the embedded video
|
||||
link uses non-secure plain HTTP. Your browser may therefore block it from
|
||||
loading due to mixed content policy. To fix this, embed the video using a
|
||||
secure link if available (https://...), or load this page over plain HTTP by
|
||||
replacing "https://" with "http://" in the address bar (your websocket will
|
||||
still be secured using HTTPS, but this will permit non-secure content to load).'
|
||||
|
||||
window.GenericIframePlayer = class GenericIframePlayer extends Player
|
||||
constructor: (data, iframeSrc, customMixedContentWarning) ->
|
||||
if not (this instanceof GenericIframePlayer)
|
||||
return new GenericIframePlayer(data, iframeSrc, customMixedContentWarning)
|
||||
|
||||
load: (data, iframeSrc, customMixedContentWarning) ->
|
||||
@setMediaProperties(data)
|
||||
|
||||
@player = $('<iframe/>').attr(
|
||||
src: iframeSrc
|
||||
frameborder: '0'
|
||||
)
|
||||
removeOld(@player)
|
||||
|
||||
if iframeSrc.indexOf('http:') == 0
|
||||
if customMixedContentWarning
|
||||
warning = customMixedContentWarning
|
||||
else
|
||||
warning = DEFAULT_WARNING
|
||||
|
||||
makeAlert('Mixed Content Warning', warning).appendTo($('#videowrap'))
|
||||
20
player/hitbox.coffee
Normal file
20
player/hitbox.coffee
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
HITBOX_ERROR = 'Hitbox.tv only serves its content over plain HTTP, but you are
|
||||
viewing this page over secure HTTPS. Your browser therefore blocks the
|
||||
hitbox embed due to mixed content policy. In order to view hitbox, you must
|
||||
view this page over plain HTTP (change "https://" to "http://" in the address
|
||||
bar)-- your websocket will still be connected using secure HTTPS. This is
|
||||
something I have asked Hitbox to fix but they have not done so yet.'
|
||||
|
||||
window.HitboxPlayer = class HitboxPlayer extends CustomEmbedPlayer
|
||||
constructor: (data) ->
|
||||
if not (this instanceof HitboxPlayer)
|
||||
return new HitboxPlayer(data)
|
||||
|
||||
@load(data)
|
||||
|
||||
load: (data) ->
|
||||
data.meta.embed =
|
||||
src: "http://hitbox.tv/embed/#{data.id}"
|
||||
tag: 'iframe'
|
||||
mixedContentError: HITBOX_ERROR
|
||||
super(data)
|
||||
|
|
@ -9,6 +9,7 @@ TYPE_MAP =
|
|||
tw: TwitchPlayer
|
||||
cu: CustomEmbedPlayer
|
||||
rt: RTMPPlayer
|
||||
hb: HitboxPlayer
|
||||
|
||||
window.loadMediaPlayer = (data) ->
|
||||
if data.type of TYPE_MAP
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue