Commit 258a348b authored by Zhai Zirun's avatar Zhai Zirun

finished rudimentary functionality for checkAllergens

parent f45604a2
......@@ -15,11 +15,11 @@ const client = new Client({
}
});
function checkAllergens() { //TODO: insert argument NAME OF OBJECT
function checkAllergens(srcName n) { //TODO: insert argument NAME OF OBJECT
client.connect();
//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) => {
//TODO: fill in names of columns of db
client.query('SELECT Containsgluten, Containsdairy, Containscorn, Containsmeat FROM productsIngredients WHERE Product = n;', (err, res) => {
if (err) throw err;
for (let col of res.cols) {
if (col) {
......@@ -29,6 +29,7 @@ function checkAllergens() { //TODO: insert argument NAME OF OBJECT
//TODO: modify behaviour according to different allergens
}
client.end();
return false;
});
}
......@@ -57,7 +58,7 @@ 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
if (checkAllergens(srcElement.srcName)) {
srcElement.classList.add(MOUSE_VISITED_CLASSNAME); //changes outline of pic
//TODO: modify behaviour according to different allergens
}
......
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