code
stringlengths
28
313k
docstring
stringlengths
25
85.3k
func_name
stringlengths
1
74
language
stringclasses
1 value
repo
stringlengths
5
60
path
stringlengths
4
172
url
stringlengths
44
218
license
stringclasses
7 values
function edit(grid, event, onDoubleClick) { if ( event.isDataCell && !(event.getCellProperty('editOnDoubleClick') ^ onDoubleClick) // both same (true or falsy)? ) { grid.onEditorActivate(event); } if (this.next) { this.next[onDoubleClick ? 'handleDoubleClick' : 'handleCl...
@param {Hypergrid} grid @param {Object} event - the event details @memberOf KeyPaging.prototype
edit
javascript
fin-hypergrid/core
src/features/CellEditing.js
https://github.com/fin-hypergrid/core/blob/master/src/features/CellEditing.js
MIT
function doubleClickDelay(grid, event) { var columnProperties; return ( event.isHeaderCell && !(columnProperties = event.columnProperties).unsortable && columnProperties.sortOnDoubleClick && 300 ); }
@memberOf ColumnSelection.prototype @desc Replace the most recent selection with a single cell selection that is moved (offsetX,offsetY) from the previous selection extent. @param {Hypergrid} grid @param {number} offsetX - x coordinate to start at @param {number} offsetY - y coordinate to start at
doubleClickDelay
javascript
fin-hypergrid/core
src/features/ColumnSelection.js
https://github.com/fin-hypergrid/core/blob/master/src/features/ColumnSelection.js
MIT
function sort(grid, event, onDoubleClick) { var columnProperties; if ( event.isHeaderCell && !(columnProperties = event.columnProperties).unsortable && !(columnProperties.sortOnDoubleClick ^ onDoubleClick) // both same (true or falsy)? ) { grid.fireSyntheticColumnSortEvent(ev...
@memberOf ColumnSorting.prototype @param {Hypergrid} grid @param {Object} event - the event details
sort
javascript
fin-hypergrid/core
src/features/ColumnSorting.js
https://github.com/fin-hypergrid/core/blob/master/src/features/ColumnSorting.js
MIT
function moveLaterally(grid, detail, deltaX) { var cellEvent = detail.editor.event, gridX = cellEvent.visibleColumn.index, gridY = cellEvent.visibleRow.index, originX = gridX, C = grid.renderer.visibleColumns.length; cellEvent = new grid.behavior.CellEvent; // redefine so we don...
Navigate away from the filter cell when: 1. Coming from a cell editor (`event.detail.editor` defined). 2. The cell editor was for a filter cell. 3. The key (`event.detail.char) maps (through {@link module:defaults.navKeyMap|navKeyMap}) to one of: * `'UP'` or `'DOWN'` - Selects first visible data cell under filter ce...
moveLaterally
javascript
fin-hypergrid/core
src/features/Filters.js
https://github.com/fin-hypergrid/core/blob/master/src/features/Filters.js
MIT
function moveCellSelection(grid) { var rows; if ( grid.properties.collapseCellSelections && grid.properties.singleRowSelectionMode && // let's only attempt this when in this mode !grid.properties.multipleSelections && // and only when in single selection mode (rows = grid.getSel...
@memberOf RowSelection.prototype @desc Replace the most recent row selection with a single cell row selection `offsetY` rows from the previous selection. @param {Hypergrid} grid @param {number} offsetY - y coordinate to start at
moveCellSelection
javascript
fin-hypergrid/core
src/features/RowSelection.js
https://github.com/fin-hypergrid/core/blob/master/src/features/RowSelection.js
MIT
get charMap() { return this.behavior.charMap; }
@returns {number} The total number of logical rows of all subgrids. @memberOf Hypergrid#
charMap
javascript
fin-hypergrid/core
src/Hypergrid/index.js
https://github.com/fin-hypergrid/core/blob/master/src/Hypergrid/index.js
MIT
function Var() { this.gridRenderer = defaults.gridRenderer; this.rowHeaderCheckboxes = defaults.rowHeaderCheckboxes; this.rowHeaderNumbers = defaults.rowHeaderNumbers; this.gridBorder = defaults.gridBorder; this.gridBorderTop = defaults.gridBorderTop; this.gridBorderRight = defaults.gridBorderRi...
Creates an instance variable backer for use by the getters and setters described in {@link dynamicProperties}. @constructor @memberOf Hypergrid~ @private
Var
javascript
fin-hypergrid/core
src/Hypergrid/index.js
https://github.com/fin-hypergrid/core/blob/master/src/Hypergrid/index.js
MIT
function getValue(selectedRowIndex, j) { var dataRow = dataModel.getRow(selectedRowIndex); rows[j] = valOrFunc(dataRow, column); }
@param {boolean|number[]|string[]} [hiddenColumns=false] - _Per {@link Hypergrid~getColumns}._ @returns {{}} @memberOf Hypergrid#
getValue
javascript
fin-hypergrid/core
src/Hypergrid/selection.js
https://github.com/fin-hypergrid/core/blob/master/src/Hypergrid/selection.js
MIT
function getValue(selectedRowIndex, r) { var dataRow = dataModel.getRow(selectedRowIndex); result[c][r] = valOrFunc(dataRow, column); }
@param {boolean|number[]|string[]} [hiddenColumns=false] - _Per {@link Hypergrid~getColumns}._ @returns {Array} @memberOf Hypergrid#
getValue
javascript
fin-hypergrid/core
src/Hypergrid/selection.js
https://github.com/fin-hypergrid/core/blob/master/src/Hypergrid/selection.js
MIT
function getColumns(hiddenColumns) { var columns, allColumns = this.behavior.getColumns(), activeColumns = this.behavior.getActiveColumns(); if (Array.isArray(hiddenColumns)) { columns = []; hiddenColumns.forEach(function(index) { var key = typeof index === 'number' ...
@param {boolean|number[]|string[]} [hiddenColumns=false] - One of: `false` - Active column list `true` - All column list `Array` - Active column list with listed columns prefixed as needed (when not already in the list). Each item in the array may be either: * `number` - index into all column list * `string` - name of ...
getColumns
javascript
fin-hypergrid/core
src/Hypergrid/selection.js
https://github.com/fin-hypergrid/core/blob/master/src/Hypergrid/selection.js
MIT
function valOrFunc(dataRow, column) { var result, calculator; if (dataRow) { result = dataRow[column.name]; calculator = (typeof result)[0] === 'f' && result || column.calculator; if (calculator) { result = calculator(dataRow, column.name); } } return result |...
@this {dataRowObject} @param column @returns {string}
valOrFunc
javascript
fin-hypergrid/core
src/Hypergrid/selection.js
https://github.com/fin-hypergrid/core/blob/master/src/Hypergrid/selection.js
MIT
function applyTheme(theme) { var themeLayer, grids, props, themeObject; if (theme && typeof theme === 'object' && !Object.getOwnPropertyNames(theme).length) { theme = null; } if (this._theme) { grids = [this]; themeLayer = this._theme; props = this.properties; ...
@summary The Hypergrid theme registry. @desc The standard registry consists of a single theme, `default`, built from values in defaults.js.
applyTheme
javascript
fin-hypergrid/core
src/Hypergrid/themes.js
https://github.com/fin-hypergrid/core/blob/master/src/Hypergrid/themes.js
MIT
function WritablePoint(x, y) { // skip x and y initialization here for performance // because typically reset after instantiation }
Variation of `rectangular.Point` but with writable `x` and `y` @constructor
WritablePoint
javascript
fin-hypergrid/core
src/lib/cellEventFactory.js
https://github.com/fin-hypergrid/core/blob/master/src/lib/cellEventFactory.js
MIT
function factory(grid) { /** * @summary Create a new CellEvent object. * * @classdesc `CellEvent` is a very low-level object that needs to be super-efficient. JavaScript objects are well known to be light weight in general, but at this level we need to be careful. * * These objects were or...
@name cellEventFactory @summary Create a custom `CellEvent` class. @desc Create a custom definition of `CellEvent` for each grid instance, setting the `grid`, `behavior`, and `dataModel` properties on the prototype. As this happens once per grid instantiation, it avoids having to perform this set up work on every `Ce...
factory
javascript
fin-hypergrid/core
src/lib/cellEventFactory.js
https://github.com/fin-hypergrid/core/blob/master/src/lib/cellEventFactory.js
MIT
function CellEvent(gridX, gridY) { // remaining instance vars are non-enumerable so `CellEditor` constructor won't mix them in (for mustache use). Object.defineProperties(this, { /** * @name visibleColumn * @type {visibleColumnArray} * @memberOf CellEve...
@summary Create a new CellEvent object. @classdesc `CellEvent` is a very low-level object that needs to be super-efficient. JavaScript objects are well known to be light weight in general, but at this level we need to be careful. These objects were originally only being created on mouse events. This was no big deal a...
CellEvent
javascript
fin-hypergrid/core
src/lib/cellEventFactory.js
https://github.com/fin-hypergrid/core/blob/master/src/lib/cellEventFactory.js
MIT
deprecated = function(methodName, dotProps, since, args, notes) { if (typeof args === 'string') { // `args` omitted notes = args; args = undefined; } var chain = dotProps.split('.'), warned = this.$$DEPRECATION_WARNED = this.$$DEPRECATION_WARNED || {}, result = this,...
User is warned and new property is returned or new method is called and the result is returned. @param {string} methodName - Warning key paired with arbitrary warning in `dotProps` OR deprecated method name with parentheses containing optional argument list paired with replacement property or method in `dotProps`. @par...
deprecated
javascript
fin-hypergrid/core
src/lib/deprecated.js
https://github.com/fin-hypergrid/core/blob/master/src/lib/deprecated.js
MIT
function getTextWidth(string) { var metrics = fontMetrics[this.cache.font] = fontMetrics[this.cache.font] || {}; string += ''; for (var i = 0, sum = 0, len = string.length; i < len; ++i) { var c = string[i]; sum += metrics[c] = metrics[c] || this.measureText(c).width; } return sum; }
Accumulates width of string in pixels, character by character, by chaching character widths and reusing those values when previously cached. NOTE: There is a minor measuring error when taking the sum of the pixel widths of individual characters that make up a string vs. the pixel width of the string taken as a whole. ...
getTextWidth
javascript
fin-hypergrid/core
src/lib/graphics.js
https://github.com/fin-hypergrid/core/blob/master/src/lib/graphics.js
MIT
function getTextHeight(font) { var result = fontData[font]; if (!result) { result = {}; var text = document.createElement('span'); text.textContent = 'Hg'; text.style.font = font; var block = document.createElement('div'); block.style.display = 'inline-block'; ...
@memberOf module:defaults @param font @returns {*}
getTextHeight
javascript
fin-hypergrid/core
src/lib/graphics.js
https://github.com/fin-hypergrid/core/blob/master/src/lib/graphics.js
MIT
function formatDigit(d) { return this.localizedDigits[d]; }
Transform a number to or from a string representation with localized digits. @param {function} digitTransformer - A function bound to `this`. @param {number} number @returns {string} @private @memberOf DateFormatter.prototype
formatDigit
javascript
fin-hypergrid/core
src/lib/Localization.js
https://github.com/fin-hypergrid/core/blob/master/src/lib/Localization.js
MIT
function Localization(locale, numberOptions, dateOptions) { this.locale = locale; /** * @name number * @see The {@link NumberFormatter|NumberFormatter} class * @memberOf Localization.prototype */ this.int = this.float = this.construct('number', NumberFormatter, numberOptions); /** ...
All members are localizers (conform to {@link localizerInterface}) with exception of `get`, `set`, and localizer constructors which are named (by convention) ending in "Formmatter". The application developer is free to add localizers and localizer factory methods. See the {@link Localization#construct|construct} conve...
Localization
javascript
fin-hypergrid/core
src/lib/Localization.js
https://github.com/fin-hypergrid/core/blob/master/src/lib/Localization.js
MIT
function singularOf(name) { endings.find(function(ending) { if (ending.plural.test(name)) { name = name.replace(ending.plural, ending.singular); return true; } }); return name; }
Fetch a registered item. @param {string} [name] @returns {*|undefined} A registered item or `undefined` if unregistered. @memberOf Registry#
singularOf
javascript
fin-hypergrid/core
src/lib/Registry.js
https://github.com/fin-hypergrid/core/blob/master/src/lib/Registry.js
MIT
function SelectionModel(grid) { this.grid = grid; this.reset(); }
@constructor @desc We represent selections as a list of rectangles because large areas can be represented and tested against quickly with a minimal amount of memory usage. Also we need to maintain the selection rectangles flattened counter parts so we can test for single dimension contains. This is how we know to highl...
SelectionModel
javascript
fin-hypergrid/core
src/lib/SelectionModel.js
https://github.com/fin-hypergrid/core/blob/master/src/lib/SelectionModel.js
MIT
function shaker(event) { if (!event || event.propertyName === 'left') { el.style.left = x + dx + 'px'; if (!shakes--) { el.removeEventListener('transitionend', shaker); transitions.pop(); el.style.transition = transitions.join(','); ...
Shake element back and fourth a few times as if to say, "Nope!" @type {effectFunction} @memberOf module:effects
shaker
javascript
fin-hypergrid/core
src/lib/DOM/effects.js
https://github.com/fin-hypergrid/core/blob/master/src/lib/DOM/effects.js
MIT
function glower(event) { var was = styleWas[event.propertyName]; if (was.undo) { el.style[event.propertyName] = was.style; was.undo = false; } else if (!--values) { el.removeEventListener('transitionend', glower); el.style.transition = transition; ...
Transition styles on element for a moment and revert as if to say, "Whoa!." @type {effectFunction} @memberOf module:effects
glower
javascript
fin-hypergrid/core
src/lib/DOM/effects.js
https://github.com/fin-hypergrid/core/blob/master/src/lib/DOM/effects.js
MIT
function paintCellsAsNeeded(gc) { var cellEvent, visibleColumns = this.visibleColumns, visibleRows = this.visibleRows, C = visibleColumns.length, cLast = C - 1, r, R = visibleRows.length, p = 0, pool = this.cellEventPool, preferredWidth, columnClip, //...
@summary Render the grid only as needed ("partial render"). @desc Paints all the cells of a grid, one column at a time, but only as needed. Partial render is supported only by those cells whose cell renderer supports it by returning before rendering (based on `config.snapshot`). #### On reset Defers to {@link Render...
paintCellsAsNeeded
javascript
fin-hypergrid/core
src/renderer/by-cells.js
https://github.com/fin-hypergrid/core/blob/master/src/renderer/by-cells.js
MIT
function paintCellsByColumnsAndRows(gc) { var grid = this.grid, gridProps = grid.properties, prefillColor, rowPrefillColors, gridPrefillColor = gridProps.backgroundColor, cellEvent, rowBundle, rowBundles, columnBundle, columnBundles, visibleColumns = this.visibleColum...
@summary Render the grid with consolidated row OR column rects. @desc Paints all the cells of a grid, one column at a time. First, a background rect is drawn using the grid background color. Then, if there are any rows with their own background color _that differs from the grid background color,_ these are consolidat...
paintCellsByColumnsAndRows
javascript
fin-hypergrid/core
src/renderer/by-columns-and-rows.js
https://github.com/fin-hypergrid/core/blob/master/src/renderer/by-columns-and-rows.js
MIT
function paintCellsByColumnsDiscrete(gc) { var prefillColor, cellEvent, visibleColumns = this.visibleColumns, visibleRows = this.visibleRows, C = visibleColumns.length, cLast = C - 1, r, R = visibleRows.length, pool = this.cellEventPool, preferredWidth, ...
@summary Render the grid with discrete column rects. @desc Paints all the cells of a grid, one column at a time. In this grid renderer, a background rect is _not_ drawn using the grid background color. Rather, all columns paint their own background rects, with color defaulting to grid background color. The idea of p...
paintCellsByColumnsDiscrete
javascript
fin-hypergrid/core
src/renderer/by-columns-discrete.js
https://github.com/fin-hypergrid/core/blob/master/src/renderer/by-columns-discrete.js
MIT
function paintCellsByRows(gc) { var grid = this.grid, gridProps = grid.properties, prefillColor, rowPrefillColors, gridPrefillColor = gridProps.backgroundColor, cellEvent, rowBundle, rowBundles = this.rowBundles, visibleColumns = this.visibleColumns, vr, visibleRows =...
@summary Render the grid. @desc _**NOTE:** This grid renderer is not as performant as the others and it's use is not recommended if you care about performance. The reasons for the wanting performance are unclear, possibly having to do with the way Chrome optimizes access to the column objects?_ Paints all the cells of...
paintCellsByRows
javascript
fin-hypergrid/core
src/renderer/by-rows.js
https://github.com/fin-hypergrid/core/blob/master/src/renderer/by-rows.js
MIT
get properties() { return this.grid.properties; }
CAUTION: Keep in place! Used by {@link Canvas}. @memberOf Renderer.prototype @returns {Object} The current grid properties object.
properties
javascript
fin-hypergrid/core
src/renderer/index.js
https://github.com/fin-hypergrid/core/blob/master/src/renderer/index.js
MIT
function fetchCompletion(gc, fetchError) { if (!fetchError) { // STEP 1: Render the grid immediately (before next refresh) just to get column widths // (for better performance this could be done off-screen but this works fine as is) this.gridRenderer.paintCells.call(this, gc); // STE...
Resets the cell properties cache in the matching `CellEvent` object from the renderer's pool. This will insure that a new cell properties object will be known to the renderer. (Normally, the cache is not reset until the pool is updated by the next call to {@link Renderer#computeCellBounds}). @param {number|CellEvent} x...
fetchCompletion
javascript
fin-hypergrid/core
src/renderer/index.js
https://github.com/fin-hypergrid/core/blob/master/src/renderer/index.js
MIT
function computeCellsBounds() { var scrollTop = this.getScrollTop(), scrollLeft = this.getScrollLeft(), bounds = this.getBounds(), grid = this.grid, behavior = grid.behavior, hasTreeColumn = behavior.hasTreeColumn(), treeColumnIndex = behavior.treeColumnIndex, ...
This function creates several data structures: * {@link Renderer#visibleColumns} * {@link Renderer#visibleRows} Original comment: "this function computes the grid coordinates used for extremely fast iteration over painting the grid cells. this function is very fast, for thousand rows X 100 columns on a modest machine ...
computeCellsBounds
javascript
fin-hypergrid/core
src/renderer/index.js
https://github.com/fin-hypergrid/core/blob/master/src/renderer/index.js
MIT
function getSubrects() { var dw = this.dataWindow; if (!this.grid.properties.fetchSubregions) { var rect = this.grid.newRectangle(dw.left, dw.top, dw.width, dw.height); // convert from InclusiveRect return [rect]; } var orderedColumnIndexes = this.visibleColumns.map(function(vc) { retur...
@summary Create a list of `Rectangle`s representing visible cells. @desc When `grid.properties.fetchSubregions` is true, this function needs to handle: 1. unordered columns 2. column gaps (hidden columns) 3. the single row gap that results when there are fixed rows and remaining rows are scrolled down @ToDo This funct...
getSubrects
javascript
fin-hypergrid/core
src/renderer/index.js
https://github.com/fin-hypergrid/core/blob/master/src/renderer/index.js
MIT
function resetRowHeaderColumnWidth(gc, rowCount) { var columnProperties = this.grid.behavior.getColumnProperties(this.grid.behavior.rowColumnIndex), gridProps = this.grid.properties, width = 2 * columnProperties.cellPadding; // Checking images.checked also supports a legacy feature in which che...
@summary Resize the handle column. @desc Handle column width is sum of: * Width of text the maximum row number, if visible, based on handle column's current font * Width of checkbox, if visible * Some padding @this {Renderer} @param {CanvasRenderingContext2D} gc @param {number} rowCount
resetRowHeaderColumnWidth
javascript
fin-hypergrid/core
src/renderer/index.js
https://github.com/fin-hypergrid/core/blob/master/src/renderer/index.js
MIT
function _extractParamValue(paramsKeyVals, paramName) { let map = _parseKeyValueListToMap(paramsKeyVals) return map.get(paramName) || ''; }
@param {string[]} paramsKeyVals @param {string} paramName @returns {string}
_extractParamValue
javascript
openwrt/luci
applications/luci-app-acme/htdocs/luci-static/resources/view/acme.js
https://github.com/openwrt/luci/blob/master/applications/luci-app-acme/htdocs/luci-static/resources/view/acme.js
Apache-2.0
function get_branch(version) { return version.replace('-SNAPSHOT', '').split('.').slice(0, 2).join('.'); }
Returns the branch of a given version. This helps to offer upgrades for point releases (aka within the branch). Logic: SNAPSHOT -> SNAPSHOT 21.02-SNAPSHOT -> 21.02 21.02.0-rc1 -> 21.02 19.07.8 -> 19.07 @param {string} version Input version from which to determine the branch @returns {string} The determined branch
get_branch
javascript
openwrt/luci
applications/luci-app-attendedsysupgrade/htdocs/luci-static/resources/view/attendedsysupgrade/overview.js
https://github.com/openwrt/luci/blob/master/applications/luci-app-attendedsysupgrade/htdocs/luci-static/resources/view/attendedsysupgrade/overview.js
Apache-2.0
removeOpenClass = function () { d3.selectAll("svg .njg-open").classed("njg-open", false); }
@function @name removeOpenClass Remove open classes from nodes and links
removeOpenClass
javascript
openwrt/luci
applications/luci-app-bmx7/root/www/luci-static/resources/bmx7/js/netjsongraph.js
https://github.com/openwrt/luci/blob/master/applications/luci-app-bmx7/root/www/luci-static/resources/bmx7/js/netjsongraph.js
Apache-2.0
function uploadNextFile(index) { if (index >= totalFiles) { self.loadFileList(currentPath).then(function() { self.initResizableColumns(); }); return; } var file = files[index]; var fullFilePath = joinPath(directoryPath, file.name); if (statusInfo) { statusInfo.textContent = _('Uploa...
Initializes the resizable functionality for the Help window.
uploadNextFile
javascript
openwrt/luci
applications/luci-app-filemanager/htdocs/luci-static/resources/view/system/filemanager.js
https://github.com/openwrt/luci/blob/master/applications/luci-app-filemanager/htdocs/luci-static/resources/view/system/filemanager.js
Apache-2.0
function doDrag(e) { var currentX = e.pageX; var newWidth = startWidth + (currentX - startX); if (newWidth >= minWidth && newWidth <= maxWidth) { header.style.width = newWidth + 'px'; if (field) { config.columnWidths[field] = newWidth; } var rows = table.querySelect...
Determines whether a given Uint8Array represents UTF-8 text data. @param {Uint8Array} uint8Array - The binary data to check. @returns {boolean} - Returns true if the data is UTF-8 text, false otherwise.
doDrag
javascript
openwrt/luci
applications/luci-app-filemanager/htdocs/luci-static/resources/view/system/filemanager.js
https://github.com/openwrt/luci/blob/master/applications/luci-app-filemanager/htdocs/luci-static/resources/view/system/filemanager.js
Apache-2.0
function _byteToChar(b) { // If the byte is not printable, use a dot instead return (b >= 32 && b <= 126) ? String.fromCharCode(b) : _NON_PRINTABLE_CHAR; }
Converts a byte to its corresponding character. If the byte is not printable, returns a non-printable character. @param {number} b - The byte to convert. @returns {string} - The corresponding character.
_byteToChar
javascript
openwrt/luci
applications/luci-app-filemanager/htdocs/luci-static/resources/view/system/filemanager/HexEditor.js
https://github.com/openwrt/luci/blob/master/applications/luci-app-filemanager/htdocs/luci-static/resources/view/system/filemanager/HexEditor.js
Apache-2.0
constructor(hexeditDomObject) { this.hexedit = _fillHexeditDom(hexeditDomObject); this.offsets = this.hexedit.querySelector('.offsets'); this.hexview = this.hexedit.querySelector('.hexview'); this.textview = this.hexedit.querySelector('.textview'); this.hexeditContent = this.hexedit.querySelector('.hexedit-co...
Constructs a HexEditor instance. @param {HTMLElement} hexeditDomObject - The DOM element for the hex editor.
constructor
javascript
openwrt/luci
applications/luci-app-filemanager/htdocs/luci-static/resources/view/system/filemanager/HexEditor.js
https://github.com/openwrt/luci/blob/master/applications/luci-app-filemanager/htdocs/luci-static/resources/view/system/filemanager/HexEditor.js
Apache-2.0
addSearchUI() { // Create search container const searchContainer = document.createElement('div'); searchContainer.classList.add('hexedit-search-container'); // Helper function to create search groups const createSearchGroup = (type, placeholder) => { const container = document.createElement('div'); con...
Adds the search interface with input fields, status fields, and navigation buttons.
addSearchUI
javascript
openwrt/luci
applications/luci-app-filemanager/htdocs/luci-static/resources/view/system/filemanager/HexEditor.js
https://github.com/openwrt/luci/blob/master/applications/luci-app-filemanager/htdocs/luci-static/resources/view/system/filemanager/HexEditor.js
Apache-2.0
handleFindNext(searchType) { const inputElement = document.getElementById(`hexedit-search-${searchType}`); const currentPattern = inputElement.value.trim(); // Check if the search pattern has changed if (this.lastSearchPatterns[searchType] !== currentPattern) { // Update the last search pattern this.last...
Handles the "Find Next" button click for a specific search type. @param {string} searchType - The type of search ('ascii', 'hex', 'regex').
handleFindNext
javascript
openwrt/luci
applications/luci-app-filemanager/htdocs/luci-static/resources/view/system/filemanager/HexEditor.js
https://github.com/openwrt/luci/blob/master/applications/luci-app-filemanager/htdocs/luci-static/resources/view/system/filemanager/HexEditor.js
Apache-2.0
handleFindPrevious(searchType) { const inputElement = document.getElementById(`hexedit-search-${searchType}`); const currentPattern = inputElement.value.trim(); // Check if the search pattern has changed if (this.lastSearchPatterns[searchType] !== currentPattern) { // Update the last search pattern this....
Handles the "Find Previous" button click for a specific search type. @param {string} searchType - The type of search ('ascii', 'hex', 'regex').
handleFindPrevious
javascript
openwrt/luci
applications/luci-app-filemanager/htdocs/luci-static/resources/view/system/filemanager/HexEditor.js
https://github.com/openwrt/luci/blob/master/applications/luci-app-filemanager/htdocs/luci-static/resources/view/system/filemanager/HexEditor.js
Apache-2.0
findNextMatch(cursorPosition) { for (let i = 0; i < this.matches.length; i++) { if (this.matches[i].index > cursorPosition) { return i; } } // If there are no matches after the cursor position, return -1 return -1; }
Finds the index of the next match after the given cursor position. @param {number} cursorPosition - The current cursor position. @returns {number} - The index in the matches array or -1 if not found.
findNextMatch
javascript
openwrt/luci
applications/luci-app-filemanager/htdocs/luci-static/resources/view/system/filemanager/HexEditor.js
https://github.com/openwrt/luci/blob/master/applications/luci-app-filemanager/htdocs/luci-static/resources/view/system/filemanager/HexEditor.js
Apache-2.0
findPreviousMatch(cursorPosition) { for (let i = this.matches.length - 1; i >= 0; i--) { if (this.matches[i].index < cursorPosition) { return i; } } // If there are no matches before the cursor position, return -1 return -1; }
Finds the index of the previous match before the given cursor position. @param {number} cursorPosition - The current cursor position. @returns {number} - The index in the matches array or -1 if not found.
findPreviousMatch
javascript
openwrt/luci
applications/luci-app-filemanager/htdocs/luci-static/resources/view/system/filemanager/HexEditor.js
https://github.com/openwrt/luci/blob/master/applications/luci-app-filemanager/htdocs/luci-static/resources/view/system/filemanager/HexEditor.js
Apache-2.0
performSearch(searchType) { let pattern = ''; switch (searchType) { case 'ascii': pattern = document.getElementById('hexedit-search-ascii').value.trim(); break; case 'hex': pattern = document.getElementById('hexedit-search-hex').value.trim(); break; case 'regex': pattern = document.getE...
Performs the search based on the specified search type. @param {string} searchType - The type of search ('ascii', 'hex', 'regex').
performSearch
javascript
openwrt/luci
applications/luci-app-filemanager/htdocs/luci-static/resources/view/system/filemanager/HexEditor.js
https://github.com/openwrt/luci/blob/master/applications/luci-app-filemanager/htdocs/luci-static/resources/view/system/filemanager/HexEditor.js
Apache-2.0
highlightAllMatches(searchType) { // Rendering will handle highlights based on this.matches this.searchTypeForHighlight = searchType; // Store current search type for rendering // Set active view based on search type if (searchType === 'ascii' || searchType === 'regex') { this.activeView = 'text'; // Text v...
Highlights all matched patterns in the hex and text views based on search type. @param {string} searchType - The type of search ('ascii', 'hex', 'regex').
highlightAllMatches
javascript
openwrt/luci
applications/luci-app-filemanager/htdocs/luci-static/resources/view/system/filemanager/HexEditor.js
https://github.com/openwrt/luci/blob/master/applications/luci-app-filemanager/htdocs/luci-static/resources/view/system/filemanager/HexEditor.js
Apache-2.0
navigateToMatch(matchIndex) { if (this.matches.length === 0) { // Update status field to 0/0 if no matches this.updateSearchStatus(this.currentSearchType, 0, 0); console.log('No matches to navigate.'); return; } // Ensure matchIndex is within bounds if (matchIndex < 0 || matchIndex >= this.matches....
Navigates to a specific match by its index. @param {number} matchIndex - The index in the matches array to navigate to.
navigateToMatch
javascript
openwrt/luci
applications/luci-app-filemanager/htdocs/luci-static/resources/view/system/filemanager/HexEditor.js
https://github.com/openwrt/luci/blob/master/applications/luci-app-filemanager/htdocs/luci-static/resources/view/system/filemanager/HexEditor.js
Apache-2.0
searchASCII(pattern) { const dataStr = new TextDecoder('iso-8859-1').decode(this.data); const regex = new RegExp(pattern, 'g'); let match; while ((match = regex.exec(dataStr)) !== null) { this.matches.push({ index: match.index, length: pattern.length }); // Prevent infinite loops with zero-leng...
Searches for an ASCII pattern and stores all match positions. @param {string} pattern - The ASCII pattern to search for.
searchASCII
javascript
openwrt/luci
applications/luci-app-filemanager/htdocs/luci-static/resources/view/system/filemanager/HexEditor.js
https://github.com/openwrt/luci/blob/master/applications/luci-app-filemanager/htdocs/luci-static/resources/view/system/filemanager/HexEditor.js
Apache-2.0
searchHEX(pattern) { // Remove spaces and validate hex string const cleanedPattern = pattern.replace(/\s+/g, ''); if (!/^[0-9a-fA-F]+$/.test(cleanedPattern)) { throw new Error('Invalid HEX pattern.'); } if (cleanedPattern.length % 2 !== 0) { throw new Error('HEX pattern length must be even.'); } //...
Searches for a HEX pattern and stores all match positions. @param {string} pattern - The HEX pattern to search for (e.g., "4F6B").
searchHEX
javascript
openwrt/luci
applications/luci-app-filemanager/htdocs/luci-static/resources/view/system/filemanager/HexEditor.js
https://github.com/openwrt/luci/blob/master/applications/luci-app-filemanager/htdocs/luci-static/resources/view/system/filemanager/HexEditor.js
Apache-2.0
searchRegex(regexPattern) { const regex = new RegExp(regexPattern, 'g'); const dataStr = new TextDecoder('iso-8859-1').decode(this.data); let match; while ((match = regex.exec(dataStr)) !== null) { const byteIndex = match.index; // With 'iso-8859-1', char index == byte index const length = match[0].length...
Searches using a regular expression and stores all match positions. @param {RegExp} regexPattern - The regular expression pattern to search for.
searchRegex
javascript
openwrt/luci
applications/luci-app-filemanager/htdocs/luci-static/resources/view/system/filemanager/HexEditor.js
https://github.com/openwrt/luci/blob/master/applications/luci-app-filemanager/htdocs/luci-static/resources/view/system/filemanager/HexEditor.js
Apache-2.0
scrollToMatch(index) { const lineNumber = Math.floor(index / this.bytesPerRow); const lineHeight = 16; // Height of one row in pixels // Calculate new scroll position to ensure the matched line is visible const newScrollTop = Math.max(0, (lineNumber * lineHeight) - ((this.visibleRows / 2) * lineHeight)); co...
Scrolls the editor to make the match at the specified index visible. @param {number} index - The byte index of the match.
scrollToMatch
javascript
openwrt/luci
applications/luci-app-filemanager/htdocs/luci-static/resources/view/system/filemanager/HexEditor.js
https://github.com/openwrt/luci/blob/master/applications/luci-app-filemanager/htdocs/luci-static/resources/view/system/filemanager/HexEditor.js
Apache-2.0
calculateVisibleRows() { const lineHeight = 16; // Height of one row in pixels const containerHeight = this.hexeditContent.clientHeight; this.visibleRows = Math.floor(containerHeight / lineHeight); this.visibleByteCount = this.bytesPerRow * this.visibleRows; console.log(`calculateVisibleRows: visibleRows=${th...
Calculates the number of visible rows based on the container's height.
calculateVisibleRows
javascript
openwrt/luci
applications/luci-app-filemanager/htdocs/luci-static/resources/view/system/filemanager/HexEditor.js
https://github.com/openwrt/luci/blob/master/applications/luci-app-filemanager/htdocs/luci-static/resources/view/system/filemanager/HexEditor.js
Apache-2.0
setData(data) { this.data = data; this.totalRows = Math.ceil(this.data.length / this.bytesPerRow); console.log(`setData: data length=${this.data.length}, totalRows=${this.totalRows}`); this.calculateVisibleRows(); // Ensure visibleRows are calculated before rendering }
Sets the data to be displayed in the hex editor. @param {Uint8Array} data - The data to set.
setData
javascript
openwrt/luci
applications/luci-app-filemanager/htdocs/luci-static/resources/view/system/filemanager/HexEditor.js
https://github.com/openwrt/luci/blob/master/applications/luci-app-filemanager/htdocs/luci-static/resources/view/system/filemanager/HexEditor.js
Apache-2.0
getData() { return this.data; }
Retrieves the current data from the hex editor. @returns {Uint8Array} - The current data.
getData
javascript
openwrt/luci
applications/luci-app-filemanager/htdocs/luci-static/resources/view/system/filemanager/HexEditor.js
https://github.com/openwrt/luci/blob/master/applications/luci-app-filemanager/htdocs/luci-static/resources/view/system/filemanager/HexEditor.js
Apache-2.0
handleScroll(event) { const scrollTop = this.hexeditContent.scrollTop; const lineHeight = 16; // Approximate height of a byte row in pixels const firstVisibleLine = Math.floor(scrollTop / lineHeight); const newStartIndex = firstVisibleLine * this.bytesPerRow; console.log(`handleScroll: scrollTop=${scrollTop}...
Handles the scroll event for virtual scrolling. @param {Event} event - The scroll event.
handleScroll
javascript
openwrt/luci
applications/luci-app-filemanager/htdocs/luci-static/resources/view/system/filemanager/HexEditor.js
https://github.com/openwrt/luci/blob/master/applications/luci-app-filemanager/htdocs/luci-static/resources/view/system/filemanager/HexEditor.js
Apache-2.0
renderDom() { // Clear existing content [this.offsets, this.hexview, this.textview].forEach(view => view.innerHTML = ''); const lineHeight = 16; // Approximate line height in pixels const totalLines = Math.ceil(this.data.length / this.bytesPerRow); // Set the height of the content area to simulate the total ...
Renders the visible portion of the hex editor based on the current scroll position.
renderDom
javascript
openwrt/luci
applications/luci-app-filemanager/htdocs/luci-static/resources/view/system/filemanager/HexEditor.js
https://github.com/openwrt/luci/blob/master/applications/luci-app-filemanager/htdocs/luci-static/resources/view/system/filemanager/HexEditor.js
Apache-2.0
updateSelection() { // Restore the background color of the previous selection if any if (this.previousSelectedIndex !== null) { const prevHexSpan = this.hexview.querySelector(`span[data-byte-index="${this.previousSelectedIndex}"]`); const prevTextSpan = this.textview.querySelector(`span[data-byte-index="${thi...
Updates the visual selection in the hex and text views.
updateSelection
javascript
openwrt/luci
applications/luci-app-filemanager/htdocs/luci-static/resources/view/system/filemanager/HexEditor.js
https://github.com/openwrt/luci/blob/master/applications/luci-app-filemanager/htdocs/luci-static/resources/view/system/filemanager/HexEditor.js
Apache-2.0
focusActiveView() { if (this.activeView === 'hex') { this.hexview.focus(); } else if (this.activeView === 'text') { this.textview.focus(); } }
Focuses the active view (hex or text).
focusActiveView
javascript
openwrt/luci
applications/luci-app-filemanager/htdocs/luci-static/resources/view/system/filemanager/HexEditor.js
https://github.com/openwrt/luci/blob/master/applications/luci-app-filemanager/htdocs/luci-static/resources/view/system/filemanager/HexEditor.js
Apache-2.0
_registerEventHandlers() { // Make hexview and textview focusable by setting tabindex this.hexview.tabIndex = 0; this.textview.tabIndex = 0; // Handle focus on hexview this.hexview.addEventListener("focus", () => { this.activeView = 'hex'; this.updateSelection(); }); // Handle focus on textview ...
Registers event handlers for the hex editor.
_registerEventHandlers
javascript
openwrt/luci
applications/luci-app-filemanager/htdocs/luci-static/resources/view/system/filemanager/HexEditor.js
https://github.com/openwrt/luci/blob/master/applications/luci-app-filemanager/htdocs/luci-static/resources/view/system/filemanager/HexEditor.js
Apache-2.0
setValueAt(index, value) { this.data[index] = value; // If the index is within the rendered range, update the display if (index >= this.startIndex && index < this.startIndex + this.visibleByteCount) { const hexSpan = this.hexview.querySelector(`span[data-byte-index="${index}"]`); const textSpan = this.textv...
Sets the value at a specific index in the data and updates the view if necessary. @param {number} index - The byte index to set. @param {number} value - The value to set.
setValueAt
javascript
openwrt/luci
applications/luci-app-filemanager/htdocs/luci-static/resources/view/system/filemanager/HexEditor.js
https://github.com/openwrt/luci/blob/master/applications/luci-app-filemanager/htdocs/luci-static/resources/view/system/filemanager/HexEditor.js
Apache-2.0
setSelectedIndex(index) { this.selectedIndex = index; console.log(`setSelectedIndex called with index: ${index}`); if (index !== null) { // Calculate the line number of the selected index const lineNumber = Math.floor(index / this.bytesPerRow); const lineHeight = 16; // Height of one row in pixels co...
Sets the currently selected byte index and updates the view. @param {number|null} index - The byte index to select, or null to clear selection.
setSelectedIndex
javascript
openwrt/luci
applications/luci-app-filemanager/htdocs/luci-static/resources/view/system/filemanager/HexEditor.js
https://github.com/openwrt/luci/blob/master/applications/luci-app-filemanager/htdocs/luci-static/resources/view/system/filemanager/HexEditor.js
Apache-2.0
updateSearchStatus(searchType, current, total) { // Update only the relevant search type status field ['ascii', 'hex', 'regex'].forEach(type => { const statusElement = document.getElementById(`hexedit-search-status-${type}`); if (type === searchType) { statusElement.textContent = `${current}/${total}`; ...
Updates the search status field for a given search type. @param {string} searchType - The type of search ('ascii', 'hex', 'regex'). @param {number} current - The current match index. @param {number} total - The total number of matches.
updateSearchStatus
javascript
openwrt/luci
applications/luci-app-filemanager/htdocs/luci-static/resources/view/system/filemanager/HexEditor.js
https://github.com/openwrt/luci/blob/master/applications/luci-app-filemanager/htdocs/luci-static/resources/view/system/filemanager/HexEditor.js
Apache-2.0
function _fillHexeditDom(hexedit) { hexedit.classList.add("hexedit"); hexedit.tabIndex = -1; // Create headers const offsetsHeader = document.createElement("div"); offsetsHeader.classList.add("offsets-header"); offsetsHeader.innerText = _("Offset (h)"); const hexviewHeader = document.createElement("div"); hex...
Fills the hex editor DOM structure. @param {HTMLElement} hexedit - The DOM element for the hex editor. @returns {HTMLElement} - The filled hex editor DOM element.
_fillHexeditDom
javascript
openwrt/luci
applications/luci-app-filemanager/htdocs/luci-static/resources/view/system/filemanager/HexEditor.js
https://github.com/openwrt/luci/blob/master/applications/luci-app-filemanager/htdocs/luci-static/resources/view/system/filemanager/HexEditor.js
Apache-2.0
function _keyShouldApply(event) { if (event.key === "Enter") return 1; if (event.key === "Tab") return 1; if (event.key === "Backspace") return -1; if (event.key === "ArrowLeft") return -1; if (event.key === "ArrowRight") return 1; if (event.key === "ArrowUp") return -16; if (event.key === "ArrowDown") return 16...
Determines if a key event should result in a byte index change. @param {KeyboardEvent} event - The keyboard event. @returns {number|null} - The byte index change or null.
_keyShouldApply
javascript
openwrt/luci
applications/luci-app-filemanager/htdocs/luci-static/resources/view/system/filemanager/HexEditor.js
https://github.com/openwrt/luci/blob/master/applications/luci-app-filemanager/htdocs/luci-static/resources/view/system/filemanager/HexEditor.js
Apache-2.0
function parseInlineMarkdown(text) { // Convert **text** and __text__ to <strong>text</strong> return text .replace(/\*\*(.+?)\*\*/g, '<strong>$1</strong>') .replace(/__(.+?)__/g, '<strong>$1</strong>'); }
Parses inline Markdown elements like bold text. Supported inline elements: - Bold text (**text** or __text__) @param {string} text - The text to parse. @returns {string} - The text with inline Markdown converted to HTML.
parseInlineMarkdown
javascript
openwrt/luci
applications/luci-app-filemanager/htdocs/luci-static/resources/view/system/filemanager/md.js
https://github.com/openwrt/luci/blob/master/applications/luci-app-filemanager/htdocs/luci-static/resources/view/system/filemanager/md.js
Apache-2.0
function escapeHtml(text) { const map = { '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#039;', }; return text.replace(/[&<>"']/g, function(m) { return map[m]; }); }
Escapes HTML special characters to prevent XSS attacks. @param {string} text - The text to escape. @returns {string} - The escaped text.
escapeHtml
javascript
openwrt/luci
applications/luci-app-filemanager/htdocs/luci-static/resources/view/system/filemanager/md.js
https://github.com/openwrt/luci/blob/master/applications/luci-app-filemanager/htdocs/luci-static/resources/view/system/filemanager/md.js
Apache-2.0
function setCookie(name, value, expires, path, domain, secure) { document.cookie = name + "=" + escape(value) + ((expires) ? "; expires=" + expires.toGMTString() : "") + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : ""); }
Sets a Cookie with the given name and value. name Name of the cookie value Value of the cookie [expires] Expiration date of the cookie (default: end of current session) [path] Path where the cookie is valid (default: path of calling document) [domain] Domain where the cookie is valid (default: domain of...
setCookie
javascript
openwrt/luci
applications/luci-app-olsr-viz/htdocs/luci-static/resources/olsr-viz.js
https://github.com/openwrt/luci/blob/master/applications/luci-app-olsr-viz/htdocs/luci-static/resources/olsr-viz.js
Apache-2.0
function getCookie(name) { var results = document.cookie.match(name + '=(.*?)(;|$)'); if (results) { return unescape(results[1]); } return null; }
Gets the value of the specified cookie. name Name of the desired cookie. Returns a string containing value of specified cookie, or null if cookie does not exist.
getCookie
javascript
openwrt/luci
applications/luci-app-olsr-viz/htdocs/luci-static/resources/olsr-viz.js
https://github.com/openwrt/luci/blob/master/applications/luci-app-olsr-viz/htdocs/luci-static/resources/olsr-viz.js
Apache-2.0
function deleteCookie(name, path, domain) { if (getCookie(name)) { document.cookie = name + "=" + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + "; expires=Thu, 01-Jan-70 00:00:01 GMT"; } }
Deletes the specified cookie. name name of the cookie [path] path of the cookie (must be same as path used to create cookie) [domain] domain of the cookie (must be same as domain used to create cookie)
deleteCookie
javascript
openwrt/luci
applications/luci-app-olsr-viz/htdocs/luci-static/resources/olsr-viz.js
https://github.com/openwrt/luci/blob/master/applications/luci-app-olsr-viz/htdocs/luci-static/resources/olsr-viz.js
Apache-2.0
parse() { const args = arguments; this.children.forEach((child) => { child.parse(...args); }); }
Parse this element's form input. The `parse()` function recursively walks the form element tree and triggers input value reading and validation for each encountered element. Elements which are hidden due to unsatisfied dependencies are skipped. @returns {Promise<void>} Returns a promise resolving once this element's...
parse
javascript
openwrt/luci
modules/luci-base/htdocs/luci-static/resources/form.js
https://github.com/openwrt/luci/blob/master/modules/luci-base/htdocs/luci-static/resources/form.js
Apache-2.0
render() { L.error('InternalError', 'Not implemented'); }
Render the form element. The `render()` function recursively walks the form element tree and renders the markup for each element, returning the assembled DOM tree. @abstract @returns {Node|Promise<Node>} May return a DOM Node or a promise resolving to a DOM node containing the form element's markup, including the mar...
render
javascript
openwrt/luci
modules/luci-base/htdocs/luci-static/resources/form.js
https://github.com/openwrt/luci/blob/master/modules/luci-base/htdocs/luci-static/resources/form.js
Apache-2.0
stripTags(s) { if (typeof(s) == 'string' && !s.match(/[<>\&]/)) return s; const x = dom.elem(s) ? s : dom.parse(`<div>${s}</div>`); x.querySelectorAll('br').forEach((br) => { x.replaceChild(document.createTextNode('\n'), br); }); return (x.textContent ?? x.innerText ?? '').replace(/([ \t]*\n)+/g, '\n...
Strip any HTML tags from the given input string, and decode HTML entities. @param {string} s The input string to clean. @returns {string} The cleaned input string with HTML tags removed, and HTML entities decoded.
stripTags
javascript
openwrt/luci
modules/luci-base/htdocs/luci-static/resources/form.js
https://github.com/openwrt/luci/blob/master/modules/luci-base/htdocs/luci-static/resources/form.js
Apache-2.0
titleFn(attr, ...args) { let s = null; if (typeof(this[attr]) == 'function') s = this[attr](...args); else if (typeof(this[attr]) == 'string') s = args.length ? this[attr].format(...args) : this[attr]; if (s != null) s = this.stripTags(String(s)).trim(); if (s == null || s == '') return null; ...
Format the given named property as title string. This function looks up the given named property and formats its value suitable for use as element caption or description string. It also strips any HTML tags from the result. If the property value is a string, it is passed to `String.format()` along with any additional...
titleFn
javascript
openwrt/luci
modules/luci-base/htdocs/luci-static/resources/form.js
https://github.com/openwrt/luci/blob/master/modules/luci-base/htdocs/luci-static/resources/form.js
Apache-2.0
findElements(...args) /* ... */{ let q = null; if (args.length == 1) q = args[0]; else if (args.length == 2) q = '[%s="%s"]'.format(args[0], args[1]); else L.error('InternalError', 'Expecting one or two arguments to findElements()'); return this.root.querySelectorAll(q); }
Return all DOM nodes within this Map which match the given search parameters. This function is essentially a convenience wrapper around `querySelectorAll()`. This function is sensitive to the amount of arguments passed to it; if only one argument is specified, it is used as selector-expression as-is. When two argument...
findElements
javascript
openwrt/luci
modules/luci-base/htdocs/luci-static/resources/form.js
https://github.com/openwrt/luci/blob/master/modules/luci-base/htdocs/luci-static/resources/form.js
Apache-2.0
findElement(...args) /* ... */{ const res = this.findElements(...args); return res.length ? res[0] : null; }
Return the first DOM node within this Map which matches the given search parameters. This function is essentially a convenience wrapper around `findElements()` which only returns the first found node. This function is sensitive to the amount of arguments passed to it; if only one argument is specified, it is used as s...
findElement
javascript
openwrt/luci
modules/luci-base/htdocs/luci-static/resources/form.js
https://github.com/openwrt/luci/blob/master/modules/luci-base/htdocs/luci-static/resources/form.js
Apache-2.0
chain(config) { if (this.parsechain.indexOf(config) == -1) this.parsechain.push(config); }
Tie another UCI configuration to the map. By default, a map instance will only load the UCI configuration file specified in the constructor but sometimes access to values from further configuration files is required. This function allows for such use cases by registering further UCI configuration files which are neede...
chain
javascript
openwrt/luci
modules/luci-base/htdocs/luci-static/resources/form.js
https://github.com/openwrt/luci/blob/master/modules/luci-base/htdocs/luci-static/resources/form.js
Apache-2.0
section(cbiClass, ...args) { if (!CBIAbstractSection.isSubclass(cbiClass)) L.error('TypeError', 'Class must be a descendent of CBIAbstractSection'); const obj = cbiClass.instantiate([this, ...args]); this.append(obj); return obj; }
Add a configuration section to the map. LuCI forms follow the structure of the underlying UCI configurations. This means that a map, which represents a single UCI configuration, is divided into multiple sections which in turn contain an arbitrary number of options. While UCI itself only knows two kinds of sections - ...
section
javascript
openwrt/luci
modules/luci-base/htdocs/luci-static/resources/form.js
https://github.com/openwrt/luci/blob/master/modules/luci-base/htdocs/luci-static/resources/form.js
Apache-2.0
load() { const doCheckACL = (!(this instanceof CBIJSONMap) && this.readonly == null); const loadTasks = [ doCheckACL ? callSessionAccess('uci', this.config, 'write') : true ]; const configs = this.parsechain ?? [ this.config ]; loadTasks.push(...configs.map(L.bind((config, i) => { return i ? L.resolveDefaul...
Load the configuration covered by this map. The `load()` function first loads all referenced UCI configurations, then it recursively walks the form element tree and invokes the load function of each child element. @returns {Promise<void>} Returns a promise resolving once the entire form completed loading all data. Th...
load
javascript
openwrt/luci
modules/luci-base/htdocs/luci-static/resources/form.js
https://github.com/openwrt/luci/blob/master/modules/luci-base/htdocs/luci-static/resources/form.js
Apache-2.0
parse() { const tasks = []; if (Array.isArray(this.children)) for (let i = 0; i < this.children.length; i++) tasks.push(this.children[i].parse()); return Promise.all(tasks); }
Parse the form input values. The `parse()` function recursively walks the form element tree and triggers input value reading and validation for each child element. Elements which are hidden due to unsatisfied dependencies are skipped. @returns {Promise<void>} Returns a promise resolving once the entire form complete...
parse
javascript
openwrt/luci
modules/luci-base/htdocs/luci-static/resources/form.js
https://github.com/openwrt/luci/blob/master/modules/luci-base/htdocs/luci-static/resources/form.js
Apache-2.0
save(cb, silent) { this.checkDepends(); return this.parse() .then(cb) .then(this.data.save.bind(this.data)) .then(this.load.bind(this)) .catch((e) => { if (!silent) { ui.showModal(_('Save error'), [ E('p', {}, [ _('An error occurred while saving the form:') ]), E('p', {}, [ E('em'...
Save the form input values. This function parses the current form, saves the resulting UCI changes, reloads the UCI configuration data and redraws the form elements. @param {function} [cb] An optional callback function that is invoked after the form is parsed but before the changed UCI data is saved. This is useful t...
save
javascript
openwrt/luci
modules/luci-base/htdocs/luci-static/resources/form.js
https://github.com/openwrt/luci/blob/master/modules/luci-base/htdocs/luci-static/resources/form.js
Apache-2.0
reset() { return this.renderContents(); }
Reset the form by re-rendering its contents. This will revert all unsaved user inputs to their initial form state. @returns {Promise<Node>} Returns a promise resolving to the top-level form DOM node once the re-rendering is complete.
reset
javascript
openwrt/luci
modules/luci-base/htdocs/luci-static/resources/form.js
https://github.com/openwrt/luci/blob/master/modules/luci-base/htdocs/luci-static/resources/form.js
Apache-2.0
render() { return this.load().then(this.renderContents.bind(this)); }
Render the form markup. @returns {Promise<Node>} Returns a promise resolving to the top-level form DOM node once the rendering is complete.
render
javascript
openwrt/luci
modules/luci-base/htdocs/luci-static/resources/form.js
https://github.com/openwrt/luci/blob/master/modules/luci-base/htdocs/luci-static/resources/form.js
Apache-2.0
cfgsections() { L.error('InternalError', 'Not implemented'); }
Enumerate the UCI section IDs covered by this form section element. @abstract @throws {InternalError} Throws an `InternalError` exception if the function is not implemented. @returns {string[]} Returns an array of UCI section IDs covered by this form element. The sections will be rendered in the same order as the ret...
cfgsections
javascript
openwrt/luci
modules/luci-base/htdocs/luci-static/resources/form.js
https://github.com/openwrt/luci/blob/master/modules/luci-base/htdocs/luci-static/resources/form.js
Apache-2.0
filter(section_id) { return true; }
Filter UCI section IDs to render. The filter function is invoked for each UCI section ID of a given type and controls whether the given UCI section is rendered or ignored by the form section element. The default implementation always returns `true`. User code or classes extending `AbstractSection` may override this f...
filter
javascript
openwrt/luci
modules/luci-base/htdocs/luci-static/resources/form.js
https://github.com/openwrt/luci/blob/master/modules/luci-base/htdocs/luci-static/resources/form.js
Apache-2.0
load() { const section_ids = this.cfgsections(); const tasks = []; if (Array.isArray(this.children)) for (let i = 0; i < section_ids.length; i++) tasks.push(this.loadChildren(section_ids[i]) .then(Function.prototype.bind.call((section_id, set_values) => { for (let i = 0; i < set_values.length;...
Load the configuration covered by this section. The `load()` function recursively walks the section element tree and invokes the load function of each child option element. @returns {Promise<void>} Returns a promise resolving once the values of all child elements have been loaded. The promise may reject with an error...
load
javascript
openwrt/luci
modules/luci-base/htdocs/luci-static/resources/form.js
https://github.com/openwrt/luci/blob/master/modules/luci-base/htdocs/luci-static/resources/form.js
Apache-2.0
parse() { const section_ids = this.cfgsections(); const tasks = []; if (Array.isArray(this.children)) for (let i = 0; i < section_ids.length; i++) for (let j = 0; j < this.children.length; j++) tasks.push(this.children[j].parse(section_ids[i])); return Promise.all(tasks); }
Parse this sections form input. The `parse()` function recursively walks the section element tree and triggers input value reading and validation for each encountered child option element. Options which are hidden due to unsatisfied dependencies are skipped. @returns {Promise<void>} Returns a promise resolving once ...
parse
javascript
openwrt/luci
modules/luci-base/htdocs/luci-static/resources/form.js
https://github.com/openwrt/luci/blob/master/modules/luci-base/htdocs/luci-static/resources/form.js
Apache-2.0
option(cbiClass, ...args) { if (!CBIAbstractValue.isSubclass(cbiClass)) throw L.error('TypeError', 'Class must be a descendant of CBIAbstractValue'); const obj = cbiClass.instantiate([ this.map, this, ...args ]); this.append(obj); return obj; }
Add a configuration option widget to the section. Note that [taboption()]{@link LuCI.form.AbstractSection#taboption} should be used instead if this form section element uses tabs. @param {LuCI.form.AbstractValue} optionclass The option class to use for rendering the configuration option. Note that this value must be ...
option
javascript
openwrt/luci
modules/luci-base/htdocs/luci-static/resources/form.js
https://github.com/openwrt/luci/blob/master/modules/luci-base/htdocs/luci-static/resources/form.js
Apache-2.0
taboption(tabName, ...args) { if (!this.tabs?.[tabName]) throw L.error('ReferenceError', 'Associated tab not declared'); const obj = this.option(...args); obj.tab = tabName; this.tabs[tabName].children.push(obj); return obj; }
Add a configuration option widget to a tab of the section. @param {string} tabName The name of the section tab to add the option element to. @param {LuCI.form.AbstractValue} optionclass The option class to use for rendering the configuration option. Note that this value must be the class itself, not a class instance ...
taboption
javascript
openwrt/luci
modules/luci-base/htdocs/luci-static/resources/form.js
https://github.com/openwrt/luci/blob/master/modules/luci-base/htdocs/luci-static/resources/form.js
Apache-2.0
cfgvalue(section_id, option) { const rv = (arguments.length == 1) ? {} : null; for (let i = 0, o; (o = this.children[i]) != null; i++) if (rv) rv[o.option] = o.cfgvalue(section_id); else if (o.option == option) return o.cfgvalue(section_id); return rv; }
Query underlying option configuration values. This function is sensitive to the amount of arguments passed to it; if only one argument is specified, the configuration values of all options within this section are returned as a dictionary. If both the section ID and an option name are supplied, this function returns t...
cfgvalue
javascript
openwrt/luci
modules/luci-base/htdocs/luci-static/resources/form.js
https://github.com/openwrt/luci/blob/master/modules/luci-base/htdocs/luci-static/resources/form.js
Apache-2.0
formvalue(section_id, option) { const rv = (arguments.length == 1) ? {} : null; for (let i = 0, o; (o = this.children[i]) != null; i++) { const func = this.map.root ? this.children[i].formvalue : this.children[i].cfgvalue; if (rv) rv[o.option] = func.call(o, section_id); else if (o.option == option) ...
Query underlying option widget input values. This function is sensitive to the amount of arguments passed to it; if only one argument is specified, the widget input values of all options within this section are returned as a dictionary. If both the section ID and an option name are supplied, this function returns the...
formvalue
javascript
openwrt/luci
modules/luci-base/htdocs/luci-static/resources/form.js
https://github.com/openwrt/luci/blob/master/modules/luci-base/htdocs/luci-static/resources/form.js
Apache-2.0
getUIElement(section_id, option) { const rv = (arguments.length == 1) ? {} : null; for (let i = 0, o; (o = this.children[i]) != null; i++) if (rv) rv[o.option] = o.getUIElement(section_id); else if (o.option == option) return o.getUIElement(section_id); return rv; }
Obtain underlying option LuCI.ui widget instances. This function is sensitive to the amount of arguments passed to it; if only one argument is specified, the LuCI.ui widget instances of all options within this section are returned as a dictionary. If both the section ID and an option name are supplied, this function ...
getUIElement
javascript
openwrt/luci
modules/luci-base/htdocs/luci-static/resources/form.js
https://github.com/openwrt/luci/blob/master/modules/luci-base/htdocs/luci-static/resources/form.js
Apache-2.0
getOption(option) { const rv = (arguments.length == 0) ? {} : null; for (let i = 0, o; (o = this.children[i]) != null; i++) if (rv) rv[o.option] = o; else if (o.option == option) return o; return rv; }
Obtain underlying option objects. This function is sensitive to the amount of arguments passed to it; if no option name is specified, all options within this section are returned as a dictionary. If an option name is supplied, this function returns the matching LuCI.form.AbstractValue instance only. @param {string} ...
getOption
javascript
openwrt/luci
modules/luci-base/htdocs/luci-static/resources/form.js
https://github.com/openwrt/luci/blob/master/modules/luci-base/htdocs/luci-static/resources/form.js
Apache-2.0
cbid(section_id) { if (section_id == null) L.error('TypeError', 'Section ID required'); return 'cbid.%s.%s.%s'.format( this.uciconfig ?? this.section.uciconfig ?? this.map.config, section_id, this.option); }
Obtain the internal ID ("cbid") of the element instance. Since each form section element may map multiple underlying configuration sections, the configuration section ID is required to form a fully qualified ID pointing to the specific element instance within the given specific section. @param {string} section_id The...
cbid
javascript
openwrt/luci
modules/luci-base/htdocs/luci-static/resources/form.js
https://github.com/openwrt/luci/blob/master/modules/luci-base/htdocs/luci-static/resources/form.js
Apache-2.0
load(section_id) { if (section_id == null) L.error('TypeError', 'Section ID required'); return this.map.data.get( this.uciconfig ?? this.section.uciconfig ?? this.map.config, this.ucisection ?? section_id, this.ucioption ?? this.option); }
Load the underlying configuration value. The default implementation of this method reads and returns the underlying UCI option value (or the related JavaScript property for `JSONMap` instances). It may be overridden by user code to load data from non-standard sources. @param {string} section_id The configuration sect...
load
javascript
openwrt/luci
modules/luci-base/htdocs/luci-static/resources/form.js
https://github.com/openwrt/luci/blob/master/modules/luci-base/htdocs/luci-static/resources/form.js
Apache-2.0
getUIElement(section_id) { const node = this.map.findElement('id', this.cbid(section_id)); const inst = node ? dom.findClassInstance(node) : null; return (inst instanceof ui.AbstractElement) ? inst : null; }
Obtain the underlying `LuCI.ui` element instance. @param {string} section_id The configuration section ID @throws {TypeError} Throws a `TypeError` exception when no `section_id` was specified. @return {LuCI.ui.AbstractElement|null} Returns the `LuCI.ui` element instance or `null` in case the form option implementati...
getUIElement
javascript
openwrt/luci
modules/luci-base/htdocs/luci-static/resources/form.js
https://github.com/openwrt/luci/blob/master/modules/luci-base/htdocs/luci-static/resources/form.js
Apache-2.0
cfgvalue(section_id, set_value) { if (section_id == null) L.error('TypeError', 'Section ID required'); if (arguments.length == 2) { this.data ??= {}; this.data[section_id] = set_value; } return this.data?.[section_id]; }
Query the underlying configuration value. The default implementation of this method returns the cached return value of [load()]{@link LuCI.form.AbstractValue#load}. It may be overridden by user code to obtain the configuration value in a different way. @param {string} section_id The configuration section ID @throws ...
cfgvalue
javascript
openwrt/luci
modules/luci-base/htdocs/luci-static/resources/form.js
https://github.com/openwrt/luci/blob/master/modules/luci-base/htdocs/luci-static/resources/form.js
Apache-2.0
formvalue(section_id) { const elem = this.getUIElement(section_id); return elem ? elem.getValue() : null; }
Query the current form input value. The default implementation of this method returns the current input value of the underlying [LuCI.ui]{@link LuCI.ui.AbstractElement} widget. It may be overridden by user code to handle input values differently. @param {string} section_id The configuration section ID @throws {TypeE...
formvalue
javascript
openwrt/luci
modules/luci-base/htdocs/luci-static/resources/form.js
https://github.com/openwrt/luci/blob/master/modules/luci-base/htdocs/luci-static/resources/form.js
Apache-2.0
textvalue(section_id) { let cval = this.cfgvalue(section_id); if (cval == null) cval = this.default; if (Array.isArray(cval)) cval = cval.join(' '); return (cval != null) ? '%h'.format(cval) : null; }
Obtain a textual input representation. The default implementation of this method returns the HTML-escaped current input value of the underlying [LuCI.ui]{@link LuCI.ui.AbstractElement} widget. User code or specific option element implementations may override this function to apply a different logic, e.g. to return `Ye...
textvalue
javascript
openwrt/luci
modules/luci-base/htdocs/luci-static/resources/form.js
https://github.com/openwrt/luci/blob/master/modules/luci-base/htdocs/luci-static/resources/form.js
Apache-2.0
validate(section_id, value) { return true; }
Apply custom validation logic. This method is invoked whenever incremental validation is performed on the user input, e.g. on keyup or blur events. The default implementation of this method does nothing and always returns `true`. User code may override this method to provide additional validation logic which is not c...
validate
javascript
openwrt/luci
modules/luci-base/htdocs/luci-static/resources/form.js
https://github.com/openwrt/luci/blob/master/modules/luci-base/htdocs/luci-static/resources/form.js
Apache-2.0