diff options
author | Jo-Philipp Wich <jo@mein.io> | 2020-08-03 14:39:40 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2020-08-05 13:51:16 +0200 |
commit | 572090101db2afc621d2d18ef3e3d6a86202a406 (patch) | |
tree | 3c4540a8113d3b871de7fa459c7e6dc874d6debd /modules | |
parent | f2965b759ad26c5f11b1cea43c5e4e6c5ac3b3b8 (diff) |
luci-base: form.js: add ability to specify regular expression dependencies
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'modules')
-rw-r--r-- | modules/luci-base/htdocs/luci-static/resources/form.js | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/modules/luci-base/htdocs/luci-static/resources/form.js b/modules/luci-base/htdocs/luci-static/resources/form.js index 89d92c8f9..d5e3e941a 100644 --- a/modules/luci-base/htdocs/luci-static/resources/form.js +++ b/modules/luci-base/htdocs/luci-static/resources/form.js @@ -1132,6 +1132,9 @@ var CBIAbstractSection = CBIAbstractElement.extend(/** @lends LuCI.form.Abstract var isEqual = function(x, y) { + if (typeof(y) == 'object' && y instanceof RegExp) + return (x == null) ? false : y.test(x); + if (x != null && y != null && typeof(x) != typeof(y)) return false; @@ -1428,6 +1431,10 @@ var CBIAbstractValue = CBIAbstractElement.extend(/** @lends LuCI.form.AbstractVa * Equivalent to the previous example. * </li> * <li> + * <code>opt.depends({ foo: /test/ })</code><br> + * Require the value of `foo` to match the regular expression `/test/`. + * </li> + * <li> * <code>opt.depends({ foo: "test", bar: "qrx" })</code><br> * Require the value of `foo` to be `test` and the value of `bar` to be * `qrx`. @@ -1449,11 +1456,11 @@ var CBIAbstractValue = CBIAbstractElement.extend(/** @lends LuCI.form.AbstractVa * </li> * </ul> * - * @param {string|Object<string, string|boolean>} optionname_or_depends + * @param {string|Object<string, string|RegExp>} optionname_or_depends * The name of the option to depend on or an object describing multiple * dependencies which must be satified (a logical "and" expression). * - * @param {string} optionvalue + * @param {string} optionvalue|RegExp * When invoked with a plain option name as first argument, this parameter * specifies the expected value. In case an object is passed as first * argument, this parameter is ignored. |