// 定义服务器端域名
var javaApi = '/api/swagger/';
// var  mineName = '麦垛山煤矿';
// var  mineName = '枣泉煤矿';
// var  mineName = 'E信管理';
var  mineName = '智慧洗煤厂';
// 枣泉
// var URLjava = 'http://zaoquan.nxjiewei.com:8011'+javaApi;
// var URLjava = 'http://colliery.nxjiewei.com'+javaApi;
// var URLjava = 'http://192.168.0.109:8080/';
// var urlphp = 'http://colliery.nxjiewei.com/';
// 工单上传图片和文件地址
// var urlphp = 'http://zaoquan.nxjiewei.com:8011/';
var ceshiUrl = 'http://47.105.143.227:8083/';//测试地址java
// 设备物资，固定电缆
// var urlJavaOld = 'http://nxjiewei.com/colliery-system/api/page/v1/eqByNameList.html'
// var URLjava = 'http://apptest.jieweizhineng.com'+javaApi;
// 麦陀山
// var URLjava = 'http://maiduoshan.nxjiewei.com'+javaApi;
// var urlphp = 'http://maiduoshan.nxjiewei.com/';
// 宁东运营部
// var URLjava = 'http://ningdongyunying.nxjiewei.com'+javaApi;
// var urlphp = 'http://ningdongyunying.nxjiewei.com/';
// 智慧洗煤厂
var URLjava = 'http://xixuan.nxjiewei.com'+javaApi;
var urlphp = 'http://xixuan.nxjiewei.com/';
var UrlRouter = {
    loginApi:urlphp+'api/oauth/token',//登录
    vcodeApi:urlphp+'api/sms/vcode',//发送验证吗
    setApi:urlphp+'api/user/mobile/set',//绑定手机号
    repasswordApi:urlphp+'api/user/repassword',//修改密码
    bannerApi:urlphp+'api/scrollImg/list',//banner
    nwesApi:urlphp+'api/article/list',//新闻
    NoticeApi:urlphp+'api/notice/list',//公告
    ImgApi:urlphp+'api/homeNav/list',//图片导航
    DistrictteamApi:urlphp+'api/home/links',//区队
    userInfoApi:urlphp+'api/user/info',//个人信息
    findMessageApi:URLjava+'api/dynamic/v1/findMessage/',//消息列表   二维码 、 巡检记录
    getPageDynamicApi:URLjava+'api/dynamic/v1/getPageDynamic',//获取二维码列表
    getRecordDynamicApi:URLjava+'api/dynamic/v1/getRecordDynamic',//获取巡检列表
    addPageDynamicApi:URLjava+'api/dynamic/v1/addPageDynamic',//已读二维码
    addRecordDynamicApi:URLjava+'api/dynamic/v1/addRecordDynamic',//已读巡检记录
    regionApi:urlphp+'api/monitor/video/region',//监控列表权限
    // cameraApi:urlphp+'api/monitor/video/camera',//监控子项
    findMessageCount:URLjava+'api/dynamic/v1/findMessageCount/',
    seachQrcode:URLjava+'api/page/v1/getPageList',//查询二维码
    getDeviceValueTypeCode:ceshiUrl+'api/device/v1/getDeviceValueTypeCode/',//查询传感器的数值信息
    getData:ceshiUrl+'api/data/v1/getData',//实时数据查询
    getDeviceInfo:ceshiUrl+'api/device/v1/getDeviceInfo',//查询传感器信息
    searchData:ceshiUrl+'api/data/v1/searchData',//查询传感器实时数据详情
    securityJurisdiction:urlphp+'api/detection/show',//安全监测权限
    getGroupList:urlphp+"api/section/getGroupList",//获取部门列表
    getPersonalList:urlphp+'api/user/list',//获取部门人员
    searchPersonal:urlphp+'api/user/search',//搜索人员
    wordOrderList:urlphp+'api/worksheet/classify/list',//工单分类
    applyList:urlphp+'api/worksheet/design/list',//可申请工单列表
    getApplyD:urlphp+'api/worksheet/design/',//获取可申请工单详情
    submitApply:urlphp+'api/worksheet/apply',//提交工单信息
    getNewsList:urlphp+'api/message/list',//消息列表
    getRead:urlphp+'api/message/read',//已读消息
    getNewsNum:urlphp+'api/message/unread_num',//消息总数
    thumbs:urlphp+'api/user/like/post',//点赞or取消点赞
    comment:urlphp+'api/user/comment/post',//提交留言
    delComment:urlphp+'api/user/comment/del',//删除留言
    simulationTotal:urlphp+'api/safety/simulation/total',//模拟量统计
    sluicetTotal:urlphp+'api/safety/sluice/total',//开关量统计
    safetyDetaile:urlphp+'api/safety/info/total',//安全数据详情
    downWellTotal:urlphp+'api/personnel/month/total',//一周下井趋势
    currentPersonalNum:urlphp+'api/personnel/now',//一周下井趋势当前人数
    getBanNowDayTotal:URLjava+'api/pdcban/v1/getBanNowDayTotal',//今日产量
    getBanDayList:URLjava+'/api/pdcban/v1/getBanDayList',//一周的产量
    getMonthSumByYear:URLjava+'api/pdcban/v1/getMonthSumByYear',//一年的产量
    getBulletin:urlphp+'api/dispatch/bulletin',//生产数据公告
    getSchedule:urlphp+'api/dispatch/schedule',//调度统计
    getAlarmData:urlphp+'api/safety/alarm',//报警分类
    getGasData:urlphp+'api/safety/methane',//瓦斯异常情况
    getChangMessageList:URLjava+'api/dynamic/v1/changMessageList/',//二维码和记录置为已读
    chartsJurisdiction:urlphp+'api/dispatch/show',//图表权限
    personalLocation:urlphp+'api/personnel/show',//人员定位权限
    getPersonnalList:urlphp+'api/personnel/region/total',//人员定位列表
    getPersonnalDistributionList:urlphp+'api/personnel/mine/total',//每个矿井人数统计
    getPersonnalDe:urlphp+'api/personnel/mine/people',//人员详情
    searchPeople:urlphp+'api/personnel/people/search',//查询人员定位
    peopleInfo:urlphp+'api/personnel/people/info',//个人详情
    getDayHourTotal:URLjava+'api/pdcban/v1/getDayHourTotal',//皮带称产量
    getPeopleNow:urlphp+'api/personnel/people/now',//当前下井人数
    getOfficeTotal:urlphp+'api/personnel/office/total',//井下人员（部门分布）
    getBasicTotal:urlphp+'api/personnel/basic/total',//基层区队
    getWorkingTotal:urlphp+'api/personnel/working/total',//工作面人数统计
    getDepartToday:urlphp+'api/personnel/depart/today',//各部门人数统计
    getFacilityStatus:urlphp+'api/personnel/facility/status',//人员定位系统设备运行状态
    getTimeout:urlphp+'api/personnel/timeout/total',//人员超时统计
    getHelptotal:urlphp+'api/personnel/help/total',//人员求救统计
    getPersonnelTimeoutDetails:urlphp+'api/personnel/timeout/info',//人员超时统计详情
    getPersonnelHelpDetails:urlphp+'api/personnel/help/info',//人员求救统计详情
    getPersonnelFacilityDetails:urlphp+'api/personnel/facility/info',//人员求救统计详情
    getPersonnelWorkingDetails:urlphp+'api/personnel/working/info',//工作面人员详情
    getPersonneldepartDetails:urlphp+'api/personnel/depart/people',//井下部门分布列表
    getPersonneltodayDetails:urlphp+'api/personnel/depart/people/today',//井下部门分布列表
    getBanDayThree:URLjava+'api/pdcban/v1/getBanDayThree',//一周的产量列表
    getBanNowDayAllTotal:URLjava+'api/pdcban/v1/getBanNowDayAllTotal',//今日产量
    getEfficacyCut:urlphp+'api/dispatch/efficacy/cut',//割煤刀数
    efficacyShow:urlphp+'api/efficacy/show',//效能管控
    getEfficacyInfo:urlphp+'api/dispatch/efficacy/cut/info',//割煤刀数工作面列表
};
var mySwiper;//插件
/**
 * 加载动画
 *
 */
