mirror of https://github.com/calzoneman/sync.git
Add hitbox and update mixed content errors
This commit is contained in:
parent
b279a41122
commit
8dd3280305
|
@ -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) ->
|
genParam = (name, value) ->
|
||||||
$('<param/>').attr(
|
$('<param/>').attr(
|
||||||
name: name
|
name: name
|
||||||
|
@ -38,9 +45,19 @@ window.CustomEmbedPlayer = class CustomEmbedPlayer extends Player
|
||||||
return object
|
return object
|
||||||
|
|
||||||
loadIframe: (embed) ->
|
loadIframe: (embed) ->
|
||||||
iframe = $('<iframe/>').attr(
|
if embed.src.indexOf('http:') == 0 and location.protocol == 'https:'
|
||||||
src: embed.src
|
if embed.mixedContentError?
|
||||||
frameborder: '0'
|
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'))
|
|
|
@ -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
|
tw: TwitchPlayer
|
||||||
cu: CustomEmbedPlayer
|
cu: CustomEmbedPlayer
|
||||||
rt: RTMPPlayer
|
rt: RTMPPlayer
|
||||||
|
hb: HitboxPlayer
|
||||||
|
|
||||||
window.loadMediaPlayer = (data) ->
|
window.loadMediaPlayer = (data) ->
|
||||||
if data.type of TYPE_MAP
|
if data.type of TYPE_MAP
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
(function() {
|
(function() {
|
||||||
var CustomEmbedPlayer, DailymotionPlayer, LivestreamPlayer, Player, RTMPPlayer, SoundCloudPlayer, TYPE_MAP, TwitchPlayer, VideoJSPlayer, VimeoPlayer, YouTubePlayer, genParam, sortSources,
|
var CustomEmbedPlayer, DEFAULT_ERROR, DailymotionPlayer, HITBOX_ERROR, HitboxPlayer, LivestreamPlayer, Player, RTMPPlayer, SoundCloudPlayer, TYPE_MAP, TwitchPlayer, VideoJSPlayer, VimeoPlayer, YouTubePlayer, genParam, sortSources,
|
||||||
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
|
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
|
||||||
hasProp = {}.hasOwnProperty;
|
hasProp = {}.hasOwnProperty;
|
||||||
|
|
||||||
|
@ -786,6 +786,8 @@
|
||||||
|
|
||||||
})(Player);
|
})(Player);
|
||||||
|
|
||||||
|
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 = function(name, value) {
|
genParam = function(name, value) {
|
||||||
return $('<param/>').attr({
|
return $('<param/>').attr({
|
||||||
name: name,
|
name: name,
|
||||||
|
@ -835,12 +837,23 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
CustomEmbedPlayer.prototype.loadIframe = function(embed) {
|
CustomEmbedPlayer.prototype.loadIframe = function(embed) {
|
||||||
var iframe;
|
var alert, error, iframe;
|
||||||
iframe = $('<iframe/>').attr({
|
if (embed.src.indexOf('http:') === 0 && location.protocol === 'https:') {
|
||||||
src: embed.src,
|
if (embed.mixedContentError != null) {
|
||||||
frameborder: '0'
|
error = embed.mixedContentError;
|
||||||
});
|
} else {
|
||||||
return iframe;
|
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 CustomEmbedPlayer;
|
return CustomEmbedPlayer;
|
||||||
|
@ -883,6 +896,31 @@
|
||||||
|
|
||||||
})(CustomEmbedPlayer);
|
})(CustomEmbedPlayer);
|
||||||
|
|
||||||
|
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 = HitboxPlayer = (function(superClass) {
|
||||||
|
extend(HitboxPlayer, superClass);
|
||||||
|
|
||||||
|
function HitboxPlayer(data) {
|
||||||
|
if (!(this instanceof HitboxPlayer)) {
|
||||||
|
return new HitboxPlayer(data);
|
||||||
|
}
|
||||||
|
this.load(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
HitboxPlayer.prototype.load = function(data) {
|
||||||
|
data.meta.embed = {
|
||||||
|
src: "http://hitbox.tv/embed/" + data.id,
|
||||||
|
tag: 'iframe',
|
||||||
|
mixedContentError: HITBOX_ERROR
|
||||||
|
};
|
||||||
|
return HitboxPlayer.__super__.load.call(this, data);
|
||||||
|
};
|
||||||
|
|
||||||
|
return HitboxPlayer;
|
||||||
|
|
||||||
|
})(CustomEmbedPlayer);
|
||||||
|
|
||||||
TYPE_MAP = {
|
TYPE_MAP = {
|
||||||
yt: YouTubePlayer,
|
yt: YouTubePlayer,
|
||||||
vi: VimeoPlayer,
|
vi: VimeoPlayer,
|
||||||
|
@ -893,7 +931,8 @@
|
||||||
li: LivestreamPlayer,
|
li: LivestreamPlayer,
|
||||||
tw: TwitchPlayer,
|
tw: TwitchPlayer,
|
||||||
cu: CustomEmbedPlayer,
|
cu: CustomEmbedPlayer,
|
||||||
rt: RTMPPlayer
|
rt: RTMPPlayer,
|
||||||
|
hb: HitboxPlayer
|
||||||
};
|
};
|
||||||
|
|
||||||
window.loadMediaPlayer = function(data) {
|
window.loadMediaPlayer = function(data) {
|
||||||
|
|
Loading…
Reference in New Issue