<style type="text/css">
  .btn_link .label {
    position: absolute;
    top: -5px;
    right: -5px;
    left: 80%;
    bottom: 80%;
  }
</style>

<?php $Setting = app('anlutro\LaravelSettings\SettingStore'); ?>
<?php $setting = app('anlutro\LaravelSettings\Facade'); ?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8" />
  <title>
  <?php $CommunityPresenter = app('NSST\Presenters\CommunityPresenter'); ?>
  <?php echo e($CommunityPresenter->comName()); ?> <?php echo e($setting::get('system_name','全方位建築智慧化管理系統')); ?>

  </title>
  <meta name="description" content="app, web app, responsive, admin dashboard, admin, flat, flat ui, ui kit, off screen nav" />
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" /> 
  <link rel="stylesheet" href="<?php echo e(asset('monitor_assets/css/bootstrap.css')); ?>" type="text/css" />
  <link rel="stylesheet" href="<?php echo e(asset('monitor_assets/css/animate.css')); ?>" type="text/css" />
  <link rel="stylesheet" href="<?php echo e(asset('monitor_assets/css/font-awesome.min.css')); ?>" type="text/css" />
  <link rel="stylesheet" href="<?php echo e(asset('monitor_assets/css/font.css')); ?>" type="text/css" cache="false" />
  <link rel="stylesheet" href="<?php echo e(asset('monitor_assets/js/fuelux/fuelux.css')); ?>" type="text/css" />
  <link rel="stylesheet" href="<?php echo e(asset('monitor_assets/css/plugin.css')); ?>" type="text/css" />
  <link rel="stylesheet" href="<?php echo e(asset('monitor_assets/css/app.css')); ?>" type="text/css" />
  <link rel="stylesheet" type="text/css" href="<?php echo e(asset('assets/global/plugins/bootstrap-toastr/toastr.min.css')); ?>"/>
  <?php if($Setting->get('monitor_loading_image') == 'on'): ?>
  <link rel="stylesheet" type="text/css" href="<?php echo e(asset('assets/global/plugins/pace/themes/pace-theme-center-circle.css')); ?>"/>
  <?php endif; ?>
  <link rel="stylesheet" type="text/css" href="<?php echo e(asset('assets/global/plugins/jquery-keyboard/jqkeyboard.css')); ?>">

  <!--[if lt IE 9]>
    <script src="js/ie/respond.min.js" cache="false"></script>
    <script src="js/ie/html5.js" cache="false"></script>
    <script src="js/ie/fix.js" cache="false"></script>
  <![endif]-->
  <style type="text/css">
body{
  font-family: Microsoft JhengHei;
}

.metro {
    width: 95%;
    margin: 0 auto 0;
}


.metro li {
    -webkit-transform: perspective(600px);
    -webkit-transform-style: preserve-3d;
    -webkit-transform-origin-x: 50%;
    -webkit-transform-origin-y: 50%;
    -ms-transform: perspective(600px);
    -ms-transform-style: preserve-3d;
    -ms-transform-origin-x: 50%;
    -ms-transform-origin-y: 50%;
    transform: perspective(600px);
    transform-style: preserve-3d;
    transform-origin-x: 50%;
    transform-origin-y: 50%;
    cursor: default;
    position: relative;
    text-align: center;
    margin: 0 10px 10px 0;
    width: 23%;
    height: 140px;
    color: #ffffff;
    float: left;
    -webkit-transition: .2s -webkit-transform, 1s opacity;
    -ms-transition: .2s -ms-transform, 1s opacity;
    transition: .2s transform, 1s opacity;
    cursor:pointer;
    list-style-type:none;
}

.metro li i {
    font-size: 50px;
    margin: 28px 0 0;
}

.metro li span {
    color: rgba(255, 255, 255, 0.8);
    text-transform: uppercase;
    position: absolute;
    left: 15px;
    bottom: 15px;
    text-align: center;
    font-weight: bold;
    font-size: 20px;
}

.metro .badge {
    left: 75%;
    bottom: 15px;
    font-weight: bold;
    font-size: 24px;
}




.metro li:nth-child(5):active, .metro li:first-child:active {
    -webkit-transform: scale(0.95);
    -ms-transform: scale(0.95);
    transform: scale(0.95);
}

.metro li:nth-child(7):active, .metro li:nth-child(2):active {
    -webkit-transform: perspective(600px) rotate3d(1, 0, 0, -10deg);
    -ms-transform: perspective(600px) rotate3d(1, 0, 0, -10deg);
    transform: perspective(600px) rotate3d(1, 0, 0, -10deg);
}

.metro li:nth-child(8):active,.metro li:nth-child(3):active {
    -webkit-transform: perspective(600px) rotate3d(0, 1, 0, 10deg);
    -ms-transform: perspective(600px) rotate3d(0, 1, 0, 10deg);  
    transform: perspective(600px) rotate3d(0, 1, 0, 10deg); 
}

.metro li:nth-child(9):active,.metro li:nth-child(4):active {
    -webkit-transform: perspective(600px) rotate3d(0, 1, 0, -10deg);
    -ms-transform: perspective(600px) rotate3d(0, 1, 0, -10deg);
    transform: perspective(600px) rotate3d(0, 1, 0, -10deg);
}