(function( window, undefined ) {
    "use strict";
    var auiToast = function() {
        // this.create();
    };
    var isShow = false;
    auiToast.prototype = {
        create: function(params,callback) {
            var self = this;
            var toastHtml = '';
            switch (params.type) {
                case "success":
                    var iconHtml = '<i class="aui-iconfont aui-icon-correct"></i>';
                    break;
                case "fail":
                    var iconHtml = '<i class="aui-iconfont aui-icon-close"></i>';
                    break;
                case "custom":
                    var iconHtml = params.html;
                    break;
                case "loading":
                    var iconHtml = '<div class="aui-toast-loading"></div>';
                    break;
            }

            var titleHtml = params.title ? '<div class="aui-toast-content">'+params.title+'</div>' : '';
            toastHtml = `<div class="api-toast">
              <div class="aui-toast">${iconHtml+titleHtml}</div>
            </div>`
            if(document.querySelector(".aui-toast"))return;
            document.body.insertAdjacentHTML('beforeend', toastHtml);
            var duration = params.duration ? params.duration : "2000";
            self.show();
            if(params.type == 'loading'){
                if(callback){
                    callback({
                        status: "success"
                    });
                };
            }else{
                setTimeout(function(){
                    self.hide();
                }, duration)
            }
        },
        show: function(){
            var self = this;
            document.querySelector(".aui-toast").style.display = "block";
            document.querySelector(".aui-toast").style.marginTop =  "-"+Math.round(document.querySelector(".aui-toast").offsetHeight/2)+"px";
            if(document.querySelector(".aui-toast"))return;
        },
        hide: function(){
            var self = this;
            if(document.querySelector(".aui-toast")){
                document.querySelector(".api-toast").remove()
            }
        },
        remove: function(){
            if(document.querySelector(".aui-dialog"))document.querySelector(".aui-dialog").parentNode.removeChild(document.querySelector(".aui-dialog"));
            if(document.querySelector(".aui-mask")){
                document.querySelector(".aui-mask").classList.remove("aui-mask-out");
            }
            return true;
        },
        success: function(params,callback){
            var self = this;
            params.type = "success";
            return self.create(params,callback);
        },
        fail: function(params,callback){
            var self = this;
            params.type = "fail";
            return self.create(params,callback);
        },
        custom:function(params,callback){
            var self = this;
            params.type = "custom";
            return self.create(params,callback);
        },
        loading:function(params,callback){
            var self = this;
            params.type = "loading";
            return self.create(params,callback);
        }
    };
    window.auiToast = auiToast;
})(window);
(function( window, undefined ) {
    "use strict";
    var apiToast = function() {
        // this.create();
    };
    var isShow = false;
    apiToast.prototype = {
        create: function(params,callback) {
            var self = this;
            var toastHtml = '';
            switch (params.type) {
                case "success":
                    var iconHtml = '<i class="aui-iconfont aui-icon-correct"></i>';
                    break;
                case "fail":
                    var iconHtml = '<i class="aui-iconfont aui-icon-close"></i>';
                    break;
                case "custom":
                    var iconHtml = params.html;
                    break;
                case "loading":
                    var iconHtml = '<div class="api-toast-loading"></div>';
                    break;
            }

            var titleHtml = params.title ? '<div class="api-toast-content">'+params.title+'</div>' : '';
            toastHtml = `<div class="api-toast">${iconHtml+titleHtml}</div>`
            if(document.querySelector(".api-toast"))return;
            document.body.insertAdjacentHTML('beforeend', toastHtml);
            var duration = params.duration ? params.duration : "2000";
            self.show();
            if(params.type == 'loading'){
                if(callback){
                    callback({
                        status: "success"
                    });
                };
            }else{
                setTimeout(function(){
                    self.hide();
                }, duration)
            }
        },
        show: function(){
            var self = this;
            document.querySelector(".api-toast").style.display = "block";
            document.querySelector(".api-toast").style.marginTop =  "-"+Math.round(document.querySelector(".api-toast").offsetHeight/2)+"px";
            if(document.querySelector(".api-toast"))return;
        },
        hide: function(){
            var self = this;
            if(document.querySelector(".api-toast")){
                document.querySelector(".api-toast").parentNode.removeChild(document.querySelector(".api-toast"));
            }
        },
        remove: function(){
            if(document.querySelector(".api-dialog"))document.querySelector(".api-dialog").parentNode.removeChild(document.querySelector(".api-dialog"));
            if(document.querySelector(".api-mask")){
                document.querySelector(".api-mask").classList.remove("api-mask-out");
            }
            return true;
        },
        success: function(params,callback){
            var self = this;
            params.type = "success";
            return self.create(params,callback);
        },
        fail: function(params,callback){
            var self = this;
            params.type = "fail";
            return self.create(params,callback);
        },
        custom:function(params,callback){
            var self = this;
            params.type = "custom";
            return self.create(params,callback);
        },
        loading:function(params,callback){
            var self = this;
            params.type = "loading";
            return self.create(params,callback);
        }
    };
    window.apiToast = apiToast;
})(window);
/**
 *
 */
