Console Errors
Susi is a personal assistant developed by FOSSASIA. It has many clients including web chat, andoid and iOS app, and many chatbots.
Now we are developing a chrome extension for it which is named as chromebot.
There were many errors in console.
The errors were-
Uncaught TypeError: Cannot read property 'addEventListener` of null at allowmic.js :5
Failed to load resource: net:: ERR_FILE_NOT_FOUND
Following the stack trace of the first error I found out that two elements were present on login page and was only present in DOM when the login page gets opened.
And the allowmic.js
was necessary to be included in the main extension window.
So for figuring out the solution I put all the event listeners in a if clause
if(micAccess) {
micAccess.addEventListener("click", () => {
navigator.webkitGetUserMedia({
audio: true
}, function (stream) {
stream.stop();
}, function () {
console.log("no access");
});
});
}
if(preDefThemes) {
preDefThemes.addEventListener("click",(e) => {
if(e.target!==e.currentTarget){
theme= e.target.id;
console.log(theme);
}
e.stopPropagation;
});
}
if(submit) {
submit.addEventListener("click",()=>{
localStorage.setItem("theme",theme);
console.log("success");
alert("success");
});
}
if(backgroundChange) {
backgroundChange.addEventListener("submit", (e) => {
e.preventDefault();
theValue = backUrl.value;
if (!theValue) {
alert("Error: No value specified");
} else {
localStorage.setItem("theValue", theValue);
alert("Successfully stored");
}
});
}
Which solved my first issue of errors due to Uncaught TypeError.
Second Error was due to there was a custom background variable which was used in setting custom background which was only set when user chose a custom background.
So I put it as optional.
Then the console was free of errors.
For Browsing the code of susi chromebot, Click here
Posted on Utopian.io - Rewarding Open Source Contributors
Thank you for the contribution. It has been approved.
Thank you for making the requested edits! They make the article a lot nicer to read on mobile.
You can contact us on Discord.
[utopian-moderator]
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Your contribution cannot be approved yet. Could you please clean up the screenshots to remove the large white spaces that break up your article?
You may edit your post here, as shown below:
You can contact us on Discord.
[utopian-moderator]
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Thanks I have made the suggested changes!
Submitted for reapproval
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Hey @ms10398 I am @utopian-io. I have just upvoted you!
Achievements
Community-Driven Witness!
I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!
Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit