BrowserUI is considered legacy infrastructure. Even though legacy infrastructure is highly developed, you should consider updating it to Vercengen specifications to write no-code end-to-end software in JSON5 only.
BrowserUI has no dependencies for its components and context menus, although it recommends the use of Tippy.js for tooltips.
Due to their lengths, various documentation sections have been moved to separate pages. If you would like to view them inline alongside comprehensive documentation as a single page, please visit BrowserUI - Comprehensive Documentation. This page is for core documentation only.
BrowserUI (sometimes stylised UF/BrowserUI) is the main frontend UI library module and component of Universal Framework, Confoederatio's main software engine. It typically contains regular DOM functions as well as more advanced context menus and dynamic custom frontend UIs that can be spawned into various containers utilising JSON5 logic.
These functions, alongside their documentation, are generally presented below in order of importance. There is currently work underway to make sure that createContextMenu() can be easily recursive with collapsible folders and subfolders without the use of .type = 'html' components.
createContextMenu() - Creates a context menu within the DOM.
arg0_options: (Object)
anchor: (String/HTMLElement) - The query selector to pin a context menu to.
class: (String) - The CSS class prefix to prepend.
do_not_append: (Boolean) - Whether to append to the existing element's HTML or not.
id: (String) - The ID of the context menu.
name: (String) - Optional. Title of the context menu. Undefined; will not display by default.
maximum_height: (String) - Optional. The height after which a scrollbar should appear in CSS units.
maximum_width: (String) - Optional. Maximum width in CSS units.
<input_key>: (Object, Component)
return_html: (Boolean) - Optional. Whether to return the html_string instead of modifying the anchor element. False by default.
Returns: (HTMLElement/String)
createContextMenuIndex() - Creates a nested context menu index framework to read from global.config.<config_key>, i.e. ‘global.config.group_actions’. Requires config and config.defines.common to be defined in your project.
Note. This should almost always be used in conjunction with createContextMenuInterface() unless you wish to implement the associated interface logic yourself.
arg0_options: (Object)
config_key: (String) - The main global.config key where categories are stored.
namespace: (String) - The global-level namespace in which dynamically created functions using createContextMenuInterface() will be placed.
Returns: (Void, dynamically-created Global Functions):
global.getAll<options.namespace>s: (Function) - Returns all Object, ContextMenus within a given JSON config/namespace.
arg0_options: (Object)
return_keys: (Boolean) - Optional. Whether to return the keys of all flattened Object, ContextMenu objects in the JSON config. False by default.
global.get<options.namespace>: (Function) - Returns an Object, ContextMenu within a given JSON config/namespace.
arg0_name: (String) - The name of the ContextMenu to look for within the JSON config.
arg1_options: (Object)
return_key: (Boolean) - Optional. Whether to return the key of the interface instead of the actual Object, ContextMenu.
Returns: (Object, ContextMenu/String)
global.get<options.namespace>sAtOrder: (Function) - Returns an Array<Object, ContextMenu> within a given JSON config/namespace.
arg0_options: (Object)
order: (Number) - The .order field at which to return Context Menu bindings.
return_object: (Boolean) - Optional. Whether to return an Object containing all Context Menus that have this .order. False by default.
return_keys: (Boolean) - Optional. Whether to return all flattened keys instead of an Array<Object, ContextMenu>, which is default behaviour. False by default.
global.get<options.namespace>sCategory: (Function) - Returns a Context Menu category, usually all set at the same order. These Context Menu categories are used to define orders with multiple Context Menu bindings.
arg0_name: (String) - The given Context Menu category name.
arg1_options: (Object)
return_key: (Boolean) - Optional. Whether to return the key instead. False by default.
Returns: (Object, ContextMenuCategory)
global.get<options.namespace>sInput: (Function) - Returns the element of an input within a context menu JSON config if available.
arg0_namespace_id: (String) - The namespace of the given context menu types you assigned.
arg1_input_id: (String) - The ID/key name of the input to fetch the HTMLElement for.
Returns: (HTMLElement)
global.get<options.namesace>sLowestOrder: (Function) - Returns the lowest .order in the given context menu JSON config.
Returns: (Number)
global.get<options.namespace>sNavigationObject: (Function) - Returns the root navigation menu for use in creating that interface.
Returns: (Object, ContextMenu)
createContextMenuInterface() - Creates a nested context menu interface framework to read from global.config.<config_key>, i.e. ‘global.config.group_actions’. Requires config and config.defines.common to be defined in your project. Requires createContextMenuIndex().
arg0_options: (Object)
anchor: (String) - The default anchor query selector for where your recursive Context Menus from this JSON config will be bound.
class: (String) - The class to apply to Context Menus spawned from the given namespace. If you wish to avoid default UF styling, append ‘ unique’ onto the end of your .class String.
config_key: (String) - Typically the given options.namespace from createContextMenuIndex(). Always refers to global.config.<config_key>.
interface_key: (String) - Optional. Same as options.config_key by default. Where variable bindings are stored. Always refers to global.interfaces.<interface_key>.
left_margin: (String) - Optional. The CSS calc attribute to prepend when calculating offset margins.
limit_key: (String) - Limit key if applicable, first argument fed into parseLimit() from JSON5DSL.
right_margin: (String) - Optional. The CSS calc attribute to prepend when calculating offset margins.
namespace: (String) - Used for global function names, i.e. .namespace = ‘BrushAction’ results in closeBrushActionContextMenu() being defined.
navigation_mode: (String) - Optional. Either ‘icons’/'list'/'list_icons'. ‘list’ by default.
type: (String) - Optional. Either ‘default’/'entity'/'group'. ‘default’ by default.
Returns: (Void, dynamically-created Global Functions):
global.close<options.namespace>ContextMenu() - Closes a ContextMenu at a given order.
arg0_order: (Number)
arg1_options: (Object) - The .options field to pass onto get<options.namespace>sAnchorElement() and refresh<options.namespace>sContextMenus().
global.close<options.namespace>ContextMenus() - Closes all ContextMenus currently open for this namespace.
arg0_options: (Object) - The .options field to pass onto get<options.namespace>sAnchorElement().
global.close<options.namespace>LastContextMenu() - Closest the last opened ContextMenu for this namespace.
arg0_options: (Object) - The .options field to pass onto get<options.namespace>sOpenOrders() and close<options.namespace>ContextMenu().
global.get<options.namespace>sAnchorElement() - Fetches the given anchor element specified for ContextMenus in the namespace.
arg0_options: (Object)
return_selector: (Boolean) - Optional. Whether to return the query selector instead of the actual HTMLElement. False by default.
Returns: (HTMLElement/String)
global.get<options.namespace>sOpenOrders() - Returns an array of all open orders for a given namespace's ContextMenus.
Returns: Array<Number>
global.get<options.namespace>sInputObject() - Returns the given state object for a ContextMenu namespace.
arg0_options: (Object) - The .options field to pass onto get<options.namespace>sAnchorElement().
Returns: (Object)
<context_menu_key>: (Object)
<variable_key>: (Variable)
global.print<options.namespace>sContextMenu() - Prints a given ContextMenu for the namespace's JSON config.
arg0_namespace_obj: (Object) - The given ContextMenu JSON object to render.
arg1_options: (Object)
type: Either ‘default’/'entity'/group'. Extendable to different data types within your project.
entity_id: (String) - Optional. The entity ID/entity object to fetch custom render logic for. Naissance GIS option.
group_id: (String) - Optional. The hierarchy group ID to fetch custom render logic for.
options: (Object)
<variable_key>: (Variable) - Used for .placeholder bindings to populate default input information with.
timestamp: (Number) - Optional. The current timestamp to pass to ContextMenu population functions. Naissance GIS option.
<variable_key>: (Variable) - Also added to HTMLAttributes for the given namespace anchor element.
global.print<options.namespace>sNavigationMenu() - Prints the root navigation ContextMenu for the namespace's JSON config.
arg0_parent_el: (HTMLElement) - The parent element/container for the root navigation ContextMenu to be displayed in.
arg1_options: (Object) - The .options field to pass onto get<options.namespace>sAnchorElement(), as well as JSON5DSL's parseEffect().
limit_key: (String) - Used for JSON5DSL's parseLimit(). Determines the type of limit scope to parse if applicable.
scroll_selector: (String) - The query selector if the ContextMenu is bound to a scrollable container so that it vertically adjusts to the spawnpoint of the ContextMenu.
y: (Number) - The raw y adjustment in px to apply using CSS.
<variable_key>: (Variable) - Also added to HTMLAttributes for the given namespace anchor element.
global.refresh<options.namespace>sContextMenus() - Refreshes all ContextMenus for the given namespace, including any state/layout changes.
arg0_options: (Object) - The .options field to pass onto get<options.namespace>sAnchorElement().
Returns: (Number) - The total layout width of all ContextMenus for this JSON namespace in px.
global.refresh<options.namespace>sContextMenuInputs() - Refreshes only state changes for a given namespace.
arg0_options: (Object) - The .options field to pass onto get<options.namespace>sAnchorElement().
createPageMenu() - Creates a page menu within the DOM with multiple tabs.
arg0_options: (Object)
id: (String)
anchor: (String) - The query selector anchor in which the page menu is created. If options.tab_anchor is specified, this is just where page content is displayed instead.
tab_anchor: (String) - Optional. The query selector where the tabs menu is created. Defaults to creating two elements in anchor if not available.
default: (String) - Optional. The default tab for the page menu to rest on. This is the first key by default.
pages: (Object, PageDictionary)
<page_key>: (Object, ContextMenu) - Inherits arg0_options from createContextMenu().
name: (String)
html: (Array<String>/String) - Optional. Any custom HTML to load into the page instead of ContextMenu options.
<key>: (Variable) - Optional. The same as most context menus. Does not apply if local .html is defined.
special_function: (Function) - The function to execute upon clicking this tab.
arg0_e: (Event, Onclick)
special_function: (Function) - The function to execute upon clicking any tab.
addSection() - Creates a foldable section/foldable element that can be minimised/expanded.
arg0_options: (Object)
expand_class: (String) - Optional. The class to add when the content is expanded. ‘uf-expanded’ by default.
minimise_class: (String) - Optional. The class to add when the content is collapsed. ‘uf-minimised’ by default.
selector: (String) - The selector for the various elements that can be minimised/expanded. Note that the first element covered by the selector will have the actual chevron controller.
selector_class: (String) - Optional. The class to add to the chevron controller. ‘uf-chevron minimise’ by default.
src: (String) - The source of the chevron image. ‘./UF/gfx/chevron_icon.png’ by default.
is_collapsed: (Boolean) - Optional. Whether the section should start in a collapsed state. False by default.
Nested hierarchies are a special type of Component with dedicated functions and bindings. These are typically used for file inputs, as well as for any type of recursive nested list (i.e. for elements currently being rendered). They are generally split into three distinct types: File Explorers (which are in charge of folder and file management), Generic Hierarchies, and Naissance GIS Hierarchies (used for GIS purposes, i.e. geographical groups and entities).
You may also define custom Hierarchy types, please view BrowserUI - Hierarchies#Custom Hierarchies for specific examples (related to File Explorer defines).
File Explorers are a custom type of Detached Component that exist for purposes of navigating the saves folder, or for providing file inputs in general. createFileExplorer() is the main function for creating new File Explorer Detached Components within your application.
Hierarchies are generic Detached Components that can be used anywhere a sortable nested list is required. Note that you may wish to extend them with custom bindings for nested context menus; see initHierarchy() for more information.
Supporting functions can be used by developers to help populate and update state within BrowserUI Hierarchies and other Detached Components. Updates are managed by renderHierarchy().
insertEntityAtBottom() and insertGroupAtTop() are typically used for default population purposes.
Undo/Redo Trees are used as the standard within UF and UF/BrowserUI, as well as broader Confoederatio software. If you prefer managing a conventional Undo/Redo stack, this can be done via a DALS restriction to the default timeline only.
By default, the UI for Undo/Redo Trees is also provided and can be bound to any valid query selector or HTMLElement.
‘context_menu’ - [WIP] Not yet implemented. Use an ‘html’ component with a e.innerHTML = createContextMenu() .onload field instead.
‘datalist’
options: (Object)
<option_key>: (String)
Returns: (String) - Selected <option> .value for the given datalist.
‘date’
name: (String)
multiple_rows: (Boolean) - Whether hours/minutes should be on a separate row from years/months/days.
Returns: (Object, Date)
year: (Number)
month: (Number) - Ranges from 1-12.
day: (Number) - Ranges from 1-28/30/31.
hour: (Number) - Ranges from 0-23.
minute: (Number) Ranges from 0-59.
‘date_length’
name: (String)
Returns: (Object, Date)
year: (Number)
month: (Number) - Ranges from 1-12.
day: (Number) - Ranges from 1-28/30/31.
hour: (Number) - Ranges from 0-23.
minute: (Number) Ranges from 0-59.
‘email’
name: (String)
attributes: (Object, HTMLAttributes)
Returns: (String)
‘file’ - [WIP] Not entirely integrated as a component. Use dedicated File Explorer functions instead.
‘hierarchy’ - [WIP] Not entirely integrated as a component. Use dedicated Hierarchy functions instead.
‘hidden’
‘html’
name: (String) - Optional. The heading to display for this HTML Component.
custom_html_function: (Object) - The custom HTML function to define for parsing. Should return a variable if this is a readable input component.
arg0_element: (HTMLElement)
innerHTML: (HTMLString)
‘image’ - [WIP] Not yet implemented.
‘number’
name: (String)
attributes: (Object, HTMLAttributes)
onclick: (Function)
arg0_e: (Event, Onclick)
Returns: (Number)
‘password’
name: (String)
attributes: (Object, HTMLAttributes)
Returns: (String)
‘radio’
name: (String)
attributes: (Object, HTMLAttributes)
options: (Object)
<option_key>: (String)
Returns: (String) - The .id of the chosen radio option.
‘range’
name: (String)
attributes: (Object, HTMLAttributes)
max: (Number)
min: (Number)
onclick: (Function)
arg0_e: (Event, Onclick)
options: (Object)
VALUE: (Number) - The default placeholder value for ‘range’.
value_equation: (String, Localisation) - The localisation string for the value equation, i.e. how to parse input values. ‘n’ stands for the input VALUE.
Returns: (Number)
‘reset’
name: (String)
‘search_select’
name: (String)
attributes: (Object, HTMLAttributes)
onchange: (Function) - Fires upon clicking an item in the search_select Component.
arg0_element: (HTMLElement)
onclick: (Function) - Fires upon clicking an item in the search_select Component.
arg0_element: (HTMLElement)
options: (Object)
<option_key>: (String)
Returns: (String) - The [data-value] attribute of the selected item for search_select.
‘select’
name: (String)
attributes: (Object, HTMLAttributes)
onclick: (Function)
arg0_e: (Event, Onclick)
options: (Object)
<option_key>: (String)
Returns: (String) - The .id of the selected <option>.
‘sortable_list’
name: (String)
attributes: (Object, HTMLAttributes)
delete_button_name: (String) - Human-readable name for the delete button.
disable_remove: (Boolean) - Whether removing items from the list should be allowed.
has_controls: (Boolean) - Whether controls for the sortable_list Component should be shown.
onchange: (Function) - Fires upon any user-driven UI change for the sortable_list Component.
arg0_element: (HTMLElement)
onremove: (Function) - Fires upon removing a user removing an item from the sortable_list Component.
arg0_element: (HTMLElement)
options: (Object)
<option_key>: (String)
Returns: (Array<HTMLElement>) - Returns an array of elements in sequential order from the query selector ul.sortable-list > li > span.
Localisation in UF/BrowserUI almost entirely depends on parseVariableString() as of 1.0, which is designed to function similarly to that of a template string, with which it may be coordinated.
parseVariableString() - Parses a variable string and returns its resolved value.
arg0_string: (String) - The string which to resolve.
arg1_options: (Object)
<key>: (Variable)
regex_replace: (Object)
<key>: (Variable)
Returns: (Variable) - Type coerced to a string for most localisation purposes.
Main article(s): BrowserUI - Internal Helper Functions
Internal Helper Functions exist within BrowserUI for QOL purposes. They may be used by end developers for extending BrowserUI for their own purposes, particularly for creating new types of component Objects without being forced to use .type = ‘html’ with a .onload function.
Due to their length, these functions have been moved to a separate documentation article.