Index: js/customBuild.js =================================================================== --- js/customBuild.js (revision 8207) +++ js/customBuild.js (working copy) @@ -21,12 +21,13 @@ //relates module values to module names - initialized in setup var moduleNames; - var createModuleNamesArray = function (model) { - var array = []; + var createModuleNamesObject = function (model) { + var moduleNamesObject = {}; for (var i = 0; i < model.moduleInfo.length; i++) { - array[model.moduleInfo[i].moduleValue] = model.moduleInfo[i].moduleName; + var modInfo = model.moduleInfo[i]; + moduleNamesObject[modInfo.moduleValue] = modInfo.moduleName; } - return array; + return moduleNamesObject; }; /** @@ -403,19 +404,6 @@ //add click handler to uncheck all if it exists addClickHandler("unCheckAll", unselectAllModules, that); }; - - /** - * Given a the list of the indices of the checked modules return the names of the checked modules - * - * @param {Object} valuesArray - */ - var getModuleNames = function (valuesArray) { - var namesArray = []; - for (var i = 0; i < valuesArray.length; i++) { - namesArray[i] = moduleNames[valuesArray[i]]; - } - return namesArray; - }; /** * Adds javascript dependent aria tags to the markup. @@ -429,24 +417,26 @@ selections.attr("aria-live", "polite"); selections.attr("aria-relevant", "all"); }; - + /** - * Takes an array of module names and converts it to a comma separated string for output. - * - * @param {Object} moduleNames, an array associating module values with their names - */ - var getNamesString = function (moduleNames) { - var namesString = "Modules selected: "; - var arrayLength = moduleNames.length; + * Given a the list of the indices of the checked modules return a string + * containing the names of the checked modules + * + * @param {Object} valuesArray + */ + var getNamesString = function (valuesArray) { + var nameString = "Modules Selected: "; + var arrayLength = valuesArray.length; for (var i = 0; i < arrayLength; i++) { - namesString += moduleNames[i]; + nameString += moduleNames[valuesArray[i]]; if (i < arrayLength - 1) { - namesString += ", "; + nameString += ", "; } } - return namesString; + return nameString; }; - + + /** * Outputs a list of module names of the currently selected modules to the interface. Useful * for accessibility purposes. @@ -455,12 +445,12 @@ * */ var updateSelectedModules = function (that) { - var model = that.model; - var modulesSelected = "Modules selected: none"; - if (model.moduleSelections.length > 0) { - modulesSelected = getNamesString(getModuleNames(model.moduleSelections)); + var selections = that.model.moduleSelections; + var modulesSelectedString = "Modules selected: none"; + if (selections.length > 0) { + modulesSelectedString = getNamesString(selections); } - that.locate("moduleSelections").html(modulesSelected); + that.locate("moduleSelections").html(modulesSelectedString); }; /** @@ -484,7 +474,7 @@ that.applier = fluid.makeChangeApplier(that.model); that.idMap = {}; that.moduleValues = extractArray(that.options.model.moduleInfo, "moduleValue"); - moduleNames = createModuleNamesArray(that.options.model); + moduleNames = createModuleNamesObject(that.options.model); bindEventHandlers(that); initSelectionCounter(that);