summaryrefslogtreecommitdiffhomepage
path: root/applications/luci-app-adblock/luasrc/view/adblock/query.htm
blob: fb659958dbce77a9b5a69bb20a30a4db74e4fd2c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<%#
Copyright 2017-2018 Dirk Brenken (dev@brenken.org)
This is free software, licensed under the Apache License, Version 2.0
-%>

<%+header%>

<script type="text/javascript">
//<![CDATA[
	var stxhr = new XHR();

	function update_status(data)
	{
		var domain = data.value || data.placeholder;
		var input  = document.getElementById('query_input');
		var output = document.getElementById('query_output');

		if (input && output)
		{
			output.innerHTML =
				'<img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" /> ' +
				'<%:Waiting for command to complete...%>'
			;
			input.parentNode.style.display = 'block';
			input.style.display = 'inline';
			stxhr.post('<%=luci.dispatcher.build_url('admin/services/adblock/advanced/result/')%>' + domain, { token: '<%=token%>' },
				function(x)
				{
					if (x.responseText)
					{
						input.style.display = 'none';
						output.innerHTML = String.format('<pre>%h</pre>', x.responseText);
					}
					else
					{
						input.style.display = 'none';
						output.innerHTML = '<span class="error"><%:Blocklist not found!%></span>';
					}
				}
			);
		}
	}
//]]>
</script>

<form method="post" action="<%=REQUEST_URI%>" onsubmit="update_status(this.input); return false;">
	<div class="cbi-map">
		<div class="cbi-section">
			<div class="cbi-section-descr"><%:This form allows you to query active block lists for certain domains, e.g. for whitelisting.%></div>
			<div style="width:33%; float:left;">
				<input type="text" placeholder="google.com" name="input" />
				<input type="button" value="<%:Query%>" class="cbi-button cbi-button-apply" onclick="update_status(this.form.input)" />
			</div>
			<br style="clear:both" />
			<br />
		</div>
	</div>
	<div class="cbi-section" style="display:none">
		<h3 id="query_input"><%:Collecting data...%></h3>
		<span id="query_output"></span>
	</div>
</form>

<%+footer%>