Iterate FDB JSON, LocalStorage and populate fields

Iterate FDB JSON, LocalStorage and populate fields

by Andrew Pougher

HTML

<div id="placeholder"></div>
<ul id="members"></ul>
<input type='text' id="cal1" size="110"><br>
    <input type='text' id="cal2" size="110"><br>
        <input type='text' id="cal3" size="110"><br>
            <code></code>

CSS

ul#members {
    font-size:23px;
    list-style-type:square
}

JavaScript

if (localStorage.getItem("CalendarFeedFlights") == null){
    
    var data = {
    "CalendarFeedFlights": "http:\/\/www.focusdashboard.com\/feeds\/calendars\/3ca79d41-e71f-4c4d-9e16-d7ea40e50b69-flights.ics",
    "CalendarFeedFull": "http:\/\/www.focusdashboard.com\/feeds\/calendars\/3ca79d41-e71f-4c4d-9e16-d7ea40e50b69.ics",
    "CalendarFeedTrips": "http:\/\/www.focusdashboard.com\/feeds\/calendars\/3ca79d41-e71f-4c4d-9e16-d7ea40e50b69-trips.ics",
    "EmailAlerts": [{
        "AlertName": "emailalertaddhotel",
        "AlertText": "A hotel has been added to the booking",
        "SavedValue": false
    }, {
        "AlertName": "emailalertaddcar",
        "AlertText": "A car has been added to the booking",
        "SavedValue": false
    }, {
        "AlertName": "emailalertxxlhotel",
        "AlertText": "A hotel has been removed from the booking",
        "SavedValue": true
    }, {
        "AlertName": "emailalertxxlcar",
        "AlertText": "A car has been removed from the booking",
        "SavedValue": true
    }, {
        "AlertName": "emailalertretfltreminder",
        "AlertText": "Reminder for Return Flight",
        "SavedValue": false
    }, {
        "AlertName": "emailalertcheckinreminder",
        "AlertText": "Reminder for flight check in",
        "SavedValue": true
    }],
    "GUID": "3ca79d41-e71f-4c4d-9e16-d7ea40e50b69",
    "NumberBookingsToShow": 5
}
    }
// This would be in the Ajax Success var data = JSON.stringify(response)

localStorage.setItem("userSettings", JSON.stringify(data));
var myFeeds = localStorage.getItem("userSettings");//Retrieve the stored data set when user logged in
myFeeds = JSON.parse(myFeeds); //Converts string to object
if(myFeeds == null) //If there is no data, initialize an empty array
myFeeds = [];




var cal1=myFeeds["CalendarFeedFlights"];
var cal2=myFeeds["CalendarFeedFull"];
var cal3=myFeeds["CalendarFeedTrips"];
var guid=myFeeds["GUID"];
var...