cesium-examples/map/libs/haoutil.js

13 lines
9.7 KiB
JavaScript
Raw Permalink Normal View History

/*
* @Descripttion:
* @version: 1.0
* @Author: zhangti
* @Date: 2019-11-25 15:57:33
* @LastEditors: sueRimn
* @LastEditTime: 2019-11-25 15:58:55
*/
/**
* 用于坡面分析
*/
/* 2019-11-4 08:27:20 | 版权所有 火星科技 http://marsgis.cn */
function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var haoutil=haoutil||{};haoutil.version="2.4",haoutil.name="木遥 通用常用JS方法类库",haoutil.author="木遥QQ346819890 https://github.com/muyao1987/haoutil",haoutil.update="2019-11-02",haoutil.msg=function(t){window.toastr?toastr.info(t):window.layer?layer.msg(t):alert(t)},haoutil.tip=haoutil.msg,haoutil.oneMsg=function(t,e){haoutil.storage.get(e)||(haoutil.msg(t),haoutil.storage.add(e,!0))},haoutil.alert=function(t,e){window.layer?layer.alert(t,{title:e||"提示",skin:"layui-layer-lan layer-mars-dialog",closeBtn:0,anim:0}):alert(t)},haoutil.loading={index:-1,show:function(t){this.close(),window.NProgress?((t=t||{}).color?t.template='<div class="bar '+(t.className||"")+'" style="background-color:'+t.color+';" role="bar"></div><div class="spinner" role="spinner"><div class="spinner-icon"></div></div>':t.template='<div class="bar '+(t.className||"")+'" role="bar"></div><div class="spinner" role="spinner"><div class="spinner-icon"></div></div>',NProgress.configure(t),NProgress.start()):window.layer&&(this.index=layer.load(2,{shade:[.3,"#000000"]}))},hide:function(){this.close()},close:function(){window.NProgress?NProgress.done(!0):window.layer&&(-1!=this.index&&layer.close(this.index),this.index=-1)}},window.noArrayPrototype||(Array.prototype.indexOf=Array.prototype.indexOf||function(t){for(var e=0;e<this.length;e++)if(this[e]==t)return e;return-1},Array.prototype.remove=Array.prototype.remove||function(t){for(var e=0;e<this.length;e++)if(this[e]==t){this.splice(e,1);break}},Array.prototype.insert=Array.prototype.insert||function(t,e){null==e&&(e=0),this.splice(e,0,t)}),String.prototype.startsWith=String.prototype.startsWith||function(t){return this.slice(0,t.length)==t},String.prototype.endsWith=String.prototype.endsWith||function(t){return this.slice(-t.length)==t},String.prototype.replaceAll=String.prototype.replaceAll||function(t,e){return this.replace(new RegExp(t,"gm"),e)},Date.prototype.format=function(t){var e={"M+":this.getMonth()+1,"d+":this.getDate(),"h+":this.getHours()%12==0?12:this.getHours()%12,"H+":this.getHours(),"m+":this.getMinutes(),"s+":this.getSeconds(),"q+":Math.floor((this.getMonth()+3)/3),S:this.getMilliseconds()};for(var n in/(y+)/.test(t)&&(t=t.replace(RegExp.$1,(this.getFullYear()+"").substr(4-RegExp.$1.length))),/(E+)/.test(t)&&(t=t.replace(RegExp.$1,(1<RegExp.$1.length?2<RegExp.$1.length?"星期":"周":"")+{0:"日",1:"一",2:"二",3:"三",4:"四",5:"五",6:"六"}[this.getDay()+""])),e)new RegExp("("+n+")").test(t)&&(t=t.replace(RegExp.$1,1==RegExp.$1.length?e[n]:("00"+e[n]).substr((""+e[n]).length)));return t},haoutil.color={random:function(){return"#"+function(t){return(t+="0123456789abcdef"[Math.floor(16*Math.random())])&&6==t.length?t:arguments.callee(t)}("")}},haoutil.cookie=function(){var i;return{isH5Mobile:function(t){i=t},add:function(t,e,n){var r;0<n?(r=new Date).setTime(r.getTime+24*n*60*60*1e3):r=new Date(2147483647e3);var o=t+"="+escape(e)+"; expires="+r.toGMTString();i&&null!=window.plus?plus.navigator.setCookie(t,o):document.cookie=o},get:function(t){var e;if(i&&null!=window.plus){if(null==(e=plus.navigator.getCookie(t)))return null}else e=document.cookie;for(var n=e.split("; "),r=0;r<n.length;r++){var o=n[r].split("=");if(o[0]==t)return unescape(o[1])}return null},del:function(t){if(i&&null!=window.plus)plus.navigator.removeCookie(t);else{var e=new Date;e.setTime(e.getTime()-1e4),document.cookie=t+"=v; expires="+e.toGMTString()}}}}(),haoutil.file=function(){function n(t,e){var n=document.createElement("a");n.download=t,n.href=URL.createObjectURL(e),document.body.appendChild(n),n.click(),document.body.removeChild(n)}function r(t){for(var e=t.split(";base64,"),n=e[0].split(":")[1],r=window.atob(e[1]),o=r.length,i=new Uint8Array(o),a=0;a<o;++a)i[a]=r.charCodeAt(a);return new Blob([i],{type:n})}return{download:n,downloadFile:fu