.metro li:nth-child(6):active {
    -webkit-transform: perspective(600px) rotate3d(1, 0, 0, 10deg);
    -ms-transform: perspective(600px) rotate3d(1, 0, 0, 10deg);
    transform: perspective(600px) rotate3d(1, 0, 0, 10deg);
}

#right {
  position: absolute;
  right: 1%;
  bottom: 45vh;
  z-index: 1000;
}

#left {
  position: absolute;
  left: 100px;
  bottom: 45vh;
  z-index: 1000;
}
  </style>
</head>
<body onLoad="window.setTimeout('getRefreshTime()',1)">
  <section class="vbox">
    <header class="header bg-black navbar navbar-inverse pull-in">
      <div class="navbar-header nav-bar aside dk">
        <a class="btn btn-link visible-xs" data-toggle="class:show" data-target=".nav-primary">
          <i class="fa fa-bars"></i>
        </a>
    <?php $setting = app('anlutro\LaravelSettings\Facade'); ?>
        <a href="#" class="nav-brand" data-toggle="fullscreen"><img src="<?php echo e($setting::get('logo_brand', asset('assets/images/logo.png'))); ?>" style="max-height:40px;"></a>
        <a class="btn btn-link visible-xs" data-toggle="collapse" data-target=".navbar-collapse">
          <i class="fa fa-comment-o"></i>
        </a>
      </div>
      <div class="collapse navbar-collapse">
        <?php $CommunityPresenter = app('NSST\Presenters\CommunityPresenter'); ?>
        <span style="vertical-align: middle;line-height: 50px;font-size:18px;font-weight: bold;padding-left: 25px;"><?php echo e($CommunityPresenter->comName()); ?></span>
        <span style="vertical-align: middle;line-height: 50px;font-size:16px;padding-left: 15px;"><?php echo e($setting::get('system_name','全方位建築智慧化管理系統')); ?></span>
        <?php /* <ul class="nav navbar-nav navbar-right">
          <li class="hidden-xs">
            <a href="#" class="dk">
              <i class="fa fa-refresh text-white"></i>
            </a>
          </li>
          <li class="hidden-xs">
            <a href="#" class="dk">
              <i class="fa fa-sign-out text-white"></i>
            </a>
          </li>
        </ul> */ ?>
      </div>
    </header>
      <section id="background-section" style="    background-repeat: no-repeat;background-size: cover;background-position: center top;background-attachment: fixed;
