Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
13
rated 0 times [  18] [ 5]  / answers: 1 / hits: 17797  / 11 Years ago, sun, april 14, 2013, 12:00:00

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


More From » onclick

 Answers
45

Since onclick references a function, you can always call it via



document.querySelector(.trigger).onclick()


Of course, document.querySelector is just a matter of getting DOM object with desired function, it can be referenced any other way.


[#78921] Friday, April 12, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jensenb

Total Points: 634
Total Questions: 102
Total Answers: 102

Location: Bosnia and Herzegovina
Member since Thu, Jun 24, 2021
3 Years ago
;