Commit f45604a2 authored by Zhai Zirun's avatar Zhai Zirun

coded function of checkAllergens, some todos left

parent a40cd99a
......@@ -15,16 +15,19 @@ const client = new Client({
function checkAllergens() { //TODO: insert argument NAME OF OBJECT
//TODO: change to correct query
//TODO: find a way to connect to client at startup (le??) to remove the need to connect and disconnect repeatedly
//TODO: write db query
client.query('SELECT table_schema,table_name FROM information_schema.tables;', (err, res) => {
if (err) throw err;
for (let row of res.rows) {
for (let col of res.cols) {
if (col) {
return col;
//returns true if any allergen is present.
//TODO: modify behaviour according to different allergens
//TODO: if any of the allergen columns are true then return true (can you do that in javascript??)
......@@ -40,7 +43,7 @@ function checkAllergens() { //TODO: insert argument NAME OF OBJECT
document.addEventListener('mousemove', function (e) {
let srcElement = e.srcElement;
// Lets check if our underlying element contains any allergens.
if (srcElement.nodeName == 'IMG') {//TODO: EDIT this according to function checkAllergens above
if (srcElement.nodeName == 'IMG') {
//if (srcElement.nodeName == 'DIV' && srcElement.className == "content___1O9rr") {
//prevDOM != srcElement &&
srcName = srcElement.alt;
......@@ -54,7 +57,10 @@ document.addEventListener('mousemove', function (e) {
// if (srcName == "Waitrose coffee & walnut cake") {
// srcElement.classList.add(MOUSE_VISITED_CLASSNAME);
// }
if (checkAllergens(srcElement.srcName)) { //todo: change srcName to reference name of grocery
srcElement.classList.add(MOUSE_VISITED_CLASSNAME); //changes outline of pic
//TODO: modify behaviour according to different allergens
// The current element is now the previous. So we can remove the class
// during the next ieration.
//prevDOM = srcElement;
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