">
      <section class="hbox stretch">
        <aside class="bg-primary dk aside-sm nav-vertical no-borders" id="nav">
          <section class="vbox">
            <!-- this is sidebar header -->

            <!-- this is sidebar header -->
            <section>
              
              <nav class="nav-primary hidden-xs">
                <ul class="nav">
                  <li>
                    <a class="btn_home" href="javascript:;">
                      <i class="fa fa-home"></i>
                      <span style="font-size:130%;"><?php echo app('translator')->get('messages.homepage'); ?></span>
                    </a>
                  </li>

                  <li class="">
                    <a href="javascript:;" onclick="window.location.reload()">
                      <i class="fa fa-refresh"></i>
                      <span style="font-size:130%;"><?php echo app('translator')->get('messages.f5'); ?></span>
                    </a>
                  </li>

                  <li class="">
                    <a href="javascript:;" data-toggle="fullscreen">
                      <i class="fa fa-arrows-alt"></i>
                      <span style="font-size:130%;"><?php echo app('translator')->get('messages.f11'); ?></span>
                    </a>
                  </li>

                  <li class="">
                    <a id="btn_keyboard" href="javascript:;">
                      <i class="fa fa-keyboard-o"></i>
                      <span style="font-size:130%;"><?php echo app('translator')->get('messages.keyballll'); ?></span>
                    </a>
                  </li>
                  <hr>
                </ul>
              </nav>
            </section>
            <footer class="footer bg-gradient hidden-xs">
              <a href="<?php echo e(action('MonitorController@lock')); ?>" data-toggle="ajaxModal" class="btn btn-sm btn-link m-r-n-xs pull-right">
                <i class="fa fa-power-off"></i>
              </a>
              <?php /* <a href="#nav" data-toggle="class:nav-vertical" class="btn btn-sm btn-link m-l-n-sm">
                <i class="fa fa-bars"></i>
              </a> */ ?>
            </footer>
          </section>
        </aside>
        <section>
          <div class="wrapper" id="index1">
            <div class="row">
              <div class="col-md-12">
                <ul class="metro">
        <?php if($Setting->get('icon_news') == '1'): ?>
        <?php if($icon_exist['community'] == 'OK'): ?>
                  <li class="btn_link"  data-link="news"> <img src="<?php echo e(url().'/images/app_icon/monitor/monitor_community.png'); ?>" alt="..."style="width: 100%; height:100%"/></li>
        <?php else: ?>
                  <li class="btn_link" data-link="news" style="background: #00b6de;"><i id="btn_test" class="fa fa-gamepad "></i><span><?php echo app('translator')->get('messages.community_announce'); ?></span>
                  <span class="label label-danger" id="announce_unread"></span></li>

        <?php endif; ?>

        <?php endif; ?>

        <?php if($Setting->get('icon_repair') == '1'): ?>
                <?php if($icon_exist['repair'] == 'OK'): ?>
                  <li  class="btn_link" data-link="fault_report"><img src="<?php echo e(url().'/images/app_icon/monitor/monitor_repair.png'); ?>" alt="..." style="width: 100%; height:100%"/></li>
                <?php else: ?>
                  <li class="btn_link" data-link="fault_report" style="background: #ff7659;"><i class="fa fa-cogs"></i><span><?php echo app('translator')->get('messages.malfutn_call_out'); ?></span></li>
                <?php endif; ?>
        <?php endif; ?>
        <?php if($Setting->get('icon_mail') == '1'): ?>
                  <?php if($icon_exist['mail'] == 'OK'): ?>
                      <li class="btn_link" data-link="mail"><img src="<?php echo e(url().'/images/app_icon/monitor/monitor_mail.png'); ?>" alt="..."style="width: 100%; height:100%"/></li>
                  <?php else: ?>
                      <li class="btn_link" data-link="mail" style="background: #f8cd36;"><i class="fa fa-envelope-o"></i><span><?php echo app('translator')->get('messages.mail_checkout'); ?></span><span class="label label-danger" id="mail_unread"></span></li>

                  <?php endif; ?>
        <?php endif; ?>
        <?php if($Setting->get('icon_notice') == '1'): ?>
                  <?php if($icon_exist['notice'] == 'OK'): ?>
                      <li class="btn_link" data-link="message"><img src="<?php echo e(url().'/images/app_icon/monitor/monitor_notice.png'); ?>" alt="..." style="width: 100%; height:100%"/></li>
                  <?php else: ?>
                      <li class="btn_link" data-link="message" style="background: #f26175;"><i class="fa fa-comments-o"></i><span><?php echo app('translator')->get('messages.msg_notice'); ?></span><span class="label label-danger" id="notice_unread"></span></li>
                      
                  <?php endif; ?>
        <?php endif; ?>
        <?php if($Setting->get('icon_album') == '1'): ?>
                  <?php if($icon_exist['album'] == 'OK'): ?>
                  <li class="btn_link" data-link="album"><img src="<?php echo e(url().'/images/app_icon/monitor/monitor_album.png'); ?>" alt="..."style="width: 100%; height:100%"/></li>
                  <?php else: ?>
                  <li class="btn_link" data-link="album" style="background: #5ca7df;"><i class="fa fa-picture-o"></i><span><?php echo app('translator')->get('messages.neighberhood_album'); ?></span></li>
                  <?php endif; ?>
        <?php endif; ?>
        <?php if($Setting->get('icon_gas') == '1'): ?>
                  <?php if($icon_exist['gas'] == 'OK'): ?>
                  <li class="btn_link" data-link="record"><img src="<?php echo e(url().'/images/app_icon/monitor/monitor_gas.png'); ?>" alt="..."style="width: 100%; height:100%"/></li>
                  <?php else: ?>
                  <li class="btn_link" data-link="record"style=" background: #9e7ac2;"><i class="fa fa-music"></i><span><?php echo app('translator')->get('messages.gas_meter_read'); ?></span></li>
                  <?php endif; ?>

        <?php endif; ?>
                  <?php /* <li><i class="fa fa-heart"></i><span><?php echo app('translator')->get('messages.neighberhood_service'); ?></span></li> */ ?>
        <?php if($Setting->get('icon_pubFacility') == '1'): ?>
                  <?php if($icon_exist['pubFacility'] == 'OK'): ?>
                  <li class="btn_link" data-link="inst"><img src="<?php echo e(url().'/images/app_icon/monitor/monitor_pubFacility.png'); ?>" alt="..."style="width: 100%; height:100%"/></li>
                  <?php else: ?>
                  <li class="btn_link" data-link="inst" style=" background: #00b6de;"><i class="fa fa-edit"></i><span><?php echo app('translator')->get('messages.reserve_facility'); ?></span></li>
                  <?php endif; ?>
        <?php endif; ?>
        <?php if($Setting->get('icon_calendar') == '1'): ?>
                  <?php if($icon_exist['calendar'] == 'OK'): ?>
                  <li class="btn_link" data-link="calendar"><img src="<?php echo e(url().'/images/app_icon/monitor/monitor_calendar.png'); ?>" alt="..."style="width: 100%; height:100%"/></li>
                  <?php else: ?>
                  <li class="btn_link" data-link="calendar" style="background: #9e7ac2;"><i class="fa fa-calendar"></i><span><?php echo app('translator')->get('messages.community_calendar'); ?></span></li>
                  <?php endif; ?>

        <?php endif; ?>
                </ul>
              </div>
            </div>
            <i id="right" class="fa fa-chevron-circle-right fa-4x"></i>
          </div>
          <div class="wrapper" id="index2" style="display:none;">
            <div class="row">
              <div class="col-md-12">
                <ul class="metro">
                  <?php /* <li><i class="fa fa-picture-o"></i><span><?php echo app('translator')->get('messages.hihi_place'); ?></span></li> */ ?>
                  
        <?php if($Setting->get('icon_lostfound') == '1'): ?>
                  <?php if($icon_exist['lostfound'] == 'OK'): ?>
                  <li class="btn_link" data-link="lost_thing"><img src="<?php echo e(url().'/images/app_icon/monitor/monitor_lostfound.png'); ?>" alt="..."style="width: 100%; height:100%"/></li>
                  <?php else: ?>
                  <li class="btn_link" data-link="lost_thing" style="background: #f8cd36;"><i class="fa fa-heart"></i><span><?php echo app('translator')->get('messages.lost_and_found'); ?></span></li>
                  <?php endif; ?>
        <?php endif; ?>    
        <?php if($Setting->get('icon_rules') == '1'): ?>
                  <?php if($icon_exist['rules'] == 'OK'): ?>
                  <li class="btn_link" data-link="com"><img src="<?php echo e(url().'/images/app_icon/monitor/monitor_rules.png'); ?>" alt="..."style="width: 100%; height:100%"/></li>
                  <?php else: ?>
                  <li class="btn_link" data-link="com" style="background: #5ca7df;"><i class="fa fa-calendar"></i><span><?php echo app('translator')->get('messages.nei_group_rule'); ?></span></li>
                  <?php endif; ?>
        <?php endif; ?>
                <?php if($icon_exist['intercom'] == 'OK'): ?>
                  <li class="btn_link"  data-link="alarm"><img src="<?php echo e(url().'/images/app_icon/monitor/monitor_intercom.png'); ?>" alt="..."style="width: 100%; height:100%"/>
                  <span class="label label-danger" ></span></li>
                <?php else: ?>
                  <li class="btn_link" data-link="alarm" style="background: #56dea7;"><i id="btn_test" class="fa fa-bell-o"></i><span>對講安防</span>
                  <span class="label label-danger" ></span></li>
                <?php endif; ?>
        <?php if($icon_exist['community'] == 'OK'): ?>
                  <li class="btn_link"  data-link="information"> <img src="<?php echo e(url().'/images/app_icon/monitor/monitor_informaiton.png'); ?>" alt="..."style="width: 100%; height:100%"/></li>
        <?php else: ?>
                  <li class="btn_link" data-link="information" style="background: #00b6de;"><i id="btn_test" class="fa fa-gamepad "></i><span>資訊快遞</span>
                  <span class="label label-danger" id="announce_unread"></span></li>

                  <li class="btn_link" data-link="weather" style="background: #f26175;"><i id="btn_test" class="fa fa-gamepad "></i><span>氣象顯示</span>
                  <span class="label label-danger" id="announce_unread"></span></li>
        <?php endif; ?>
        <?php if($Setting->get('icon_plant') == '1'): ?>
          <?php if($icon_exist['plant'] == 'OK'): ?>
              <li class="btn_link" data-link="plant">
                <img src="<?php echo e(url().'/images/app_icon/monitor/monitor_plant.png'); ?>" alt="..."style="width: 100%; height:100%"/>
              </li>
          <?php else: ?>
              <li class="btn_link" data-link="plant" style="background: #56dea7;">
                <i class="fa fa-leaf"></i>
                <span>植栽維養</span>
                <span class="label label-danger" id="plant_unread"></span>
              </li>
          <?php endif; ?>
        <?php endif; ?>
                </ul>
              </div>
            </div>
            <i id="left" class="fa fa-chevron-circle-left fa-4x"></i>
          </div>
          <div class="wrapper" id="content" style="display:none;">
            
          </div>
        </section>

      </section>
      
      
    </section>
    <footer class="footer bg-dark">
      <p><?php echo e($setting::get('copyright_1','2015 © NSST 全方位建築智慧化管理系統')); ?> <?php echo e($setting::get('copyright_company','新保科技有限公司')); ?></p>
    </footer>
  </section>
  <script src="<?php echo e(asset('monitor_assets/js/jquery.min.js')); ?>"></script>
  <script src="<?php echo e(asset('assets/global/plugins/jquery-ui/jquery-ui.min.js')); ?>" type="text/javascript"></script>
  <!-- Bootstrap -->
  <script src="<?php echo e(asset('monitor_assets/js/bootstrap.js')); ?>"></script>
  <!-- Sparkline Chart -->
  <script src="<?php echo e(asset('monitor_assets/js/charts/sparkline/jquery.sparkline.min.js')); ?>"></script>
  <!-- App -->
  <script src="<?php echo e(asset('monitor_assets/js/app.js')); ?>"></script>
  <script src="<?php echo e(asset('monitor_assets/js/app.plugin.js')); ?>"></script>
  <script src="<?php echo e(asset('monitor_assets/js/app.data.js')); ?>"></script>
  <script src="<?php echo e(asset('monitor_assets/js/slimscroll/jquery.slimscroll.min.js')); ?>" cache="false"></script>
  <!-- Sparkline Chart -->
  <script src="<?php echo e(asset('monitor_assets/js/charts/sparkline/jquery.sparkline.min.js')); ?>"></script>
  <!-- Easy Pie Chart -->
  <script src="<?php echo e(asset('monitor_assets/js/charts/easypiechart/jquery.easy-pie-chart.js')); ?>"></script>
  <!-- Morris -->
  <script src="<?php echo e(asset('/assets/global/scripts/web_socket.js')); ?>"></script>
  <script src="<?php echo e(asset('monitor_assets/js/charts/morris/raphael-min.js')); ?>" cache="false"></script>
  <script src="<?php echo e(asset('monitor_assets/js/charts/morris/morris.min.js')); ?>" cache="false"></script>
  <script src="<?php echo e(asset('assets/global/plugins/bootstrap-toastr/toastr.min.js')); ?>" type="text/javascript" ></script>
  <script src="<?php echo e(asset('assets/global/plugins/pace/pace.min.js')); ?>" type="text/javascript" ></script>
  <script type="text/javascript" src="<?php echo e(asset('assets/global/plugins/jquery-keyboard/jqkeyboard-min.js')); ?>"></script>
  <script type="text/javascript" src="<?php echo e(asset('assets/global/plugins/jquery-keyboard/jqk.layout.en.js')); ?>"></script>

  <script src="<?php echo e(asset('monitor_assets/js/fuelux/fuelux.js')); ?>"></script>
  <script type="text/javascript">
  $(document).ready(function(){
    if("<?php echo e($icon_exist['background']); ?>"=="OK"){
      $('#background-section').css('background-image', "url(<?php echo e(url().'/images/app_icon/monitor/monitor_background.png'); ?>)");

    }

            connect();
            jqKeyboard.init();
            $.ajax({
            type : 'GET',
            url  : '<?php echo e(action('MonitorController@getPushTips')); ?>',
            data : {
              link : $(this).data('link'),
            },
            success : function(html){
              if(html.community>0){
                $("#announce_unread").html(html.community);
              }else{
                $("#announce_unread").html("");
              }
              if(html.notice>0){
                $("#notice_unread").html(html.notice);
              }else{
                $("#notice_unread").html("");
              }
              if(html.mail>0){
                $("#mail_unread").html(html.mail);
              }else{
                $("#mail_unread").html("");
              }
            },
            error : function(){
              toastr['error']('<?php echo app('translator')->get('messages.loading_fail_retry'); ?>');
            }
          });


  });
