Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@beckettkev
Last active April 6, 2016 13:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save beckettkev/daac5370e0535cb3d0c150bb19bfae67 to your computer and use it in GitHub Desktop.
Save beckettkev/daac5370e0535cb3d0c150bb19bfae67 to your computer and use it in GitHub Desktop.
(function (userProfiles, $) {
...
//Store the value in our JSON object
function updateProperty (key, value) {
userProfiles.Current[key] = value;
}
//This method iterates through the nested ugly JSON object array to get what we need (IE9+ or you will need to refactor the array.some functionality)
function getPropertyByKey (results, key, keyName, defaultValue) {
if (typeof results[key] !== 'undefined') {
return results[key];
} else {
results.UserProfileProperties.results.some(function(item, i) {
if (item[keyName] === key) {
defaultValue = item.Value;
return true;
} else {
return false;
}
});
return defaultValue;
}
}
...
})(MyCompany.UserProfiles = MyCompany.UserProfiles || {}, jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment