Age | Commit message (Collapse) | Author |
|
Fixes: #3066
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
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>
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Fixes: #3003
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
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>
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
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>
|
|
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>
|
|
JS CBI fields have no parent form element anymore.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
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>
|
|
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>
|
|
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>
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
- 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>
|
|
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>
|
|
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>
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
- 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>
|
|
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>
|
|
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>
|
|
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>
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
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>
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
- 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>
|
|
Use node.closest() in findParent() when available since it should be faster
than manaually traversing the ancestor chain.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Just use node.addEventListener() directly since all reasonably recent
browsers support it nowadays.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
- Refactor and fix datatype validation functions
- Turn the type compilation and validation into a proper class
- Display tooltip with error hint on invalid inputs
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
The implementation allowed a hexadecimal string without any colons.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Add the required JS and CSS infrastructure to support rich hover/focus
tooltips for element.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Implement the string hash algorithm used by LuCI's translation system in
JavaScript and provide a `_()` translation wrapper function to lookup
messages in the global string table.
Once client side translation loading is activated in a later commit,
JavaScript code can use the same string translation mechanism as server
side Lua code, e.g. `_("Static Routes")` would yield "Statische Routen"
when the German translation is loaded.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
This fixes errors reported by LGTM.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
|
|
On MS Edge, the behaviour of "value" attributes on "li" elements is
unreliable, so use the "data-" prefix to circumvent the problem.
Ref: https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/19320991/
Fixes: #2224
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Remove some superfluous code which was added with a previous commit.
Fixes: 8270f10f1 ("luci-base: cbi.js: code cleanups")
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
- unify code style
- add matchesElem() helper
- replace nodeName checks with selector tests
- replace className manipulations with classList operations
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
This is required to allow for validating the create field values in
later commits.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Change the cbi.js code to create a div based button element instead of an
image button.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|