function getRefreshTime() {
  var Time_Sec = 18001 - reciprocal();
  if(Time_Sec < 60){
    $('#reciprocal_time').css("color","red");
    $('#css_refresh').css("color","red");
  } 
  var Time_Hour = Math.floor((Time_Sec % ( 24 * 3600 )) / 3600 );
  var Time_Min = Math.floor((Time_Sec % 3600 ) / (60));
  var Time_Sec_ = Math.floor(Time_Sec % 60);
  var Time_All = Time_Hour + "時" + Time_Min + "分" + Time_Sec_ + "秒後重整";
  var NowDate = new Date();
  var min = NowDate.getMinutes();
  var sec = NowDate.getSeconds();
  if( (min == 0 && sec < 1) || (min == 30 && sec < 1) ){
    socketAction_monitor('update_monitor');
  }
  if(Time_Sec_ < 0){
    Time_All = "正在重新載入頁面";
  }
  $('#reciprocal_time').text(Time_All);
  window.setTimeout('getRefreshTime()',1000);
}

refresh_start_date = new Date();
refresh_start_time = refresh_start_date.getTime();

function reciprocal() { 
  var myDate = new Date(); 
  var time_Now = myDate.getTime(); 
  var time_Diff = time_Now - refresh_start_time;
  this.diffSecs = time_Diff / 1000;
  return(this.diffSecs);
}