/**
 * ajax 封装
 */
(function (window) {
  /**
   ** 带加载效果的ajax
  **/
  var h = {};
  h.fnReuestData = function (pPartUrl,pHeaders,pMethod,pData,pCallback) {
      toast.loading({
          title: "加载中",
          duration: 2000
      });
      var tHeaders = pHeaders? pHeaders :'';
      var tAjax = {
          url:pPartUrl,
          method:pMethod,
          headers:tHeaders,
          dataType:'json',
          data:{
            values:pData
          },
          timeout: 30
      };
      api.ajax(tAjax,function(ret,err){
          if ('function' === typeof pCallback) {
            pCallback(ret,err)
          }
      });
    };
    /**
    *不带低白加载效果
    **/
    h.fnReuestDataNoW = function (pPartUrl,pHeaders,pMethod,pData,pCallback) {
        apiToast.loading({
            title: "加载中",
            duration: 2000
        });
        var tHeaders = pHeaders? pHeaders :'';
        var tAjax = {
            url:pPartUrl,
            method:pMethod,
            headers:tHeaders,
            dataType:'json',
            data:{
              values:pData
            },
            timeout: 30
        };
        api.ajax(tAjax,function(ret,err){
            if ('function' === typeof pCallback) {
              pCallback(ret,err)
            }
        });
      };
    /**
     ** 不带加载效果的ajax
    **/
    h.fnReuestDataNologing = function (pPartUrl,pHeaders,pMethod,pData,pCallback) {
        var tHeaders = pHeaders? pHeaders :'';
        var tAjax = {
            url:pPartUrl,
            method:pMethod,
            headers:tHeaders,
            dataType:'json',
            data:{
              values:pData
            },
            timeout: 30
        };
        api.ajax(tAjax,function(ret,err){
            if ('function' === typeof pCallback) {
              pCallback(ret,err)
            }
        });
      };
      h.fnReuestDataJSON = function (pPartUrl,pHeaders,pMethod,pData,pCallback) {
          toast.loading({
              title: "加载中",
              duration: 2000
          });
          var tHeaders = pHeaders? pHeaders :'';
          var tAjax = {
              url:pPartUrl,
              method:pMethod,
              contentType:'application/json',
              headers:tHeaders,
              dataType:'json',
              data:{
                values:pData
              },
              timeout: 30
          };
          api.ajax(tAjax,function(ret,err){
              if ('function' === typeof pCallback) {
                pCallback(ret,err)
              }
          });
        };
    window.$http = h;
}(window));
/**
 * 常用方法
 */
