Read the statement by Michael Teeuw here.
MMM-MealViewer
-
So I now get the following table:
Elementary Lunch
Entree “Bold” Cheese Pizza
Entree “Bold” Pepperoni Pizza
Vegetable Parmesan Butternut Gratin
Vegetable Seasoned Green Beans
Elementary Alternative
Entree Chef Salad
Entree Bologna & Cheese SandwichThe foodItemType in the first column and the foodItemName in the second column are siblings in the data array.
I’d like turn the first occurrence of foodItemType into a category so the table looks like this (ignore the spacing hyphens):
Elementary Lunch
Entree “Bold” Cheese Pizza
--------------“Bold” Pepperoni Pizza
Vegetable Parmesan Butternut Gratin
-------------------Seasoned Green Beans
Elementary Alternative
Entree Chef Salad
-------------Bologna & Cheese SandwichHere’s the current loop that creates the table. Any help would be appreciated.
// Iterate through the cafeteria lines for the school for (var j = 0; j < this.results[i].menuSchedules[0].menuBlocks[0].cafeteriaLineList.data.length; j++) { if (this.results[i].menuSchedules[0].menuBlocks[0].cafeteriaLineList.data[j].name !== 'Elmwood Vegetarian Hot Entree') { // Set up header row with the cafeteria line name cafeteriaLineRow = document.createElement("tr"); cafeteriaLineName = document.createElement("td"); cafeteriaLineName.innerHTML = this.results[i].menuSchedules[0].menuBlocks[0].cafeteriaLineList.data[j].name.replace("Elmwood Elementary", "Elementary Lunch").replace("Elmwood Alternative", "Elementary Alternative"); cafeteriaLineRow.appendChild(cafeteriaLineName); wrapper.appendChild(cafeteriaLineRow); // Iterate through the menu items for the cafeteria line for (var k = 0; k < this.results[i].menuSchedules[0].menuBlocks[0].cafeteriaLineList.data[j].foodItemList.data.length; k++) { if (this.results[i].menuSchedules[0].menuBlocks[0].cafeteriaLineList.data[j].foodItemList.data[k].item_Name !== 'Choice Of:') { foodItemTypeRow = documen t.createElement("tr"); foodItemType = document.createElement("td"); foodItemType.innerHTML = this.results[i].menuSchedules[0].menuBlocks[0].cafeteriaLineList.data[j].foodItemList.data[k].item_Type; foodItemName = document.createElement("td"); foodItemName.innerHTML = this.results[i].menuSchedules[0].menuBlocks[0].cafeteriaLineList.data[j].foodItemList.data[k].item_Name; foodItemTypeRow.appendChild(foodItemType); wrapper.appendChild(foodItemTypeRow); foodItemTypeRow.appendChild(foodItemName); wrapper.appendChild(foodItemTypeRow); } } } }
-
@kazanjig I know this post is old, but I’m trying to accomplish this in a different way. I was trying to do it with PHP instead and the XML coming back from the Mealviewer API isn’t recognized but when I load it directly in my browser all looks good. Would you be willing to share all the code you’re using to load this? I’m not as familiar with how the MM code works and how you’re plugging this into the whole thing. My implementation is just a shared home calendar view that I rolled myself (I may have to look into implementing MM though now that I’ve stumbled upon all this).
-
@gonzonia PHP won’t work in this software. If he doesn’t answer you I will be happy to help you get this going…
-
@cowboysdude Thanks. I’m happy to use a JS implementation as well. The family calendar I created is just hitting a wordpress site I’m hosting on a mac mini. PHP was just so that it could load pre-render but the main thing is just to get the meal list populated on the calendar screen instead of having a separate tab open in the browser. I haven’t had a lot of time to try to look into this or switching to MM. I hate to be hijacking a MM thread but this is literally the only discussion I’ve found of anyone accessing the MealViewer data like this.
-
This post is deleted! -
This post is deleted! -
Okay. I’ve decided to build a MagicMirror to replace my homegrown and now I’m trying to implement this module. I’ve downloaded the repository for this from GitHub and ran npm install.
I’ve added some config info to set the school and position. It’s showing breakfast and “Tomorrow’s Undefined”. I’d like it to show lunch. Help? -
Open the developers window, ctrl-shift-i on the keyboard. Select the console tab and scroll up to see any errors. Usually red text
-
@sdetweil Thank you. That’s helpful (I’m still learning the ins and outs of Magic Mirror) but there’s no errors. The “Undefined” is coming up while it’s loading the data. There’s no documentation for the module, I’m thinking there’s something that’s missing in the setup.
-
@gonzonia can u should your config info?
looking at the code, these are the options that are configurable
defaults: { schools: [], maxWidth: "300px", updateInterval: 5 * 60 * 1000, interval: 1000 * 60 * 15, }
where schools is an array of names
[ ‘school1’,school2’, ‘school3’]used to call the api
https://api.mealviewer.com/api/v4/school/’ + this.config.schools[i]
school names can be found here
https://schools.mealviewer.com/comment says only for one day
// Currently set to only pull one day’s data so endDayFormatted = todayFormatted