function connect() {
       // 创建websocket
       ws = new WebSocket("ws://<?php echo e(env('WS_HOST','www.nsst.tw')); ?>:<?php echo e(env('WS_PORT','7272')); ?>");
       // 当socket连接打开时，输入用户名
       ws.onopen = onopen;
       // 当有消息时根据消息类型显示不同信息
       ws.onmessage = onmessage; 
       ws.onclose = function() {
        console.log("關閉連線，等待重新嘗試");
          connect();
       };
       ws.onerror = function() {
        console.log("出現錯誤");
       };
    }

    // Send Login Message on connected.
    function onopen()
    {
        // Login
        var login_data = '{"type":"login","client_uid":"'+name+'","com_id":"<?php echo e(env('DB_DATABASE')); ?>"}';
        console.log("WebSocket shakehand success:"+login_data);
        ws.send(login_data);
    }

    // 服务端发来消息时
    function onmessage(e)
    {
        var data = eval("("+e.data+")");
        switch(data['type']){
            // 服务端ping客户端
            case 'ping':
                ws.send('{"type":"pong"}');
                break;;
            case 'system':
              // toastr[data['level']](data['content']);
              break;
            case 'action':
            if(data['action'] == "update_monitor"||data['action'] == "add_monitor"||data['action'] == "group_update"||data['action'] == "solo_update"){
              socketAction_monitor(data['action']);
            }
              
              break;
        }
    }
