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