summaryrefslogtreecommitdiffhomepage
path: root/applications/luci-app-vpn-policy-routing/luasrc/view/vpn-policy-routing/js.htm
diff options
context:
space:
mode:
authorStan Grishin <stangri@melmac.net>2019-12-30 07:51:42 -0700
committerStan Grishin <stangri@melmac.net>2019-12-30 07:51:42 -0700
commit25c884a479c4ce7bbb337be67433555a34e63bf9 (patch)
treef6ad65e8c5460e46867f94ec55b9c436a7c7846c /applications/luci-app-vpn-policy-routing/luasrc/view/vpn-policy-routing/js.htm
parentd07cfba160ca7eb433e74f1ffad8d10e2b9cc9ca (diff)
luci-app-vpn-policy-routing: initial release
Signed-off-by: Stan Grishin <stangri@melmac.net>
Diffstat (limited to 'applications/luci-app-vpn-policy-routing/luasrc/view/vpn-policy-routing/js.htm')
-rw-r--r--applications/luci-app-vpn-policy-routing/luasrc/view/vpn-policy-routing/js.htm59
1 files changed, 59 insertions, 0 deletions
diff --git a/applications/luci-app-vpn-policy-routing/luasrc/view/vpn-policy-routing/js.htm b/applications/luci-app-vpn-policy-routing/luasrc/view/vpn-policy-routing/js.htm
new file mode 100644
index 0000000000..7c190328f4
--- /dev/null
+++ b/applications/luci-app-vpn-policy-routing/luasrc/view/vpn-policy-routing/js.htm
@@ -0,0 +1,59 @@
+<script type="text/javascript">
+//<![CDATA[
+ function button_action(action) {
+ var xhr = new XHR(false);
+ var btn_start = document.getElementById("btn_start");
+ var btn_action = document.getElementById("btn_action");
+ var btn_stop = document.getElementById("btn_stop");
+ var btn_enable = document.getElementById("btn_enable");
+ var btn_disable = document.getElementById("btn_disable");
+ var btn_spinner;
+ switch (action.name) {
+ case "start":
+ btn_spinner = document.getElementById("btn_start_spinner");
+ break;
+ case "action":
+ btn_spinner = document.getElementById("btn_action_spinner");
+ break;
+ case "stop":
+ btn_spinner = document.getElementById("btn_stop_spinner");
+ break;
+ case "enable":
+ btn_spinner = document.getElementById("btn_enable_spinner");
+ break;
+ case "disable":
+ btn_spinner = document.getElementById("btn_disable_spinner");
+ break;
+ }
+ btn_start.disabled = true;
+ btn_action.disabled = true;
+ btn_stop.disabled = true;
+ btn_enable.disabled = true;
+ btn_disable.disabled = true;
+ spinner(btn_spinner, 1);
+ xhr.get('<%=luci.dispatcher.build_url("admin", "vpn", "vpn-policy-routing", "action")%>/' + action.name, null,
+ function (x) {
+ if (!x) {
+ return;
+ }
+ btn_start.disabled = false;
+ btn_action.disabled = false;
+ btn_stop.disabled = false;
+ btn_enable.disabled = false;
+ btn_disable.disabled = false;
+ spinner(btn_spinner, 0);
+ location.reload();
+ });
+}
+function spinner(element, state) {
+ if (state === 1) {
+ element.style.width = "16px";
+ element.innerHTML = '<img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" width="16" height="16" style="vertical-align:middle" />';
+ }
+ else {
+ element.style.width = "0px";
+ element.innerHTML = '';
+ }
+}
+//]]>
+</script> \ No newline at end of file