2012-04-30 11:23:03 +00:00
|
|
|
/*\
|
2012-05-03 20:47:16 +00:00
|
|
|
title: $:/core/modules/macros/video.js
|
2012-04-30 11:23:03 +00:00
|
|
|
type: application/javascript
|
|
|
|
module-type: macro
|
|
|
|
|
2012-05-19 17:23:14 +00:00
|
|
|
Video macro
|
|
|
|
|
2012-04-30 11:23:03 +00:00
|
|
|
\*/
|
|
|
|
(function(){
|
|
|
|
|
2012-05-04 17:49:04 +00:00
|
|
|
/*jslint node: true, browser: true */
|
|
|
|
/*global $tw: false */
|
2012-04-30 11:23:03 +00:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
exports.info = {
|
|
|
|
name: "video",
|
|
|
|
params: {
|
|
|
|
src: {byName: "default", type: "text"},
|
|
|
|
type: {byName: true, type: "text"},
|
|
|
|
width: {byName: true, type: "text"},
|
|
|
|
height: {byName: true, type: "text"}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
exports.executeMacro = function() {
|
|
|
|
var src = this.params.src,
|
|
|
|
videoType = this.params.type || "vimeo",
|
|
|
|
videoWidth = this.params.width || 640,
|
|
|
|
videoHeight = this.params.height || 360;
|
|
|
|
switch(videoType) {
|
|
|
|
case "vimeo":
|
2012-06-09 17:36:32 +00:00
|
|
|
return $tw.Tree.Element("iframe",{
|
2012-04-30 11:23:03 +00:00
|
|
|
src: "http://player.vimeo.com/video/" + src + "?autoplay=0",
|
|
|
|
width: videoWidth,
|
|
|
|
height: videoHeight,
|
|
|
|
frameborder: 0
|
2012-06-09 17:36:32 +00:00
|
|
|
});
|
2012-04-30 11:23:03 +00:00
|
|
|
case "youtube":
|
2012-06-09 17:36:32 +00:00
|
|
|
return $tw.Tree.Element("iframe",{
|
2012-04-30 11:23:03 +00:00
|
|
|
type: "text/html",
|
|
|
|
src: "http://www.youtube.com/embed/" + src,
|
|
|
|
width: videoWidth,
|
|
|
|
height: videoHeight,
|
|
|
|
frameborder: 0
|
2012-06-09 17:36:32 +00:00
|
|
|
});
|
2012-04-30 11:23:03 +00:00
|
|
|
case "archiveorg":
|
2012-06-09 17:36:32 +00:00
|
|
|
return $tw.Tree.Element("iframe",{
|
2012-04-30 11:23:03 +00:00
|
|
|
src: "http://www.archive.org/embed/" + src,
|
|
|
|
width: videoWidth,
|
|
|
|
height: videoHeight,
|
|
|
|
frameborder: 0
|
2012-06-09 17:36:32 +00:00
|
|
|
});
|
2012-04-30 11:23:03 +00:00
|
|
|
default:
|
2012-06-09 17:36:32 +00:00
|
|
|
return null;
|
2012-04-30 11:23:03 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
})();
|