I'm using a script called photobooth for JavaScript where the user is supposed to click the camera icon to take a picture, but instead I want it to be code executed. Here is the snippet of code that I believe to be the photobooth take picture event.
var L = g("blind");
g("trigger").onclick = function () {
L.className = "blind", L.style.opacity = 1, setTimeout(function () {
L.className = "blind anim", L.style.opacity = 0
}, 50);
var e = {};
C.isActive() ? e = C.getData() : f ? e = {
x: (p - T.videoWidth) / 2,
y: (d - T.videoHeight) / 2,
width: T.videoWidth,
height: T.videoHeight
} : e = {
x: 0,
y: 0,
width: p,
height: d
};
var t = y("canvas");
t.width = e.width, t.height = e.height;
if (f) t.getContext("2d").drawImage(T, Math.max(0, e.x - (p - T.videoWidth) / 2), Math.max(e.y - (d - T.videoHeight) / 2), e.width, e.height, 0, 0, e.width, e.height);
else {
var n = x.getImageData(e.x, e.y, e.width, e.height);
t.getContext("2d").putImageData(n, 0, 0)
}
h.onImage(t.toDataURL())
};
I would like to call that event or change it so I can call it, I'm not very good with js so any help would be great!
here is the source: photobooth js
is using jquery an option? you can do something like this
$("#trigger").click();
or if you really want native js you can do something like this
document.getElementById("trigger").click();