luci-app-adblock: sync with adblock 3.0.0
[project/luci.git] / applications / luci-app-adblock / luasrc / view / adblock / query.htm
1 <%#
2 Copyright 2017 Dirk Brenken (dev@brenken.org)
3 This is free software, licensed under the Apache License, Version 2.0
4 -%>
5
6 <%+header%>
7
8 <script type="text/javascript" src="<%=resource%>/cbi.js"></script>
9 <script type="text/javascript">
10 //<![CDATA[
11         var stxhr = new XHR();
12
13         function update_status(data)
14         {
15                 var domain = data.value;
16                 var input = document.getElementById('query_input');
17                 var output = document.getElementById('query_output');
18
19                 if (input && output)
20                 {
21                         output.innerHTML =
22                                 '<img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" /> ' +
23                                 '<%:Waiting for command to complete...%>'
24                         ;
25                         input.parentNode.style.display = 'block';
26                         input.style.display = 'inline';
27                         stxhr.post('<%=luci.dispatcher.build_url('admin/services/adblock/advanced/result/')%>' + domain, { token: '<%=token%>' },
28                                 function(x)
29                                 {
30                                         if (x.responseText)
31                                         {
32                                                 input.style.display = 'none';
33                                                 output.innerHTML = String.format('<pre>%h</pre>', x.responseText);
34                                         }
35                                         else
36                                         {
37                                                 input.style.display = 'none';
38                                                 output.innerHTML = '<span class="error"><%:Invalid domain specified!%></span>';
39                                         }
40                                 }
41                         );
42                 }
43         }
44 //]]>
45 </script>
46
47 <form method="post" action="<%=REQUEST_URI%>">
48         <div class="cbi-map">
49                 <fieldset class="cbi-section">
50                         <div class="cbi-section-descr"><%:This form allows you to query active block lists for certain domains, e.g. for whitelisting.%></div>
51                         <div style="width:33%; float:left;">
52                                 <input style="margin: 5px 0" type="text" value="www.lede-project.org" name="input" />
53                                 <input type="button" value="<%:Query%>" class="cbi-button cbi-button-apply" onclick="update_status(this.form.input)" />
54                         </div>
55                         <br style="clear:both" />
56                         <br />
57                 </fieldset>
58         </div>
59         <fieldset class="cbi-section" style="display:none">
60                 <legend id="query_input"><%:Collecting data...%></legend>
61                 <span id="query_output"></span>
62         </fieldset>
63 </form>
64
65 <%+footer%>