From f426f810c5482f59aad424cbf9050d89bcb7c337 Mon Sep 17 00:00:00 2001 From: sola Date: Thu, 5 Oct 2023 09:37:43 +1300 Subject: [PATCH 1/2] andrews things --- assets/recipes.html | 5 +++++ assets/scripts/script.js | 17 +++++++++++++++++ src/MyApp.cpp | 23 +++++++++++++++++++++++ src/MyApp.h | 2 ++ 4 files changed, 47 insertions(+) diff --git a/assets/recipes.html b/assets/recipes.html index a616934..a4b71de 100644 --- a/assets/recipes.html +++ b/assets/recipes.html @@ -15,6 +15,11 @@

Planner

Home

Recipes

+
+ +
+
+
diff --git a/assets/scripts/script.js b/assets/scripts/script.js index 4a18799..d84fcb5 100644 --- a/assets/scripts/script.js +++ b/assets/scripts/script.js @@ -264,6 +264,23 @@ function getSaved(){ } } +function getAndrews(){ + try { + const jsonRecipes = GetAndrews(); + const recipes = JSON.parse(jsonRecipes); + console.log("Recipes:", recipes); + document.getElementById('andrews-recipe-container').innerHTML = ""; + + for (let recipe of recipes) { + displayCard(recipe, 'andrews-recipe-container'); + } + } catch (error) { + console.error("Error fetching recipes:", error); + alert("Failed to fetch recipes. Please try again later."); + } +} + + function getFeatured(){ try { const jsonRecipes = ShowFeatured(); diff --git a/src/MyApp.cpp b/src/MyApp.cpp index 1547b72..88a0a91 100644 --- a/src/MyApp.cpp +++ b/src/MyApp.cpp @@ -321,6 +321,28 @@ JSValue MyApp::GetSaved(const JSObject &thisObject, const JSArgs &args) return JSValue(jsonRecipes.c_str()); } +JSValue MyApp::GetAndrews(const JSObject &thisObject, const JSArgs &args) +{ + std::cout << "Get saved called" << std::endl; + std::vector andrewsList; + andrewsList.push_back(690); + andrewsList.push_back(854); + andrewsList.push_back(537034); + andrewsList.push_back(540717); + std::vector returnAndrews; + // std::sort (savedRecipes.begin(), savedRecipes.end()); + // savedRecipes.erase(std::unique(savedRecipes.begin(), savedRecipes.end(), savedRecipes.end())); + RecipeDatabase recipeDB; + for (int recipe : andrewsList) + { + // std::cout << recipe << std::endl; + returnAndrews.push_back(recipeDB.getRecipeById(recipe)); + } + std::string jsonRecipes = convertRecipesToJson(returnAndrews); + + return JSValue(jsonRecipes.c_str()); +} + JSValue MyApp::ShowFeatured(const JSObject &thisObject, const JSArgs &args){ std::cout<<"show featured called"<< std::endl; @@ -429,6 +451,7 @@ void MyApp::OnDOMReady(ultralight::View *caller, global["AddToMealPlanner"] = BindJSCallbackWithRetval(&MyApp::AddToMealPlanner); global["SaveRecipe"] = BindJSCallback(&MyApp::SaveRecipe); global["GetSaved"] = BindJSCallbackWithRetval(&MyApp::GetSaved); + global["GetAndrews"] = BindJSCallbackWithRetval(&MyApp::GetAndrews); global["ShowFeatured"] = BindJSCallbackWithRetval(&MyApp::ShowFeatured); global["GetIngredientsByRecipe"] = BindJSCallbackWithRetval(&MyApp::GetIngredientsByRecipe); global["GetReviewsByRecipe"] = BindJSCallbackWithRetval(&MyApp::GetReviewsByRecipe); diff --git a/src/MyApp.h b/src/MyApp.h index f8c1dc3..2a25c17 100644 --- a/src/MyApp.h +++ b/src/MyApp.h @@ -65,6 +65,8 @@ JSValue AddToMealPlanner(const JSObject& thisObject, const JSArgs& args); JSValue GetSaved(const JSObject& thisObject, const JSArgs& args); +JSValue GetAndrews(const JSObject& thisObject, const JSArgs& args); + JSValue ShowFeatured(const JSObject& thisObject, const JSArgs& args); void SaveRecipe(const JSObject& thisObject, const JSArgs& args); From 4e2f70ec0d204ef963b22bb5bf6a49f88f26a959 Mon Sep 17 00:00:00 2001 From: sola Date: Thu, 5 Oct 2023 21:03:39 +1300 Subject: [PATCH 2/2] changed some recipes for all images --- src/MyApp.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/MyApp.cpp b/src/MyApp.cpp index 88a0a91..87462c8 100644 --- a/src/MyApp.cpp +++ b/src/MyApp.cpp @@ -325,8 +325,8 @@ JSValue MyApp::GetAndrews(const JSObject &thisObject, const JSArgs &args) { std::cout << "Get saved called" << std::endl; std::vector andrewsList; - andrewsList.push_back(690); - andrewsList.push_back(854); + andrewsList.push_back(496252); + andrewsList.push_back(537453); andrewsList.push_back(537034); andrewsList.push_back(540717); std::vector returnAndrews;