2015-06-30 01:32:18 +00:00
|
|
|
CUSTOM_EMBED_WARNING = 'This channel is embedding custom content from %link%.
|
|
|
|
Since this content is not trusted, you must click "Embed" below to allow
|
|
|
|
the content to be embedded.<hr>'
|
2015-06-21 14:27:51 +00:00
|
|
|
|
2015-06-30 01:32:18 +00:00
|
|
|
window.CustomEmbedPlayer = class CustomEmbedPlayer extends EmbedPlayer
|
2015-06-18 22:46:33 +00:00
|
|
|
constructor: (data) ->
|
|
|
|
if not (this instanceof CustomEmbedPlayer)
|
|
|
|
return new CustomEmbedPlayer(data)
|
|
|
|
|
|
|
|
@load(data)
|
|
|
|
|
|
|
|
load: (data) ->
|
2015-06-30 01:32:18 +00:00
|
|
|
if not data.meta.embed?
|
2015-06-18 22:46:33 +00:00
|
|
|
console.error('CustomEmbedPlayer::load(): missing meta.embed')
|
|
|
|
return
|
|
|
|
|
2015-06-30 01:32:18 +00:00
|
|
|
embedSrc = data.meta.embed.src
|
2023-01-12 01:57:02 +00:00
|
|
|
|
|
|
|
link = document.createElement('a')
|
|
|
|
link.href = embedSrc
|
|
|
|
link.target = '_blank'
|
|
|
|
link.rel = 'noopener noreferer'
|
|
|
|
|
|
|
|
strong = document.createElement('strong')
|
|
|
|
strong.textContent = embedSrc
|
|
|
|
link.appendChild(strong)
|
|
|
|
|
|
|
|
# TODO: Ideally makeAlert() would allow optionally providing a DOM
|
|
|
|
# element instead of requiring HTML text
|
|
|
|
alert = makeAlert('Untrusted Content', CUSTOM_EMBED_WARNING.replace('%link%', link.outerHTML),
|
2015-06-30 01:32:18 +00:00
|
|
|
'alert-warning')
|
|
|
|
.removeClass('col-md-12')
|
|
|
|
$('<button/>').addClass('btn btn-default')
|
|
|
|
.text('Embed')
|
2022-01-23 00:18:51 +00:00
|
|
|
.on('click', =>
|
2015-06-30 01:32:18 +00:00
|
|
|
super(data)
|
2015-06-21 14:27:51 +00:00
|
|
|
)
|
2015-06-30 01:32:18 +00:00
|
|
|
.appendTo(alert.find('.alert'))
|
|
|
|
removeOld(alert)
|