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>
23 lines
688 B
HTML
23 lines
688 B
HTML
<%#
|
|
Copyright 2008 Steven Barth <steven@midlink.org>
|
|
Copyright 2008 Jo-Philipp Wich <jow@openwrt.org>
|
|
Licensed to the public under the Apache License 2.0.
|
|
-%>
|
|
|
|
<%
|
|
if not luci.dispatcher.context.template_header_sent then
|
|
include("themes/" .. theme .. "/header")
|
|
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>
|