|
12 | 12 |
|
13 | 13 | (function ($) { |
14 | 14 |
|
15 | | - var webcam = { |
| 15 | + var webcam = { |
16 | 16 |
|
17 | | - width: 320, |
18 | | - height: 240, |
| 17 | + width: 320, |
| 18 | + height: 240, |
19 | 19 |
|
20 | | - mode: "callback", // callback | save | stream |
| 20 | + mode: "callback", // callback | save | stream |
21 | 21 |
|
22 | | - swffile: "jscam.swf", |
23 | | - quality: 85, |
| 22 | + swffile: "jscam.swf", |
| 23 | + quality: 85, |
24 | 24 |
|
25 | | - debug: function(type, string) {}, |
| 25 | + debug: function () {}, |
| 26 | + onCapture: function () {}, |
| 27 | + onTick: function () {}, |
| 28 | + onSave: function () {}, |
| 29 | + onLoad: function () {} |
| 30 | + }; |
26 | 31 |
|
27 | | - onCapture: function () {}, |
28 | | - onTick: function (count) {}, |
29 | | - onSave: function () {}, |
30 | | - onLoad: function () {} |
31 | | - }; |
| 32 | + window.webcam = webcam; |
32 | 33 |
|
33 | | - window.webcam = webcam; |
| 34 | + $.fn.webcam = function(options) { |
34 | 35 |
|
35 | | - $.fn.webcam = function(options) { |
36 | | - |
37 | | - if (typeof options === "object") { |
38 | | - for (var ndx in webcam) { |
39 | | - if (typeof options[ndx] !== "undefined") { |
40 | | - webcam[ndx] = options[ndx]; |
41 | | - } |
42 | | - } |
| 36 | + if (typeof options === "object") { |
| 37 | + for (var ndx in webcam) { |
| 38 | + if (typeof options[ndx] !== "undefined") { |
| 39 | + webcam[ndx] = options[ndx]; |
43 | 40 | } |
| 41 | + } |
| 42 | + } |
44 | 43 |
|
45 | | - this.append('<object id="webcam-object" type="application/x-shockwave-flash" data="'+webcam.swffile+'" width="'+webcam.width+'" height="'+webcam.height+'"><param name="movie" value="'+webcam.swffile+'" /><param name="FlashVars" value="mode='+webcam.mode+'&quality='+webcam.quality+'" /></object>'); |
| 44 | + this.append('<object id="webcam-object" type="application/x-shockwave-flash" data="'+webcam.swffile+'" width="'+webcam.width+'" height="'+webcam.height+'"><param name="movie" value="'+webcam.swffile+'" /><param name="FlashVars" value="mode='+webcam.mode+'&quality='+webcam.quality+'" /></object>'); |
46 | 45 |
|
47 | | - (_register = function(run) { |
| 46 | + (_register = function(run) { |
48 | 47 |
|
49 | | - var cam = document.getElementById('webcam-object'); |
| 48 | + var cam = document.getElementById('webcam-object'); |
50 | 49 |
|
51 | | - if (typeof cam.capture !== "undefined") { |
| 50 | + if (typeof cam.capture !== "undefined") { |
52 | 51 |
|
53 | | - /* Simple callback methods are not allowed :-/ */ |
54 | | - webcam.capture = function(x) { try {return cam.capture(x);} catch(e) {} }; |
55 | | - webcam.save = function(x) { try {return cam.save(x);} catch(e) {} }; |
56 | | - webcam.setCamera = function(x) { try {return cam.setCamera(x);} catch(e) {} }; |
57 | | - webcam.getCameraList = function( ) { try {return cam.getCameraList();} catch(e) {} }; |
| 52 | + /* Simple callback methods are not allowed :-/ */ |
| 53 | + webcam.capture = function(x) { |
| 54 | + try { |
| 55 | + return cam.capture(x); |
| 56 | + } catch(e) {} |
| 57 | + } |
| 58 | + webcam.save = function(x) { |
| 59 | + try { |
| 60 | + return cam.save(x); |
| 61 | + } catch(e) {} |
| 62 | + } |
| 63 | + webcam.setCamera = function(x) { |
| 64 | + try { |
| 65 | + return cam.setCamera(x); |
| 66 | + } catch(e) {} |
| 67 | + } |
| 68 | + webcam.getCameraList = function() { |
| 69 | + try { |
| 70 | + return cam.getCameraList(); |
| 71 | + } catch(e) {} |
| 72 | + } |
58 | 73 |
|
59 | | - webcam.onLoad(); |
60 | | - } else if (0 == run) { |
61 | | - webcam.debug("error", "Flash movie not yet registered!"); |
62 | | - } else { |
63 | | - /* Flash interface not ready yet */ |
64 | | - window.setTimeout(_register, 1000 * (4 - run), run - 1); |
65 | | - } |
66 | | - })(3); |
67 | | - } |
| 74 | + webcam.onLoad(); |
| 75 | + } else if (0 == run) { |
| 76 | + webcam.debug("error", "Flash movie not yet registered!"); |
| 77 | + } else { |
| 78 | + /* Flash interface not ready yet */ |
| 79 | + window.setTimeout(_register, 1000 * (4 - run), run - 1); |
| 80 | + } |
| 81 | + })(3); |
| 82 | + } |
68 | 83 |
|
69 | 84 | })(jQuery); |
0 commit comments