function socketAction_monitor(action)
    {
      $.ajax({
            type : 'GET',
            url  : '<?php echo e(action('MonitorController@getPushTips')); ?>',
            data : {
              link : $(this).data('link'),
            },
            success : function(html){
              if(html.community>0){
                $("#announce_unread").html(html.community);
              }else{
                $("#announce_unread").html("");
              }
              if(html.news>0){
                $("#news_unread").html(html.news);
              }else{
                $("#news_unread").html("");
              }
              if(html.meet>0){
                $("#meeting_unread").html(html.meet);
              }else{
                $("#meeting_unread").html("");
              }
              if(html.activity>0){
                $("#party_unread").html(html.activity);
              }else{
                $("#party_unread").html("");
              }
              if(html.account>0){
                $("#pay_unread").html(html.account);
              }else{
                $("#pay_unread").html("");
              }
              if(html.tender>0){
                $("#hiii_unread").html(html.tender);
              }else{
                $("#hiii_unread").html("");
              }
              if(html.coupon>0){
                $("#gd_unread").html(html.coupon);
              }else{
                $("#gd_unread").html("");
              }
            },
            error : function(){
              toastr['error']('<?php echo app('translator')->get('messages.loading_fail_retry'); ?>');
            }
          });
      } 
$(document).on('click','#right',function(){
  $('#index1').fadeOut(function(){
    $('#index2').fadeIn();
  });
});

$(document).on('click','#left',function(){
  $('#index2').fadeOut(function(){
    $('#index1').fadeIn();
  });
});

$(document).on('click','.btn_home',function(){
  // clear_page();
  // $('#content').fadeOut(function(){
  //   $('#index1').fadeIn();
  // });
  window.location.reload();
});

$(document).on('click','#btn_keyboard',function(){
  $('#jq-keyboard').show();
});



var clear_page = function(){
  $('#index1').fadeOut();
  $('#index2').fadeOut();
  $('#content').fadeOut();
  return true;
}

var clear_content = function(){
  $('#content').html('');
}


$(document).on('click','.btn_link',function(){
  $.ajax({
    type : 'GET',
    url  : '<?php echo e(action('MonitorController@link')); ?>',
    data : {
      link : $(this).data('link'),
      page : $(this).data('page'),
      
    },
    success : function(html){
      if(clear_page() == true){
        $('#content').html(html);
        $('#content').fadeIn();
      }
    },
    error : function(){
      toastr['error']('<?php echo app('translator')->get('messages.loading_fail_retry'); ?>');
    }
  });
});

$(document).on('click','.btn_news_list',function(){
    console.log($(this).data('page'));
  $.ajax({
    type: 'GET',
    url: '<?php echo e(action('MonitorController@newsList')); ?>',
    data:{
      type : $(this).data('type'),
      page : $(this).data('page')
    },
    success: function(html){
      clear_page();
      $('#content').html(html);
      $('#content').fadeIn();
    },
    error : function(){
      toastr['error']('<?php echo app('translator')->get('messages.loading_fail_retry'); ?>');
    }
  });
});

$(document).on('click','.btn_news_view',function(){
  $.ajax({
    type: 'GET',
    url: '<?php echo e(action('MonitorController@newsView')); ?>',
    data:{
      type : $(this).data('type'),
      id : $(this).data('id')
    },
    success: function(html){
      clear_page();
      $('#content').html(html);
      $('#content').fadeIn();
    },
    error : function(){
      toastr['error']('<?php echo app('translator')->get('messages.loading_fail_retry'); ?>');
    }
  });
});

$(document).on('click','.btn_album_list',function(){
  $.ajax({
    type: 'GET',
    url: '<?php echo e(action('MonitorController@albumList')); ?>',
    data:{
      id : $(this).data('id'),
      page : $(this).data('page')
    },
    success: function(html){
      clear_page();
      $('#content').html(html);
      $('#content').fadeIn();
    },
    error : function(){
      toastr['error']('<?php echo app('translator')->get('messages.loading_fail_retry'); ?>');
    }
  });
});

$(document).on('click','.btn_album_view',function(){
  $.ajax({
    type: 'GET',
    url: '<?php echo e(action('MonitorController@albumView')); ?>',
    data:{
      id : $(this).data('id'),
      page : $(this).data('page')
    },
    success: function(html){
      clear_page();
      $('#content').html(html);
      $('#content').fadeIn();
    },
    error : function(){
      toastr['error']('<?php echo app('translator')->get('messages.loading_fail_retry'); ?>');
    }
  });
});

$(document).on('click','.btn_record_submit',function(){
  $.ajax({
    type : 'GET',
    url : '<?php echo e(action('MonitorController@recordSubmit')); ?>',
    data : {
      id : $(this).data('id'),
      value : $('#record_'+$(this).data('id')).val()
    },
    success : function(sendback){
      toastr['success']('<?php echo app('translator')->get('messages.update_success'); ?>');
    },
    error : function(sendback){
      toastr['error']('<?php echo app('translator')->get('messages.update_failll'); ?>');
    }
  })
});

$(document).on('click','.btn_cal_list',function(){
  $.ajax({
    type: 'GET',
    url: '<?php echo e(action('MonitorController@calList')); ?>',
    data:{
      id : $(this).data('id'),
      page : $(this).data('page')
    },
    success: function(html){
      if(clear_page() == true){
        $('#content').html(html);
        $('#content').fadeIn();
      }
    },
    error : function(){
      toastr['error']('<?php echo app('translator')->get('messages.loading_fail_retry'); ?>');
    }
  });
});

