Last active
April 6, 2016 13:15
-
-
Save beckettkev/daac5370e0535cb3d0c150bb19bfae67 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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