diff --git a/index.js b/index.js index 587b14a..a77ec45 100755 --- a/index.js +++ b/index.js @@ -4,7 +4,7 @@ var configPageHtml = require('./tmp/config-page.html'); var toSource = require('tosource'); var standardComponents = require('./src/scripts/components'); var utils = require('./src/scripts/lib/utils'); -var _ = require('./src/scripts/vendor/minified')._; + /** * @param {Array} config - the Clay config * @param {function} [customFn] - Custom code to run from the config page. Will run @@ -165,13 +165,7 @@ Clay.prototype.getSettings = function(response, convert) { localStorage.setItem('clay-settings', JSON.stringify(settings)); - if (convert === false) { - return settings; - } else { - return _.mapObj(settings, function(key, value) { - return utils.prepareForAppMessage(value); - }); - } + return convert === false ? settings : utils.prepareSettingsForAppMessage(settings); }; /** diff --git a/src/scripts/lib/utils.js b/src/scripts/lib/utils.js index 46ca729..156a3c4 100644 --- a/src/scripts/lib/utils.js +++ b/src/scripts/lib/utils.js @@ -53,3 +53,18 @@ module.exports.prepareForAppMessage = function(val) { return result; }; + +/** + * Converts a Clay settings dict into one that is compatible with + * Pebble.sendAppMessage(); + * @see {prepareForAppMessage} + * @param {Object} settings + * @returns {{}} + */ +module.exports.prepareSettingsForAppMessage = function(settings) { + var result = {}; + Object.keys(settings).forEach(function(key) { + result[key] = module.exports.prepareForAppMessage(settings[key]); + }); + return result; +}; diff --git a/src/scripts/vendor/minified.js b/src/scripts/vendor/minified.js index bfb2cd8..a9816fb 100644 --- a/src/scripts/vendor/minified.js +++ b/src/scripts/vendor/minified.js @@ -1,8 +1,8 @@ // minified.js config start -- use this comment to re-create a configuration in the Builder // - Only sections add, always, amdsupport, copyobj, dollardollar, // - each, eachobj, equals, error, extend, find, format, formathtml, get, ht, -// - html, isobject, mapobj, off, on, ready, request, select, set, template, -// - trigger, underscore, wait. +// - html, isobject, off, on, ready, request, select, set, template, trigger, +// - underscore, wait. // WARNING! This file is autogenerated from minified-master.js and others. @@ -2774,46 +2774,6 @@ define('minified', function() { */ 'eachObj': eachObj, - /*$ - * @id mapobj - * @group OBJECT - * @requires - * @configurable default - * @name _.mapObj() - * @syntax _.mapObj(obj, callback) - * @syntax _.mapObj(obj, callback, ctx) - * @module UTIL - * Creates a new object with the same properties but different values using the given callback function. The function is called - * for each property of the input object to provice a new value for the property. - * - * @example Increases the values of all properties. - *
- * var r = _.mapObj({a: 1, b: 5, c: 2}, function(key, value) {
- * return value + 1;
- * });
- * // r is now {a: 2, b: 6, c: 2}
- *
- *
- * @param obj the object to use
- * @param callback The callback function(key, value) to invoke for each property.
- *