258 lines
8.7 KiB
JavaScript
258 lines
8.7 KiB
JavaScript
// _____ _ _ _____
|
|
// / ___| (_) | | / __ \
|
|
// \ `--. ___ _ __ _ _ __ | |_| / \/
|
|
// `--. \/ __| '__| | '_ \| __| | / _` | '_ ` _ \
|
|
// /\__/ / (__| | | | |_) | |_| \__/\ (_| | | | | | |
|
|
// \____/ \___|_| |_| .__/ \__|\____/\__,_|_| |_| |_|
|
|
// | |
|
|
// Version 1.6.0 |_| (c) Tele-Line Videotex Services
|
|
|
|
// Use jscompress.com to compress this file
|
|
|
|
;(function(jQuery) {
|
|
jQuery.fn.scriptcam=function(options) {
|
|
// merge passed options with default values
|
|
var opts=jQuery.extend({}, jQuery.fn.scriptcam.defaults, options);
|
|
// off we go
|
|
return this.each(function() {
|
|
// add flash to div
|
|
opts.id=this.id; // add id of plugin to the options structure
|
|
data=opts; // pass options to jquery internal data field to make them available to the outside world
|
|
data.path=decodeURIComponent("\/cam\/"); // convert URI back to normal string
|
|
|
|
jQuery('#'+opts.id).html(opts.noFlashFound); // inject no flash found message
|
|
// forward incoming flash movie calls to outgoing functions
|
|
jQuery.scriptcam.SC_promptWillShow=data.promptWillShow;
|
|
jQuery.scriptcam.SC_fileReady=data.fileReady;
|
|
jQuery.scriptcam.SC_fileConversionStarted=data.fileConversionStarted;
|
|
jQuery.scriptcam.SC_onMotion=data.onMotion;
|
|
jQuery.scriptcam.SC_onError=data.onError;
|
|
jQuery.scriptcam.SC_onHandLeft=data.onHandLeft;
|
|
jQuery.scriptcam.SC_onHandRight=data.onHandRight;
|
|
jQuery.scriptcam.SC_onWebcamReady=data.onWebcamReady;
|
|
jQuery.scriptcam.SC_connected=data.connected;
|
|
jQuery.scriptcam.SC_onPictureAsBase64=data.onPictureAsBase64;
|
|
jQuery.scriptcam.SC_disconnected=data.disconnected;
|
|
jQuery.scriptcam.SC_setVolume=data.setVolume;
|
|
jQuery.scriptcam.SC_timeLeft=data.timeLeft;
|
|
jQuery.scriptcam.SC_userLeft=data.userLeft;
|
|
jQuery.scriptcam.SC_userJoined=data.userJoined;
|
|
jQuery.scriptcam.SC_addChatText=function(value) {
|
|
value = value.replace(":{", '<img src="/cam/angry.gif" width="16" height="16" class="smiley"/>');
|
|
value = value.replace(":-{", '<img src="/cam/angry.gif" width="16" height="16" class="smiley"/>');
|
|
value = value.replace(":)", '<img src="/cam/smile.gif" width="16" height="16" class="smiley"/>');
|
|
value = value.replace(":-)", '<img src="/cam/smile.gif" width="16" height="16" class="smiley"/>');
|
|
value = value.replace(":D", '<img src="/cam/biggrin.gif" width="16" height="16" class="smiley"/>');
|
|
value = value.replace(":-D", '<img src="/cam/biggrin.gif" width="16" height="16" class="smiley"/>');
|
|
value = value.replace(":O", '<img src="/cam/ohmy.gif" width="16" height="16" class="smiley"/>');
|
|
value = value.replace(":-O", '<img src="/cam/ohmy.gif" width="16" height="16" class="smiley"/>');
|
|
value = value.replace(":(", '<img src="/cam/sad.gif" width="16" height="16" class="smiley"/>');
|
|
value = value.replace(":-(", '<img src="/cam/sad.gif" width="16" height="16" class="smiley"/>');
|
|
value = value.replace(":p", '<img src="/cam/tongue.gif" width="16" height="16" class="smiley"/>');
|
|
value = value.replace(":-p", '<img src="/cam/tongue.gif" width="16" height="16" class="smiley"/>');
|
|
value = value.replace(";)", '<img src="/cam/wink.gif" width="16" height="16" class="smiley"/>');
|
|
value = value.replace(";-)", '<img src="/cam/wink.gif" width="16" height="16" class="smiley"/>');
|
|
jQuery('#'+data.chatWindow).append(value+'<br/>');
|
|
jQuery('#'+data.chatWindow).animate({ scrollTop: jQuery('#'+data.chatWindow).prop("scrollHeight") - jQuery('#'+data.chatWindow).height() }, 100);
|
|
}
|
|
if (opts.canvasHeight && opts.canvasHeight) {
|
|
var newWidth=opts.canvasWidth;
|
|
var newHeight=opts.canvasHeight;
|
|
}
|
|
else {
|
|
// no canvas dimensions given, make our own horizontal layout
|
|
var newWidth=opts.width*opts.zoom;
|
|
var newHeight=opts.height*opts.zoom;
|
|
if (opts.chatRoom) {
|
|
newWidth=(opts.width*opts.zoom)+(opts.width*opts.zoomChat)+5; // make room for two horizontal video windows with a margin of 5
|
|
opts.posX=(opts.width*opts.zoom)+5;
|
|
newHeight=opts.height*Math.max(opts.zoom,opts.zoomChat);
|
|
};
|
|
}
|
|
// make new dimensions are not below minimum flash size
|
|
if (newWidth < 215) {
|
|
newWidth=215;
|
|
}
|
|
if (newHeight < 138) {
|
|
newHeight=138;
|
|
}
|
|
if (opts.rotate!=0 || opts.skewX!=0 || opts.skewY!=0 || opts.flip!=0 || opts.zoom!=1 || opts.zoomChat!=1) {
|
|
// no GPU acceleration
|
|
var params = {
|
|
menu: 'false',
|
|
wmode: 'window',
|
|
allowScriptAccess: 'always',
|
|
allowFullScreen: 'true'
|
|
};
|
|
}
|
|
else {
|
|
// GPU acceleration when no filter is used
|
|
var params = {
|
|
menu: 'false',
|
|
wmode: 'direct',
|
|
allowScriptAccess: 'always',
|
|
allowFullScreen: 'true'
|
|
};
|
|
};
|
|
// Escape all values contained in the flashVars (IE needs this)
|
|
for (var key in opts) {
|
|
opts[key] = encodeURIComponent(opts[key]);
|
|
};
|
|
if (fileExists(decodeURIComponent(data.path)+'scriptcam.swf')) {
|
|
swfobject.embedSWF(decodeURIComponent(data.path)+'scriptcam.swf', opts.id, newWidth, newHeight, '11.6', false, opts, params);
|
|
}
|
|
else {
|
|
alert(decodeURIComponent(data.path)+'scriptcam.swf not found, please check the path parameter');
|
|
}
|
|
});
|
|
};
|
|
|
|
function fileExists(url) {
|
|
var http = new XMLHttpRequest();
|
|
http.open('HEAD', url, false);
|
|
http.send();
|
|
return http.status==200;
|
|
}
|
|
|
|
jQuery.scriptcam={};
|
|
|
|
// outgoing functions (calling the flash movie)
|
|
|
|
jQuery.scriptcam.getFrameAsBase64=function() {
|
|
return jQuery('#'+data.id).get(0).SC_getFrameAsBase64();
|
|
}
|
|
|
|
jQuery.scriptcam.version=function() {
|
|
return jQuery('#'+data.id).get(0).SC_version();
|
|
}
|
|
|
|
jQuery.scriptcam.hardwareacceleration=function() {
|
|
return jQuery('#'+data.id).get(0).SC_hardwareacceleration();
|
|
}
|
|
|
|
jQuery.scriptcam.getMotionParameters=function() {
|
|
jQuery('#'+data.id).get(0).SC_getMotionParameters();
|
|
}
|
|
|
|
jQuery.scriptcam.getBarCode=function() {
|
|
return jQuery('#'+data.id).get(0).SC_getBarCode();
|
|
}
|
|
|
|
jQuery.scriptcam.startRecording=function() {
|
|
jQuery('#'+data.id).get(0).SC_startRecording();
|
|
}
|
|
|
|
jQuery.scriptcam.pauseRecording=function() {
|
|
jQuery('#'+data.id).get(0).SC_pauseRecording();
|
|
}
|
|
|
|
jQuery.scriptcam.resumeRecording=function() {
|
|
jQuery('#'+data.id).get(0).SC_resumeRecording();
|
|
}
|
|
|
|
jQuery.scriptcam.closeCamera=function() {
|
|
jQuery('#'+data.id).get(0).SC_closeCamera();
|
|
}
|
|
|
|
jQuery.scriptcam.changeVolume=function(value) {
|
|
jQuery('#'+data.id).get(0).SC_changeVolume(value);
|
|
}
|
|
|
|
jQuery.scriptcam.sendMessage=function(value) {
|
|
jQuery('#'+data.id).get(0).SC_sendMessage(value);
|
|
}
|
|
|
|
jQuery.scriptcam.playMP3=function(value) {
|
|
jQuery('#'+data.id).get(0).SC_playMP3(value);
|
|
}
|
|
|
|
jQuery.scriptcam.changeCamera=function(value) {
|
|
jQuery('#'+data.id).get(0).SC_changeCamera(value);
|
|
}
|
|
|
|
jQuery.scriptcam.changeMicrophone=function(value) {
|
|
jQuery('#'+data.id).get(0).SC_changeMicrophone(value);
|
|
}
|
|
|
|
// set javascript default values (flash default values are managed in the swf file)
|
|
jQuery.fn.scriptcam.defaults={
|
|
width:320,
|
|
height:240,
|
|
chatWindow:'chatWindow',
|
|
path:'',
|
|
zoom:1,
|
|
zoomChat:1,
|
|
rotate:0,
|
|
skewX:0,
|
|
skewY:0,
|
|
flip:0,
|
|
noFlashFound:'<p>You need <a href="http://www.adobe.com/go/getflashplayer">Adobe Flash Player 11.7</a> to use this software.<br/>Please click on the link to download the installer.</p>'
|
|
};
|
|
})(jQuery);
|
|
|
|
// incoming functions (calls coming from flash) - must be public and forward calls to the scriptcam plugin
|
|
|
|
function SC_onError(errorId,errorMsg) {
|
|
jQuery.scriptcam.SC_onError(errorId,errorMsg);
|
|
}
|
|
|
|
function SC_fileReady(fileName) {
|
|
jQuery.scriptcam.SC_fileReady(fileName);
|
|
}
|
|
|
|
function SC_fileConversionStarted(fileName) {
|
|
jQuery.scriptcam.SC_fileConversionStarted(fileName);
|
|
}
|
|
|
|
function SC_onMotion(decodedString) {
|
|
jQuery.scriptcam.SC_onMotion(decodedString);
|
|
}
|
|
|
|
function SC_promptWillShow() {
|
|
jQuery.scriptcam.SC_promptWillShow();
|
|
}
|
|
function SC_onHandLeft() {
|
|
jQuery.scriptcam.SC_onHandLeft();
|
|
}
|
|
function SC_onHandRight() {
|
|
jQuery.scriptcam.SC_onHandRight();
|
|
}
|
|
function SC_onWebcamReady(cameraNames,camera,microphoneNames,microphone) {
|
|
jQuery.scriptcam.SC_onWebcamReady(cameraNames,camera,microphoneNames,microphone);
|
|
}
|
|
|
|
function SC_onPictureAsBase64(value) {
|
|
jQuery.scriptcam.SC_onPictureAsBase64(value);
|
|
}
|
|
|
|
function SC_connected() {
|
|
jQuery.scriptcam.SC_connected();
|
|
}
|
|
|
|
function SC_disconnected() {
|
|
jQuery.scriptcam.SC_disconnected();
|
|
}
|
|
|
|
function SC_setVolume(value) {
|
|
jQuery.scriptcam.SC_setVolume(value);
|
|
}
|
|
|
|
function SC_onMotion(motion,brightness,color,motionx,motiony) {
|
|
jQuery.scriptcam.SC_onMotion(motion,brightness,color,motionx,motiony);
|
|
}
|
|
|
|
function SC_timeLeft(value) {
|
|
jQuery.scriptcam.SC_timeLeft(value);
|
|
}
|
|
|
|
function SC_addChatText(value) {
|
|
jQuery.scriptcam.SC_addChatText(value);
|
|
}
|
|
|
|
function SC_userJoined(value) {
|
|
jQuery.scriptcam.SC_userJoined(value);
|
|
}
|
|
|
|
function SC_userLeft(value) {
|
|
jQuery.scriptcam.SC_userLeft(value);
|
|
} |