<!DOCTYPE html>

<html lang="zh-CN">



<head>

  <meta charset="UTF-8">

  <meta name="viewport" content="width=device-width, initial-scale=1.0">

  <title><?php echo $_LANG['zjmf_client_setting']; ?></title>

  <link rel="stylesheet" href="modules/servers/zjmfcloud/templates/server_innerpage/css/embed/bootstrap.min.css">

  <link rel="stylesheet" href="modules/servers/zjmfcloud/templates/server_innerpage/css/embed/selectFilter.css">

  <link rel="stylesheet" href="modules/servers/zjmfcloud/templates/server_innerpage/css/embed/global.css">

  <link rel="stylesheet" href="modules/servers/zjmfcloud/templates/server_innerpage/css/embed/01setting.css">



  <script src="modules/servers/zjmfcloud/templates/server_innerpage/lib/embed/jquery.min.js"></script>

  <script src="modules/servers/zjmfcloud/templates/server_innerpage/lib/embed/bootstrap.min.js"></script>

  <script src="modules/servers/zjmfcloud/templates/server_innerpage/lib/embed/sweetAlert2.min.js"></script>

</head>



<body>

  <div class="container">

    <div class="row">

      <?php if((count($useIso) == 0 && $host_type == 'hyperv') || (count($useIso) <= 2 && $host_type != 'hyperv')){ ?>

      <div class="col-12 col-md-6">

        <div class="mountingISO">

          <div class="public_title">

            <span class="public_title_text"><?php echo $_LANG['zjmf_client_setting_ios']; ?></span>

            <!-- <ul class="public_title_ul">

              <li></li>

              <li></li>

              <li></li>

            </ul> -->

          </div>

          <div class="mountingISO_select">

            <div class="selectItem">

              <div class="iso-box">

                <div class="filter-text">

                  <input class="filter-title" type="text" readonly placeholder="<?php echo $_LANG['zjmf_client_security_rules_select']; ?>" />

                  <i class="icon icon-filter-arrow"></i>

                </div>

                <select id="iso" name="filter">

                   <?php 

          				    if($node_isos['data']){

            				    foreach($node_isos['data'] as $v){

                          foreach($v['info'] as $info){

                            echo sprintf('<option value="%d">%s</option>', $info['id'], $info['name']);

                          }

                        }

                      }else{

                    ?>

              				<option value="" disabled><?php echo $_LANG['zjmf_client_setting_ios_ondata']; ?></option>

                   <?php } ?>

                </select>

              </div>

            </div>

          </div>

          <div class="mountingISO_btn">

            <button class="btn_main purple" id="mountingISOBtn"><?php echo $_LANG['zjmf_client_nat_web_confirm']; ?></button>

          </div>

        </div>

      </div>

      <?php } ?>

      <?php if($host_type != 'hyperv'){ ?>

      <div class="col-12 col-md-6">

        <div class="startupItem">

          <div class="public_title">

            <span class="public_title_text"><?php echo $_LANG['zjmf_client_setting_setboot']; ?></span>

            <!-- <ul class="public_title_ul">

              <li></li>

              <li></li>

            </ul> -->

          </div>

          <div class="startupItem_select">

            <div class="selectItem">

              <div class="startup-box">

                <div class="filter-text">

                  <input class="filter-title" type="text" readonly placeholder="<?php echo $_LANG['zjmf_client_security_rules_select']; ?>" />

                  <i class="icon icon-filter-arrow"></i>

                </div>

                <select id="drive" name="filter">

				  <?php foreach($bootorder as $key=>$val){ if($key==$useBootorder) $selected="selected";else $selected=""; ?>	

                  <option value="<?php echo $key; ?>" <?php echo $selected; ?> ><?php echo $val; ?></option>

                  <?php } ?>

                </select>

              </div>

            </div>

          </div>

          <div class="startupItem_btn">

            <button class="btn_main purple" id="startupItemBtn"><?php echo $_LANG['zjmf_client_nat_web_confirm']; ?></button>

          </div>

        </div>

      </div>

      <?php } ?>

	  <?php if($useIso){ ?>

      <div class="col-12 col-md-6">

        <div class="currentIso">

          <div class="public_title">

            <span class="public_title_text"><?php echo $_LANG['zjmf_client_setting_ios_this']; ?></span>

          </div>

          <div class="currentIso_text">

			<?php foreach($useIso as $v){ ?>

            <div class="iso_item">

              <span class="iso_item_text"><?php echo $v['name']; ?></span>

              <button class="iso_item_uniBtn purple" data-id="<?php echo $v['id']; ?>"><?php echo $_LANG['zjmf_client_setting_unmount']; ?></button>

            </div>

            <?php } ?>

          </div>

        </div>

      </div>

	  <?php } ?>

    </div>

  </div>

  <script type="text/javascript" src="modules/servers/zjmfcloud/templates/server_innerpage/lib/embed/selectFilter.js"></script>

 <script>

	function getUrlParam(name) {

		var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象

		var r = window.location.search.substr(1).match(reg);  //匹配目标参数

		if (r != null) return decodeURI(r[2]); return null; //返回参数值

	}    

	$('.iso-box').selectFilter({

      callBack: function (val) {

        console.log(val + '是返回的值')

      }

    });

    $('.startup-box').selectFilter({

      callBack: function (val) {

        console.log(val + '是返回的值')

      }

    });



    const mountingISOBtn = document.querySelector('#mountingISOBtn')

    const startupItemBtn = document.querySelector('#startupItemBtn')



    if(mountingISOBtn){

      mountingISOBtn.addEventListener('click', function () {

        if($(this).data('disabled') == 'true'){

            return;

        }

        iso_mount_btn = $(this)

        Swal.fire({

          position: 'top',

          title: "<?php echo $_LANG['zjmf_client_setting_mount']; ?>",

          type: 'question',

          showCancelButton: true,

          confirmButtonColor: '#6e9aff',

          cancelButtonColor: '#d33',

          confirmButtonText: "<?php echo $_LANG['zjmf_client_setting_mount_confirm']; ?>",

          cancelButtonText: "<?php echo $_LANG['zjmf_layer_cancel']; ?>"

        }).then((result) => {

          if (result.value) {

            iso_mount_btn.html($('#loading-circle').html());

            iso_mount_btn.data('disabled', 'true');

            ajax({

                type:"post",

                url:"clientarea.php?action=productdetails&id="+getUrlParam('id')+"&ac=setting",

                data:{"func":"mountIso","isoId":$("#iso").val()},

                success:function(data){

                  if(data.status==200){

                    Swal.fire({

                      position: 'top',

                      title: "<?php echo $_LANG['zjmf_check_mount_success']; ?>",

                      type: 'success',

                      confirmButtonColor: '#6e9aff',

                    }).then((isConfirm) => window.location.reload());

                  }else{

                    iso_mount_btn.html("<?php echo $_LANG['zjmf_client_nat_web_confirm']; ?>")

                    iso_mount_btn.data('disabled', 'false')

                    Swal.fire("<?php echo $_LANG['zjmf_check_mount_error']; ?>", data.msg, "error");

                  }

                }

            })

          }

        })

      })

    }



    if(startupItemBtn){

      startupItemBtn.addEventListener('click', function () {

        if($(this).data('disabled') == 'true'){

            return;

        }

        drive_change_btn = $(this)

        Swal.fire({

          position: 'top',

          title: "<?php echo $_LANG['zjmf_client_setting_setboot_change']; ?>",

          type: 'question',

          showCancelButton: true,

          confirmButtonColor: '#6e9aff',

          cancelButtonColor: '#d33',

          confirmButtonText: "<?php echo $_LANG['zjmf_client_setting_setboot_change_y']; ?>",

          cancelButtonText: "<?php echo $_LANG['zjmf_layer_cancel']; ?>"

        }).then((result) => {

          if (result.value) {

            drive_change_btn.html($('#loading-circle').html());

            drive_change_btn.data('disabled', 'true');

            ajax({

                type:"post",

                url:"clientarea.php?action=productdetails&id="+getUrlParam('id')+"&ac=setting",

                data:{"func":"setBootOrder","bootOrderId":$("#drive").val()},

                success:function(data){

                  if(data.status==200){

                    Swal.fire({

                      position: 'top',

                      title: "<?php echo $_LANG['zjmf_client_setting_setboot_change_success']; ?>",

                      type: 'success',

                      confirmButtonColor: '#6e9aff',

                    }).then((isConfirm) => window.location.reload());

                  }else{

                    drive_change_btn.html("<?php echo $_LANG['zjmf_client_nat_web_confirm']; ?>")

                    drive_change_btn.data('disabled', 'false')

                    Swal.fire("<?php echo $_LANG['zjmf_client_setting_setboot_change_error']; ?>", data.msg, "error");

                  }

                    

                }

            })

          }

        })

      })

    }



    $(document).on('click', ".iso_item_uniBtn", function () {

      if($(this).data('disabled') == 'true'){

          return;

      }

      iso_unmount_btn = $(this)

      var id = $(this).data("id")

      Swal.fire({

        position: 'top',

        title: "<?php echo $_LANG['zjmf_client_setting_unmount_ios']; ?>",

        type: 'question',

        showCancelButton: true,

        confirmButtonColor: '#6e9aff',

        cancelButtonColor: '#d33',

        confirmButtonText: "<?php echo $_LANG['zjmf_client_setting_unmount_ios_confirm']; ?>",

        cancelButtonText: "<?php echo $_LANG['zjmf_layer_cancel']; ?>"

      }).then((result) => {

        if (result.value) {

          iso_unmount_btn.html($('#loading-circle').html());

          iso_unmount_btn.data('disabled', 'true');

          ajax({

              type:"post",

              url:"clientarea.php?action=productdetails&id="+getUrlParam('id')+"&ac=setting",

              data:{"func":"unmountIso","unmountIsoId":id},

              success:function(data){

                if(data.status==200){

                  Swal.fire({

                    position: 'top',

                    title: "<?php echo $_LANG['zjmf_check_unmount_success']; ?>",

                    type: 'success',

                    confirmButtonColor: '#6e9aff',

                  }).then((isConfirm) => window.location.reload());

                }else{

                  iso_unmount_btn.html("<?php echo $_LANG['zjmf_client_setting_unmount']; ?>")

                  iso_unmount_btn.data('disabled', 'false')

                  Swal.fire("<?php echo $_LANG['zjmf_check_unmount_error']; ?>", data.msg, "error");

                }

                  

              }

          })

        }

      })

    })

    function ajax(options){

      //创建一个ajax对象

      var xhr = new XMLHttpRequest() || new ActiveXObject("Microsoft,XMLHTTP");

      //数据的处理 {a:1,b:2} a=1&b=2;

      if(typeof(options.data)!='string'){

          var str = "";

          for(var key in options.data){

              str+="&"+key+"="+options.data[key];

          }

          str = str.slice(1)

      }else{

          var str = options.data;

      }

      options.dataType=options.dataType||'json';

      if(options.type == "get"){

          var url = options.url+"?"+str;

          xhr.open("get",url);

          xhr.setRequestHeader("Authorization","JWT eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyaW5mbyI6eyJpZCI6MjM0LCJ1c2VybmFtZSI6Ilx1NGUwZFx1ODk4MVx1NjRjZFx1NGY1Y1x1OGZkOVx1NGUyYVx1OGQyNlx1NjIzNyJ9LCJpc3MiOiJ3d3cuaWRjU21hcnQuY29tIiwiYXVkIjoid3d3LmlkY1NtYXJ0LmNvbSIsImlwIjoiMjIyLjE4Mi41Ny4yMjMiLCJpYXQiOjE2MDM3NjE5OTksIm5iZiI6MTYwMzc2MTk5OSwiZXhwIjoxNjAzNzY5MTk5fQ.lBaBxlop9MvF8IF2PFeVlNMmBmt1wCG09Shbpjn3swQ");

          xhr.send();

      }else if(options.type == "post"){

          xhr.open("post",options.url);

          xhr.setRequestHeader("content-type","application/x-www-form-urlencoded");

          xhr.setRequestHeader("Authorization","JWT eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyaW5mbyI6eyJpZCI6MjM0LCJ1c2VybmFtZSI6Ilx1NGUwZFx1ODk4MVx1NjRjZFx1NGY1Y1x1OGZkOVx1NGUyYVx1OGQyNlx1NjIzNyJ9LCJpc3MiOiJ3d3cuaWRjU21hcnQuY29tIiwiYXVkIjoid3d3LmlkY1NtYXJ0LmNvbSIsImlwIjoiMjIyLjE4Mi41Ny4yMjMiLCJpYXQiOjE2MDM3NjE5OTksIm5iZiI6MTYwMzc2MTk5OSwiZXhwIjoxNjAzNzY5MTk5fQ.lBaBxlop9MvF8IF2PFeVlNMmBmt1wCG09Shbpjn3swQ");

          xhr.send(str)

      }

      //监听

      xhr.onreadystatechange = function(){

          //当请求成功的时候

          if(xhr.readyState == 4 && xhr.status == 200){

              var d = xhr.responseText;

              d = JSON.parse(d);

              //将请求的数据传递给成功回调函数

              options.success&&options.success(d)

          }else if(xhr.status != 200){

              //当失败的时候将服务器的状态传递给失败的回调函数

              options.error&&options.error(xhr.status);

          }

      }

    }

  </script>

</body>



</html>