summaryrefslogtreecommitdiffstats
path: root/logfiles-tail-html.lsp
blob: 6bfe26da7780725e7504ab54a73f7e6915e4a6f2 (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
<% local form, viewlibrary, page_info = ... %>
<% require("viewfunctions") %>

<script type="text/javascript" src="/js/jquery-latest.js"></script>
<script type="text/javascript">
	var currentoffset = -1024
	var ID
	function Update(){
		$.ajaxSetup({cache:false});
		$.getJSON(
			'<%= page_info.script .. page_info.prefix .. page_info.controller .. "/" .. page_info.action %>',
			{name:'<% io.write(form.value.filename.value) if form.value.grep.value ~= "" then io.write("',grep:'"..form.value.grep.value) end %>', offset:currentoffset},
			function(data) {
				data.value.filecontent.value = data.value.filecontent.value.split("\n").join("<br>\n");
				$("#filecontent").append(data.value.filecontent.value).scrollTop(999999999);
				currentoffset = data.value.filesize.value;
				$("DT:contains('File size')").next().text(currentoffset);
			}
		);
		ID=window.setTimeout("Update();", 1000);
	}
	$(function(){
		$("#Start").attr("disabled","disabled");
	   	<% if not form.value.filename.errtxt then %>
	   	Update();
		<% else %>
		$("#Stop").attr("disabled","disabled");
		<% end %>
	});
</script>

<H1>Tail File</H1>
<DL>
<% 
displayitem(form.value.filename)
displayitem(form.value.filesize)
if form.value.grep.value ~= "" then
	displayitem(form.value.grep)
end
%>
</DL>
<textarea id="filecontent">
</textarea>
<DL>
<DT>Start / Stop tailing file</DT>
<DD>
<input TYPE="button" ID="Start" VALUE="Start" onClick='Update(); $("#Start").attr("disabled","disabled");$("#Stop").removeAttr("disabled");'>
<input TYPE="button" ID="Stop" VALUE="Stop" onClick='window.clearTimeout(ID); $("#Stop").attr("disabled","disabled");$("#Start").removeAttr("disabled");'>
</DD>
</DL>