I'm new in using Jquery window and I Just want to ask because I'm so confused if I am using the addEventListener and removeEventListener correctly?
I just want to remove the DOMContentLoaded
when I selected the tab that is not the 3rd Tab. How can I check if the eventListener is removed? Thanks enter code here
var currentTabIndex = $("#example-tabs").steps("getCurrentIndex").val();
if(currentTabIndex == 2){
AddDomContentLoaded();
}
else{
RemoveDomContentLoaded();
}
function AddDomContentLoaded() {
window.addEventListener("DOMContentLoaded", GetDomContentLoaded(), false);
}
function RemoveDomContentLoaded() {
window.removeEventListener("DOMContentLoaded", GetDomContentLoaded());
}
function GetDomContentLoaded() {
var video = document.getElementById("video");
function successCallback(stream) {
// Set the source of the video element with the stream from the camera
if (video.mozSrcObject !== undefined) {
video.mozSrcObject = stream;
} else {
//video.src = (window.URL && window.URL.createObjectURL(stream)) || stream;
// var binaryData = [];
// binaryData.push(data);
// window.URL.createObjectURL(new Blob(binaryData, { type: "application/zip" }))
video.srcObject = stream;
}
video.play();
}
function errorCallback(error) {
$('[id^="capture"]').hide();
}
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia;
window.URL = window.URL || window.webkitURL || window.mozURL || window.msURL;
// Call the getUserMedia method with our callback functions
if (navigator.getUserMedia) {
navigator.getUserMedia({ video: true }, successCallback, errorCallback);
}
}