Commit b3ed65cc authored by Clara Stoddart's avatar Clara Stoddart

Edited content.js

parent 2cbbb700
......@@ -3,6 +3,7 @@ var MOUSE_VISITED_CLASSNAME_FALSE = 'crx_mouse_visited_false';
var MOUSE_VISITED_CLASSNAME_NOT_IN_DB = 'crx_mouse_visited_not_in_db';
var srcName;
var dietNum = 999;
var dietNumSet = false;
// function dietNumInit() {
// var a = document.getElementById("Dairy").checked;
......@@ -32,11 +33,11 @@ return promise;
document.addEventListener('mousemove', function (e) {
let srcElement = e.srcElement;
if (srcElement.nodeName == 'IMG' && dietNum != 999) {
if (srcElement.nodeName == 'IMG' && dietNumSet) {
srcName = srcElement.alt;
promise = checkAllergen(srcName).then(
function(responseText) {
console.log("Success");
console.log("Successfully queried database");
console.log(dietNum);
if (responseText == "1" || responseText == undefined) {
srcElement.classList.add(MOUSE_VISITED_CLASSNAME);
......@@ -48,9 +49,7 @@ document.addEventListener('mousemove', function (e) {
},
function(failureStatus) {
console.log(failureStatus);
if (failureStatus == 0) {
console.log("Not in database");
}
console.log("XMLHttpRequest failed");
});
console.info(srcElement.currentSrc);
console.dir(srcElement);
......@@ -63,4 +62,5 @@ chrome.runtime.onMessage.addListener(
"from a content script:" + sender.tab.url :
"from the extension");
dietNum = request.dietNum;
dietNumSet = true;
});
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment