• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
MagicMirror Forum
  • Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
  1. Home
  2. kazanjig
A New Chapter for MagicMirror: The Community Takes the Lead
Read the statement by Michael Teeuw here.
K
Offline
  • Profile
  • Following 0
  • Followers 0
  • Topics 2
  • Posts 7
  • Groups 0

kazanjig

@kazanjig

3
Reputation
296
Profile views
7
Posts
0
Followers
0
Following
Joined Jan 17, 2019, 5:05 AM
Last Online Feb 25, 2019, 6:51 PM

kazanjig Unfollow Follow

Best posts made by kazanjig

  • RE: MMM-MealViewer

    .@cowboysdude was exceptionally helpful last night.
    thumbs up

    posted in Development
    K
    kazanjig
    Feb 17, 2019, 4:19 PM
  • RE: 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 Sandwich

    The 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 Sandwich

    Here’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);
                  }
                }
              }
            }
    
    posted in Development
    K
    kazanjig
    Feb 17, 2019, 9:10 PM
  • RE: Conditional formatting of config (e.g., MMM-Unsplash)

    @seann good point, I could just put the collections directly in the module rather than the config, that would do it. @parnic suggested using profile switcher, or at least there may be functionality to grab. I should be able to take it from here – pretty simple. The most time-consuming part will be creating the collection of collections.

    posted in Development
    K
    kazanjig
    Feb 18, 2019, 6:56 PM

Latest posts made by kazanjig

  • RE: Conditional formatting of config (e.g., MMM-Unsplash)

    @seann good point, I could just put the collections directly in the module rather than the config, that would do it. @parnic suggested using profile switcher, or at least there may be functionality to grab. I should be able to take it from here – pretty simple. The most time-consuming part will be creating the collection of collections.

    posted in Development
    K
    kazanjig
    Feb 18, 2019, 6:56 PM
  • Conditional formatting of config (e.g., MMM-Unsplash)

    Is it possible to have conditional statements in the config? For example, for MMM-Unsplash, to have separate image collections for time of day, season, etc.?

    posted in Development
    K
    kazanjig
    Feb 18, 2019, 6:37 PM
  • RE: 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 Sandwich

    The 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 Sandwich

    Here’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);
                  }
                }
              }
            }
    
    posted in Development
    K
    kazanjig
    Feb 17, 2019, 9:10 PM
  • RE: MMM-MealViewer

    MAJOR EDIT, MAJOR DUMMIE: helps if you append the rows to the table… Success! Now for some CSS.

    @cowboysdude I edited my earlier post… minor detail about it being the weekend and not being able to pull lunch data for a day with no school. Now just having getting the data to show up in the table…

    It will display the “loading” message, but then it’s blank when this.loaded = true. I outputted the innerHTML values to console and they’re all there. Not sure why they won’t show up in the DOM.

      getDom: function() {
        // Set up the local wrapper
        var wrapper = null;
    
        // If we have some data to display then build the results table
        if (this.loaded) {
          wrapper = document.createElement("table");
    
          // Iterate through the schools
          for (var i = 0; i < this.results.length; i++) {
    
            // Set up header row with the school name
            schoolRow = document.createElement("tr");
    
            schoolName = document.createElement("td");
            schoolName.innerHTML = this.results[i].physicalLocation.name;
    
            schoolRow.appendChild(schoolName);
    
            // Iterate through the cafeteria lines for the school
            for (var j = 0; j < this.results[i].menuSchedules[0].menuBlocks[0].cafeteriaLineList.data.length; j++) {
    
              // 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;
    
              cafeteriaLineRow.appendChild(cafeteriaLineName);
    
              // 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++) {
    
                foodItemRow = document.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;
    
                foodItemRow.appendChild(foodItemType);
                foodItemRow.appendChild(foodItemName);
              }
            }
          }
        }
    
        else {
          // Otherwise lets just use a simple div
          wrapper = document.createElement('div');
          wrapper.innerHTML = 'Loading menu data...';
        }
    
        return wrapper;
      },
    
    posted in Development
    K
    kazanjig
    Feb 17, 2019, 7:24 PM
  • RE: MMM-MealViewer

    But now I seem to have gotten myself into a pickle. I tried expanding the functionality to add a date range and multiple schools and, of course, I broke it. It’s doing the same thing as before where the ‘cafeteriaLineList’ property is stripped out of the helper results…

    EDIT:
    LOL, it’s the weekend and I had it pulling just for today, Sunday. Of course there’s no data. Dumb da dumb dumb…

    posted in Development
    K
    kazanjig
    Feb 17, 2019, 5:59 PM
  • RE: MMM-MealViewer

    .@cowboysdude was exceptionally helpful last night.
    thumbs up

    posted in Development
    K
    kazanjig
    Feb 17, 2019, 4:19 PM
  • MMM-MealViewer

    I’m trying to develop a module to get today’s school lunch menu options from my kids’ school. The district uses a service provided by mealviewer.com. The API is available at https://api.mealviewer.com/api/v4/school/[schoolname]/[date range start MM-DD-YYYY]/[date range end MM-DD-YYYY]/. To keep it simple I’m only pulling the current day so the start and end date values are the same.

    Here’s an example: https://api.mealviewer.com/api/v4/school/ElmwoodElementary/02-15-2019/02-15-2019/

    You can see that there is a TON of XML data returned. I’m only interested in the [CafeteriaLine] nodes and each of their respective [FoodItem] nodes and then the respective [Item_Type] and [Item_Name] for each [FoodItem].

    I’m able to send an HTTP request and get (some) data but, unfortunately, most of the nonsense is returned and I don’t see the menu information. It’s like a big chunk out of the middle of the XML data is missing, whether I dump it out to the log before or after parsing it to JSON.

    Any thoughts?

    posted in Development
    K
    kazanjig
    Feb 16, 2019, 10:41 PM
Enjoying MagicMirror? Please consider a donation!
MagicMirror created by Michael Teeuw.
Forum managed by Sam, technical setup by Karsten.
This forum is using NodeBB as its core | Contributors
Contact | Privacy Policy