$(document).on('click','.btn_inst_cancel',function(){
  $.ajax({
    type : 'GET',
    url : '<?php echo e(action('MonitorController@instCancel')); ?>',
    data : {
      id : $(this).data('id'),
    },
    success : function(sendback){
      toastr['success']('<?php echo app('translator')->get('messages.can_bookform_suc'); ?>');
    },
    error : function(sendback){
      toastr['error']('<?php echo app('translator')->get('messages.can_fail_f5'); ?>');
    }
  })
});

$(document).on('change','select[name="inst_id"]',function(){
  $.ajax({
    type : 'GET',
    url : '<?php echo e(action('MonitorController@instAction')); ?>',
    data : {
      type : 'select_inst',
      inst_id : $(this).val()
    },
    success : function (sendback){
      $('select[name="date"]').html('');
      $.each(sendback.days , function(key,value){

        $('select[name="date"]').append('<option value="'+value+'">'+value+'</option>');
      })
      $('#form-group-date').show();
      $('.form-group').show();
      if(sendback.person == 0){
        $('select[name="person"]').html('<option value="0"><?php echo app('translator')->get('messages.box_rule'); ?></option>');
      }else{
        $('select[name="person"]').html('');
        for (var i=1;i<sendback.person;i++){
          $('select[name="person"]').append('<option value="'+i+'">'+i+'</option>')
        }
      }
    },
    error : function(sendback){
      toastr['error']('<?php echo app('translator')->get('messages.got_fail_f5'); ?>');
    }
  })
}); 

$(document).on('click','select[name="date"]',function(){
  $.ajax({
    type : 'GET',
    url : '<?php echo e(action('MonitorController@instAction')); ?>',
    data : {
      type : 'select_date',
      inst_id : $('select[name="inst_id"]').val(),
      date : $(this).val()
    },
    success : function (sendback){
      $('select[name="time_section"]').html('');
      $.each(sendback , function(key,value){
        $('select[name="time_section"]').append('<option value="'+value+'">'+value+'</option>')
      });
      $('#form-group-timesection').show();
      
    },
    error : function(sendback){
      toastr['error']('<?php echo app('translator')->get('messages.got_fail_f5'); ?>');
    }
  })
}); 

$(document).on('click','#btn_inst_submit',function(){
  var inst_id = $('select[name="inst_id"]').val();
  var date = $('select[name="date"]').val();
  var time_section = $('select[name="time_section"]').val();
  var person = $('select[name="person"]').val();
  var point_type = $('select[name="point_type"]').val();

  if(inst_id == '' || date == '' || time_section == '' || person == '' || point_type == ''){
    toastr['error']('<?php echo app('translator')->get('messages.fill_not_yet'); ?>');
  }else{
    $.ajax({
      type : 'GET',
      url : '<?php echo e(action('MonitorController@instAction')); ?>',
      data : {
        type : 'inst_submit',
        inst_id : inst_id,
        date : date,
        time_section : time_section,
        person : person,
        point_type : point_type,
        platform: "monitor"
      },
      success : function(sendback){
        if(sendback.check === false){
          $.each(sendback.message, function( index, value ) {
            toastr['warning'](value);
          });
        }else{
          toastr['success']('<?php echo app('translator')->get('messages.suc_send_book_form'); ?>');
          $.ajax({
            type : 'GET',
            url  : '<?php echo e(action('MonitorController@link')); ?>',
            data : {
              link : 'inst'
            },
            success : function(html){
              if(clear_page() == true){
                $('#content').html(html);
                $('#content').fadeIn();
              }
            },
            error : function(){
              toastr['error']('<?php echo app('translator')->get('messages.loading_fail_retry'); ?>');
            }
          });
        }
      },
      error : function(sendback){
        toastr['error']('<?php echo app('translator')->get('messages.fail_send_f5'); ?>');
      }
    })
  }
});

$(document).on('change','#planting_id',function(){
  $.ajax({
    type : 'GET',
    url  : '<?php echo e(action('MonitorController@plant')); ?>',
    data : {
      mode : 'getTimeSection',
      planting_id : $('#planting_id').val(),
    },
    success : function(sendback){
      $('#planting_time_section').empty();
      for(var i=0;i<sendback.each_section.length;i++){
        $('#planting_time_section').append('<option value="' + sendback.each_section[i] + '">' + sendback.each_section[i] + '</option>')
      }
    },
    error : function(){
      toastr['error']('<?php echo app('translator')->get('messages.loading_fail_retry'); ?>');
    }
  });
});

$(document).on('click','#btn_PlantingCreateOrder',function(){
  $('#btn_PlantingCreateOrder').prop('disabled',true);
  $.ajax({
    type : 'GET',
    url  : '<?php echo e(action('MonitorController@plant')); ?>',
    data : {
      mode : 'setOrder',
      planting_id : $('#planting_id').val(),
      date : $('#planting_date').val(),
      time_section : $('#planting_time_section').val()
    },
    success : function(sendback){
      if(sendback.message == ''){
        toastr['success']('申請成功');
        $.ajax({
          type : 'GET',
          url  : '<?php echo e(action('MonitorController@link')); ?>',
          data : {
            link : 'plant',
          },
          success : function(html){
            if(clear_page() == true){
              $('#content').html(html);
              $('#content').fadeIn();
            }
          },
          error : function(){
            toastr['error']('<?php echo app('translator')->get('messages.loading_fail_retry'); ?>');
          }
        });
      }else{
        toastr['warning'](sendback.message);
        $('#btn_PlantingCreateOrder').prop('disabled',false);
      }
    },
    error : function(sendback){
      toastr['error'](sendback.message);
      $('#btn_PlantingCreateOrder').prop('disabled',false);
    }
  });
});

