2 Copyright
2019 Stan Grishin
<stangri@melmac.net
>
6 local packageName =
"simple-adblock"
7 local enabledFlag = luci.model.uci.cursor():get(packageName,
"config",
"enabled")
8 if nixio.fs.access(
"/var/run/" .. packageName ..
".json") then
9 tmpfs = luci.jsonc.parse(luci.util.trim(luci.sys.exec(
"cat /var/run/" .. packageName ..
".json")))
11 local tmpfsVersion, tmpfsStatus, tmpfsMessage, tmpfsError, tmpfsStats =
"",
"Stopped"
12 if tmpfs and tmpfs['data'] then
13 if tmpfs['data']['status'] and tmpfs['data']['status'] ~=
"" then
14 tmpfsStatus = tmpfs['data']['status']
16 if tmpfs['data']['message'] and tmpfs['data']['message'] ~=
"" then
17 tmpfsMessage = tmpfs['data']['message']
19 if tmpfs['data']['error'] and tmpfs['data']['error'] ~=
"" then
20 tmpfsError = tmpfs['data']['error']
22 if tmpfs['data']['stats'] and tmpfs['data']['stats'] ~=
"" then
23 tmpfsStats = tmpfs['data']['stats']
25 if tmpfs['data']['version'] and tmpfs['data']['version'] ~=
"" then
26 tmpfsVersion =
" (" .. packageName ..
" " .. tmpfs['data']['version'] ..
")"
29 if tmpfsStatus ==
"Stopped" then
30 btn_start_style =
"cbi-button cbi-button-apply important"
31 btn_action_style =
"cbi-button cbi-button-apply important"
32 btn_stop_style =
"cbi-button cbi-button-reset -disabled"
34 btn_start_style =
"cbi-button cbi-button-apply -disabled"
35 btn_action_style =
"cbi-button cbi-button-apply important"
36 btn_stop_style =
"cbi-button cbi-button-reset important"
38 if enabledFlag ~=
"1" then
39 btn_start_style =
"cbi-button cbi-button-apply -disabled"
40 btn_action_style =
"cbi-button cbi-button-apply -disabled"
41 btn_enable_style =
"cbi-button cbi-button-apply important"
42 btn_disable_style =
"cbi-button cbi-button-reset -disabled"
44 btn_enable_style =
"cbi-button cbi-button-apply -disabled"
45 btn_disable_style =
"cbi-button cbi-button-reset important"
49 <%+simple-adblock/css%
>
50 <%+simple-adblock/js%
>
52 <div class=
"cbi-value"><label class=
"cbi-value-title">Service Control
</label>
53 <div class=
"cbi-value-field">
54 <input type=
"button" class=
"<%=btn_start_style%>" id=
"btn_start" name=
"start" value=
"<%:Start%>" onclick=
"button_action(this)" />
55 <span id=
"btn_start_spinner" class=
"btn_spinner"></span>
56 <input type=
"button" class=
"<%=btn_action_style%>" id=
"btn_action" name=
"action" value=
"<%:Force Re-Download%>" onclick=
"button_action(this)" />
57 <span id=
"btn_action_spinner" class=
"btn_spinner"></span>
58 <input type=
"button" class=
"<%=btn_stop_style%>" id=
"btn_stop" name=
"stop" value=
"<%:Stop%>" onclick=
"button_action(this)" />
59 <span id=
"btn_stop_spinner" class=
"btn_spinner"></span>
64 <input type=
"button" class=
"<%=btn_enable_style%>" id=
"btn_enable" name=
"enable" value=
"<%:Enable%>" onclick=
"button_action(this)" />
65 <span id=
"btn_enable_spinner" class=
"btn_spinner"></span>
66 <input type=
"button" class=
"<%=btn_disable_style%>" id=
"btn_disable" name=
"disable" value=
"<%:Disable%>" onclick=
"button_action(this)" />
67 <span id=
"btn_disable_spinner" class=
"btn_spinner"></span>