(function (window) {
    var e = {};
    /**
     * 封装消息发送时间
     */
    e.sendEvent = function (name,extra) {
        api.sendEvent({
            name: name,
            extra: extra
        });
    };
    /**
     * 消息监听事件
     */
    e.addEventListener = function (name,callback) {
        api.addEventListener({
            name: name
        }, function(ret, err){
            callback(ret)
        });
    };
    /**
     *  滑动底部监听事件
     */
    e.scrollBottomListener = function (callback,threshold) {
        api.addEventListener({
            name: 'scrolltobottom',
            extra:{
                threshold: threshold || 0
            }
        }, function(ret, err){
            callback(ret)
        });
    };
    /**
     * frame
     *
     */
    e.openFrame = function (name,headers,footer,pageParam,otherParam){
      var headerH = headers ? $api.dom(headers).offsetHeight : 0;
      var footetH = footer ? $api.dom(footer).offsetHeight : 0;
      api.openFrame({
        name: name,
        url: name + '.html',
        bounces: true,
        scrollEnabled:false,
        hScrollBarEnabled:false,
        progress:{
            type:'page'
        },
        animation:{
          type:'fade'
        },
        rect: {
          x: 0,
          y: headerH,
          w: 'auto',
          h: 'auto'
        },
        pageParam: api.pageParam || {}
      });
    };
    /**
    *打开弹出框
    *
    **/
    e.openPopup = function (w,h,name,pageParam) {
      api.openFrame({
        name: name,
        url: name + '.html',
        bgColor:'rgba(0,0,0,.6)',
        bounces: false,
        rect: {
          x: 0,
          y: 0,
          w: w,
          h: h
        },
        animation:{
          type:'fade'
        },
        pageParam: pageParam
      });
    }
    /**
     * Win
     *
     */
     e.openWin = function (winName,winUrl,pageParam,otherParam) {
       var param = {
           name:winName,
           url:winUrl+'.html',
           scrollEnabled:false,
           hScrollBarEnabled:false,
           pageParam:pageParam,
           animation: {
             type:'fade',
             duration:450
          }
       }
       Object.assign(param,otherParam|| {});
       api.openWin(param)
     }
     /**
     ** openTabLayout
     **/
     e.openTabLayout = function (name,url,title,value) {
        var param = {
          name: name,
          url: url+'.html',
          bgColor: '#fff',
          title: title,
          bounces: true,
          navigationBar: {
             height:'50',
             background:'#009fe8',
             color:'#fff'
          },
          pageParam:value
        }
       api.openTabLayout(param);
     }
     /**
     ** 提示框无网络
     **/
     e.tips = function (el,text) {
       var str = `<div id="tips">
                   <p>
                     <i></i>
                     ${text}
                   </p>
                 </div>`;
       $api.append($api.dom(el),str);
     }
     e.removeTips = function (el) {
        $api.remove($api.byId(el));
     }
     /***
      没有内容提示页面
      el = body
      Image显示图片路径
     ***/
     e.NotContent = function (el,elID,Image) {
       var html =  `<div class="noText" id="${elID}">
                     <img src="${Image}" alt="">
                   </div>`;
      $api.append($api.dom(el),html);
     }
    /**
    *删除NotContent
    **/
    e.deletNotContent = function (elID) {
      $api.remove($api.byId(elID));
    }
    window.$event = e;
}(window));
/**
 * 工具累
 *  */
