1 <%# Copyright
2020 Stan Grishin
<stangri@melmac.ca
> -%
>
3 <%+simple-adblock/css%
>
7 local packageName =
"simple-adblock"
8 local serviceRunning, serviceEnabled = false, false;
9 local tmpfs, tmpfsStatus;
10 local jsonStatusFile =
"/var/run/" .. packageName ..
"/" .. packageName ..
".json"
11 if nixio.fs.access(jsonStatusFile) then
12 tmpfs = luci.jsonc.parse(luci.util.trim(luci.sys.exec(
"cat " .. jsonStatusFile)))
13 if tmpfs and tmpfs['data'] and tmpfs['data']['status'] then
14 tmpfsStatus = tmpfs['data']['status']
17 if tmpfsStatus ==
"statusStarting" or tmpfsStatus ==
"statusRestarting" or
18 tmpfsStatus ==
"statusForceReloading" or tmpfsStatus ==
"statusDownloading" or
19 tmpfsStatus ==
"statusError" or tmpfsStatus ==
"statusWarning"
20 or tmpfsStatus ==
"statusSuccess" then
24 if luci.model.uci.cursor():get(packageName,
"config",
"enabled") ==
"1" then
28 if serviceEnabled then
29 btn_start_status = true
30 btn_action_status = true
31 btn_stop_status = true
32 btn_enable_status = false
33 btn_disable_status = true
35 btn_start_status = false
36 btn_action_status = false
37 btn_stop_status = false
38 btn_enable_status = true
39 btn_disable_status = false
41 if serviceRunning then
42 btn_start_status = false
43 btn_action_status = true
44 btn_stop_status = true
46 btn_action_status = false
47 btn_stop_status = false
52 <input type=
"button" class=
"btn 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=
"btn 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=
"btn 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=
"btn 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=
"btn 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>
73 <%-if not btn_start_status then%
>
74 <script type=
"text/javascript">document.getElementById(
"btn_start").disabled = true;
</script>
76 <%-if not btn_action_status then%
>
77 <script type=
"text/javascript">document.getElementById(
"btn_action").disabled = true;
</script>
79 <%-if not btn_stop_status then%
>
80 <script type=
"text/javascript">document.getElementById(
"btn_stop").disabled = true;
</script>
82 <%-if not btn_enable_status then%
>
83 <script type=
"text/javascript">document.getElementById(
"btn_enable").disabled = true;
</script>
85 <%-if not btn_disable_status then%
>
86 <script type=
"text/javascript">document.getElementById(
"btn_disable").disabled = true;
</script>