1 <%# Copyright
2020 Stan Grishin
<stangri@melmac.net
> -%
>
3 <%+simple-adblock/css%
>
7 local packageName =
"simple-adblock"
8 local serviceRunning, serviceEnabled = false, false;
9 local tmpfs, tmpfsStatus;
10 if nixio.fs.access(
"/var/run/" .. packageName ..
".json") then
11 tmpfs = luci.jsonc.parse(luci.util.trim(luci.sys.exec(
"cat /var/run/" .. packageName ..
".json")))
12 if tmpfs and tmpfs['data'] and tmpfs['data']['status'] then
13 tmpfsStatus = tmpfs['data']['status']
16 if tmpfsStatus ==
"statusStarting" or tmpfsStatus ==
"statusRestarting" or
17 tmpfsStatus ==
"statusForceReloading" or tmpfsStatus ==
"statusDownloading" or
18 tmpfsStatus ==
"statusError" or tmpfsStatus ==
"statusWarning"
19 or tmpfsStatus ==
"statusSuccess" then
23 if luci.model.uci.cursor():get(packageName,
"config",
"enabled") ==
"1" then
27 if serviceEnabled then
28 btn_start_status = true
29 btn_action_status = true
30 btn_stop_status = true
31 btn_enable_status = false
32 btn_disable_status = true
34 btn_start_status = false
35 btn_action_status = false
36 btn_stop_status = false
37 btn_enable_status = true
38 btn_disable_status = false
40 if serviceRunning then
41 btn_start_status = false
42 btn_action_status = true
43 btn_stop_status = true
45 btn_action_status = false
46 btn_stop_status = false
50 <div class=
"cbi-value"><label class=
"cbi-value-title">Service Control
</label>
51 <div class=
"cbi-value-field">
52 <input type=
"button" class=
"cbi-button cbi-button-apply" id=
"btn_start" name=
"start" value=
"<%:Start%>"
53 onclick=
"button_action(this)" />
54 <span id=
"btn_start_spinner" class=
"btn_spinner"></span>
55 <input type=
"button" class=
"cbi-button cbi-button-apply" id=
"btn_action" name=
"action" value=
"<%:Force Re-Download%>"
56 onclick=
"button_action(this)" />
57 <span id=
"btn_action_spinner" class=
"btn_spinner"></span>
58 <input type=
"button" class=
"cbi-button cbi-button-reset" id=
"btn_stop" name=
"stop" value=
"<%:Stop%>"
59 onclick=
"button_action(this)" />
60 <span id=
"btn_stop_spinner" class=
"btn_spinner"></span>
65 <input type=
"button" class=
"cbi-button cbi-button-apply" id=
"btn_enable" name=
"enable" value=
"<%:Enable%>"
66 onclick=
"button_action(this)" />
67 <span id=
"btn_enable_spinner" class=
"btn_spinner"></span>
68 <input type=
"button" class=
"cbi-button cbi-button-reset" id=
"btn_disable" name=
"disable" value=
"<%:Disable%>"
69 onclick=
"button_action(this)" />
70 <span id=
"btn_disable_spinner" class=
"btn_spinner"></span>
74 <%-if not btn_start_status then%
>
75 <script type=
"text/javascript">document.getElementById(
"btn_start").disabled = true;
</script>
77 <%-if not btn_action_status then%
>
78 <script type=
"text/javascript">document.getElementById(
"btn_action").disabled = true;
</script>
80 <%-if not btn_stop_status then%
>
81 <script type=
"text/javascript">document.getElementById(
"btn_stop").disabled = true;
</script>
83 <%-if not btn_enable_status then%
>
84 <script type=
"text/javascript">document.getElementById(
"btn_enable").disabled = true;
</script>
86 <%-if not btn_disable_status then%
>
87 <script type=
"text/javascript">document.getElementById(
"btn_disable").disabled = true;
</script>