forked from leftypol/leftypol
try4
This commit is contained in:
parent
26a729e9d8
commit
88070b3c4a
1 changed files with 17 additions and 25 deletions
|
@ -26,48 +26,40 @@
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
const ON = "[Remove]";
|
const ON = "[Remove]";
|
||||||
const OFF = "[Embed]";
|
const OFF = "[Embed]";
|
||||||
const YOUTUBE = 'www.youtube.com';
|
const YOUTUBE = 'www.youtube.com';
|
||||||
const ONION = 'tuberyps2pn6dor6h47brof3w2asmauahhk4ei42krugybzzzo55klad.onion';
|
const ONION = 'tuberyps2pn6dor6h47brof3w2asmauahhk4ei42krugybzzzo55klad.onion';
|
||||||
const PROXY = 'incogtube.com'
|
const PROXY = 'incogtube.com'
|
||||||
function addEmbedButton(index, videoNode) {
|
function addEmbedButton(index, videoNode) {
|
||||||
videoNode = $(videoNode);
|
videoNode = $(videoNode);
|
||||||
var contents = videoNode.contents();
|
var contents = videoNode.contents();
|
||||||
var videoId = videoNode.data('video');
|
var videoId = videoNode.data('video');
|
||||||
var span = $("<span>[Embed]</span>");
|
var span = $("<span>[Embed]</span>");
|
||||||
var spanProxy = $("<span>[Proxy]</span>");
|
var spanProxy = $("<span>[Proxy]</span>");
|
||||||
var defaultEmbed = location.hostname.includes("onion") ? ONION : YOUTUBE;
|
|
||||||
var makeEmbedNode = function(embedHost) {
|
var makeEmbedNode = function(embedHost) {
|
||||||
$('<iframe style="float:left;margin: 10px 20px" type="text/html" '+
|
$('<iframe style="float:left;margin: 10px 20px" type="text/html" '+
|
||||||
'width="360" height="270" src="//' + embedHost + '/embed/' + videoId +
|
'width="360" height="270" src="//' + embedHost + '/embed/' + videoId +
|
||||||
'?autoplay=1&html5=1" allowfullscreen frameborder="0"/>');
|
'?autoplay=1&html5=1" allowfullscreen frameborder="0"/>');
|
||||||
}
|
}
|
||||||
var defaultEmbed = location.hostname.includes("onion") ? ONION : YOUTUBE;
|
var defaultEmbed = makeEmbedNode(location.hostname.includes("onion") ? ONION : YOUTUBE);
|
||||||
var proxyEmbed = makeEmbedNode(proxyEmbed);
|
var proxyEmbed = makeEmbedNode(proxyEmbed);
|
||||||
videoNode.click(function(e) {
|
videoNode.click(function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
if (span.text() == ON){
|
if (span.text() == ON){
|
||||||
|
videoNode.append(spanProxy);
|
||||||
videoNode.append(contents);
|
videoNode.append(contents);
|
||||||
defaultEmbed.remove();
|
defaultEmbed.remove();
|
||||||
proxyEmbed.remove();
|
proxyEmbed.remove();
|
||||||
span.text(OFF);
|
span.text(OFF);
|
||||||
spanProxy.hidden = false;
|
} else {
|
||||||
} else{
|
|
||||||
contents.detach();
|
contents.detach();
|
||||||
videoNode.append(defaultEmbed);
|
|
||||||
span.text(ON);
|
span.text(ON);
|
||||||
spanProxy.hidden = true;
|
spanProxy.remove();
|
||||||
|
videoNode.append(e.target == spanProxy[0] ? proxyEmbed : defaultEmbed);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
spanProxy.click(function(e) {
|
|
||||||
e.preventDefault();
|
|
||||||
contents.detach();
|
|
||||||
videoNode.append(proxyEmbed);
|
|
||||||
span.text(ON);
|
|
||||||
spanProxy.hidden = true;
|
|
||||||
});
|
|
||||||
|
|
||||||
videoNode.append(span);
|
videoNode.append(span);
|
||||||
videoNode.append(spanProxy);
|
videoNode.append(spanProxy);
|
||||||
}
|
}
|
||||||
|
@ -77,7 +69,7 @@ $(document).ready(function(){
|
||||||
|
|
||||||
// allow to work with auto-reload.js, etc.
|
// allow to work with auto-reload.js, etc.
|
||||||
$(document).on('new_post', function(e, post) {
|
$(document).on('new_post', function(e, post) {
|
||||||
$('div.video-container', post).each(addEmbedButton);
|
$('div.video-container', post).each(addEmbedButton);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue