The Code-Bin
Links
Home
Add your code!
All Listings
About
Latest Entry
Featured Scripts
Author's Website
Latest Entries
FFMPEG Thumbnail Scr...
PHP, 0.8KB
Jul. 29, 10:24pm
John
Z80 Assembler, 190 bytes
Feb. 17, 3:36am
John
Z80 Assembler, 176 bytes
Sep. 13, 2:19am
John
Z80 Assembler, 77 bytes
Sep. 13, 2:18am
John
Z80 Assembler, 209 bytes
Sep. 13, 2:17am
jquery webcam
Posted by: LM | March 2, 2011 @ 9:07pm
Javascript Code
[
Download
]
jQuery("#webcam").webcam( { width : 320, height : 240, mode : "save", // save, callback swffile : "/swf/jscam.swf", // jscam_canvas_only.swf, jscam.swf onTick : function(remain) { if (0 == remain) { jQuery("#status").text("Cheese!"); } else { jQuery("#status") .text(remain + " seconds remaining..."); } }, onSave : function(data) { for ( var i = 0; i < 320; i++) { var tmp = parseInt(col[i]); img.data[pos + 0] = (tmp >> 16) & 0xff; img.data[pos + 1] = (tmp >> 8) & 0xff; img.data[pos + 2] = tmp & 0xff; img.data[pos + 3] = 0xff; pos += 4; } if (pos >= 0x4B000) { ctx.putImageData(img, 0, 0); pos = 0; } jQuery("#status").text("Done!"); /*var url = "redirect" ; window.location = url;*/ }, onCapture : function() { //webcam.save('/webcam.php'); webcam.save('/webcam.php'); webcam.save(); //Webcam.save ( '/Users/upload/' ); jQuery("#flash").css("display", "block"); jQuery("#flash").fadeOut(100, function() { jQuery("#flash").css("opacity", 1); }); }, debug : function(type, string) { jQuery("#status").html(type + ": " + string); }, onLoad : function() { var cams = webcam.getCameraList(); for ( var i in cams) { jQuery("#cams").append("<li>" + cams[i] + "</li>"); } } }); function getPageSize() { var xScroll, yScroll; if (window.innerHeight && window.scrollMaxY) { xScroll = window.innerWidth + window.scrollMaxX; yScroll = window.innerHeight + window.scrollMaxY; } else if (document.body.scrollHeight > document.body.offsetHeight) { // all but Explorer Mac xScroll = document.body.scrollWidth; yScroll = document.body.scrollHeight; } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari xScroll = document.body.offsetWidth; yScroll = document.body.offsetHeight; } var windowWidth, windowHeight; if (self.innerHeight) { // all except Explorer if (document.documentElement.clientWidth) { windowWidth = document.documentElement.clientWidth; } else { windowWidth = self.innerWidth; } windowHeight = self.innerHeight; } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode windowWidth = document.documentElement.clientWidth; windowHeight = document.documentElement.clientHeight; } else if (document.body) { // other Explorers windowWidth = document.body.clientWidth; windowHeight = document.body.clientHeight; } // for small pages with total height less then height of the viewport if (yScroll < windowHeight) { pageHeight = windowHeight; } else { pageHeight = yScroll; } // for small pages with total width less then width of the viewport if (xScroll < windowWidth) { pageWidth = xScroll; } else { pageWidth = windowWidth; } return [ pageWidth, pageHeight ]; } window.addEventListener("load", function() { jQuery("body").append("<div id=\"flash\"></div>"); var canvas = document.getElementById("canvas"); if (canvas.getContext) { ctx = document.getElementById("canvas").getContext("2d"); ctx.clearRect(0, 0, 320, 240); var img = new Image(); img.src = "/static/logo.gif"; img.onload = function() { ctx.drawImage(img, 129, 89); } image = ctx.getImageData(0, 0, 320, 240); } var pageSize = getPageSize(); jQuery("#flash").css({ height : pageSize[1] + "px" }); }, false); window.addEventListener("resize", function() { var pageSize = getPageSize(); jQuery("#flash").css({ height : pageSize[1] + "px" }); }, false);
Syntax Highlighting
[
Open in new window
]
Author Comments
none
Rating
4.49 / 8
260 Votes
http://codebin.yi.org/1149
page generated in 0.00 seconds