<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>{{ title }}</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <!-- 新 Bootstrap4 核心 CSS 文件 -->
    <link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/4.1.0/css/bootstrap.min.css">

    <!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
    <script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>

    <!-- popper.min.js 用于弹窗、提示、下拉菜单 -->
    <script src="https://cdn.bootcss.com/popper.js/1.12.5/umd/popper.min.js"></script>

    <!-- 最新的 Bootstrap4 核心 JavaScript 文件 -->
    <script src="https://cdn.bootcss.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
    <!-- Rita 網頁 title 旁邊的 icon -->
    <!-- 參考資料 https://codertw.com/%E5%89%8D%E7%AB%AF%E9%96%8B%E7%99%BC/26839/ -->
    <link rel="icon" href="..\static\img\icon-3.ico" type="image/x-icon">
    <!--
    <script src="../static/js/sign_in.js"></script>

    <link rel="stylesheet" href="../static/css/sign_in.css">
-->
    <script>
        $(document).ready(function () {
            $("#coffee_title_pc").text('Smart Coffee 總貨櫃系統');
            $("#coffee_title_phone").text('總貨櫃系統');
            loading_status();
        });

        function loading_status(){
            $.get('/loading/container', '', function (res) {
                if (res.Clean_container == 'Waiting') {
                    $("#CleanContainer_status").css("background-color", "#C0C0C0") 
                } else if (res.Clean_container == 'Working') {
                    $("#CleanContainer_status").css("background-color", "forestgreen")
                } else if (res.Clean_container == 'Warning') {
                    $("#CleanContainer_status").css("background-color", "crimson")
                }

                if (res.ColorSelect_container == 'Waiting') {
                    $("#ColorContainer_status").css("background-color", "#C0C0C0") 
                } else if (res.ColorSelect_container == 'Working') {
                    $("#ColorContainer_status").css("background-color", "forestgreen")
                } else if (res.ColorSelect_container == 'Warning') {
                    $("#ColorContainer_status").css("background-color", "crimson")
                }

                if (res.Peel_container == 'Waiting') {
                    $("#PeelContainer_status").css("background-color", "#C0C0C0") 
                } else if (res.Peel_container == 'Working') {
                    $("#PeelContainer_status").css("background-color", "forestgreen")
                } else if (res.Peel_container == 'Warning') {
                    $("#PeelContainer_status").css("background-color", "crimson")
                }

                if (res.Ferment_container == 'Waiting') {
                    $("#FermentContainer_status").css("background-color", "#C0C0C0") 
                } else if (res.Ferment_container == 'Working') {
                    $("#FermentContainer_status").css("background-color", "forestgreen")
                } else if (res.Ferment_container == 'Warning') {
                    $("#FermentContainer_status").css("background-color", "crimson")
                }

                if (res.Dry_container == 'Waiting') {
                    $("#DryContainer_status").css("background-color", "#C0C0C0") 
                } else if (res.Dry_container == 'Working') {
                    $("#DryContainer_status").css("background-color", "forestgreen")
                } else if (res.Dry_container == 'Warning') {
                    $("#DryContainer_status").css("background-color", "crimson")
                }
            }, 'json');
        }

    </script>

    <style>
        /* .Container_position {
            position: absolute;
            top: 100px;
            left: 125px;
            width: 1295px;
            height: 100px;
        } */
        /* 桶槽狀態顯示的顏色條 */
        .div-Container-Status {
            width: 100%; 
            height: 20px; 
            background-color: #c0c0c0; 
            text-align: center;
            background-color: black;
        }
        /* 各桶槽圖片大小的共同 CSS, 詳細位置數值如下 */
        .div_Container_position {
            text-align: center;
            font-weight: bold;
            border: 1px aquamarine solid;
        }
        #CleanContainer {
            position: absolute;
            top: 85px;
            left: 115px;
            width: 245px;
            height: 590px;
        }
        #ColorContainer {
            position: absolute;
            top: 85px;
            left: 370px;
            width: 255px;
            height: 590px;
        }
        #PeelContainer {
            position: absolute;
            top: 85px;
            left: 635px;
            width: 250px;
            height: 590px;
        }
        #FermentContainer {
            position: absolute;
            top: 85px;
            left: 900px;
            width: 220px;
            height: 590px;
        }
        #DryContainer {
            position: absolute;
            top: 85px;
            left: 1135px;
            width: 280px;
            height: 590px;
        }
    </style>
</head>

<body>
    <div id="wrapper">
        <div id="coffee_header">
            <!-- 匯入共同使用的 header.html 內容 -->
            {% include 'header.html' %}
        </div>

        <div style="height: 605px;">
            <br>
            <br>
            <!-- 底圖 各貨櫃示意圖 -->
            <!-- <center><img src="../static/img/Coffee_home.png" style="margin: auto; width: 1300px;"></center> -->

            <!-- 清洗浮選槽 -->
            <div id="CleanContainer" tabindex="0" class="div_Container_position" role="button">
                清洗浮選狀態
                <div id="CleanContainer_status" class="div-Container-Status"></div>
                <img src="../static/img/clean.png" width="100%">
            </div>

            <!-- 色選機 -->
            <div id="ColorContainer" tabindex="0" class="div_Container_position" role="button">
                色選機狀態
                <div id="ColorContainer_status" class="div-Container-Status"></div>
                <img src="../static/img/color.png" width="100%">
            </div>

            <!-- 脫皮機 -->
            <div id="PeelContainer" tabindex="0" class="div_Container_position" role="button">
                脫皮機狀態
                <div id="PeelContainer_status" class="div-Container-Status"></div>
                <img src="../static/img/peel.png" width="100%">
            </div>

            <!-- 發酵槽 -->
            <div id="FermentContainer" tabindex="0" class="div_Container_position" role="button">
                發酵槽狀態
                <div id="FermentContainer_status" class="div-Container-Status"></div>
                <img src="../static/img/ferment.png" width="100%">
            </div>
            
            <!-- 乾燥槽 -->
            <div id="DryContainer" tabindex="0" class="div_Container_position" role="button">
                乾燥槽狀態
                <div id="DryContainer_status" class="div-Container-Status"></div>
                <img src="../static/img/dry.png" width="100%">
            </div>

            <br>
            <br>

        </div>
        <script>
            var button_CleanContainer = document.getElementById('CleanContainer');
            button_CleanContainer.addEventListener('click', function () {
                window.location.href = '/clean';
            });
            var button_ColorContainer = document.getElementById('ColorContainer');
            button_ColorContainer.addEventListener('click', function () {
                window.location.href = '/clean';
            });
            var button_PeelContainer = document.getElementById('PeelContainer');
            button_PeelContainer.addEventListener('click', function () {
                window.location.href = '/clean';
            });
            var button_FermentContainer = document.getElementById('FermentContainer');
            button_FermentContainer.addEventListener('click', function () {
                window.location.href = '/ferment';
            });
            var button_DryContainer = document.getElementById('DryContainer');
            button_DryContainer.addEventListener('click', function () {
                window.location.href = '/dry';
            });
        </script>

        <div id="coffee_footer">
            <!-- 匯入共同使用的 footer.html 內容 -->
            {% include 'footer.html' %}
        </div>
    </div>

</body>

</html>