<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Aisky-Sixth</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>

    <!--可用來建立使用者小圖示-->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">

    <script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.3.0/socket.io.dev.js"></script>

<!--    <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/socket.io/1.3.6/socket.io.min.js"></script>-->

<!--    <script src="https://cdn.socket.io/4.0.1/socket.io.min.js" integrity="sha384-LzhRnpGmQP+lOvWruF/lgkcqD+WDVt9fU3H4BWmwP5u5LTmkUGafMcpZKNObVMLU" crossorigin="anonymous"></script>-->



    <style>
        body {
	        margin:0;
        }

        .navbar-dark .navbar-nav .nav-link {
            color: white;
            cursor: pointer;
	        text-decoration:none;
            width: 130px;
            height: 46px;
        }

        .nav-top {
	        line-height:40px;
	        background-color: #C4C4C4;
        }

        .website_title{
            font-family: Roboto;
            font-style: normal;
            font-weight: normal;
            font-size: 30px;
            color: #000000;
        }

        .navbar-nav > li{
	        float: none;
	        display: inline-block;
	        width: 110px;
            margin: 0 auto;
            text-align: center;
        }

        .navbar-nav > li a{
            font-size: 20px;
        }

        .main-page {
            margin-top: 150px;
        }

        .page-title {
            font-family: Roboto;
            font-style: normal;
            font-weight: bold;
            font-size: 36px;
        }


        .flex {
            display: flex;
            flex-direction: row;
            flex-wrap: wrap;
            justify-content: center;
        }

          .set-link {
            display: inline-block;
            width: 350px;
            height: 100px;
            line-height: 100px;
            background: #008CBA;
            border: 1px solid #CFCFCF;
            box-sizing: border-box;
            color: #FFFFFF;
            border-radius: 10px;
            font-size: 36px;

        }

        .fa{
            display: inline-block;
            font: normal normal normal 14px/1 FontAwesome;
            font-size: inherit;
            text-rendering: auto;
            -webkit-font-smoothing: antialiased;
        }

        .fa-user-o:before{
            content: "\f2c0";
        }

        button {
            cursor: pointer;
        }


        @media(max-width:373px){
            .card {
                margin-right: 0px;
            }
        }

        @media(max-width:577px){

        }

        @media(min-width:576px){


        }
         @media(min-width:768px){
            .navbar-nav > li {
                 margin-left: 0px;
            }
            .navbar-nav .li-block {
                display:none;
            }
         }

         @media(min-width:991px){
            .navbar-nav > li {
                 margin-left: 20px;
            }
            .navbar-nav .li-block {
                display:none;
            }
         }

         @media(min-width:1200px){
            .navbar-nav > li {
                 margin-left: 35px;
            }
            .navbar-nav .li-block {
                display: inline-block;
                width: 100px;
            }
         }

         @media(min-width:1400px){
            .navbar-nav .li-block {
                display: inline-block;
                width: 200px;
            }

         }


         @media(min-width:1689px) {
            .navbar-nav > li {
                 margin-left: 50px;
            }
            .navbar-nav .li-block {
                display: inline-block;
                width: 500px;
            }
         }


    </style>

		<script>
            // // 原本就註解
            // //驗證token，如果不符合或過期就登出回登入頁
            // var str = localStorage.getItem('Hello');
            // $.ajax({
            //     type: "GET",
            //     url: "/auth",
            //     headers: {'Authorization': 'Bearer ' + str},
            //     success: function(result){
            //         console.log(result.identity);
            //     },
            //     error: function(result){
            //         window.location.href='/logout';
            //     }
            // });
            


            $(function(){
                console.log("OK")

                var namespace = '/test_conn';
                var url = 'http://127.0.0.1';
                var port = '5000';
                // var socket = io.connect(url + ':' + port + namespace);

                // var item = document.getElementById('python3.8-status');
                // item.style.width = '0%';
                // item.innerText = '0%';
                // timer_python38 = window.setInterval("AddBarIndex('python3.8-status')", 2000);

                // window.setInterval("abs_update()", 1000);


                // socket.on('connect', function() {
                //     socket.emit('connect_event', {data: 'connected!'});
                //     print("SOCKET CONNECT")
                // });

                // socket.on('user-confirm', function(msg) {
                //     console.log(msg);
                //     if(msg == 'pass'){
                //         var item = document.getElementById('python3.8-status');
                //         item.style.width = '2%';
                //         item.innerText = '2%';
                //         timer_python38 = window.setInterval("AddBarIndex('python3.8-status')", 2000);
                //     };
                // });

                // socket.on('stdout', function(msg) {
                //     if(msg.indexOf('python3.8') != -1){
                //         ItemInstallSuccess(timer_python38, 'python3.8');
                //         timer_python3_pip = window.setInterval("AddBarIndex('python3-pip-status')", 2000);
                //     };

                //     if(msg.indexOf('python3-pip') != -1){
                //         ItemInstallSuccess(timer_python3_pip, 'python3-pip');
                //         timer_git = window.setInterval("AddBarIndex('git-status')", 2000);
                //     };

                //     if(msg.indexOf('git') != -1){
                //         ItemInstallSuccess(timer_git, 'git');
                //         timer_wget = window.setInterval("AddBarIndex('wget-status')", 2000);
                //     };

                //     if(msg.indexOf('wget') != -1){
                //         ItemInstallSuccess(timer_wget, 'wget');
                //         timer_grep = window.setInterval("AddBarIndex('grep-status')", 2000);
                //     };

                //     if(msg.indexOf('grep') != -1){
                //         ItemInstallSuccess(timer_grep, 'grep');
                //         timer_tasksel = window.setInterval("AddBarIndex('tasksel-status')", 2000);
                //     };

                //     if(msg.indexOf('tasksel') != -1){
                //         ItemInstallSuccess(timer_tasksel, 'tasksel');
                //         timer_lamp_server = window.setInterval("AddBarIndex('lamp-server-status')", 2000);
                //     };

                //     if(msg.indexOf('lamp-server') != -1){
                //         ItemInstallSuccess(timer_lamp_server, 'lamp-server');
                //         timer_phpMyAdmin510_all_languages = window.setInterval("AddBarIndex('phpMyAdmin-5.1.0-all-languages.tar.gz-status')", 2000);
                //     };

                //     // // 原本就註解
                //     // if(msg.indexOf('phpMyAdmin-5.1.0-all-languages.tar.gz') != -1){
                //     //     ItemInstallSuccess(timer_phpMyAdmin510_all_languages, 'phpMyAdmin-5.1.0-all-languages.tar.gz');
                //     //     timer_openssl = window.setInterval("AddBarIndex('openssl-status')", 2000);
                //     // };

                //     if(msg.indexOf('install phpmyadmin done') != -1){
                //         ItemInstallSuccess(timer_phpMyAdmin510_all_languages, 'phpMyAdmin-5.1.0-all-languages.tar.gz');
                //         timer_openssl = window.setInterval("AddBarIndex('openssl-status')", 2000);
                //     };

                //     if(msg.indexOf('openssl') != -1){
                //         ItemInstallSuccess(timer_openssl, 'openssl');
                //         timer_php_common = window.setInterval("AddBarIndex('php-common-status')", 2000);
                //     };

                //     if(msg.indexOf('php-common') != -1){
                //         ItemInstallSuccess(timer_php_common, 'php-common');
                //         timer_php_curl = window.setInterval("AddBarIndex('php-curl-status')", 2000);
                //     };

                //     if(msg.indexOf('php-curl') != -1){
                //         ItemInstallSuccess(timer_php_curl, 'php-curl');
                //         timer_php_json = window.setInterval("AddBarIndex('php-json-status')", 2000);
                //     };

                //     if(msg.indexOf('php-json') != -1){
                //         ItemInstallSuccess(timer_php_json, 'php-json');
                //         timer_php_mbstring = window.setInterval("AddBarIndex('php-mbstring')", 2000);
                //     };

                //     if(msg.indexOf('php-mbstring') != -1){
                //         ItemInstallSuccess(timer_php_mbstring, 'php-mbstring');
                //         timer_php_mysql = window.setInterval("AddBarIndex('php-mysql')", 2000);
                //     };

                //     if(msg.indexOf('php-mysql') != -1){
                //         ItemInstallSuccess(timer_php_mysql, 'php-mysql');
                //         timer_php_xml = window.setInterval("AddBarIndex('php-xml-status')", 2000);
                //     };

                //     if(msg.indexOf('php-xml') != -1){
                //         ItemInstallSuccess(timer_php_xml, 'php-xml');
                //         timer_php_zip = window.setInterval("AddBarIndex('php-zip-status')", 2000);
                //     };

                //     if(msg.indexOf('php-zip') != -1){
                //         ItemInstallSuccess(timer_php_zip, 'php-zip');
                //         timer_php72_mbstring = window.setInterval("AddBarIndex('php7.2-mbstring-status')", 2000);
                //     };

                //     if(msg.indexOf('php7.2-mbstring') != -1){
                //         ItemInstallSuccess(timer_php72_mbstring, 'php7.2-mbstring');
                //         timer_php72_xml = window.setInterval("AddBarIndex('php7.2-xml-status')", 2000);
                //     };

                //     if(msg.indexOf('php7.2-xml') != -1){
                //         ItemInstallSuccess(timer_php72_xml, 'php7.2-xml');
                //         timer_php72_mysql = window.setInterval("AddBarIndex('php7.2-mysql-status')", 2000);
                //     };

                //     if(msg.indexOf('php7.2-mysql') != -1){
                //         ItemInstallSuccess(timer_php72_mysql, 'php7.2-mysql');
                //         timer_php72_common = window.setInterval("AddBarIndex('php7.2-common-status')", 2000);
                //     };

                //     if(msg.indexOf('php7.2-common') != -1){
                //         ItemInstallSuccess(timer_php72_common, 'php7.2-common');
                //         timer_php72_curl = window.setInterval("AddBarIndex('php7.2-curl-status')", 2000);
                //     };

                //     if(msg.indexOf('php7.2-curl') != -1){
                //         ItemInstallSuccess(timer_php72_curl, 'php7.2-curl');
                //         timer_php72_json = window.setInterval("AddBarIndex('php7.2-json-status')", 2000);
                //     };

                //     if(msg.indexOf('php7.2-json') != -1){
                //         ItemInstallSuccess(timer_php72_json, 'php7.2-json');
                //         timer_php72_zip = window.setInterval("AddBarIndex('php7.2-zip-status')", 2000);
                //     };

                //     if(msg.indexOf('php7.2-zip') != -1){
                //         ItemInstallSuccess(timer_php72_zip, 'php7.2-zip');
                //         timer_service_apache2 = window.setInterval("AddBarIndex('service-apache2-start-status')", 2000);
                //     };

                //     if(msg.indexOf('service apache2 start') != -1){
                //         ItemInstallSuccess(timer_service_apache2, 'service-apache2-start');
                //         timer_setting_mysql = window.setInterval("AddBarIndex('setting-mysql-status')", 2000);
                //     };
                //     console.log(msg);
                //     console.log('test1');
                // });
                // socket.on('stderr', function(msg) {
                //     if(msg.indexOf('python3.8') != -1){
                //         ItemInstallFail(timer_python38, 'python3.8');
                //         timer_python3_pip = window.setInterval("AddBarIndex('python3-pip-status')", 2000);
                //     };

                //     if(msg.indexOf('python3-pip') != -1){
                //         ItemInstallFail(timer_python3_pip, 'python3-pip');
                //         timer_git = window.setInterval("AddBarIndex('git-status')", 2000);
                //     };

                //     if(msg.indexOf('git') != -1){
                //         ItemInstallFail(timer_git, 'git');
                //         timer_wget = window.setInterval("AddBarIndex('wget-status')", 2000);
                //     };

                //     if(msg.indexOf('wget') != -1){
                //         ItemInstallFail(timer_wget, 'wget');
                //         timer_grep = window.setInterval("AddBarIndex('grep-status')", 2000);
                //     };

                //     if(msg.indexOf('grep') != -1){
                //         ItemInstallFail(timer_grep, 'grep');
                //         timer_tasksel = window.setInterval("AddBarIndex('tasksel-status')", 2000);
                //     };

                //     if(msg.indexOf('tasksel') != -1){
                //         ItemInstallFail(timer_tasksel, 'tasksel');
                //         timer_lamp_server = window.setInterval("AddBarIndex('lamp-server-status')", 2000);
                //     };

                //     if(msg.indexOf('lamp-server') != -1){
                //         ItemInstallFail(timer_lamp_server, 'lamp-server');
                //         timer_phpMyAdmin = window.setInterval("AddBarIndex('phpMyAdmin-5.1.0-all-languages.tar.gz-status')", 2000);
                //     };

                //     // // 原本就註解
                //     // if(msg.indexOf('phpMyAdmin-5.1.0-all-languages.tar.gz') != -1){
                //     //     ItemInstallFail(timer_phpMyAdmin, 'phpMyAdmin-5.1.0-all-languages.tar.gz');
                //     //     timer_openssl = window.setInterval("AddBarIndex('openssl-status')", 2000);
                //     // };

                //     if(msg.indexOf('openssl') != -1){
                //         ItemInstallFail(timer_openssl, 'openssl');
                //         timer_php_common = window.setInterval("AddBarIndex('php-common-status')", 2000);
                //     };

                //     if(msg.indexOf('php-common') != -1){
                //         ItemInstallFail(timer_php_common, 'php-common');
                //         timer_php_curl = window.setInterval("AddBarIndex('php-curl-status')", 2000);
                //     };

                //     if(msg.indexOf('php-curl') != -1){
                //         ItemInstallFail(timer_php_curl, 'php-curl');
                //         timer_php_json = window.setInterval("AddBarIndex('php-json-status')", 2000);
                //     };

                //     if(msg.indexOf('php-json') != -1){
                //         ItemInstallFail(timer_php_json, 'php-json');
                //         timer_php_mbstring = window.setInterval("AddBarIndex('php-mbstring')", 2000);
                //     };

                //     if(msg.indexOf('php-mbstring') != -1){
                //         ItemInstallFail(timer_php_mbstring, 'php-mbstring');
                //         timer_php_mysql = window.setInterval("AddBarIndex('php-mysql')", 2000);
                //     };

                //     if(msg.indexOf('php-mysql') != -1){
                //         ItemInstallFail(timer_php_mysql, 'php-mysql');
                //         timer_php_xml = window.setInterval("AddBarIndex('php-xml-status')", 2000);
                //     };

                //     if(msg.indexOf('php-xml') != -1){
                //         ItemInstallFail(timer_php_xml, 'php-xml');
                //         timer_php_zip = window.setInterval("AddBarIndex('php-zip-status')", 2000);
                //     };

                //     if(msg.indexOf('php-zip') != -1){
                //         ItemInstallFail(timer_php_zip, 'php-zip');
                //         timer_php72_mbstring = window.setInterval("AddBarIndex('php7.2-mbstring-status')", 2000);
                //     };

                //     if(msg.indexOf('php7.2-mbstring') != -1){
                //         ItemInstallFail(timer_php72_mbstring, 'php7.2-mbstring');
                //         timer_php72_xml = window.setInterval("AddBarIndex('php7.2-xml-status')", 2000);
                //     };

                //     if(msg.indexOf('php7.2-xml') != -1){
                //         ItemInstallFail(timer_php72_xml, 'php7.2-xml');
                //         timer_php72_mysql = window.setInterval("AddBarIndex('php7.2-mysql-status')", 2000);
                //     };

                //     if(msg.indexOf('php7.2-mysql') != -1){
                //         ItemInstallFail(timer_php72_mysql, 'php7.2-mysql');
                //         timer_php72_common = window.setInterval("AddBarIndex('php7.2-common-status')", 2000);
                //     };

                //     if(msg.indexOf('php7.2-common') != -1){
                //         ItemInstallFail(timer_php72_common, 'php7.2-common');
                //         timer_php72_curl = window.setInterval("AddBarIndex('php7.2-curl-status')", 2000);
                //     };

                //     if(msg.indexOf('php7.2-curl') != -1){
                //         ItemInstallFail(timer_php72_curl, 'php7.2-curl');
                //         timer_php72_json = window.setInterval("AddBarIndex('php7.2-json-status')", 2000);
                //     };

                //     if(msg.indexOf('php7.2-json') != -1){
                //         ItemInstallFail(timer_php72_json, 'php7.2-json');
                //         timer_php72_zip = window.setInterval("AddBarIndex('php7.2-zip-status')", 2000);
                //     };

                //     if(msg.indexOf('php7.2-zip') != -1){
                //         ItemInstallFail(timer_php72_zip, 'php7.2-zip');
                //         timer_service_apache2 = window.setInterval("AddBarIndex('service-apache2-start-status')", 2000);
                //     };

                //     if(msg.indexOf('service apache2 start') != -1){
                //         ItemInstallFail(timer_service_apache2, 'service-apache2-start');
                //         timer_setting_mysql = window.setInterval("AddBarIndex('setting-mysql-status')", 2000);
                //     };
                //     console.log(msg);
                //     console.log('test2');
                // });
            });

        </script>