(function(window) {
  var d = {};
    /**
     * append
     * doT模版的封装
     * root DOM名称如ID 或class
     * doT template 名称
     * data ajax返回数据
     */
    d.append = function (root,template,data) {
      var evalText = doT.compile($api.html($api.dom(template)))
      if (typeof root == 'string'){
          $api.append($api.dom(root),evalText(data))
      }else{
        $api.append(root,evalText(data))
      }
    };
   /**
     * html
     * doT模版的封装
     * root DOM名称如ID 或class
     * doT template 名称
     * data ajax返回数据
     */
    d.html = function (root,template,data) {
      var evalText = doT.compile($api.html($api.dom(template)))
      if (typeof root == 'string'){
          $api.html($api.dom(root),evalText(data))
      }else{
        $api.html(root,evalText(data))
      }
    };
    /**
   * after
   * doT模版的封装
   * root DOM名称如ID 或class
   * doT template 名称
   * data ajax返回数据
   */
  d.after = function (root,template,data) {
    var evalText = doT.compile($api.html($api.dom(template)))
    if (typeof root == 'string'){
        $api.after($api.dom(root),evalText(data))
    }else{
      $api.after(root,evalText(data))
    }
  };
  /**
   ** 缓存路径 cache:协议对应的真实目录
  **/
  d.CACHE_DIR = function (url) {
    return api.cacheDir + '/'+ url + '/' + api.frameName + '.json';
  }
  /**
   ** 缓存路径 box://协议对应的真实目录
  **/
  d.BOX_DIR = function () {
    return api.cacheDir + '/'+ url + '/' + api.frameName + '.json';
  }
  /**
   **把数据也入文件做数据缓存处理
  **/
  d.writeFile = function (url,data) {
    api.writeFile({
      path:url,
      data:JSON.stringify(data)
    })
  };
  /**
  **读取文件中缓存的数据
  **/
  d.readFile = function (url,callback) {
    api.readFile({
        path: url
    }, function(ret, err){
        callback(ret,err)
    });
  };
  /**轮播**/
  d.swiper = function (el,loops,type) {
    mySwiper = new Swiper(el, {
        pagination: {
            el: '.swiper-pagination',
            type: type,
        },
        loop:false,
        observer:true,
        observeSlideChildren:true,
        speed:600,
        autoplay: {
        delay: 3000,
        disableOnInteraction: false,
      },
    });
  }
  window.$apis = d
}(window));
/**
 * 面板
 *
 */
