{% extends "../../theme.html" %}

{% block content %}
{%include 'menu.html'%}

<div class="pannel">
    <div class="ul5">
        {% for v in data['list'] %}
        <dl>
            <dt>{{v['looptype']}}：{{v['loop']}}{{v['hour']}}:{{v['minute']}}
            <div class="right r-btns">
            {% if v['status'] == True %}
            <a href="javascript:;" onclick="Farm.Cancel(this, '{{v['id']}}', '/device/update_set_loop?id={{v['id']}}')" class="link primary">取消设置</a>
            {% else %}
            {{v['cdates']}} <a href="javascript:;" onclick="Farm.Recovery(this, '{{v['id']}}', '/device/update_set_loop?id={{v['id']}}')" class="link primary">恢复</a>
            {% end %}
            </div>
            </dt>
            <dt>{{v['oper']}}
            </dt>
            {% for dv in v['device'] %}
            <dd>{{dv['name']}}</dd>
            {% end %}
        </dl>
        {% end %}
    </div>
</div>

{%set url = data['url']['loop'] %}
{%include '../../inc/page.html'%}

{% end %}

{% block script %}
<script type="text/javascript">
Array.prototype.indexOf = function(val) {              
    for (var i = 0; i < this.length; i++) {  
        if (this[i] == val) return i;  
    }  
    return -1;  
};
Array.prototype.remove = function(val) {  
    var index = this.indexOf(val);  
    if (index > -1) {  
        this.splice(index, 1);  
    }  
};
function looptype(e) {
	var value = e.val();
	if (value == 1) {
		$(".day-cont").hide();
	} else if (value == 2) {
		$(".day-cont").eq(0).show();
		$(".day-cont").eq(1).hide();
	} else if (value == 3) {
		$(".day-cont").eq(0).hide();
		$(".day-cont").eq(1).show();
	}
}
function set(e, id) {
    var i = e.find('i');
    var c = i.attr('class');
    var v = [];
    var val = $('#update_loop').val();
    if (val) {
        v = val.split(',');
    }
    if (c.indexOf('checked') == -1) {
        i.addClass('checked');
        v.push(id);
    } else {
        i.removeClass('checked');
        v.remove(id);
    }
    $("#update_loop").val(v.join(','));
}
</script>
{% end %}