</head>





<body>
    <nav class="fixed-top">
        <nav class="navbar navbar-expand-md nav-top justify-content-center">
            <div>
                <span class="website_title">伺服器建置</span>
            </div>
        </nav>
        <nav class="navbar navbar-expand-md bg-dark navbar-dark nav-bottom">
            <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsibleNavbar">
                <span class="navbar-toggler-icon"></span>
            </button>
            <div class="collapse navbar-collapse" id="collapsibleNavbar">
                <ul class="navbar-nav">
                    <li class="nav-item">
                        <a class="nav-link" href="/">首頁</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="/incoming_check">進貨檢測</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="/burn_program">感測器燒錄</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="/modify_permissions">權限設置</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="/add_sensor">新增感測器</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="/add_server">伺服器建置</a>
                    </li>
                    <li class="li-block"></li>
                    <li class="nav-item">
                        <a class="nav-link" href="#"><i class="fa fa-user-o"></i> {{params.username}}</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="/logout">Logout</a>
                    </li>
                </ul>
            </div>
        </nav>
    </nav>
    <div class="main-page">
        <div class="container">
            <div class="row">
                <div class="col" style="margin: auto; ">
                    <table  class="table table-bordered" style="font-size:23px;margin-top:30px;">
                        <tbody>
                            <tr>
                                <td>1.請輸入您的IP位置:</td>
                                <td><input type="text" name="user_ip" value="60.250.156.232"></td>
                            </tr>
                            <tr>
                                <td>2.請輸入您的登入帳號:</td>
                                <td><input type="text" name="user_loginname" value="root"></td>
                            </tr>
                            <tr>
                                <td>3.請輸入您的username:</td>
                                <td><input type="text" name="user_username" value="gs1802"></td>
                            </tr>
                            <tr>
                                <td>4.請輸入您的password:</td>
                                <td><input type="password" name="user_password" value="g53743001"></td>
                            </tr>
                        </tbody>
                    </table>
                    <div class="text-center">
                        <input type="button" value="建置" name="add_server" style="cursor:pointer;" onclick="AddServer()">
                    </div>
                    <div class="text-center" id="addServer-status" style="margin-top:30px;color:red;visibility:hidden;">
                        <h2>伺服器建置中...</h2>
                    </div>
                    <div>
                        <h1>Item install status</h1>
                        <table  class="table table-bordered" style="font-size:23px;margin-top:30px;">
                            <tbody>
                                <tr>
                                    <th>Item</th>
                                    <th>Status</th>
                                </tr>
                                {% for item in params.L %}
                                    <tr>
                                        <td>{{loop.index}}.{{item}}</td>
                                        <td>
                                            <div class="progress" style="height:35px;">
                                                <div id="{{item}}-status" name="{{item}}-status" class="progress-bar progress-bar-striped" 
                                                    style="width:0%; height:35px; font-size:20px; color:black; text-align:center;">0%
                                                </div>
                                            </div>
                                        </td>
                                    </tr>
                                {% endfor %}
