fb659958dbce77a9b5a69bb20a30a4db74e4fd2c
[project/luci.git] / applications / luci-app-adblock / luasrc / view / adblock / query.htm
1 <%#
2 Copyright 2017-2018 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">
9 //<![CDATA[
10 var stxhr = new XHR();
11
12 function update_status(data)
13 {
14 var domain = data.value || data.placeholder;
15 var input = document.getElementById('query_input');
16 var output = document.getElementById('query_output');
17
18 if (input && output)
19 {
20 output.innerHTML =
21 '<img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" /> ' +
22 '<%:Waiting for command to complete...%>'
23 ;
24 input.parentNode.style.display = 'block';
25 input.style.display = 'inline';
26 stxhr.post('<%=luci.dispatcher.build_url('admin/services/adblock/advanced/result/')%>' + domain, { token: '<%=token%>' },
27 function(x)
28 {
29 if (x.responseText)
30 {
31 input.style.display = 'none';
32 output.innerHTML = String.format('<pre>%h</pre>', x.responseText);
33 }
34 else
35 {
36 input.style.display = 'none';
37 output.innerHTML = '<span class="error"><%:Blocklist not found!%></span>';
38 }
39 }
40 );
41 }
42 }
43 //]]>
44 </script>
45
46 <form method="post" action="<%=REQUEST_URI%>" onsubmit="update_status(this.input); return false;">
47 <div class="cbi-map">
48 <div class="cbi-section">
49 <div class="cbi-section-descr"><%:This form allows you to query active block lists for certain domains, e.g. for whitelisting.%></div>
50 <div style="width:33%; float:left;">
51 <input type="text" placeholder="google.com" name="input" />
52 <input type="button" value="<%:Query%>" class="cbi-button cbi-button-apply" onclick="update_status(this.form.input)" />
53 </div>
54 <br style="clear:both" />
55 <br />
56 </div>
57 </div>
58 <div class="cbi-section" style="display:none">
59 <h3 id="query_input"><%:Collecting data...%></h3>
60 <span id="query_output"></span>
61 </div>
62 </form>
63
64 <%+footer%>