Warning : session_start(): Session cannot be started after headers have already been sent in /home/tvrreohg/public_html/manga.php on line 13
import $ from 'jquery';
import env from '../core/env';
import key from '../core/key';
export default class VideoDialog {
constructor(context) {
this.context = context;
this.ui = $.summernote.ui;
this.$body = $(document.body);
this.$editor = context.layoutInfo.editor;
this.options = context.options;
this.lang = this.options.langInfo;
}
initialize() {
const $container = this.options.dialogsInBody ? this.$body : this.options.container;
const body = [
'',
`${this.lang.video.url} ${this.lang.video.providers} `,
` `,
'
',
].join('');
const buttonClass = 'btn btn-primary note-btn note-btn-primary note-video-btn';
const footer = ` `;
this.$dialog = this.ui.dialog({
title: this.lang.video.insert,
fade: this.options.dialogsFade,
body: body,
footer: footer,
}).render().appendTo($container);
}
destroy() {
this.ui.hideDialog(this.$dialog);
this.$dialog.remove();
}
bindEnterKey($input, $btn) {
$input.on('keypress', (event) => {
if (event.keyCode === key.code.ENTER) {
event.preventDefault();
$btn.trigger('click');
}
});
}
createVideoNode(url) {
// video url patterns(youtube, instagram, vimeo, dailymotion, youku, peertube, mp4, ogg, webm)
const ytRegExp = /\/\/(?:(?:www|m)\.)?(?:youtu\.be\/|youtube\.com\/(?:embed\/|v\/|watch\?v=|watch\?.+&v=))([\w|-]{11})(?:(?:[\?&]t=)(\S+))?$/;
const ytRegExpForStart = /^(?:(\d+)h)?(?:(\d+)m)?(?:(\d+)s)?$/;
const ytMatch = url.match(ytRegExp);
const gdRegExp = /(?:\.|\/\/)drive\.google\.com\/file\/d\/(.[a-zA-Z0-9_-]*)\/view/;
const gdMatch = url.match(gdRegExp);
const igRegExp = /(?:www\.|\/\/)instagram\.com\/p\/(.[a-zA-Z0-9_-]*)/;
const igMatch = url.match(igRegExp);
const vRegExp = /\/\/vine\.co\/v\/([a-zA-Z0-9]+)/;
const vMatch = url.match(vRegExp);
const vimRegExp = /\/\/(player\.)?vimeo\.com\/([a-z]*\/)*(\d+)[?]?.*/;
const vimMatch = url.match(vimRegExp);
const dmRegExp = /.+dailymotion.com\/(video|hub)\/([^_]+)[^#]*(#video=([^_&]+))?/;
const dmMatch = url.match(dmRegExp);
const youkuRegExp = /\/\/v\.youku\.com\/v_show\/id_(\w+)=*\.html/;
const youkuMatch = url.match(youkuRegExp);
const peerTubeRegExp =/\/\/(.*)\/videos\/watch\/([^?]*)(?:\?(?:start=(\w*))?(?:&stop=(\w*))?(?:&loop=([10]))?(?:&autoplay=([10]))?(?:&muted=([10]))?)?/;
const peerTubeMatch = url.match(peerTubeRegExp);
const qqRegExp = /\/\/v\.qq\.com.*?vid=(.+)/;
const qqMatch = url.match(qqRegExp);
const qqRegExp2 = /\/\/v\.qq\.com\/x?\/?(page|cover).*?\/([^\/]+)\.html\??.*/;
const qqMatch2 = url.match(qqRegExp2);
const mp4RegExp = /^.+.(mp4|m4v)$/;
const mp4Match = url.match(mp4RegExp);
const oggRegExp = /^.+.(ogg|ogv)$/;
const oggMatch = url.match(oggRegExp);
const webmRegExp = /^.+.(webm)$/;
const webmMatch = url.match(webmRegExp);
const fbRegExp = /(?:www\.|\/\/)facebook\.com\/([^\/]+)\/videos\/([0-9]+)/;
const fbMatch = url.match(fbRegExp);
let $video;
if (ytMatch && ytMatch[1].length === 11) {
const youtubeId = ytMatch[1];
var start = 0;
if (typeof ytMatch[2] !== 'undefined') {
const ytMatchForStart = ytMatch[2].match(ytRegExpForStart);
if (ytMatchForStart) {
for (var n = [3600, 60, 1], i = 0, r = n.length; i < r; i++) {
start += (typeof ytMatchForStart[i + 1] !== 'undefined' ? n[i] * parseInt(ytMatchForStart[i + 1], 10) : 0);
}
}
}
$video = $('