partkeepr

fork of partkeepr
git clone https://git.e1e0.net/partkeepr.git
Log | Files | Refs | Submodules | README | LICENSE

commit 55fd3cf9cc9ccd4a26e6c40bca228c088551fc6d
parent 81dedf6aea729182f367761b321e9c0e1e3fffc0
Author: timoahummel <privat@timohummel.com>
Date:   Sat, 12 May 2012 19:52:05 -0700

Merge pull request #178 from scrupeus/add-userprefdefault

Added optional default value for user preferences
Diffstat:
Msrc/frontend/js/PartKeepr.js | 11++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/frontend/js/PartKeepr.js b/src/frontend/js/PartKeepr.js @@ -266,18 +266,19 @@ Ext.application({ return this.tipOfTheDayStore; }, /** - * Queries for a specific user preference. Returns either the value or null if the - * preference was not found. + * Queries for a specific user preference. Returns either the value or a default value if + * the preference was not found. * @param key The key to query - * @returns the key value, or null if nothing was found + * @param defaultValue A default value to return (optional) + * @returns the key value, or defaultValue if preference key was not found */ - getUserPreference: function (key) { + getUserPreference: function (key, defaultValue) { var record = this.userPreferenceStore.findRecord("key", key); if (record) { return record.get("value"); } else { - return null; + return (typeof defaultValue == "undefined") ? null : defaultValue; } }, /**