summaryrefslogtreecommitdiffhomepage
path: root/applications/luci-app-vpnbypass/luasrc/view/vpnbypass/js.htm
blob: 76809e9387b3297e0c875b219fca9e03c377ca65 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60

<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", "services", "vpnbypass", "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>