<script type="text/javascript">
	//<![CDATA[
	function clear_log(btn) {
		XHR.get('<%=url([[admin]], [[nas]], [[alist]], [[clear_log]])%>', null,
			function(x, data) {
				if(x && x.status == 200) {
					var log_textarea = document.getElementById('log_textarea');
					log_textarea.innerHTML = "";
					log_textarea.scrollTop = log_textarea.scrollHeight;
				}
				location.reload();
			}
		);
	}
	var scrolled = false;
	XHR.poll(2, '<%=url([[admin]], [[nas]], [[alist]], [[get_log]])%>', null,
		function(x, data) {
			if(x && x.status == 200) {
				var log_textarea = document.getElementById('log_textarea');
				var str = x.responseText;
				var logs = str.replace(//g, "🔧");
				log_textarea.innerHTML = logs;
				if (!scrolled) {
					log_textarea.scrollTop = log_textarea.scrollHeight;
					scrolled = true;
				}
			}
		}
	);
	//]]>
</script>
<fieldset class="cbi-section" id="_log_fieldset">
	<input class="cbi-button cbi-input-remove" type="button" onclick="clear_log()" value="<%:Clear logs%>" style="margin-left: 10px; margin-top: 10px;">
	<textarea id="log_textarea" class="cbi-input-textarea" style="width: calc(100% - 20px); height: 500px; margin: 10px;" data-update="change" rows="5" wrap="off" readonly="readonly"></textarea>
</fieldset>
