luci-base: add L.media() URL construction helper

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
This commit is contained in:
Jo-Philipp Wich 2020-01-28 11:14:15 +01:00
parent 8c860a1d9c
commit b60b4790d1
2 changed files with 23 additions and 0 deletions

View file

@ -1750,6 +1750,28 @@
return this.path(this.env.resource, arguments);
},
/**
* Construct an URL path relative to the media resource path of the
* LuCI ui (usually `/luci-static/$theme_name`).
*
* The resulting URL is guaranteed to only contain the characters
* `a-z`, `A-Z`, `0-9`, `_`, `.`, `%`, `,`, `;`, and `-` as well
* as `/` for the path separator.
*
* @instance
* @memberof LuCI
*
* @param {string[]} [parts]
* An array of parts to join into an URL path. Parts may contain
* slashes and any of the other characters mentioned above.
*
* @return {string}
* Returns the resulting URL path.
*/
media: function() {
return this.path(this.env.media, arguments);
},
/**
* Return the complete URL path to the current view.
*

View file

@ -18,6 +18,7 @@
<script type="text/javascript">
L = new LuCI(<%= luci.http.write_json({
token = token,
media = media,
resource = resource,
scriptname = luci.http.getenv("SCRIPT_NAME"),
pathinfo = luci.http.getenv("PATH_INFO"),