Файл: templates/Default/js/luka.js
Строк: 135
<?php
window.webcam = {
version:'1.0.9',
ie:!!navigator.userAgent.match(/MSIE/),
protocol:location.protocol.match(/https/i) ? 'https' :'http',
callback:null,
swf_url:'/templates/Default/js/webcam.swf',
shutter_url:'/templates/Default/js/shutter.mp3',
api_url:'/index.php?go=editprofile&act=uploadweb',
loaded:false,
quality:90,
shutter_sound:true,
stealth:false,
hooks:{onLoad:null,onComplete:null,onError:null},
set_hook:function(name,callback) {
if (typeof(this.hooks[name])=='undefined')
return alert("Hook type not supported:" + name);
this.hooks[name] = callback;
},
fire_hook:function(name,value) {
if (this.hooks[name]) {
if (typeof(this.hooks[name])=='function') {
this.hooks[name](value);
}
else if (typeof(this.hooks[name])=='array') {
this.hooks[name][0][this.hooks[name][1]](value);
}
else if (window[this.hooks[name]]) {
window[ this.hooks[name] ](value);
}
return true;
}
return false;
},
set_api_url:function(url) {
this.api_url = url;
},
set_swf_url:function(url) {
this.swf_url = url;
},
get_html:function(width,height,server_width,server_height) {
if (!server_width) server_width = width;
if (!server_height) server_height = height;
var html = '';
var flashvars = 'shutter_enabled=' + (this.shutter_sound ? 1 :0) +
'&shutter_url=' + escape(this.shutter_url) +
'&width=' + width +
'&height=' + height +
'&server_width=' + server_width +
'&server_height=' + server_height;
if (this.ie) {
html += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="'+this.protocol+'://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="'+width+'" height="'+height+'" id="webcam_movie" align="middle"><param name="allowScriptAccess" value="always" /><param name="allowFullScreen" value="false" /><param name="movie" value="'+this.swf_url+'" /><param name="loop" value="false" /><param name="menu" value="false" /><param name="quality" value="best" /><param name="bgcolor" value="#ffffff" /><param name="flashvars" value="'+flashvars+'"/></object>';
}
else {
html += '<embed id="webcam_movie" src="'+this.swf_url+'" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="'+width+'" height="'+height+'" name="webcam_movie" align="middle" allowScriptAccess="always" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="'+flashvars+'" />';
}
this.loaded = false;
return html;
},
get_movie:function() {
if (!this.loaded) return alert("ERROR:Movie is not loaded yet");
var movie = document.getElementById('webcam_movie');
if (!movie) alert("ERROR:Cannot locate movie 'webcam_movie' in DOM");
return movie;
},
set_stealth:function(stealth) {
this.stealth = stealth;
},
snap:function(url,callback,stealth) {
if (callback) this.set_hook('onComplete',callback);
if (url) this.set_api_url(url);
if (typeof(stealth) != 'undefined') this.set_stealth( stealth );
this.get_movie()._snap( this.api_url,this.quality,this.shutter_sound ? 1 :0,this.stealth ? 1 :0 );
},
freeze:function() {
this.get_movie()._snap('',this.quality,this.shutter_sound ? 1 :0,0 );
$('#button_div_gray').show();
$('#button_div').hide();
},
upload:function(url,callback) {
if (callback) this.set_hook('onComplete',callback);
if (url) this.set_api_url(url);
this.get_movie()._upload( this.api_url );
$.post('/index.php?go=editprofile&act=uploadweb',{i:'1'},function(d){
$('#ava').html(d);
$('#newbox_miniature').hide();
Profile.miniature();
});
},
reset:function() {
this.get_movie()._reset();
$('#button_div_gray').hide();
$('#button_div').show();
},
configure:function(panel) {
if (!panel) panel = "camera";
this.get_movie()._configure(panel);
},
set_quality:function(new_quality) {
this.quality = new_quality;
},
set_shutter_sound:function(enabled,url) {
this.shutter_sound = enabled;
this.shutter_url = url ? url :'shutter.mp3';
},
flash_notify:function(type,msg) {
switch (type) {
case 'flashLoadComplete':
this.loaded = true;
this.fire_hook('onLoad');
break;
case 'error':
if (!this.fire_hook('onError',msg)) {
alert("JPEGCam Flash Error:" + msg);
}
break;
case 'success':
this.fire_hook('onComplete',msg.toString());
break;
default:
alert("jpegcam flash_notify:" + type + ":" + msg);
break;
}
}
};
?>