API Docs for JavaScript File OptSelector.js
Auto-Extracted Documentation
The following information is automatically extracted from the JS code files. Methods and variables that begin with the double underscore ("__") are considered to be part of the private API of the library.
function OptSelector()
Utility to help with create HTML selectors (drop-down menus)
Contains a variety of methods to control the data, keys, and displays that are shown in the menu
function buildOptSelector()
Standard build function for OptSelector
Use this in preference to new keyword, for fluent coding style.
OptSelector.prototype.sortByDisplay = function(kdisp)
Maintaining the K/V pairing, sort by display values.
OptSelector.prototype.configureFromMap = function(themap)
Configure the key/values in this selector from a JavaScript Map
Keys are the interior values, Map values are the display values
OptSelector.prototype.configureFromList = function(thelist)
Configure the key/values in this selector from single list
Both interior values and display values are the list elements
OptSelector.prototype.configureFromHash = function(thehash)
Configure the key/values in this selector from a JavaScript hash/dict
Interior values are hash keys, display values are hash values
OptSelector.prototype.setKeyList = function(kdisp)
Sets the keys and values from the given flat list
In this case keys and values will be the same.
Deprecated: use configureFromList instead
OptSelector.prototype.insertStartingPair = function(kinit, dinit)
Insert a starting pair into the key/display list
This is useful for creating drop-downs with starter/dummy values that don't do anything
Often use this AFTER sortByValue
OptSelector.prototype.setSelectOpener = function(selopen)
Sets the opening select statement for the selector
Provide the attributes etc you need for the select here.
OptSelector.prototype.setAttribute = function(attrname, attrval)
Set an Attribute of the select element that will be generated
Usage of this operation is incompatible with setSelectOpener
OptSelector.prototype.setElementName = function(thename)
Set the name attribute of the selector
Shorthand for setAttribute("name", ...)
OptSelector.prototype.setOnChange = function(funcname)
Set the onChange attribute
Shorthand for setAttribute("onChange")
By convention, you are required to include the "javascript:" prefix
OptSelector.prototype.autoPopulate = function()
Smart auto-populate of span (or div) based on naming convention
To use this, you must set the element name using setElementName
And you must have a span with the ID=name+"_span"
OptSelector.prototype.setSelectedKey = function(skey)
Sets the key that will be selected by default
You must set the key list first.
One of the keys must match the input.
OptSelector.prototype.setFromMap = function(optmap)
Set key/value pairs from the given map.
Keys will be keys of map, displays will be values.
Deprecated: this method is misnamed
Use configureFromMap or configureFromHash instead
OptSelector.prototype.setIndex2DispList = function(dlist)
Sets the key/values from the given flat list
Keys will be INDEXES, values will be items.
Deprecated: use one of the configureFrom(...) methods instead
OptSelector.prototype.setKeyDispList = function(klist, dlist)
Sets key/values from given list pair.
Keys are from first list, values are from second list
Deprecated: use one of the configureFrom(...) methods instead
OptSelector.prototype.getHtmlString = function()
Get the actual full select string for the OptSelector.
This starts with the select tag and ends with closing select tag.
OptSelector.prototype.resetData = function()
Clears the key/value pairs
this is primarily for internal use, callers should prefer to just
create a new OptSelector object
OptSelector.prototype.getFullOptionStr = function()
Get the full list of options as a flat string
You can use this if you want to write out the select tags yourself.
OptSelector.prototype.getSingleOptionStr = function(idx)
Get the ith option string
const GENERIC_OPT_SELECT_MAP = new Map();
Map of Element name to selected KEYS for OptSelector objects that use this feature
OptSelector.prototype.useGenericUpdater = function()
Configure this select to use a generic update function
This function will pull the value of the OptSelector into the GENERIC_OPT_SELECT_MAP
when the selector is changed
You must provide an element name before calling this function
function initGenericSelect(copymap)
Deprecated, just set data in GENERIC_OPT_SELECT_MAP directly
function getGenericSelectValue(k) {
Deprecated, just access GENERIC_OPT_SELECT_MAP directly
Big question: is the data in here going to come out of the map with its original types...?
function __genericOptSelectorUpdate(selectname)
Update the GENERIC_OPT_SELECT_MAP from the form value with given name
The key of the map is the given name
Also call redisplay()
This is the method called by OptSelectors that are configured with the useGenericUpdater option