diff options
author | Jo-Philipp Wich <jo@mein.io> | 2018-11-21 18:44:59 +0100 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2018-11-22 12:49:14 +0100 |
commit | 706c6836e40046ca82efc3355fc018fd37654d88 (patch) | |
tree | 95fcf2aeb5ffd0cd9773e03e7007f1960fa82199 /modules/luci-base/luasrc | |
parent | 17690f2d73b640cf4bbf082fe96f5b3075a040fe (diff) |
luci-base: introduce common JavaScript api
Introduce a new script file luci.js which is included by default and
intended to be the common location of functions currently scattered
in cbi.js and xhr.js.
The luci.js file provides a LuCI() class which - among other things -
implements helpers to construct URL paths and making HTTP requests.
A singleton instance of the class is instantiated as window.L upon
load and preset with the necessary environment information.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'modules/luci-base/luasrc')
-rw-r--r-- | modules/luci-base/luasrc/view/header.htm | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/modules/luci-base/luasrc/view/header.htm b/modules/luci-base/luasrc/view/header.htm index f6e20c9a40..2813c4d943 100644 --- a/modules/luci-base/luasrc/view/header.htm +++ b/modules/luci-base/luasrc/view/header.htm @@ -10,3 +10,14 @@ luci.dispatcher.context.template_header_sent = true end %> + +<script type="text/javascript" src="<%=resource%>/luci.js"></script> +<script type="text/javascript"> + L = new LuCI(<%= luci.http.write_json({ + token = token, + resource = resource, + scriptname = luci.http.getenv("SCRIPT_NAME"), + pathinfo = luci.http.getenv("PATH_INFO"), + requestpath = luci.dispatcher.context.requestpath + }) %>); +</script> |