$(document).on('click','.btn_PlantCancel',function(){
  var uid = $(this).attr('uid');
  $.ajax({
    type : 'GET',
    url  : '<?php echo e(action('MonitorController@plant')); ?>',
    data : {
      mode : 'cancel',
      uid  : uid
    },
    success : function(sendback){
      if(sendback.message == ''){
        toastr['success']('預約單已成功取消');
        $.ajax({
          type : 'GET',
          url  : '<?php echo e(action('MonitorController@link')); ?>',
          data : {
            link : 'plant',
          },
          success : function(html){
            if(clear_page() == true){
              $('#content').html(html);
              $('#content').fadeIn();
            }
          },
          error : function(){
            toastr['error']('<?php echo app('translator')->get('messages.loading_fail_retry'); ?>');
          }
        });
      }else{
        toastr['warning'](sendback.message);
      }
    },
    error : function(){
      toastr['error']('<?php echo app('translator')->get('messages.loading_fail_retry'); ?>');
    }
  });
});

$(document).on('click','#btn_logout',function(){
  var logout_password = $('#logout_password').val();
  if(logout_password != ''){
    $.ajax({
      type : 'GET',
      url : '<?php echo e(action('MonitorController@logoutCheck')); ?>',
      data : {
        password : logout_password
      },
      success : function(sendback){
        toastr['success']('<?php echo app('translator')->get('messages.suc_logout'); ?>');
        window.location.reload();
      },
      error : function(sendback){
        toastr['error']('<?php echo app('translator')->get('messages.error_psd_retry'); ?>');
      }
    });
  }else{
    toastr['error']('<?php echo app('translator')->get('messages.enter_man_psd'); ?>');
  }
});

$(document).on('click','.btn_information_list',function(){
    console.log($(this).data('page'));
  $.ajax({
    type: 'GET',
    url: '<?php echo e(action('MonitorController@information')); ?>',
    data:{
      type : $(this).data('type'),
      page : $(this).data('page')
    },
    success: function(html){
      clear_page();
      $('#content').html(html);
      $('#content').fadeIn();
    },
    error : function(){
      toastr['error']('<?php echo app('translator')->get('messages.loading_fail_retry'); ?>');
    }
  });
});

$(document).on('click','.btn_important_information_list',function(){
    console.log($(this).data('page'));
  $.ajax({
    type: 'GET',
    url: '<?php echo e(action('MonitorController@important_information')); ?>',
    data:{
      type : $(this).data('type'),
      page : $(this).data('page')
    },
    success: function(html){
      clear_page();
      $('#content').html(html);
      $('#content').fadeIn();
    },
    error : function(){
      toastr['error']('<?php echo app('translator')->get('messages.loading_fail_retry'); ?>');
    }
  });
});

$(document).on('click','.btn_health_list',function(){
    console.log($(this).data('page'));
  $.ajax({
    type: 'GET',
    url: '<?php echo e(action('MonitorController@health')); ?>',
    data:{
      type : $(this).data('type'),
      page : $(this).data('page')
    },
    success: function(html){
      clear_page();
      $('#content').html(html);
      $('#content').fadeIn();
    },
    error : function(){
      toastr['error']('<?php echo app('translator')->get('messages.loading_fail_retry'); ?>');
    }
  });
});

$(document).on('click','.btn_weather_list',function(){
    console.log($(this).data('page'));
  $.ajax({
    type: 'GET',
    url: '<?php echo e(action('MonitorController@weather')); ?>',
    data:{
      type : $(this).data('type'),
      page : $(this).data('page')
    },
    success: function(html){
      clear_page();
      $('#content').html(html);
      $('#content').fadeIn();
    },
    error : function(){
      toastr['error']('<?php echo app('translator')->get('messages.loading_fail_retry'); ?>');
    }
  });
});

$(document).on('click','.btn_message_view',function(){
  $.ajax({
    type: 'GET',
    url: '<?php echo e(action('MonitorController@messageList')); ?>',
    data:{
      id : $(this).data('id')
    },
    success: function(html){
      clear_page();
      $('#content').html(html);
      $('#content').fadeIn();
    },
    error : function(){
      toastr['error']('<?php echo app('translator')->get('messages.loading_fail_retry'); ?>');
    }
  });
});

$(document).on('click','.btn_traffic_list',function(){
    console.log($(this).data('page'));
  $.ajax({
    type: 'GET',
    url: '<?php echo e(action('MonitorController@traffic')); ?>',
    data:{
      type : $(this).data('type'),
      page : $(this).data('page')
    },
    success: function(html){
      clear_page();
      $('#content').html(html);
      $('#content').fadeIn();
    },
    error : function(){
      toastr['error']('<?php echo app('translator')->get('messages.loading_fail_retry'); ?>');
    }
  });
});

</script>
</body>
</html>