<style>
    .NewsTdHeight{ line-height: 20px; }
</style>
<fieldset class="cbi-section">
    <table width="100%" class="NewsTdHeight">
        <tr><td width="35%" align="right"><input type="button" class="cbi-button cbi-button-reload" value="<%:Rescue the original system kernel%>" onclick="return b_rescue_kernel(this)"/></td><td  width="65%" align="left"><span id="_current_rescue_version"><%:Collecting data...%></span>　<span id="_check_rescue"></span></td></tr>
    </table>
</fieldset>
<script type="text/javascript">//<![CDATA[
    function b_rescue_kernel(btn)
    {
        btn.disabled = true;
        btn.value = '<%:Rescuing...%>';
        XHR.get('<%=luci.dispatcher.build_url("admin", "system", "amlogic", "start_amlogic_rescue")%>', null, function(x, status) {
        if ( x && x.status == 200 ) {
            btn.disabled = false;
            btn.value = '<%:Rescue the original system kernel%>';
        }
        else {
            btn.disabled = false;
            btn.value = '<%:Rescue the original system kernel%>';
        }
        return false;
        });
    }

    var _check_rescue = document.getElementById('_check_rescue');
	XHR.poll(1, '<%=luci.dispatcher.build_url("admin", "system", "amlogic", "start_check_rescue")%>', status.start_check_rescue, function(x, status) {
	if ( x && x.status == 200 ) {
		if ( status.start_check_rescue != "\n" && status.start_check_rescue != "" ) {
			_check_rescue.innerHTML = '<font color="blue"> '+status.start_check_rescue+'</font>';
		}
		if ( status.start_check_rescue == "\n" || status.start_check_rescue == "" ) {
			_check_rescue.innerHTML = '';
		}
	}
	});

    var _current_rescue_version = document.getElementById('_current_rescue_version');
    XHR.get('<%=luci.dispatcher.build_url("admin", "system", "amlogic", "state")%>', null, function(x, status) {
    if ( x && x.status == 200 ) {
		_current_rescue_version.innerHTML = status.current_kernel_version ? "<font color=green><%:Current Version%> [ "+status.current_kernel_version+" ] </font>" : "<font color=red>"+"<%:Invalid value.%>"+"</font>";
    }
    });

//]]></script>