<!--                                <tr>-->
<!--                                    <td>1.pymysql</td>-->
<!--&lt;!&ndash;                                    <td><span name="pymysql-status"></span></td>&ndash;&gt;-->
<!--                                    <td>-->
<!--                                        <div class="progress" style="height:35px;">-->
<!--                                            <div id="pymysql-status" class="progress-bar progress-bar-striped" style="width:0%;height:35px;font-size:20px;color:black;text-align:center;">0%</div>-->
<!--                                        </div>-->
<!--                                    </td>-->
<!--                                </tr>-->
<!--                                <tr>-->
<!--                                    <td>2.eventlet</td>-->
<!--&lt;!&ndash;                                    <td><span name="eventlet-status"></span></td>&ndash;&gt;-->
<!--                                    <td>-->
<!--                                        <div class="progress" style="height:35px;">-->
<!--                                            <div id="eventlet-status" class="progress-bar progress-bar-striped" style="width:0%;height:35px;font-size:20px;color:black;text-align:center;">0%</div>-->
<!--                                        </div>-->
<!--                                    </td>-->
<!--                                </tr>-->
<!--                                <tr>-->
<!--                                    <td>3.flask</td>-->
<!--&lt;!&ndash;                                    <td><span name="eventlet-status"></span></td>&ndash;&gt;-->
<!--                                    <td>-->
<!--                                        <div class="progress" style="height:35px;">-->
<!--                                            <div id="flask-status" class="progress-bar progress-bar-striped" style="width:0%;height:35px;font-size:20px;color:black;text-align:center;">0%</div>-->
<!--                                        </div>-->
<!--                                    </td>-->
<!--                                </tr>-->
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
    <script>
            // var timer_python38 = 0;
            // var timer_python3_pip = 0;
            // var timer_git = 0;
            // var timer_wget = 0;
            // var timer_grep = 0;
            // var timer_tasksel = 0;
            // var timer_lamp_server = 0;
            // var timer_phpMyAdmin = 0;
            // var timer_openssl = 0;
            // var timer_php_common = 0;
            // var timer_php_curl = 0;
            // var timer_php_json = 0;
            // var timer_php_mbstring = 0;
            // var timer_php_mysql = 0;
            // var timer_php_xml = 0;
            // var timer_php_zip = 0;
            // var timer_php72_mbstring = 0;
            // var timer_php72_xml = 0;
            // var timer_php72_mysql = 0;
            // var timer_php72_common = 0;
            // var timer_php72_curl = 0;
            // var timer_php72_json = 0;
            // var timer_php72_zip = 0;
            // var timer_service_apache2 = 0;
            // var timer_setting_mysql = 0;
            // var timer_paho_mqtt = 0;
            // var timer_mosquitto = 0;
            // var timer_mqtt_server = 0;
            // var timer_watchdog = 0;
            // var timer_golang = 0;
            // var timer_Git_server = 0;
            // var timer_flask = 0;
            // var timer_Flask_SQLAlchemy = 0;
            // var timer_pymysql = 0;
            // var timer_flask_mqtt = 0;
            // var timer_flask_migrate = 0;
            // var timer_flask_jwt_extended = 0;
            // var timer_numpy = 0;
            // var timer_pandas = 0;
            // var timer_opencv_python = 0;
            // var timer_BeautifulSoup4 = 0;
            // var timer_selenium = 0;
            // var timer_geocoder = 0;
            // var timer_AP = 0;
            // var timer_chrony_ntpdate = 0;
            // var timer_deb_ros_packages_and_keyserver = 0;
            // var timer_update = 0;
            // var timer_upgrade = 0;
            // var timer_ros_melodic_desktop_full = 0;
            // var timer_ros_melodic_rqt = 0;
            // var timer_pythonrosdep = 0;
            // var timer_python_rosinstall = 0;
            // var timer_ROS = 0;

            function AddBarIndex(obj){
                var item = document.getElementById(obj);
                //因假設元素id內有.或是空格的使用jQuery選擇器會找不到，所以改成用js的節點來設置
                //[0].style.width 讓width顯示為%值，使用css.('width')會顯示px
                //var width = obj[0].style.width;
                var width = item.style.width;
                // console.log("width: " + width);
                var current_width = width.substring(0, width.length-1);
                console.log("current_width: " + current_width);
                item.style.width = Number(current_width) + 2 + '%';
                // console.log("item.style.width: " + item.style.width);
                item.innerText = Number(current_width) + 2 + '%';
                // console.log("item.innerText: " + item.innerText);

                if (current_width == 94) {
                    console.log(obj + ' INSTALLATION AddBar Pause');
                    eval('clearInterval(timer)');
                }
            };

            function AddServer(){
                //var item = document.getElementById('python3.8-status');
                //item.style.width = '2%';
                //item.innerText = '2%';
                //timer_python38 = window.setInterval("AddBarIndex('python3.8-status')", 2000);
                $("#addServer-status").css('visibility','visible');
                var ip = $("input[name=user_ip]").val();
                var loginname = $("input[name=user_loginname]").val();
                var username = $("input[name=user_username]").val();
                var password = $("input[name=user_password]").val();
                var json = {"ip":ip, "loginname":loginname, "username":username, "password":password};
                var abs_update_interval = window.setInterval("abs_update()", 1000);
                $.post('/add_server', json, function(resText){
                    $("#addServer-status").css('visibility','hidden');
                    if(resText == 'Authentication failed.'){
                        resText = '您輸入的密碼有誤，請重新輸入!';
                        $("input[name=user_ip]").val('');
                        $("input[name=user_username]").val('');
                        $("input[name=user_password]").val('');
                    };
                    clearInterval(abs_update_interval);
                    alert(resText);
                }, 'text');
            };

            Automatic_Build_System_installation = {
                'python3.8-installation': 'Wait',
                'python3-pip-installation': 'Wait',
                'cryptography-installation': 'Wait',
                'upgrade-installation': 'Wait',
                'grep-installation': 'Wait',
                'git-installation': 'Wait',
                'gitpython-installation': 'Wait',
                'python3-tk-installation': 'Wait',
                'wget-installation': 'Wait',
                'python3-dev-installation': 'Wait',
                'tasksel-installation': 'Wait',
                'lamp-server-installation': 'Wait',
                'phpMyAdmin-5.1.0-all-languages.tar.gz-installation': 'Wait',
                'openssl-installation': 'Wait',
                'php-common-installation': 'Wait',
                'php-curl-installation': 'Wait',
                'php-json-installation': 'Wait',
                'php-mbstring-installation': 'Wait',
                'php-mysql-installation': 'Wait',
                'php-xml-installation': 'Wait',
                'php-zip-installation': 'Wait',
                'php7.2-mbstring-installation': 'Wait',
                'php7.2-xml-installation': 'Wait',
                'php7.2-mysql-installation': 'Wait',
                'php7.2-common-installation': 'Wait',
                'php7.2-curl-installation': 'Wait',
                'php7.2-json-installation': 'Wait',
                'php7.2-zip-installation': 'Wait',
                'apache2-installation': 'Wait',
                'mysql -u root -e-installation': 'Wait',
                'paho-mqtt-installation': 'Wait',
                'mosquitto-installation': 'Wait',
                'mqtt_server_setting-installation': 'Wait',
                'rclocal/rc.local-installation': 'Wait',
                'golang-installation': 'Wait',
                'gogsfile.git-installation': 'Wait',
                'requirements-installation': 'Wait',
                'chrony-installation': 'Wait',
                '--keyserver-installation': 'Wait',
                'update-installation': 'Wait',
                'ros-melodic-desktop-full-installation': 'Wait',
                'ros-melodic-rqt*-installation': 'Wait',
                'python-rosdep-installation': 'Wait',
                'python-rosinstall-installation': 'Wait',
                'python-rosinstall-generator-installation': 'Wait',
                'python-wstool-installation': 'Wait',
                'catkin_make-installation': 'Wait'
            }

            var abs_update_process = 0;
            function abs_update() {
                if (abs_update_process === 1) {
                    return;
                }
                
                abs_update_process = 1;
                $.ajax({
                    async:false,
                    type:"GET",
                    url:"/ABS_update",
                    dataType:"JSON",
                    success:function(response){
                        for (const key of Object.entries(response)) {
                            if (response[key[0]] == 'Install') {
                                if (Automatic_Build_System_installation[key[0] + '-installation'] == 'Wait') {
                                    Automatic_Build_System_installation[key[0] + '-installation'] = 'Install';
                                    timer = window.setInterval("AddBarIndex('" + key[0] + "-status')", 2000);
                                }
                            } else if (response[key[0]] == '0') {
                                // pass
                            } else if (response[key[0]] == 'Error') {
                                if (Automatic_Build_System_installation[key[0] + '-installation'] == 'Install') {
                                    Automatic_Build_System_installation[key[0] + '-installation'] = 'Error';
                                    ItemInstallFail(timer, key[0]);
                                }
                            // } else if (response[key[0]] == 'Success') {
                            //     if (Automatic_Build_System_installation[key[0] + '-installation'] == 'Install') {
                            //         Automatic_Build_System_installation[key[0] + '-installation'] = 'Success';
                            //         ItemInstallSuccess(timer, key[0]);
                            //     }
                            } else if (Number(response[key[0]]) !== NaN) {
                                if (Automatic_Build_System_installation[key[0] + '-installation'] == 'Install') {
                                    Automatic_Build_System_installation[key[0] + '-installation'] = 'Success';
                                    ItemInstallSuccess(timer, key[0], response[key[0]]);
                                }
                            
                            } else {
                                console.log("response[key[0]]: " + response[key[0]]);
                            }
                        }
                        abs_update_process = 0;
                    },
                    error:function(thrownError){
                        console.log("thrownError: " + thrownError);
                        abs_update_process = 0;
                    }
                });
            };

            function ItemInstallSuccess(timer_item, item_name, execution_time){
                eval('clearInterval(' + timer_item + ')');
                var item = document.getElementById(item_name + '-status');
                item.style.width = '100%';
                item.innerText = execution_time + 's';
            };

            function ItemInstallFail(timer_item, item_name){
                eval('clearInterval(' + timer_item + ')');
                var item = document.getElementById(item_name + '-status');
                item.style.width = '0%';
                item.innerText = 'Fail';
                item.style.color = 'red';
                item.style.fontWeight = 'bold';
            };
    </script>
</html>