cheditor 5.1.9.4 버전 업데이트
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
// ================================================================
|
||||
// CHEditor 5
|
||||
// Movie
|
||||
// ================================================================
|
||||
var button = [
|
||||
{ alt : '', img : 'play.gif', cmd : doPlay },
|
||||
@ -7,7 +7,10 @@ var button = [
|
||||
{ alt : '', img : 'cancel.gif', cmd : popupClose }
|
||||
],
|
||||
oEditor = null,
|
||||
iframeSource = false;
|
||||
iframeSource = null,
|
||||
showMovie = false,
|
||||
defaultMovieWidth = 640,
|
||||
defaultMovieHeight = 360;
|
||||
|
||||
function init(dialog) {
|
||||
var dlg = new Dialog(this);
|
||||
@ -17,52 +20,65 @@ function init(dialog) {
|
||||
dlg.setDialogHeight();
|
||||
}
|
||||
|
||||
function doPlay()
|
||||
{
|
||||
var elem = oEditor.trimSpace(document.getElementById("fm_embed").value),
|
||||
embed = null, div = document.createElement('div'),
|
||||
pos, str, object, child, movieHeight, movieWidth, i, params = [];
|
||||
function getSource() {
|
||||
return oEditor.trimSpace(document.getElementById("fm_source").value);
|
||||
}
|
||||
|
||||
elem = oEditor.trimSpace(elem);
|
||||
if (elem == '') {
|
||||
function doPlay() {
|
||||
var embed = null,
|
||||
div = document.createElement('div'),
|
||||
pos, str, object, child, movieHeight, movieWidth, params = [], showWrapper,
|
||||
source = getSource(), iframe;
|
||||
|
||||
showMovie = true;
|
||||
if (source === '') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (elem.toLowerCase().indexOf("iframe") !== -1) {
|
||||
document.getElementById('fm_player').innerHTML = elem;
|
||||
iframeSource = true;
|
||||
showWrapper = document.getElementById('fm_player');
|
||||
if (source.toLowerCase().indexOf("iframe") !== -1) {
|
||||
showWrapper.innerHTML = source;
|
||||
iframeSource = source;
|
||||
return;
|
||||
}
|
||||
|
||||
pos = elem.toLowerCase().indexOf("embed");
|
||||
if (/https?:\/\//.test(source)) {
|
||||
iframe = createIframeElement(defaultMovieWidth, defaultMovieHeight, source);
|
||||
if (iframe) {
|
||||
showWrapper.innerHTML = '';
|
||||
showWrapper.appendChild(iframe);
|
||||
iframeSource = iframe;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
pos = source.toLowerCase().indexOf("embed");
|
||||
if (pos !== -1) {
|
||||
str = elem.substr(pos);
|
||||
str = source.substr(pos);
|
||||
pos = str.indexOf(">");
|
||||
div.innerHTML = "<" + str.substr(0, pos) + ">";
|
||||
embed = div.firstChild;
|
||||
} else {
|
||||
div.innerHTML = elem;
|
||||
div.innerHTML = source;
|
||||
object = div.getElementsByTagName('OBJECT')[0];
|
||||
if (object && object.hasChildNodes()) {
|
||||
child = object.firstChild;
|
||||
movieWidth = (isNaN(object.width) !== true) ? object.width : 320;
|
||||
movieHeight = (isNaN(object.height) !== true) ? object.height : 240;
|
||||
movieWidth = (isNaN(object.width) !== true) ? object.width : defaultMovieWidth;
|
||||
movieHeight = (isNaN(object.height) !== true) ? object.height : defaultMovieHeight;
|
||||
|
||||
do {
|
||||
if ((child.nodeName === 'PARAM') && (typeof child.name !== 'undefined') && (typeof child.value !== 'undefined')) {
|
||||
params.push({key: (child.name == 'movie') ? 'src' : child.name, val: child.value});
|
||||
if (child.nodeName === 'PARAM' && typeof child.name !== 'undefined' && typeof child.value !== 'undefined')
|
||||
{
|
||||
params.push({
|
||||
key: child.name === 'movie' ? 'src' : child.name,
|
||||
val: child.value
|
||||
});
|
||||
}
|
||||
child = child.nextSibling;
|
||||
} while (child);
|
||||
|
||||
if (params.length > 0) {
|
||||
embed = document.createElement('embed');
|
||||
embed.setAttribute("width", movieWidth);
|
||||
embed.setAttribute("height", movieHeight);
|
||||
for (i = 0; i < params.length; i++) {
|
||||
embed.setAttribute(params[i].key, params[i].val);
|
||||
}
|
||||
embed.setAttribute("type", "application/x-shockwave-flash");
|
||||
embed = createEmbedElement(movieWidth, movieHeight, params, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -72,6 +88,89 @@ function doPlay()
|
||||
}
|
||||
}
|
||||
|
||||
function createIframeElement(width, height, src) {
|
||||
var iframe = document.createElement('iframe'), uri, query, id, movie = null;
|
||||
|
||||
uri = new oEditor.URI(src);
|
||||
if (uri.path && uri.path.charAt(0) !== '/') {
|
||||
uri.path = '/' + uri.path;
|
||||
}
|
||||
|
||||
switch (uri.authority) {
|
||||
case 'youtu.be' :
|
||||
case 'youtube.com':
|
||||
case 'www.youtube.com':
|
||||
if (uri.path === '/watch' && uri.query) {
|
||||
query = uri.query.split('=');
|
||||
if (query[0] === 'v') {
|
||||
movie = '/' + query[1];
|
||||
}
|
||||
}
|
||||
if (!movie && uri.path) {
|
||||
movie = uri.path;
|
||||
if (uri.query) {
|
||||
movie += '?' + uri.query;
|
||||
}
|
||||
}
|
||||
if (movie) {
|
||||
movie = 'https://www.youtube.com/embed' + movie;
|
||||
}
|
||||
break;
|
||||
case 'vimeo.com' :
|
||||
if (uri.path) {
|
||||
movie = 'https://player.vimeo.com/video' + uri.path;
|
||||
}
|
||||
break;
|
||||
case 'afree.ca' :
|
||||
if (uri.path) {
|
||||
movie = 'http://play.afreecatv.com' + uri.path + '/embed';
|
||||
}
|
||||
break;
|
||||
case 'tv.naver.com' :
|
||||
if (uri.path) {
|
||||
id = uri.path.substring(uri.path.lastIndexOf('/'));
|
||||
movie = 'https://tv.naver.com/embed' + id + '?autoPlay=true';
|
||||
}
|
||||
break;
|
||||
case 'tv.kakao.com' :
|
||||
if (uri.path) {
|
||||
id = uri.path.substring(uri.path.lastIndexOf('/'));
|
||||
movie = 'https://tv.kakao.com/embed/player/cliplink' + id;
|
||||
}
|
||||
break;
|
||||
default :
|
||||
movie = null;
|
||||
}
|
||||
if (!movie) {
|
||||
return null;
|
||||
}
|
||||
|
||||
iframe.setAttribute('width', width);
|
||||
iframe.setAttribute('height', height);
|
||||
iframe.setAttribute('frameborder', "0");
|
||||
iframe.setAttribute('allowfullscreen', "true");
|
||||
iframe.setAttribute('src', movie);
|
||||
return iframe;
|
||||
}
|
||||
|
||||
function createEmbedElement(width, height, params, src) {
|
||||
var embed = document.createElement('embed'), i;
|
||||
|
||||
embed.setAttribute("type", "application/x-shockwave-flash");
|
||||
embed.setAttribute('width', width);
|
||||
embed.setAttribute('height', height);
|
||||
|
||||
if (src) {
|
||||
embed.setAttribute('src', src);
|
||||
}
|
||||
|
||||
for (i = 0; i < params.length; i++) {
|
||||
embed.setAttribute(params[i].key, params[i].val);
|
||||
}
|
||||
|
||||
return embed;
|
||||
}
|
||||
|
||||
function popupClose() {
|
||||
document.getElementById('fm_player').innerHTML = '';
|
||||
oEditor.popupWinCancel();
|
||||
@ -79,13 +178,17 @@ function popupClose() {
|
||||
|
||||
function doSubmit()
|
||||
{
|
||||
var source = String(oEditor.trimSpace(document.getElementById("fm_embed").value));
|
||||
var source = getSource();
|
||||
if (source === '') {
|
||||
popupClose();
|
||||
}
|
||||
if (!showMovie) {
|
||||
document.getElementById('fm_player').style.visibility = 'hidden';
|
||||
doPlay();
|
||||
}
|
||||
|
||||
if (iframeSource || source.indexOf("iframe") !== -1) {
|
||||
oEditor.insertHtmlPopup(source);
|
||||
if (iframeSource) {
|
||||
oEditor.insertHtmlPopup(iframeSource);
|
||||
} else {
|
||||
oEditor.insertFlash(source);
|
||||
}
|
||||
@ -93,3 +196,4 @@ function doSubmit()
|
||||
document.getElementById('fm_player').innerHTML = '';
|
||||
oEditor.popupWinClose();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user