Permalink
Browse files

Minor program changes to better suite mobile use

Signed-off-by: Rick Waldron waldron.rick@gmail.com <waldron.rick@gmail.com>
  • Loading branch information...
rwaldron committed Feb 29, 2012
1 parent e05f31f commit 7cd7c4378750592ed6846db58a5e8b3ecc8e04f0
Showing with 31 additions and 21 deletions.
  1. +15 −10 app.js
  2. +6 −2 lib/dmv.js
  3. +6 −2 public/javascripts/dmv.js
  4. +2 −2 public/javascripts/dmv.min.js
  5. +1 −1 public/stylesheets/style.css
  6. +0 −4 views/index.jade
  7. +1 −0 views/layout.jade
View
25 app.js
@@ -1,5 +1,6 @@
var express = require("express"),
- socket = require("socket.io");
+ socket = require("socket.io"),
+ fs = require("fs");
var app = express.createServer(),
io = socket.listen( app );
@@ -22,6 +23,7 @@ app.get( "/", function( req, res ) {
});
});
+
// Connection Pool
var connections = {
// uid: object
@@ -47,18 +49,21 @@ io.sockets.on( "connection", function( client ) {
client.on( "capture", function( data ) {
+ var file, buffer,
+ filepath = "saved/" + Date.now() + ".png";
+ // Create a buffer from the base64 encoded string
+ buffer = new Buffer( data.captured.replace(/^data:image\/\w+;base64,/, ""), "base64" );
+ // Save to new image file
+ file = fs.openSync( filepath, "w+" );
-
- // Do Stuff with captured data uri
- console.log( data.captured.length );
-
-
-
-
-
-
+ // Output regenerated, compressed code
+ fs.write( file, buffer, 0, buffer.length, 0, function( err, data ) {
+ if ( err == null ) {
+ console.log( "Saved: http://localhost:8080/" + filepath );
+ }
+ });
});
});
View
@@ -1,3 +1,7 @@
+/*! dmv - v0.1.0 - 2/28/2012
+* https://github.com/rwldrn/dmv
+* Copyright (c) 2012 Rick Waldron <waldron.rick@gmail.com>; Licensed MIT */
+
/*! dmv - v0.1.0 - 2/5/2012
* https://github.com/rwldrn/dmv
* Copyright (c) 2012 Rick Waldron <waldron.rick@gmail.com>; Licensed MIT */
@@ -68,7 +72,6 @@ var // Localize navigator for use within getUserMedia
var capture = this.canvas.toDataURL(),
image = document.querySelector( "#i_" + this.id );
- console.log( image );
if ( !image ) {
image = Operator.fixture( "img", this.id );
}
@@ -99,6 +102,7 @@ var // Localize navigator for use within getUserMedia
node.id = nodeName[0] + "_" + id;
+ console.log( document.offsetWidth );
node.style.width = "320px";
node.style.height = "280px";
@@ -155,7 +159,7 @@ var // Localize navigator for use within getUserMedia
this.listen();
},
listen: function() {
- var capture = document.querySelector("#capture");
+ var capture = document.querySelector("video");
capture.addEventListener( "click", DMV.operator.capture.bind( DMV.operator ), false );
}
@@ -1,3 +1,7 @@
+/*! dmv - v0.1.0 - 2/29/2012
+* https://github.com/rwldrn/dmv
+* Copyright (c) 2012 Rick Waldron <waldron.rick@gmail.com>; Licensed MIT */
+
/*! dmv - v0.1.0 - 2/28/2012
* https://github.com/rwldrn/dmv
* Copyright (c) 2012 Rick Waldron <waldron.rick@gmail.com>; Licensed MIT */
@@ -72,7 +76,6 @@ var // Localize navigator for use within getUserMedia
var capture = this.canvas.toDataURL(),
image = document.querySelector( "#i_" + this.id );
- console.log( image );
if ( !image ) {
image = Operator.fixture( "img", this.id );
}
@@ -103,6 +106,7 @@ var // Localize navigator for use within getUserMedia
node.id = nodeName[0] + "_" + id;
+ console.log( document.offsetWidth );
node.style.width = "320px";
node.style.height = "280px";
@@ -159,7 +163,7 @@ var // Localize navigator for use within getUserMedia
this.listen();
},
listen: function() {
- var capture = document.querySelector("#capture");
+ var capture = document.querySelector("video");
capture.addEventListener( "click", DMV.operator.capture.bind( DMV.operator ), false );
}

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -1,5 +1,5 @@
body {
- padding: 50px;
+/* padding: 50px;*/
font: 14px "Lucida Grande", Helvetica, Arial, sans-serif;
}
View
@@ -1,6 +1,2 @@
-h1= title
-
-
#operator-container
-button#capture Capture
View
@@ -2,6 +2,7 @@
html
head
title= title
+ meta(name="viewport", content="width=device-width, initial-scale=1")
link(rel="stylesheet", href="/stylesheets/style.css")
script(src="/socket.io/socket.io.js")
script(src="//code.jquery.com/jquery.min.js")

0 comments on commit 7cd7c43

Please sign in to comment.