<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

<%@ Import Namespace="WebSite.Controllers" %>
<%
    List<Light> FanList = ViewData["FanList"] as List<Light>;
%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width,user-scalable=no,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0" />
    <meta http-equiv="cache-control" content="max-age=0" />
    <meta http-equiv="cache-control" content="no-cache" />
    <meta http-equiv="expires" content="0" />
    <meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
    <meta http-equiv="pragma" content="no-cache" />
    <title>房间号：<%=ViewData["RoomNumber"] %></title>
    <link type="text/css" rel="stylesheet" href="/Styles/WeiXin/common.css" />
    <link type="text/css" rel="stylesheet" href="/Styles/WeiXin/light.css" />
    <link type="text/css" rel="stylesheet" href="/Styles/WeiXin/tip.css" />
    <script type="text/javascript" src="/Scripts/jquery.min.js"></script> 
    <script type="text/javascript" src="/Scripts/WeiXin/tip.js"></script>
    <script type="text/javascript">

        function setLight(modalId, status) {
            $.ajax({
                url: '/WeiXin/FanControl/',
                data: { roomNumber: document.getElementById("hidRoomNumber").value, groupAddress: modalId, Status: status ? 100 : 0 },
                type: "POST",
                dataType: "JSON",
                success: function (r) {
                    showTip(r.Message);
                }
            });
        }

        $(function () {
            $('#light-list li a').click(function () {
                $(this).toggleClass('selected');
                setLight($(this).attr("modal"), $(this).hasClass("selected"));
            });

            $('#menu li a').click(function () {
                $(this).parents('ul').find('.selected').removeClass('selected');
                $(this).addClass('selected');
            });
        });

    </script>
</head>
<body>
    <input id="hidRoomNumber" type="hidden" value='<%=ViewData["RoomNumber"] %>' />
     <div id="cmainFan">
    <ul id="light-list" class="clearfix">
        <% foreach (var item in FanList)
           { %>
        <li><a href="javascript:void(0)" class=' <%=item.Status != 0 ? "selected":"" %>'
            modal='<%=item.ModalAddress %>'><i class="icon icon-fun"></i><em class="text">
                <%=item.Name %></em> </a></li>
        <% } %>
       <%-- <li><a href="javascript:void(0)" class='<%: ViewData["lightMirror"] != null && (ViewData["lightMirror"] as LightState).Status != 0 ? "selected" : "" %>'
            modal='<%: ViewData["lightMirror"] != null ? (ViewData["lightMirror"] as LightState).ModalID : "" %>'>
            <i class="icon icon-light-mirror"></i><em class="text">镜前灯</em> </a></li>
        <li><a href="javascript:void(0)" class='<%: ViewData["lightRead"] != null && (ViewData["lightRead"] as LightState).Status != 0 ? "selected" : "" %>'
            modal='<%: ViewData["lightRead"] != null ? (ViewData["lightRead"] as LightState).ModalID : "" %>'>
            <i class="icon icon-light-read"></i><em class="text">阅读灯</em> </a></li>
        <li><a href="javascript:void(0)" class='<%: ViewData["lightNight"] != null && (ViewData["lightNight"] as LightState).Status != 0 ? "selected" : "" %>'
            modal='<%: ViewData["lightNight"] != null ? (ViewData["lightNight"] as LightState).ModalID : "" %>'>
            <i class="icon icon-light-night"></i><em class="text">夜灯</em> </a></li>
        <li><a href="javascript:void(0)" class='<%: ViewData["lightTube"] != null && (ViewData["lightTube"] as LightState).Status != 0 ? "selected" : "" %>'
            modal='<%: ViewData["lightTube"] != null ? (ViewData["lightTube"] as LightState).ModalID : "" %>'>
            <i class="icon icon-light-tube"></i><em class="text">筒灯</em> </a></li>
        <li><a href="javascript:void(0)" class='<%: ViewData["lightBar"] != null && (ViewData["lightBar"] as LightState).Status != 0 ? "selected" : "" %>'
            modal='<%: ViewData["lightBar"] != null ? (ViewData["lightBar"] as LightState).ModalID : "" %>'>
            <i class="icon icon-light-bar"></i><em class="text">吧台灯</em> </a></li>--%>
    </ul>
    </div>
    <% Html.RenderPartial("Footer"); %>
</body>
</html>
