Update
- Support iframe from Youtube, OK.RU, Google Drive and Fembed.
<div class="read z-depth-3" oncontextmenu="return false" onselectstart="return false" ondragstart="return false">
<div class="content noselect"></div>
</div>
<div class="video z-depth-3">
<ul class="tabs" id="tabs_swipe">
<li class="tab col s3"><a href="#google" class="trn">Google Drive</a></li>
<li class="tab col s3"><a href="#fembed" class="trn">Fembed</a></li>
<li class="tab col s3"><a href="#okru" class="trn">OK.RU</a></li>
<li class="tab col s3"><a href="#youtube" class="trn">Youtube</a></li>
</ul>
<div id="google" class="col s12"><p style="font-size: 2em; text-align: center;">ไม่มีข้อมูล</p></div>
<div id="fembed" class="col s12"><p style="font-size: 2em; text-align: center;">ไม่มีข้อมูล</p></div>
<div id="okru" class="col s12"><p style="font-size: 2em; text-align: center;">ไม่มีข้อมูล</p></div>
<div id="youtube" class="col s12"><p style="font-size: 2em; text-align: center;">ไม่มีข้อมูล</p></div>
</div>
<script>
$(document).ready(function(){
var html = '';
let youtube = /youtu.be|youtube.com/g;
let google = /google.com/g;
let fembed = /fembed.com/g;
let ok = /ok.ru/g;
let prx = /(http(s?):)([/|.|w|s|-])*.(?:jpg|gif|png)/g;
var content = `{已订阅}{章节内容}{/已订阅}`;
var link = content.split("<br/>");
for (var i in link){
if (link[i].match(prx)) {
html += '<div style="margin-bottom: 15px;"><img class="lazy center" width="100%" src="{templates}/static/image/book.svg" data-src="'+link[i]+'" /></div>';
$('.content').html(html);
$(".chapter_info,.video").hide();
} else if (link[i].match(youtube)) {
ytlink = link[i].match(/[a-zA-Z0-9_-]{11}/g);
html = '<div class="player"><iframe src="https://www.youtube.com/embed/'+ytlink+'" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe></div>';
$('#youtube').html(html);
$(".chapter_info,.read").hide();
} else if (link[i].match(google)) {
gglink = link[i].match(/([w-]){33}|([w-]){19}/g);
html = '<div class="player"><iframe src="https://drive.google.com/file/d/'+gglink+'/preview"></iframe></div>';
$('#google').html(html);
$(".chapter_info,.read").hide();
} else if (link[i].match(fembed)) {
femlink = link[i].match(/[a-zA-Z0-9_-]{15}/g);
html = '<div class="player"><iframe src="https://www.fembed.com/v/'+femlink+'" frameborder="0" allowfullscreen></iframe></div>';
$('#fembed').html(html);
$(".chapter_info,.read").hide();
} else if (link[i].match(ok)) {
oklink = link[i].match(/[0-9_-]{13}/g);
html = '<div class="player"><iframe src="//ok.ru/videoembed/'+oklink+'?nochat=1" frameborder="0" allow="autoplay" allowfullscreen></iframe></div>';
$('#okru').html(html);
$(".chapter_info,.read").hide();
} else if (link[i] != link[i].match(/(http(s?):)/g)){
$(".video").hide();
html = content.replace(/(<br[s]*/?>[s]*)+/g, '<br/><br/>');
$('.content').html(html);
} else {
break;
}
}
});
</script>