(function( window, undefined ) {
    "use strict";
    var auiCollapse = function(params) {
        this.init(params);
    };
    auiCollapse.prototype = {
        init: function(params,callback){
            var collapseHeader = document.querySelectorAll(".aui-collapse-header");
            if(collapseHeader.length){
                for(var i=0;i<collapseHeader.length;i++){
                    (function(e){
                        collapseHeader[e].onclick = function(){
                            if(collapseHeader[e].nextSibling.nextElementSibling.className.indexOf("aui-collapse-content") > -1){
                                if(collapseHeader[e].nextSibling.nextElementSibling.className.indexOf("aui-show") > -1){
                                    collapseHeader[e].nextSibling.nextElementSibling.classList.remove("aui-show");
                                    collapseHeader[e].classList.remove("aui-active");
                                }else{
                                    if(params.autoHide){
                                        if(document.querySelector(".aui-collapse-header.aui-active")){
                                            document.querySelector(".aui-collapse-header.aui-active").classList.remove("aui-active");
                                        }
                                        if(document.querySelector(".aui-collapse-content.aui-show")){
                                            document.querySelector(".aui-collapse-content.aui-show").classList.remove("aui-show");
                                        }
                                    }

                                    collapseHeader[e].nextSibling.nextElementSibling.classList.toggle("aui-show");
                                    collapseHeader[e].classList.toggle("aui-active");
                                }
                            }
                        }
                    })(i)
                }
            }
        }
    };
	window.auiCollapse = auiCollapse;
})(window);
/**
*获取当前时间
*
**/
function getNowFormatDate() {
  var now = new Date();
    var year = now.getFullYear(); //获取年份
    var month = now.getMonth(); //获取月份
    var date = now.getDate(); //获取日期
    var day = now.getDay(); //获取星期
    var hour = now.getHours(); //获取小时
    var minute = now.getMinutes(); //获取分钟
    var seconds = now.getSeconds()<10?'0'+now.getSeconds():now.getSeconds(); //获取秒
    month = month + 1;
    var arr_week = new Array("星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六");
    var week = arr_week[day];
    var time = year + "年" + month + "月" + date + "日 " + week + " " + hour + ":" + minute + ":" + seconds;
    return time;
  }
