summaryrefslogtreecommitdiffhomepage
path: root/modules/luci-base/htdocs/luci-static/resources/cbi.js
AgeCommit message (Collapse)Author
2024-03-15luci-base: cbi.js: drop CustomEvent polyfillJo-Philipp Wich
All supported browsers natively support this functionality since quite a while already. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2023-09-23luci-base: cbi.js cbi_validate_named_section_add() simplifySergey Ponomarev
Reduce if to a simple boolean evaluation Signed-off-by: Sergey Ponomarev <stokito@gmail.com>
2022-11-09luci-base: cbi.js: await L.ui load before updating tablesJo-Philipp Wich
On legacy views, the `L.ui` JavaScript class is not automatically loaded, so request it before updating tables. Fixes: e0e6989a4a ("luci-base: introduce new LuCI.ui.Table class") Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2022-02-24luci-base: introduce new LuCI.ui.Table classJo-Philipp Wich
Introduce a new `LuCI.ui.Table` class to simplify generating HTML tables for data output and turn the existing `cbi_update_table()` procedure into a wrapper around this new facility. Tables generated by the new class closely resemble the old markup but provide additional sorting capabilities. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-12-09luci-base: cbi.js: properly handle non-strings in `%h` and `%q` formatsJo-Philipp Wich
Only replace null, objects and function values with the empty string but return booleans and numbers as strings. Spotted while debugging #5587. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-11-23luci-base: cbi.js: properly handle falsy values in cbi_update_table()Jo-Philipp Wich
Fixes: #5544 Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-10-08luci-base: cbi.js: use IEC 80000-13 units to format base 2 byte valuesJo-Philipp Wich
Fixes: #5354 Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-08-11Merge pull request #5154 from TDT-AG/pr/20210628-luci-compatFlorian Eckert
luci-base: prevent empty field for adding new entry
2021-08-11luci-base: prevent empty field for adding new entryHelge Mader
Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2021-07-15luci-base: fix off-by-one in cbi_update_table()Jo-Philipp Wich
Fixes: #5189 Fixes: f919635310 ("luci-base: batch DOM updates to prevent slowdown") Ref: https://github.com/openwrt/luci/commit/f919635310286b3b905aedb716d707da1ea2c811#commitcomment-53495580 Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-07-13luci-base: batch DOM updates to prevent slowdownOlli Asikainen
Signed-off-by: Olli Asikainen <olli.asikainen@gmail.com>
2021-07-06luci-base: Fix time display errorDeYu Liu
Signed-off-by: DeYu Liu <vito_sam@outlook.com>
2020-11-27treewide: transition div tables to actual table markupJo-Philipp Wich
Modern browsers allow decomposing table markup equally well as nested div constructs, therefor migrate our <div> table markup to actual <table> tags but keep the old table/tr/th/td CSS classes for now to allow for a smooth theme transition. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-02-14luci-base: cbi.js: avoid double-initialization of dropdownsJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-02-14luci-base: cbi.js: handle translation contexts in _()Jo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-01-22luci-base: cbi.js: support plural translations and disambiguation contextsJo-Philipp Wich
- Implement `N_(count, "String singular", "String plural" [, "Context"])` plural translation function. - Extend `_()` to optionally accept a second disambiguation context argument. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-01-16luci-base: cbi.js: collapse whitespace before language string hashingJo-Philipp Wich
To mirror the behavior of the Lua runtime, we need to collapse whitepace in translation source strings before doing the string table lookup. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-09-14luci-base: cbi.js: update dependencies after widgets have been renderedJo-Philipp Wich
Fixes: #3066 Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-09-10luci-base: use cgi-io and rpcd-mod-file to handle file upload and browsingJo-Philipp Wich
Remove the old server side support for file browsing and file uploading and switch to a client side widget instead which uses XMLHTTPRequests to upload files via cgi-io and RPC calls for file listing and status queries. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-09-10luci-base: cbi.js: handle ui elements which return a promise in render()Jo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-09-10luci-base: cbi.js: fix unintended number sign overflow in formatJo-Philipp Wich
Fixes: #3003 Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-07-07luci-base: cbi.js: fix number rounding in string.format()Jo-Philipp Wich
Ensure that patterns like %d, %x, %o or %b properly truncate their operands to whole integers. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-07-07luci-base: split off CBI validations into separate classJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-07-07luci-base: cbi.js, ui.js: add custom validation callbacks, new ui widgetsJo-Philipp Wich
Implement further widget primitives like text inputs or checkboxes and support custom validation callback functions when instantiating CBI validators. Also add support initializing ui.js widgets from the "data-ui-widget" HTML attribute. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-07-07luci-base: move dropdown, combox and dynlist widget code to L.uiJo-Philipp Wich
Move the widget code to the ui class and replace it with compatibility shims in cbi.js Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-07-07luci-base: cbi.js: support field validation for formless inputsJo-Philipp Wich
JS CBI fields have no parent form element anymore. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-07-07luci-base: cbi.js: untangle dropdown and dynlists from dependency updateJo-Philipp Wich
In order to prepare the move of the dynlist and dropdown widgets into the LuCI ui class, remove the direct calls to cbi_d_update() and replace them with custom events instead. Extend cbi_init() to handle these custom events and to invoke cbi_d_update() when receiving them. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-01-05luci-base: Fix addr:port validate always failsDaniel F. Dickinson
In cbi.js there is an error which causes ipaddrport validation to always fail. JS match() return the entire match as ret[0] and individual matches (for multiple ()) as the subsequent list members. So we fix it by just fixing the index in the calls that want the individual parts. Signed-off-by: Daniel F. Dickinson <cshored@thecshore.com>
2018-12-29luci-base: rework filebrowser initializationJo-Philipp Wich
Do not call cbi_init() from the browser field template but lazily initialize the field, like it is being done for all other widgets as well. Fixes: #2398 Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-12-13luci-base: cbi.js: update deps on dynlist changes, honor placeholderJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-12-10luci-base: rework ui tabbing codeJo-Philipp Wich
- Instantiate tab menus on the client side - Simplify server side markup generation - Show error indicators in cbi tabs Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-12-02luci-base: fix ReferenceErrorJo-Philipp Wich
The showTooltip() and hideTooltip() functions have been moved to luci.js Reported-by: brv phoenix <feixuekaka1@gmail.com> Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-11-22luci-base: move DOM manipulation functions to luci.jsJo-Philipp Wich
Introduce a new luci.dom class which groups the DOM manipulation helpers such as E(), findParent(), matchesElem() etc. Provide wrappers for the old functions to ease the transition to the new functions. Also add a new widget helper function L.itemlist() which consolidates the item enumeration formatting code found on various pages. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-11-22luci-base: cbi.js: remove functions moved to luci.jsJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-11-19luci-base: further hash calculation signedness bugfixesJo-Philipp Wich
- cbi.js: make sure to treat single bytes as signed char when handling end cases - template_lmo.c: make sure to treat single bytes as signed char when handling end cases, avoids hash miscalculations on ARM Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-11-19luci-base: cbi.js: fix sfh() signedness bug for strings with 3 trailing bytesJo-Philipp Wich
Replace a sign-propagating right shift by a zero-filling right shift to avoid calculating a wrong hash code in the three-trailing-bytes case. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-11-19luci-base: cbi.js: fix sfh() hash calculation over multibyte sequencesJo-Philipp Wich
The C side implementation of the hash operates on bytes while the JS variant operated on UTF-16 codepoints, leading to miscalculations on input strings containing multibyte sequences. Recode the given string to an internal UTF-8 byte representation and calculate the hash over that. Fixes client side mapping of translation strings containing non-ASCII characters. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-11-14luci-base: cbi.js: add modal dialog functionsJo-Philipp Wich
Add two new functions showModal() and hideModal() which will fade in and close an open modal respectively. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-11-14luci-base, themes: dropdown behaviour improvementsJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-11-14luci-base: cbi.js: remove dead code in cbi_validate_field()Jo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-11-14luci-base: cbi.js: enable validation for dropdown fieldsJo-Philipp Wich
Directly attach validation handlers to cbi dropdowns as well, this allows validating dropdown choices made by the user, similar to how plain select boxes are handled by the cbi JavaScript. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-11-14luci-base: cbi.js: set .value property of cbi dropdown elementsJo-Philipp Wich
In order to make cbi dropdowns usable for validation and other code expecting native form elements, set the .value DOM property on the dropdown parent element whenever the selection is changed. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-11-14luci-base: cbi.js: properly handle cbi tooltips on nested elementsJo-Philipp Wich
Rework the tooltip event delegation logic to prevent hiding the tooltop when the cursor is moved to a children of the tooltip container element. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-11-14luci-base: cbi.js: avoid using .form property directlyJo-Philipp Wich
In order to prepare support for calling cbi validation on non-native form widgets, remove direct usages of the node.form property and lookup the containing form using findParent() instead. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-11-14luci-base: cbi.js: fix passing multiple dropdown values in change eventJo-Philipp Wich
Due to a misspelled property name, only the first value was passed in the event details. Fixes: c2b570998 ("luci-base: cbi.js: rework dropdown implementation") Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-11-11luci-base: fix translation issuesINAGAKI Hiroshi
Fixed several issues for translation. - add translation markup to "Expecting " - add missing ")" into "valid time (HH:MM:SS" Signed-off-by: INAGAKI Hiroshi <musashino.open@gmail.com>
2018-11-05luci-base: cbi.js: add client-side hexstring datatype validatorJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-11-05luci-base: cbi.js: add heuristics to attribute handling in E()Jo-Philipp Wich
If a given attribute value is a function, register it as event listener, if it is an object, filter it through JSON.stringify(), else set it as-is. This helps to reduce some boiler-plate code when building DOM structures. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-11-05luci-base, themes: rework dynlist and dropdown widgetsJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-11-05luci-base: cbi.js: rework dropdown implementationJo-Philipp Wich
- Refactor event handler closures into class methods and bind them instead - Fix quirk in dropdown placement calculation - Different dropdown placement strategy on touch devices - Broadcast custom "cbi-dropdown-change" event when value is changed - Implement setValues() method to alter dropdown selection - Prevent creating empty custom values Signed-off-by: Jo-Philipp Wich <jo@mein.io>