query.htm 1.9 KB

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