// 把时间戳转为日期或者时间
function formatDateTime(inputTime){
  let date = new Date(inputTime);
  let y = date.getFullYear();
  let m = date.getMonth() + 1;
  m = m < 10 ? ('0' + m) : m;
  let d = date.getDate();
  d = d < 10 ? ('0' + d) : d;
  let h = date.getHours();
  h = h < 10 ? ('0' + h) : h;
  let minute = date.getMinutes();
  let second = date.getSeconds();
  minute = minute < 10 ? ('0' + minute) : minute;
  second = second < 10 ? ('0' + second) : second;
  return y + '-' + m + '-' + d;
}
/**
*消除300ms延迟
***/
!function(){"use strict";function t(e,o){function i(t,e){return function(){return t.apply(e,arguments)}}var r;if(o=o||{},this.trackingClick=!1,this.trackingClickStart=0,this.targetElement=null,this.touchStartX=0,this.touchStartY=0,this.lastTouchIdentifier=0,this.touchBoundary=o.touchBoundary||10,this.layer=e,this.tapDelay=o.tapDelay||200,this.tapTimeout=o.tapTimeout||700,!t.notNeeded(e)){for(var a=["onMouse","onClick","onTouchStart","onTouchMove","onTouchEnd","onTouchCancel"],c=0,s=a.length;c<s;c++)this[a[c]]=i(this[a[c]],this);n&&(e.addEventListener("mouseover",this.onMouse,!0),e.addEventListener("mousedown",this.onMouse,!0),e.addEventListener("mouseup",this.onMouse,!0)),e.addEventListener("click",this.onClick,!0),e.addEventListener("touchstart",this.onTouchStart,!1),e.addEventListener("touchmove",this.onTouchMove,!1),e.addEventListener("touchend",this.onTouchEnd,!1),e.addEventListener("touchcancel",this.onTouchCancel,!1),Event.prototype.stopImmediatePropagation||(e.removeEventListener=function(t,n,o){var i=Node.prototype.removeEventListener;"click"===t?i.call(e,t,n.hijacked||n,o):i.call(e,t,n,o)},e.addEventListener=function(t,n,o){var i=Node.prototype.addEventListener;"click"===t?i.call(e,t,n.hijacked||(n.hijacked=function(t){t.propagationStopped||n(t)}),o):i.call(e,t,n,o)}),"function"==typeof e.onclick&&(r=e.onclick,e.addEventListener("click",function(t){r(t)},!1),e.onclick=null)}}var e=navigator.userAgent.indexOf("Windows Phone")>=0,n=navigator.userAgent.indexOf("Android")>0&&!e,o=/iP(ad|hone|od)/.test(navigator.userAgent)&&!e,i=o&&/OS 4_\d(_\d)?/.test(navigator.userAgent),r=o&&/OS [6-7]_\d/.test(navigator.userAgent),a=navigator.userAgent.indexOf("BB10")>0;t.prototype.needsClick=function(t){switch(t.nodeName.toLowerCase()){case"button":case"select":case"textarea":if(t.disabled)return!0;break;case"input":if(o&&"file"===t.type||t.disabled)return!0;break;case"label":case"iframe":case"video":return!0}return/\bneedsclick\b/.test(t.className)},t.prototype.needsFocus=function(t){switch(t.nodeName.toLowerCase()){case"textarea":return!0;case"select":return!n;case"input":switch(t.type){case"button":case"checkbox":case"file":case"image":case"radio":case"submit":return!1}return!t.disabled&&!t.readOnly;default:return/\bneedsfocus\b/.test(t.className)}},t.prototype.sendClick=function(t,e){var n,o;document.activeElement&&document.activeElement!==t&&document.activeElement.blur(),o=e.changedTouches[0],(n=document.createEvent("MouseEvents")).initMouseEvent(this.determineEventType(t),!0,!0,window,1,o.screenX,o.screenY,o.clientX,o.clientY,!1,!1,!1,!1,0,null),n.forwardedTouchEvent=!0,t.dispatchEvent(n)},t.prototype.determineEventType=function(t){return n&&"select"===t.tagName.toLowerCase()?"mousedown":"click"},t.prototype.focus=function(t){var e;o&&t.setSelectionRange&&0!==t.type.indexOf("date")&&"time"!==t.type&&"month"!==t.type?(e=t.value.length,t.setSelectionRange(e,e)):t.focus()},t.prototype.updateScrollParent=function(t){var e,n;if(!(e=t.fastClickScrollParent)||!e.contains(t)){n=t;do{if(n.scrollHeight>n.offsetHeight){e=n,t.fastClickScrollParent=n;break}n=n.parentElement}while(n)}e&&(e.fastClickLastScrollTop=e.scrollTop)},t.prototype.getTargetElementFromEventTarget=function(t){return t.nodeType===Node.TEXT_NODE?t.parentNode:t},t.prototype.onTouchStart=function(t){var e,n,r;if(t.targetTouches.length>1)return!0;if(e=this.getTargetElementFromEventTarget(t.target),n=t.targetTouches[0],o){if((r=window.getSelection()).rangeCount&&!r.isCollapsed)return!0;if(!i){if(n.identifier&&n.identifier===this.lastTouchIdentifier)return t.preventDefault(),!1;this.lastTouchIdentifier=n.identifier,this.updateScrollParent(e)}}return this.trackingClick=!0,this.trackingClickStart=t.timeStamp,this.targetElement=e,this.touchStartX=n.pageX,this.touchStartY=n.pageY,t.timeStamp-this.lastClickTime<this.tapDelay&&t.preventDefault(),!0},t.prototype.touchHasMoved=function(t){var e=t.changedTouches[0],n=this.touchBoundary;return Math.abs(e.pageX-this.touchStartX)>n||Math.abs(e.pageY-this.touchStartY)>n},t.prototype.onTouchMove=function(t){return!this.trackingClick||((this.targetElement!==this.getTargetElementFromEventTarget(t.target)||this.touchHasMoved(t))&&(this.trackingClick=!1,this.targetElement=null),!0)},t.prototype.findControl=function(t){return void 0!==t.control?t.control:t.htmlFor?document.getElementById(t.htmlFor):t.querySelector("button, input:not([type=hidden]), keygen, meter, output, progress, select, textarea")},t.prototype.onTouchEnd=function(t){var e,a,c,s,u,l=this.targetElement;if(!this.trackingClick)return!0;if(t.timeStamp-this.lastClickTime<this.tapDelay)return this.cancelNextClick=!0,!0;if(t.timeStamp-this.trackingClickStart>this.tapTimeout)return!0;if(this.cancelNextClick=!1,this.lastClickTime=t.timeStamp,a=this.trackingClickStart,this.trackingClick=!1,this.trackingClickStart=0,r&&(u=t.changedTouches[0],(l=document.elementFromPoint(u.pageX-window.pageXOffset,u.pageY-window.pageYOffset)||l).fastClickScrollParent=this.targetElement.fastClickScrollParent),"label"===(c=l.tagName.toLowerCase())){if(e=this.findControl(l)){if(this.focus(l),n)return!1;l=e}}else if(this.needsFocus(l))return t.timeStamp-a>100||o&&window.top!==window&&"input"===c?(this.targetElement=null,!1):(this.focus(l),this.sendClick(l,t),o&&"select"===c||(this.targetElement=null,t.preventDefault()),!1);return!(!o||i||!(s=l.fastClickScrollParent)||s.fastClickLastScrollTop===s.scrollTop)||(this.needsClick(l)||(t.preventDefault(),this.sendClick(l,t)),!1)},t.prototype.onTouchCancel=function(){this.trackingClick=!1,this.targetElement=null},t.prototype.onMouse=function(t){return!this.targetElement||(!!t.forwardedTouchEvent||(!t.cancelable||(!(!this.needsClick(this.targetElement)||this.cancelNextClick)||(t.stopImmediatePropagation?t.stopImmediatePropagation():t.propagationStopped=!0,t.stopPropagation(),t.preventDefault(),!1))))},t.prototype.onClick=function(t){var e;return this.trackingClick?(this.targetElement=null,this.trackingClick=!1,!0):"submit"===t.target.type&&0===t.detail||((e=this.onMouse(t))||(this.targetElement=null),e)},t.prototype.destroy=function(){var t=this.layer;n&&(t.removeEventListener("mouseover",this.onMouse,!0),t.removeEventListener("mousedown",this.onMouse,!0),t.removeEventListener("mouseup",this.onMouse,!0)),t.removeEventListener("click",this.onClick,!0),t.removeEventListener("touchstart",this.onTouchStart,!1),t.removeEventListener("touchmove",this.onTouchMove,!1),t.removeEventListener("touchend",this.onTouchEnd,!1),t.removeEventListener("touchcancel",this.onTouchCancel,!1)},t.notNeeded=function(t){var e,o,i;if(void 0===window.ontouchstart)return!0;if(o=+(/Chrome\/([0-9]+)/.exec(navigator.userAgent)||[,0])[1]){if(!n)return!0;if(e=document.querySelector("meta[name=viewport]")){if(-1!==e.content.indexOf("user-scalable=no"))return!0;if(o>31&&document.documentElement.scrollWidth<=window.outerWidth)return!0}}if(a&&(i=navigator.userAgent.match(/Version\/([0-9]*)\.([0-9]*)/))[1]>=10&&i[2]>=3&&(e=document.querySelector("meta[name=viewport]"))){if(-1!==e.content.indexOf("user-scalable=no"))return!0;if(document.documentElement.scrollWidth<=window.outerWidth)return!0}return"none"===t.style.msTouchAction||"manipulation"===t.style.touchAction||(!!(+(/Firefox\/([0-9]+)/.exec(navigator.userAgent)||[,0])[1]>=27&&(e=document.querySelector("meta[name=viewport]"))&&(-1!==e.content.indexOf("user-scalable=no")||document.documentElement.scrollWidth<=window.outerWidth))||"none"===t.style.touchAction||"manipulation"===t.style.touchAction)},t.attach=function(e,n){return new t(e,n)},"function"==typeof define&&"object"==typeof define.amd&&define.amd?define(function(){return t}):"undefined"!=typeof module&&module.exports?(module.exports=t.attach,module.exports.FastClick=t):window.FastClick=t}();


/**
 * fastclick 消除点击时间
 */
if ('addEventListener' in document) {
  document.addEventListener('DOMContentLoaded',function(){
    FastClick.attach(document.body);
  },false)
};

// 数组删除元素
Array.prototype.remove = function(val) {
  var index = this.indexOf(val);
  if (index > -1) {
  this.splice(index, 1);
  }
};
