Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Updates built files

Signed-off-by: Rick Waldron waldron.rick@gmail.com <waldron.rick@gmail.com>
  • Loading branch information...
commit 45435f85a24a135eac988db3581fcad9a422b311 1 parent d2c13f2
@rwaldron rwaldron authored
View
47 public/javascripts/dmv.js
@@ -43,7 +43,7 @@ var // Localize navigator for use within getUserMedia
this.media = Operator.fixture( "video", this.id );
// This Operator's canvas
- this.canvas = Operator.fixture("canvas");
+ this.canvas = Operator.fixture( "canvas", this.id );
this.context = this.canvas.getContext("2d");
this.socket = socket;
@@ -69,18 +69,19 @@ var // Localize navigator for use within getUserMedia
Operator.prototype.draw = function() {
// Draw current video frame to the canvas
- this.context.drawImage( this.media, 0, 0, 280, 160 );
+ this.context.drawImage( this.media, 0, 0, this.canvas.width, this.canvas.height );
};
Operator.prototype.capture = function() {
- var capture = this.canvas.toDataURL(),
- image = document.querySelector( "#i_" + this.id );
-
- if ( !image ) {
- image = Operator.fixture( "img", this.id );
- }
-
- image.src = capture;
+ var capture = this.canvas.toDataURL();
+ // ,
+ // image = document.querySelector( "#i_" + this.id );
+ //
+ // if ( !image ) {
+ // image = Operator.fixture( "img", this.id );
+ // }
+ //
+ // image.src = capture;
// Dispatch a "capture" event to the socket
this.socket.emit( "capture", {
@@ -102,13 +103,18 @@ var // Localize navigator for use within getUserMedia
// Create an HTML element fixture
Operator.fixture = function( nodeName, id ) {
var container = document.querySelector("#container"),
- node = document.createElement( nodeName );
+ node = document.createElement( nodeName ),
+ other;
node.id = nodeName[0] + "_" + id;
- console.log( document.offsetWidth );
- node.style.width = "320px";
- node.style.height = "280px";
+ console.log( nodeName, window.innerWidth, window.innerHeight );
+
+ node.style.width = window.innerWidth + "px";// "320px";
+ // // node.style.height = window.innerHeight + "px";//"280px";
+ //
+ // node.width = window.innerWidth;
+ // node.height = window.innerHeight;
// TODO: make this definable
if ( !container ) {
@@ -116,7 +122,18 @@ var // Localize navigator for use within getUserMedia
}
if ( nodeName === "canvas" ) {
- node.style.display = "none";
+ other = document.querySelector( "video[id$='" + id + "']" );
+
+ setTimeout(function check() {
+ if ( other.videoWidth > 0 ) {
+ node.width = other.videoWidth;
+ node.height = other.videoHeight;
+
+ node.style.visibility = "hidden";
+ } else {
+ setTimeout( check, 10 );
+ }
+ }, 10);
}
container.appendChild( node );
View
2  public/javascripts/dmv.min.js
@@ -1,4 +1,4 @@
/*! dmv - v0.1.0 - 2/29/2012
* https://github.com/rwldrn/dmv
* Copyright (c) 2012 Rick Waldron <waldron.rick@gmail.com>; Licensed MIT */
-(function(a){var b=a.navigator,c=function(a){var c=b.getUserMedia||b.webkitGetUserMedia,d=b.getUserMedia?{video:!0,audio:!0}:"video audio";c.call(b,d,function(b){var c=window.webkitURL?window.webkitURL.createObjectURL(b):b;a(c)})},d,e;d=function(a,b){this.id=a,this.media=d.fixture("video",this.id),this.canvas=d.fixture("canvas"),this.context=this.canvas.getContext("2d"),this.socket=b,this.dataUri="",c(function(a){this.media.src=a,this.media.addEventListener("loadedmetadata",function(){this.media.play()}.bind(this),!1),this.media.addEventListener("timeupdate",function(){this.draw()}.bind(this),!1)}.bind(this))},d.prototype.draw=function(){this.context.drawImage(this.media,0,0,280,160)},d.prototype.capture=function(){var a=this.canvas.toDataURL(),b=document.querySelector("#i_"+this.id);b||(b=d.fixture("img",this.id)),b.src=a,this.socket.emit("capture",{id:this.id,captured:this.canvas.toDataURL()})},d.id=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(a){var b=Math.random()*16|0;return(a==="x"?b:b&3|8).toString(16)}).toUpperCase()},d.fixture=function(a,b){var c=document.querySelector("#container"),d=document.createElement(a);return d.id=a[0]+"_"+b,console.log(document.offsetWidth),d.style.width="320px",d.style.height="280px",c||(c=document.body),a==="canvas"&&(d.style.display="none"),c.appendChild(d),d},d.exists=function(a){return!!document.querySelectorAll("[id$='"+a+"']").length},e={socket:null,operator:null,init:function(a){var b,c;b=localStorage.getItem("id"),b||(b=d.id(),localStorage.setItem("id",b)),e.socket=a,e.operator=new d(b,a),this.listen()},listen:function(){var a=document.querySelector("video");a.addEventListener("click",e.operator.capture.bind(e.operator),!1)}},a.DMV=e,a.Operator=d})(typeof exports=="object"&&exports||this)
+(function(a){var b=a.navigator,c=function(a){var c=b.getUserMedia||b.webkitGetUserMedia,d=b.getUserMedia?{video:!0,audio:!0}:"video audio";c.call(b,d,function(b){var c=window.webkitURL?window.webkitURL.createObjectURL(b):b;a(c)})},d,e;d=function(a,b){this.id=a,this.media=d.fixture("video",this.id),this.canvas=d.fixture("canvas",this.id),this.context=this.canvas.getContext("2d"),this.socket=b,this.dataUri="",c(function(a){this.media.src=a,this.media.addEventListener("loadedmetadata",function(){this.media.play()}.bind(this),!1),this.media.addEventListener("timeupdate",function(){this.draw()}.bind(this),!1)}.bind(this))},d.prototype.draw=function(){this.context.drawImage(this.media,0,0,this.canvas.width,this.canvas.height)},d.prototype.capture=function(){var a=this.canvas.toDataURL();this.socket.emit("capture",{id:this.id,captured:this.canvas.toDataURL()})},d.id=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(a){var b=Math.random()*16|0;return(a==="x"?b:b&3|8).toString(16)}).toUpperCase()},d.fixture=function(a,b){var c=document.querySelector("#container"),d=document.createElement(a),e;return d.id=a[0]+"_"+b,console.log(a,window.innerWidth,window.innerHeight),d.style.width=window.innerWidth+"px",c||(c=document.body),a==="canvas"&&(e=document.querySelector("video[id$='"+b+"']"),setTimeout(function f(){e.videoWidth>0?(d.width=e.videoWidth,d.height=e.videoHeight,d.style.visibility="hidden"):setTimeout(f,10)},10)),c.appendChild(d),d},d.exists=function(a){return!!document.querySelectorAll("[id$='"+a+"']").length},e={socket:null,operator:null,init:function(a){var b,c;b=localStorage.getItem("id"),b||(b=d.id(),localStorage.setItem("id",b)),e.socket=a,e.operator=new d(b,a),this.listen()},listen:function(){var a=document.querySelector("video");a.addEventListener("click",e.operator.capture.bind(e.operator),!1)}},a.DMV=e,a.Operator=d})(typeof exports=="object"&&exports||this)
View
7 public/stylesheets/style.css
@@ -1,8 +1,15 @@
body {
+ padding: 0px;
+ margin: 0px;
/* padding: 50px;*/
font: 14px "Lucida Grande", Helvetica, Arial, sans-serif;
}
a {
color: #00B7FF;
+}
+
+video {
+ padding: 0px;
+ margin: 0px;
}
View
2  views/index.jade
@@ -1,2 +1,2 @@
-#operator-container
+#container
Please sign in to comment.
Something went wrong with that request. Please try again.