luci-base: add L.media() URL construction helper
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit b60b4790d1
)
This commit is contained in:
parent
038050a912
commit
37b0a263bf
2 changed files with 23 additions and 0 deletions
|
@ -1748,6 +1748,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.
|
||||
*
|
||||
|
|
|
@ -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"),
|
||||
|
|
Loading…
Reference in a new issue